diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-20 08:56:42 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-20 08:56:42 +0000 |
commit | 21e36414c9b1d21f593a236a6a20df507a33b986 (patch) | |
tree | c77cf738688717f0571e9eb09ad99c1dadfded86 /bignum.c | |
parent | fd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (diff) |
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
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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!!!! |