Add PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_Z...

This commit is contained in:
Nigel Tao committed 2020-07-11 12:57:25 +10:00
1 parent 4d61a056e0
commit e82bc8ec7b
5 files changed
+114 -19

No files matched your search

+20 -5
View File
@@ -10064,7 +10064,9 @@ wuffs_base__private_implementation__high_prec_dec__parse(
uint32_t nd = 0;
int32_t dp = 0;
bool no_digits_before_separator = false;
if ('0' == *p) {
if (('0' == *p) &&
!(options &
WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES)) {
p++;
for (;; p++) {
if (p >= q) {
@@ -10084,10 +10086,16 @@ wuffs_base__private_implementation__high_prec_dec__parse(
}
}
} else if (('0' < *p) && (*p <= '9')) {
h->digits[nd++] = (uint8_t)(*p - '0');
dp = (int32_t)nd;
p++;
} else if (('0' <= *p) && (*p <= '9')) {
if (*p == '0') {
for (; (p < q) && (*p == '0'); p++) {
}
} else {
h->digits[nd++] = (uint8_t)(*p - '0');
dp = (int32_t)nd;
p++;
}
for (;; p++) {
if (p >= q) {
goto after_all;
@@ -11835,6 +11843,10 @@ wuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options) {
p++;
for (; p < q; p++) {
if (*p != '_') {
if (options &
WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES) {
goto decimal;
}
goto fail_bad_argument;
}
}
@@ -11858,6 +11870,9 @@ wuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options) {
}
}
if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES) {
goto decimal;
}
goto fail_bad_argument;
}