summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-03 10:02:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-03 10:02:57 +0000
commit01bb9da7acfeb868eeec4fc20061c57d85b26cf8 (patch)
tree9b0ef258786fb82863ed752fc410405f86ac2068 /bignum.c
parentde0e5e35ae39a03879d8a954dd6b75654c173cd7 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@63 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index 357a17d..481a35e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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)) {