mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
5915dc245e
commit
85e32dd221
21 changed files with 77 additions and 45 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue