From 48925716c49735e751dffaede68a4d9dcef68cc5 Mon Sep 17 00:00:00 2001 From: tadf Date: Wed, 30 Jan 2008 13:07:45 +0000 Subject: * bignum.c (rb_cstr_to_inum): '0_2' is a valid representation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bignum.c') 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; -- cgit v1.2.3