зеркало из https://github.com/github/ruby.git
* 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:
Родитель
8f5b0a4cd4
Коммит
e3215a7342
|
@ -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>
|
||||
|
||||
* 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 *ds;
|
||||
|
||||
if (len > SIZEOF_VALUE/SIZEOF_BDIGITS) {
|
||||
if (len > DIGSPERLONG) {
|
||||
if (check)
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
|
||||
len = SIZEOF_VALUE/SIZEOF_BDIGITS;
|
||||
len = DIGSPERLONG;
|
||||
}
|
||||
ds = BDIGITS(x);
|
||||
num = 0;
|
||||
|
@ -2390,7 +2390,7 @@ rb_big_aref(VALUE x, VALUE y)
|
|||
if (TYPE(y) == T_BIGNUM) {
|
||||
if (!RBIGNUM_SIGN(y))
|
||||
return INT2FIX(0);
|
||||
if (RBIGNUM_LEN(bigtrunc(y)) > SIZEOF_VALUE/SIZEOF_BDIGITS) {
|
||||
if (RBIGNUM_LEN(bigtrunc(y)) > DIGSPERLONG) {
|
||||
out_of_range:
|
||||
return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1);
|
||||
}
|
||||
|
|
|
@ -2669,8 +2669,8 @@ rb_fix_lshift(VALUE x, VALUE y)
|
|||
static VALUE
|
||||
fix_lshift(long val, unsigned long width)
|
||||
{
|
||||
if (width > (sizeof(VALUE)*CHAR_BIT-1)
|
||||
|| ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
|
||||
if (width > (SIZEOF_LONG*CHAR_BIT-1)
|
||||
|| ((unsigned long)val)>>(SIZEOF_LONG*CHAR_BIT-1-width) > 0) {
|
||||
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
|
||||
}
|
||||
val = val << width;
|
||||
|
@ -2743,7 +2743,7 @@ fix_aref(VALUE fix, VALUE idx)
|
|||
i = NUM2LONG(idx);
|
||||
|
||||
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);
|
||||
return INT2FIX(0);
|
||||
}
|
||||
|
|
4
pack.c
4
pack.c
|
@ -861,13 +861,13 @@ pack_pack(VALUE ary, VALUE fmt)
|
|||
|
||||
case 'U': /* Unicode character */
|
||||
while (len-- > 0) {
|
||||
long l;
|
||||
SIGNED_VALUE l;
|
||||
char buf[8];
|
||||
int le;
|
||||
|
||||
from = NEXTFROM;
|
||||
from = rb_to_int(from);
|
||||
l = NUM2INT(from);
|
||||
l = NUM2LONG(from);
|
||||
if (l < 0) {
|
||||
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче