Skip to content

Avoid relying on peek()-after-failbit semantics in ParseNumericValue#169

Merged
Taywee merged 1 commit into
Taywee:masterfrom
metsw24-max:explicit-trailing-input-check
May 21, 2026
Merged

Avoid relying on peek()-after-failbit semantics in ParseNumericValue#169
Taywee merged 1 commit into
Taywee:masterfrom
metsw24-max:explicit-trailing-input-check

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

ValueReader::ParseNumericValue previously relied on the interactionbetween std::ws, stream failbit state, and std::istream::peek() to detect trailing non-whitespace input.

On MSVC, extracting std::ws at EOF sets failbit in addition to eofbit. The previous logic still behaved correctly because peek() returns EOF when the stream is failed, but the control flow depended on subtle stream semantics.

Make the trailing-input check explicit by attempting to extract one additional non-whitespace character and distinguishing EOF from other stream failures directly.

No intended behavior change.

@Taywee

Taywee commented May 21, 2026

Copy link
Copy Markdown
Owner

Looks fine to me, where "fine" means "iostreams is awful, but this gets the job done".

Thanks for the PR.

@Taywee Taywee merged commit 9795f2a into Taywee:master May 21, 2026
7 checks passed
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.

2 participants