mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (rb_num2long): Don't use SIGNED_VALUE uselessly.
(check_int): Ditto. (check_short): Ditto. (rb_num2fix): Ditto. (rb_num2ulong_internal): Add a cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecb9b98774
commit
4e52c3c60c
2 changed files with 19 additions and 11 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Mon Apr 1 20:08:07 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* numeric.c (rb_num2long): Don't use SIGNED_VALUE uselessly.
|
||||||
|
(check_int): Ditto.
|
||||||
|
(check_short): Ditto.
|
||||||
|
(rb_num2fix): Ditto.
|
||||||
|
(rb_num2ulong_internal): Add a cast.
|
||||||
|
|
||||||
Mon Apr 1 18:41:35 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Apr 1 18:41:35 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: skip autoconf 2.64 and 2.66, 2.67 seems short-lived
|
* configure.in: skip autoconf 2.64 and 2.66, 2.67 seems short-lived
|
||||||
|
|
22
numeric.c
22
numeric.c
|
@ -1959,7 +1959,7 @@ rb_num2long(VALUE val)
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
if (RFLOAT_VALUE(val) < LONG_MAX_PLUS_ONE
|
if (RFLOAT_VALUE(val) < LONG_MAX_PLUS_ONE
|
||||||
&& LONG_MIN_MINUS_ONE_IS_LESS_THAN(RFLOAT_VALUE(val))) {
|
&& LONG_MIN_MINUS_ONE_IS_LESS_THAN(RFLOAT_VALUE(val))) {
|
||||||
return (SIGNED_VALUE)(RFLOAT_VALUE(val));
|
return (long)RFLOAT_VALUE(val);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char buf[24];
|
char buf[24];
|
||||||
|
@ -1991,7 +1991,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
|
||||||
long l = FIX2LONG(val); /* this is FIX2LONG, inteneded */
|
long l = FIX2LONG(val); /* this is FIX2LONG, inteneded */
|
||||||
if (wrap_p)
|
if (wrap_p)
|
||||||
*wrap_p = l < 0;
|
*wrap_p = l < 0;
|
||||||
return l;
|
return (unsigned long)l;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (TYPE(val)) {
|
switch (TYPE(val)) {
|
||||||
|
@ -2021,8 +2021,8 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
val = rb_to_int(val);
|
val = rb_to_int(val);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2032,7 +2032,7 @@ rb_num2ulong(VALUE val)
|
||||||
return rb_num2ulong_internal(val, NULL);
|
return rb_num2ulong_internal(val, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SIZEOF_INT < SIZEOF_VALUE
|
#if SIZEOF_INT < SIZEOF_LONG
|
||||||
void
|
void
|
||||||
rb_out_of_int(SIGNED_VALUE num)
|
rb_out_of_int(SIGNED_VALUE num)
|
||||||
{
|
{
|
||||||
|
@ -2041,9 +2041,9 @@ rb_out_of_int(SIGNED_VALUE num)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_int(SIGNED_VALUE num)
|
check_int(long num)
|
||||||
{
|
{
|
||||||
if ((SIGNED_VALUE)(int)num != num) {
|
if ((long)(int)num != num) {
|
||||||
rb_out_of_int(num);
|
rb_out_of_int(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2126,9 +2126,9 @@ rb_out_of_short(SIGNED_VALUE num)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_short(SIGNED_VALUE num)
|
check_short(long num)
|
||||||
{
|
{
|
||||||
if ((SIGNED_VALUE)(short)num != num) {
|
if ((long)(short)num != num) {
|
||||||
rb_out_of_short(num);
|
rb_out_of_short(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2193,13 +2193,13 @@ rb_fix2ushort(VALUE val)
|
||||||
VALUE
|
VALUE
|
||||||
rb_num2fix(VALUE val)
|
rb_num2fix(VALUE val)
|
||||||
{
|
{
|
||||||
SIGNED_VALUE v;
|
long v;
|
||||||
|
|
||||||
if (FIXNUM_P(val)) return val;
|
if (FIXNUM_P(val)) return val;
|
||||||
|
|
||||||
v = rb_num2long(val);
|
v = rb_num2long(val);
|
||||||
if (!FIXABLE(v))
|
if (!FIXABLE(v))
|
||||||
rb_raise(rb_eRangeError, "integer %"PRIdVALUE " out of range of fixnum", v);
|
rb_raise(rb_eRangeError, "integer %ld out of range of fixnum", v);
|
||||||
return LONG2FIX(v);
|
return LONG2FIX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue