1
0
mirror of https://github.com/janet-lang/janet synced 2024-09-27 22:58:13 +00:00

Make number syntax a bit stricter - no leading underscores

and no underscores in exponent.
This commit is contained in:
Calvin Rose 2019-01-03 12:13:14 -05:00
parent ddba0010b0
commit dd3fc24a1e

View File

@ -308,8 +308,9 @@ int janet_scan_number(
} else if (base == 10 && (*str == 'E' || *str == 'e')) {
foundexp = 1;
break;
} else if (*str != '_') {
/* underscores are ignored - can be used for separator */
} else if (*str == '_') {
if (!seenadigit) goto error;
} else {
int digit = digit_lookup[*str & 0x7F];
if (*str > 127 || digit >= base) goto error;
if (seenpoint) ex--;
@ -342,10 +343,6 @@ int janet_scan_number(
}
while (str < end && ee < (INT32_MAX / 40)) {
int digit = digit_lookup[*str & 0x7F];
if (*str == '_') {
str++;
continue;
}
if (*str > 127 || digit >= base) goto error;
ee = base * ee + digit;
str++;