From 21e36414c9b1d21f593a236a6a20df507a33b986 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Fri, 20 Feb 1998 08:56:42 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v1_1b8'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_1b8@87 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'bignum.c') diff --git a/bignum.c b/bignum.c index 17d9c839c5..8a6e54a9da 100644 --- a/bignum.c +++ b/bignum.c @@ -24,13 +24,13 @@ VALUE cBignum; #define BIGLO(x) ((x) & (BIGRAD-1)) static VALUE -bignew_1(class, len, sign) - VALUE class; +bignew_1(klass, len, sign) + VALUE klass; UINT len; char sign; { NEWOBJ(big, struct RBignum); - OBJSETUP(big, cBignum, T_BIGNUM); + OBJSETUP(big, klass, T_BIGNUM); big->sign = sign; big->len = len; BDIGITS(big) = ALLOC_N(USHORT, len); @@ -195,12 +195,16 @@ str2inum(str, base) base = 10; } } - len = strlen(str); if (base == 8) { - len = 3*len*sizeof(char); + while (str[0] == '0') str++; + len = 3*strlen(str)*sizeof(char); } else { /* base == 10 or 16 */ - len = 4*len*sizeof(char); + if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) { + str += 2; + } + while (str[0] == '0') str++; + len = 4*strlen(str)*sizeof(char); } if (len <= (sizeof(VALUE)*CHAR_BIT)) { @@ -1177,7 +1181,7 @@ big_abs(x) x = big_clone(x); RBIGNUM(x)->sign = 1; } - return (VALUE)x; + return x; } /* !!!warnig!!!! -- cgit v1.2.3