Skip to content

seq: Move to uucore/format common number parsing code #7624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 3, 2025

Conversation

drinkcat
Copy link
Contributor

@drinkcat drinkcat commented Mar 31, 2025

This deletes a lot of code in seq, and moves to the common implementation in uucore.


seq: Parse integral and fractional number of digits in the same function

A lot of the code can be shared, and parsing is quite straightforward
as we know that the digit is somewhat valid.

seq: Refactor to actually use PreciseNumber::num_fractional_digits

The field was unused, and actually redundant with the precision
computed separatedly.

This simplifies the code, reintroduces testing.

seq: Accept underflow in parameters

Also, add a test to check that a very, very, small number is
treated as 0. That's probably undefined behaviour, but it does
make some sense.

seq: Remove custom number parsing

Just use the format provided function.

test_seq: Modify undefined behaviour tests

GNU seq doesn't support such large positive exponents anyway,
and we are limited by i64 range, so increase the exponent value
to make sure we fully overflow that range.

Also, add a test to check that a very, very, small number is
treated as 0 (that's also undefined behaviour, but it does
make sense in a way).

@drinkcat drinkcat changed the title Parse bigdecimal seq seq: Move to uucore/format common number parsing code Mar 31, 2025
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

@drinkcat drinkcat force-pushed the parse-bigdecimal-seq branch from 5c13284 to 2dbdd7b Compare April 1, 2025 11:44
@drinkcat drinkcat marked this pull request as ready for review April 1, 2025 11:45
Copy link

github-actions bot commented Apr 1, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

@drinkcat drinkcat force-pushed the parse-bigdecimal-seq branch from 2dbdd7b to 4089cf3 Compare April 3, 2025 10:29
Copy link

github-actions bot commented Apr 3, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

drinkcat added 6 commits April 3, 2025 17:26
GNU `seq` doesn't support such large positive exponents anyway,
and we are limited by i64 range, so increase the exponent value
to make sure we fully overflow that range.

Also, add a test to check that a very, very, small number is
treated as 0 (that's also undefined behaviour, but it does
make sense in a way).
Just use the format provided function.
Also, add a test to check that a very, very, small number is
treated as 0. That's probably undefined behaviour, but it does
make some sense.
The field was unused, and actually redundant with the precision
computed separatedly.

This simplifies the code, reintroduces testing.
A lot of the code can be shared, and parsing is quite straightforward
as we know that the digit is somewhat valid.
Address review comment.
@cakebaker cakebaker force-pushed the parse-bigdecimal-seq branch from 4089cf3 to 04a1282 Compare April 3, 2025 15:26
Copy link

github-actions bot commented Apr 3, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@cakebaker cakebaker merged commit 10a4dcb into uutils:main Apr 3, 2025
67 of 68 checks passed
@cakebaker
Copy link
Contributor

Thanks!

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