Skip to content

Commit

Permalink
mrb_str_len_to_inum(): fixed a bug with separating _ in the digits; ref
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 14, 2015
1 parent 4a6a114 commit 19c744e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 19c744e

Please sign in to comment.