From 89697dc491be7f43cb240ddfddaa9f1503b9fc97 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 13 Aug 2002 09:21:18 +0000 Subject: * hash.c (rb_hash_replace): should copy ifnone. * hash.c (rb_hash_dup): should preserve HASH_PROC_DEFAULT and HASH_DELETED flags. * hash.c (rb_hash_shift): shift from empty hash should not return its default proc. * hash.c (rb_hash_default_proc): new method. [new] * array.c (rb_ary_aref): no need for Bignum check. * array.c (rb_ary_aset): explicit Bignum check removd. * numeric.c (fix_aref): normalize bignum before bit-op. * bignum.c (rb_big_rand): max may be Bignum zero. * bignum.c (rb_cstr_to_inum): should normalize bignums, to avoid returning fixable bignum value. * bignum.c (rb_uint2big): there should be no zero sized bignum. * ext/extmk.rb.in: extmake() that works properly for both tkutil (tk/tkutil.so) and digest/sha1. * hash.c (rb_hash_equal): should check HASH_PROC_DEFAULT too. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index f48598746..a62f53f74 100644 --- a/numeric.c +++ b/numeric.c @@ -1464,24 +1464,26 @@ fix_aref(fix, idx) VALUE fix, idx; { long val = FIX2LONG(fix); + long i; if (TYPE(idx) == T_BIGNUM) { - if (!RBIGNUM(idx)->sign || val >= 0) - return INT2FIX(0); - return INT2FIX(1); + idx = rb_big_norm(idx); + if (!FIXNUM_P(idx)) { + if (!RBIGNUM(idx)->sign || val >= 0) + return INT2FIX(0); + return INT2FIX(1); + } } - else { - int i = NUM2INT(idx); + i = NUM2LONG(idx); - if (i < 0) return INT2FIX(0); - if (sizeof(VALUE)*CHAR_BIT-1 < i) { - if (val < 0) return INT2FIX(1); - return INT2FIX(0); - } - if (val & (1L<