diff --git a/bignum.c b/bignum.c index 788eb4bfd2..25ca9be87e 100644 --- a/bignum.c +++ b/bignum.c @@ -706,7 +706,7 @@ rb_big2str0(x, base, trim) while (k--) { s[--j] = ruby_digitmap[num % base]; num /= base; - if (!trim && j < 1) break; + if (!trim && j <= 1) break; if (trim && i == 0 && num == 0) break; } } diff --git a/sprintf.c b/sprintf.c index de997098ba..e32c456b63 100644 --- a/sprintf.c +++ b/sprintf.c @@ -18,6 +18,8 @@ #include #define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */ +#define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT) +#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n))) static void fmt_setup _((char*,int,int,int,int)); @@ -36,7 +38,7 @@ remove_sign_bits(str, base) } } else if (base == 8) { - if (*t == '3') t++; + *t |= EXTENDSIGN(3, strlen(t)); while (*t == '7') { t++; } diff --git a/version.h b/version.h index e06387f288..381a571ce5 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-08" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20080608 -#define RUBY_PATCHLEVEL 150 +#define RUBY_PATCHLEVEL 151 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8