mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrb_str_len_to_inum(): fixed a bug with separating _ in the digits; ref #3043
This commit is contained in:
+9
-3
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user