summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 20:55:59 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 20:55:59 +0000
commita2055d63b41a6678dc7aeb17d0bece314e700c5a (patch)
tree9c8e1ebd2d5758b860763f021b9c64935e3658ed /bignum.c
parent2f1eb739412a85579ff4de5567474e7c8fe1b7c3 (diff)
parent1287260819a8e2dc5ca14da4b5e58b110064fe44 (diff)
sorry. I made wrong tags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_71@12993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/bignum.c b/bignum.c
index 473434d18e..3057f1d45a 100644
--- a/bignum.c
+++ b/bignum.c
@@ -331,13 +331,6 @@ rb_cstr_to_inum(str, base, badcheck)
VALUE z;
BDIGIT *zds;
-#define conv_digit(c) \
- (!ISASCII(c) ? -1 : \
- isdigit(c) ? ((c) - '0') : \
- islower(c) ? ((c) - 'a' + 10) : \
- isupper(c) ? ((c) - 'A' + 10) : \
- -1)
-
if (!str) {
if (badcheck) goto bad;
return INT2FIX(0);
@@ -430,13 +423,7 @@ rb_cstr_to_inum(str, base, badcheck)
}
if (*str == '0') { /* squeeze preceeding 0s */
while (*++str == '0');
- if (!*str) --str;
- }
- c = *str;
- c = conv_digit(c);
- if (c < 0 || c >= base) {
- if (badcheck) goto bad;
- return INT2FIX(0);
+ --str;
}
len *= strlen(str)*sizeof(char);
@@ -470,7 +457,7 @@ rb_cstr_to_inum(str, base, badcheck)
z = bignew(len, sign);
zds = BDIGITS(z);
for (i=len;i--;) zds[i]=0;
- while ((c = *str++) != 0) {
+ while (c = *str++) {
if (c == '_') {
if (badcheck) {
if (nondigit) goto bad;
@@ -478,7 +465,19 @@ rb_cstr_to_inum(str, base, badcheck)
}
continue;
}
- else if ((c = conv_digit(c)) < 0) {
+ else if (!ISASCII(c)) {
+ break;
+ }
+ else if (isdigit(c)) {
+ c -= '0';
+ }
+ else if (islower(c)) {
+ c -= 'a' - 10;
+ }
+ else if (isupper(c)) {
+ c -= 'A' - 10;
+ }
+ else {
break;
}
if (c >= base) break;