* 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
This commit is contained in:
parent
555eb7ded4
commit
2188bbced3
@ -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>
|
Wed Mar 19 14:08:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* encoding.c (enc_check_encoding): should not load autoloaded encoding
|
* encoding.c (enc_check_encoding): should not load autoloaded encoding
|
||||||
|
7
bignum.c
7
bignum.c
@ -532,10 +532,11 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
|||||||
for (i=len;i--;) zds[i]=0;
|
for (i=len;i--;) zds[i]=0;
|
||||||
while ((c = *str++) != 0) {
|
while ((c = *str++) != 0) {
|
||||||
if (c == '_') {
|
if (c == '_') {
|
||||||
if (badcheck) {
|
if (nondigit) {
|
||||||
if (nondigit) goto bad;
|
if (badcheck) goto bad;
|
||||||
nondigit = c;
|
break;
|
||||||
}
|
}
|
||||||
|
nondigit = c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((c = conv_digit(c)) < 0) {
|
else if ((c = conv_digit(c)) < 0) {
|
||||||
|
@ -1213,7 +1213,7 @@ class TestString < Test::Unit::TestCase
|
|||||||
assert_equal(12, "1_2".to_i(10))
|
assert_equal(12, "1_2".to_i(10))
|
||||||
assert_equal(0x40000000, "1073741824".to_i(10))
|
assert_equal(0x40000000, "1073741824".to_i(10))
|
||||||
assert_equal(0x4000000000000000, "4611686018427387904".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))
|
assert_equal(1, "1_z".to_i(10))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user