mirror of
https://github.com/janet-lang/janet
synced 2025-02-17 17:20:01 +00:00
Make number syntax a bit stricter - no leading underscores
and no underscores in exponent.
This commit is contained in:
parent
ddba0010b0
commit
dd3fc24a1e
@ -308,8 +308,9 @@ int janet_scan_number(
|
|||||||
} else if (base == 10 && (*str == 'E' || *str == 'e')) {
|
} else if (base == 10 && (*str == 'E' || *str == 'e')) {
|
||||||
foundexp = 1;
|
foundexp = 1;
|
||||||
break;
|
break;
|
||||||
} else if (*str != '_') {
|
} else if (*str == '_') {
|
||||||
/* underscores are ignored - can be used for separator */
|
if (!seenadigit) goto error;
|
||||||
|
} else {
|
||||||
int digit = digit_lookup[*str & 0x7F];
|
int digit = digit_lookup[*str & 0x7F];
|
||||||
if (*str > 127 || digit >= base) goto error;
|
if (*str > 127 || digit >= base) goto error;
|
||||||
if (seenpoint) ex--;
|
if (seenpoint) ex--;
|
||||||
@ -342,10 +343,6 @@ int janet_scan_number(
|
|||||||
}
|
}
|
||||||
while (str < end && ee < (INT32_MAX / 40)) {
|
while (str < end && ee < (INT32_MAX / 40)) {
|
||||||
int digit = digit_lookup[*str & 0x7F];
|
int digit = digit_lookup[*str & 0x7F];
|
||||||
if (*str == '_') {
|
|
||||||
str++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*str > 127 || digit >= base) goto error;
|
if (*str > 127 || digit >= base) goto error;
|
||||||
ee = base * ee + digit;
|
ee = base * ee + digit;
|
||||||
str++;
|
str++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user