mrb_str_len_to_inum(): fixed a bug with separating _ in the digits; ref #3043

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-12-14 10:39:39 +09:00
parent 4a6a11486c
commit 19c744e14d
+9 -3
View File
@@ -2125,15 +2125,21 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
break;
} /* end of switch (base) { */
if (*p == '0') { /* squeeze preceding 0s */
while (p<pend && ((c = *++p) == '0' || c == '_')) {
p++;
while (p<pend) {
c = *p++;
if (c == '_') {
if (*p == '_') {
if (p<pend && *p == '_') {
if (badcheck) goto bad;
break;
}
continue;
}
if (c != '0') {
p--;
break;
}
}
if (!(c = *p) || ISSPACE(c)) --p;
}
c = *p;
if (badcheck && c == '\0') {