timeout: Use common parser to parse time duration #7648
Merged
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.