summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-19 05:36:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-19 05:36:43 +0000
commit2188bbced38b801bac2c7a342f50975a591bd512 (patch)
tree134e5f87be2fa1e6b876c268f1d04801f703c86d
parent555eb7ded4e1fb54c434dcdd3c8348881a2a6765 (diff)
* bignum.c (rb_cstr_to_inum): treat successive underscores as
nondigit. [ruby-dev:34089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--bignum.c7
-rw-r--r--test/ruby/test_string.rb2
3 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ee70c2f071..0e77accea9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 19 14:36:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * bignum.c (rb_cstr_to_inum): treat successive underscores as
+ nondigit. [ruby-dev:34089]
+
Wed Mar 19 14:08:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (enc_check_encoding): should not load autoloaded encoding
diff --git a/bignum.c b/bignum.c
index d06bf6a6c0..72bb917cf7 100644
--- a/bignum.c
+++ b/bignum.c
@@ -532,10 +532,11 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
for (i=len;i--;) zds[i]=0;
while ((c = *str++) != 0) {
if (c == '_') {
- if (badcheck) {
- if (nondigit) goto bad;
- nondigit = c;
+ if (nondigit) {
+ if (badcheck) goto bad;
+ break;
}
+ nondigit = c;
continue;
}
else if ((c = conv_digit(c)) < 0) {
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index ed4b667a4c..c71be7d09d 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1213,7 +1213,7 @@ class TestString < Test::Unit::TestCase
assert_equal(12, "1_2".to_i(10))
assert_equal(0x40000000, "1073741824".to_i(10))
assert_equal(0x4000000000000000, "4611686018427387904".to_i(10))
- assert_equal(12, "1__2".to_i(10))
+ assert_equal(1, "1__2".to_i(10))
assert_equal(1, "1_z".to_i(10))
end