diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
commit | 85e32dd2212bc6e5bb2b48c5b6c94e048e84afeb (patch) | |
tree | 09c1328183e4ac51711b93522b53b7f0c62d5b4d /numeric.c | |
parent | 5915dc245e5efac34d676ad29ebd38d6b46f16cf (diff) |
* re.c (match_select): should propagate taintness.
* hash.c (rb_hash_set_default): Hash#default= should return the
new value.
* string.c (rb_str_to_i): accepts optional base argument. [new]
* numeric.c (rb_fix2str): should not handle negative fixnum values
int32 via calling sprintf() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -954,15 +954,20 @@ rb_fix2str(x, base) VALUE x; int base; { - char fmt[4], buf[22]; + char fmt[4], buf[22], *b = buf; + long val = FIX2LONG(x); fmt[0] = '%'; fmt[1] = 'l'; fmt[3] = '\0'; if (base == 10) fmt[2] = 'd'; else if (base == 16) fmt[2] = 'x'; else if (base == 8) fmt[2] = 'o'; else rb_raise(rb_eArgError, "illegal radix %d", base); + if (val < 0) { + val = -val; + *b++ = '-'; + } - sprintf(buf, fmt, FIX2LONG(x)); + sprintf(b, fmt, val); return rb_str_new2(buf); } |