Repository navigation
Reject empty strings as double argument values - #158
Merged
Merged
Conversation
fhgffy
marked this pull request as ready for review
October 4, 2026 22:16
Contributor
|
@fhgffy: Really appreciate your patch to correct the behavior. All the pipeline checks passed, so I'll merge it. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An explicit empty short-option value (
-d "") or positional argument is currently accepted as the double value0.strtodreturns zero without consuming any characters, butarg_dbl_scanfnonly checks whether the end pointer points to the string terminator.Require the conversion to consume characters before storing the value. Empty input now follows the existing invalid-double error path without changing the stored default or argument count. Omitted optional values retain their current behavior. Long options already report a missing-argument error for an explicit empty value; the double scanner now also rejects that value, consistent with the integer scanner.
Six tests cover short and positional empty values, explicit long-option values, omitted versus empty optional values, repeated arguments, valid zero/negative/exponent values, and neighboring invalid inputs. Five of these tests fail on the original code; the conversion controls pass.
Validation on Linux with GCC 14.2.0 and CMake 3.31.6:
The full static/source/amalgamation suite contains 176 tests; the shared-library suite contains 169. The amalgamation was regenerated before compiling. Its line-ending normalization command (
dos2unix) is unavailable in this environment; generation, compilation, and tests completed with the existing line endings. Clang, Windows/MSVC, Valgrind, and LeakSanitizer were not tested.