Skip to content

Conversation

@drinkcat
Copy link
Collaborator

Stacks on top of #7556. A bunch of fixes and additions to parsing code that brings common core parsing to parity with seq implementation, and will allow the custom seq parser to be removed in the next PR.


uucore: format: Remove TODO

Not much more that can be easily simplified now.

uucore: format: num_parser: Allow uppercase exponent

1E3 and 0x1P3 are acceptable numbers.

Sprinkle uppercase values in the tests.

uucore: format: num_parser: underflow/overflow check

When parsing floating point numbers, return errors if we end up
overflowing/underflowing BigDecimal (e.g. with large/small exponents).

uucore: format: num_parser: Add value to Overflow error

When parsing integers, we should still return the min/max value
of the type (depending on the type), and wrap that in the error.

We need to refactor the map function to handle this case better,
and add an extract function to get the value out of an error
(if any).

This fixes the integer part of #7508.

uucore: format: Fix i64::MIN printing

-i64::MIN overflows i64, so cast to i128 first.

uucore: format: num_parser: Carve out part of parse function

We'll need more logic in there.

uucore: format: num_parser: "infinity" string parsing

Not just "inf" is allowed, also "infinity".

uucore: format: extendedbigdecimal: Implement Neg trait

This is useful and will simplify some of the parsing logic later.

@github-actions
Copy link

GNU testsuite comparison:

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

drinkcat added 8 commits April 1, 2025 11:20
This is useful and will simplify some of the parsing logic later.
Not just "inf" is allowed, also "infinity".
-i64::MIN overflows i64, so cast to i128 first.
When parsing integers, we should still return the min/max value
of the type (depending on the type), and wrap that in the error.

We need to refactor the map function to handle this case better,
and add an extract function to get the value out of an error
(if any).

This fixes the integer part of uutils#7508.
When parsing floating point numbers, return errors if we end up
overflowing/underflowing BigDecimal (e.g. with large/small exponents).
1E3 and 0x1P3 are acceptable numbers.

Sprinkle uppercase values in the tests.
Not much more that can be easily simplified now.
@drinkcat drinkcat force-pushed the parse-bigdecimal-smallfixes branch from 9081d52 to bdc8cd1 Compare April 1, 2025 09:20
@drinkcat drinkcat marked this pull request as ready for review April 1, 2025 09:20
@github-actions
Copy link

github-actions bot commented Apr 1, 2025

GNU testsuite comparison:

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

@RenjiSann
Copy link
Collaborator

The changes look sound to me, no regression in the testsuite.
Will merge.

Thank you for the contribution !

@RenjiSann RenjiSann merged commit 17d81bb into uutils:main Apr 1, 2025
68 checks passed
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