summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 64cd642580..46c3fb15e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jan 30 22:06:54 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * bignum.c (rb_cstr_to_inum): '0_2' is a valid representation.
+
Tue Jan 29 22:40:12 2008 Yusuke Endoh <mame@tsg.ne.jp>
* range.c (step_i): rb_funcall receives VALUE as an argument.
diff --git a/bignum.c b/bignum.c
index 88bf9e03e6..81fa9c3916 100644
--- a/bignum.c
+++ b/bignum.c
@@ -416,7 +416,7 @@ rb_cstr_to_inum(str, base, badcheck)
len = 2;
break;
case 8:
- if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O'||str[1] == '_')) {
+ if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O')) {
str += 2;
}
case 4: case 5: case 6: case 7:
@@ -448,7 +448,14 @@ rb_cstr_to_inum(str, base, badcheck)
break;
}
if (*str == '0') { /* squeeze preceeding 0s */
- while (*++str == '0');
+ int us = 0;
+ while ((c = *++str) == '0' || c == '_') {
+ if (c == '_') {
+ if (++us >= 2)
+ break;
+ } else
+ us = 0;
+ }
if (!(c = *str) || ISSPACE(c)) --str;
}
c = *str;