diff options
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/string.c b/src/string.c index 79606f1af..552293a46 100644 --- a/src/string.c +++ b/src/string.c @@ -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') { |
