1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* numeric.c (flo_hash, int_chr): fixed type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-01-14 04:07:00 +00:00
parent 441dbecf43
commit 41d8e49dc5
2 changed files with 9 additions and 5 deletions

View file

@ -1,3 +1,7 @@
Thu Jan 14 13:06:58 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_hash, int_chr): fixed type.
Thu Jan 14 12:50:37 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_concat): fixed range check for Fixnum, and

View file

@ -566,7 +566,7 @@ flo_to_s(VALUE flt)
if (isinf(value))
return rb_usascii_str_new2(value < 0 ? "-Infinity" : "Infinity");
else if(isnan(value))
else if (isnan(value))
return rb_usascii_str_new2("NaN");
# define FLOFMT(buf, size, fmt, prec, val) snprintf(buf, size, fmt, prec, val), \
@ -956,7 +956,7 @@ flo_hash(VALUE num)
/* normalize -0.0 to 0.0 */
if (d == 0.0) d = 0.0;
hash = rb_memhash(&d, sizeof(d));
return INT2FIX(hash);
return LONG2FIX(hash);
}
VALUE
@ -1975,7 +1975,7 @@ int_chr(int argc, VALUE *argv, VALUE num)
{
char c;
int n;
long i = NUM2LONG(num);
SIGNED_VALUE i = NUM2LONG(num);
rb_encoding *enc;
VALUE str;
@ -2006,8 +2006,8 @@ int_chr(int argc, VALUE *argv, VALUE num)
enc = rb_to_encoding(argv[0]);
if (!enc) enc = rb_ascii8bit_encoding();
decode:
#if SIZEOF_INT < SIZEOF_LONG
if (i > INT_MAX) goto out_of_range;
#if SIZEOF_INT < SIZEOF_VALUE
if (i > UINT_MAX) goto out_of_range;
#endif
if (i < 0 || (n = rb_enc_codelen((int)i, enc)) <= 0) goto out_of_range;
str = rb_enc_str_new(0, n, enc);