Skip to content

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

Merged
cakebaker merged 6 commits intouutils:mainfrom
drinkcat:parse-bigdecimal-seq
Apr 3, 2025
Merged

seq: Move to uucore/format common number parsing code#7624
cakebaker merged 6 commits intouutils:mainfrom
drinkcat:parse-bigdecimal-seq

Conversation

@drinkcat
Copy link
Collaborator

@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
@github-actions
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
@github-actions
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
@github-actions
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
@github-actions
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