Repository navigation
timeout: Use common parser to parse time duration - #7648
Merged
Merged
Conversation
There were some missing corner cases when handling infinity and nan: - inf/infinity can be capitalized - nan must always be rejected, even if a suffix is provided Also, return Duration::MAX with infinite values, just for consistency (num.fract() returns 0 for infinity so technically we were just short of that). Add unit tests too. Fixes some of uutils#7475.
Values like 0e18172487393827593258 and 0e-18172487393827593258 should just be parsed as 0, and do not need to return an error.
Gives a little bit more flexibility in terms of allowed input for durations (e.g. in `timeout`), e.g. hex floating point numbers are now allowed. Fixes another part of uutils#7475.
Note that unlike GNU coreutils, any value > 0 will not be treated as 0, even if the exponent is very large.
drinkcat
marked this pull request as ready for review
April 4, 2025 16:30
|
GNU testsuite comparison: |
This was referenced Apr 5, 2025
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.
test_timeout: Add tests for very short timeouts
Note that unlike GNU coreutils, any value > 0 will not be treated
as 0, even if the exponent is very large.
uucore: parser: parse_time: Use ExtendedBigDecimal parser
Gives a little bit more flexibility in terms of allowed input
for durations (e.g. in
timeout), e.g. hex floating pointnumbers are now allowed.
Fixes another part of #7475.
uucore: parser: num_parser: Do not Underflow/Overflow when parsing 0
Values like 0e18172487393827593258 and 0e-18172487393827593258 should
just be parsed as 0, and do not need to return an error.
uucore: parser: parse_time: Handle infinity and nan
There were some missing corner cases when handling infinity and
nan:
Also, return Duration::MAX with infinite values, just for consistency
(num.fract() returns 0 for infinity so technically we were just
short of that).
Add unit tests too.
Fixes some of #7475.