From cf5d04f663e9e7a61da4dda66e78097aefe66919 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@2706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bignum.c') diff --git a/bignum.c b/bignum.c index ad1b2ca1c4..622fd5e1af 100644 --- a/bignum.c +++ b/bignum.c @@ -142,7 +142,7 @@ rb_uint2big(n) } i = DIGSPERLONG; - while (i-- && !digits[i]) ; + while (--i && !digits[i]) ; RBIGNUM(big)->len = i+1; return big; } @@ -398,7 +398,7 @@ rb_cstr_to_inum(str, base, badcheck) else { VALUE big = rb_uint2big(val); RBIGNUM(big)->sign = sign; - return big; + return bignorm(big); } } bigparse: @@ -1685,6 +1685,9 @@ rb_big_rand(max, rand_buf) long len; len = RBIGNUM(max)->len; + if (len == 0 && BDIGITS(max)[0] == 0) { + return rb_float_new(rand_buf[0]); + } v = bignew(len,1); while (len--) { BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len]; -- cgit v1.2.3