mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* pack.c (pack_pack): use NUM2LONG instead of NUM2INT.
* numeric.c (fix_lshift, fix_aref): use SIZEOF_LONG instead of SIZEOF_VALUE. * bignum.c (big2ulong, rb_big_aref): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8f5b0a4cd4
commit
e3215a7342
4 changed files with 17 additions and 8 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Tue Dec 25 03:08:53 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* pack.c (pack_pack): use NUM2LONG instead of NUM2INT.
|
||||||
|
|
||||||
|
* numeric.c (fix_lshift, fix_aref): use SIZEOF_LONG instead of
|
||||||
|
SIZEOF_VALUE.
|
||||||
|
|
||||||
|
* bignum.c (big2ulong, rb_big_aref): ditto.
|
||||||
|
|
||||||
Tue Dec 25 02:55:26 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Tue Dec 25 02:55:26 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* lib/rexml/element.rb (REXML::Elements#each): yield in each
|
* lib/rexml/element.rb (REXML::Elements#each): yield in each
|
||||||
|
|
6
bignum.c
6
bignum.c
|
@ -977,10 +977,10 @@ big2ulong(VALUE x, const char *type, int check)
|
||||||
BDIGIT_DBL num;
|
BDIGIT_DBL num;
|
||||||
BDIGIT *ds;
|
BDIGIT *ds;
|
||||||
|
|
||||||
if (len > SIZEOF_VALUE/SIZEOF_BDIGITS) {
|
if (len > DIGSPERLONG) {
|
||||||
if (check)
|
if (check)
|
||||||
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
|
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
|
||||||
len = SIZEOF_VALUE/SIZEOF_BDIGITS;
|
len = DIGSPERLONG;
|
||||||
}
|
}
|
||||||
ds = BDIGITS(x);
|
ds = BDIGITS(x);
|
||||||
num = 0;
|
num = 0;
|
||||||
|
@ -2390,7 +2390,7 @@ rb_big_aref(VALUE x, VALUE y)
|
||||||
if (TYPE(y) == T_BIGNUM) {
|
if (TYPE(y) == T_BIGNUM) {
|
||||||
if (!RBIGNUM_SIGN(y))
|
if (!RBIGNUM_SIGN(y))
|
||||||
return INT2FIX(0);
|
return INT2FIX(0);
|
||||||
if (RBIGNUM_LEN(bigtrunc(y)) > SIZEOF_VALUE/SIZEOF_BDIGITS) {
|
if (RBIGNUM_LEN(bigtrunc(y)) > DIGSPERLONG) {
|
||||||
out_of_range:
|
out_of_range:
|
||||||
return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1);
|
return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2669,8 +2669,8 @@ rb_fix_lshift(VALUE x, VALUE y)
|
||||||
static VALUE
|
static VALUE
|
||||||
fix_lshift(long val, unsigned long width)
|
fix_lshift(long val, unsigned long width)
|
||||||
{
|
{
|
||||||
if (width > (sizeof(VALUE)*CHAR_BIT-1)
|
if (width > (SIZEOF_LONG*CHAR_BIT-1)
|
||||||
|| ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
|
|| ((unsigned long)val)>>(SIZEOF_LONG*CHAR_BIT-1-width) > 0) {
|
||||||
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
|
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
|
||||||
}
|
}
|
||||||
val = val << width;
|
val = val << width;
|
||||||
|
@ -2743,7 +2743,7 @@ fix_aref(VALUE fix, VALUE idx)
|
||||||
i = NUM2LONG(idx);
|
i = NUM2LONG(idx);
|
||||||
|
|
||||||
if (i < 0) return INT2FIX(0);
|
if (i < 0) return INT2FIX(0);
|
||||||
if (sizeof(VALUE)*CHAR_BIT-1 < i) {
|
if (SIZEOF_LONG*CHAR_BIT-1 < i) {
|
||||||
if (val < 0) return INT2FIX(1);
|
if (val < 0) return INT2FIX(1);
|
||||||
return INT2FIX(0);
|
return INT2FIX(0);
|
||||||
}
|
}
|
||||||
|
|
4
pack.c
4
pack.c
|
@ -861,13 +861,13 @@ pack_pack(VALUE ary, VALUE fmt)
|
||||||
|
|
||||||
case 'U': /* Unicode character */
|
case 'U': /* Unicode character */
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
long l;
|
SIGNED_VALUE l;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
int le;
|
int le;
|
||||||
|
|
||||||
from = NEXTFROM;
|
from = NEXTFROM;
|
||||||
from = rb_to_int(from);
|
from = rb_to_int(from);
|
||||||
l = NUM2INT(from);
|
l = NUM2LONG(from);
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue