Skip to content

preserve octal state for all-zero integer prefixes under ALLOW_OCTALS - #331

Open
jdymitarai wants to merge 1 commit into
google:masterfrom
jdymitarai:fix-octal-all-zero-prefix
Open

jdymitarai wants to merge 1 commit into
google:masterfrom
jdymitarai:fix-octal-all-zero-prefix

Conversation

@jdymitarai

Copy link
Copy Markdown
Contributor

When StringToDoubleConverter is configured with ALLOW_OCTALS, strings starting with multiple zeros such as "00.5" or "00e2" were erroneously resetting octal to false because significant_digits remained zero. This allowed decimal points and exponential suffixes to slip through into decimal parsing instead of being rejected or handled as trailing junk.

We now track whether multiple leading zeros were consumed in the integer part, preserving octal mode when the integer part consists entirely of zeros while allowing single zero prefixes like "0.5" to parse as decimal numbers. In addition, parsing_done safely maps an empty octal buffer to SignedZero(sign) without triggering assertion failures.

Regression test cases covering both strict and trailing junk modes for multi-zero and single-zero inputs have been added to test-conversions.cc. All 9 cctest test suites have been verified and pass cleanly on Linux x86_64.

Resolves #330.

When StringToDoubleConverter is configured with ALLOW_OCTALS, strings starting with multiple zeros such as 00.5 or 00e2 were resetting octal to false because significant_digits was zero. This allowed decimal points and exponential suffixes to slip through into decimal parsing instead of being rejected or handled as trailing junk.

We now track whether multiple leading zeros were consumed in the integer part, preserving octal mode when the integer part consists entirely of zeros while allowing single zero prefixes like 0.5 to parse as decimal numbers. In addition, parsing_done safely maps an empty octal buffer to SignedZero(sign) without triggering assertion failures.

Regression test cases covering both strict and trailing junk modes for multi-zero and single-zero inputs have been added to test-conversions.cc, with all cctest test suites passing cleanly on Linux x86_64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant