summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 18:12:24 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 18:12:24 +0000
commite3215a73423bdfca2ee2a2cae45a616296f0f605 (patch)
tree9ab7ee75fdacc3dc0f78ff5aa3335b6de6aa6436
parent8f5b0a4cd4decba7a56d1acb9601db47d2935ec0 (diff)
* 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
-rw-r--r--ChangeLog9
-rw-r--r--bignum.c6
-rw-r--r--numeric.c6
-rw-r--r--pack.c4
4 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 67065cf7c4..33021645d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/bignum.c b/bignum.c
index 5eb093a8c4..490944aa76 100644
--- a/bignum.c
+++ b/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);
}
diff --git a/numeric.c b/numeric.c
index 6ba8686bff..b9f2b1d084 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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);
}
diff --git a/pack.c b/pack.c
index f9a907196f..0df3c567ed 100644
--- a/pack.c
+++ b/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");
}