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

parent 4a6a1148
...@@ -2125,15 +2125,21 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b ...@@ -2125,15 +2125,21 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
break; break;
} /* end of switch (base) { */ } /* end of switch (base) { */
if (*p == '0') { /* squeeze preceding 0s */ if (*p == '0') { /* squeeze preceding 0s */
while (p<pend && ((c = *++p) == '0' || c == '_')) { p++;
while (p<pend) {
c = *p++;
if (c == '_') { if (c == '_') {
if (*p == '_') { if (p<pend && *p == '_') {
if (badcheck) goto bad; if (badcheck) goto bad;
break; break;
} }
continue;
}
if (c != '0') {
p--;
break;
} }
} }
if (!(c = *p) || ISSPACE(c)) --p;
} }
c = *p; c = *p;
if (badcheck && c == '\0') { if (badcheck && c == '\0') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment