diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-28 00:51:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-28 00:51:44 +0000 |
commit | b76bf9f66fc0ef84d5d9044ef0f451d664f00946 (patch) | |
tree | d38cc5bdc8c2667425904dcb7188de1f8278855b /sprintf.c | |
parent | 641be733a63bc75e53a5ed5ed881420c54774bf1 (diff) |
* bignum.c (rb_big2str0): do not clobber space for sign.
* sprintf.c (remove_sign_bits): extends sign bit first.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -18,6 +18,8 @@ #include <math.h> #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++; } |