Daniel Hofstetter
636e4a777b
uucore/format: remove Display impl
...
of ExtendedBigDecimal
2025-04-01 17:08:04 +02:00
Nicolas Boichat
8cf4da0b19
uucore: format: Fix hexadecimal default format print
...
The default hex format, on x86(-64) prints 15 digits after the
decimal point, _but_ also trims trailing zeros, so it's not just
a simple default precision and a little bit of extra handling is
required.
Also add a bunch of tests.
Fixes #7364 .
2025-04-01 15:04:47 +02:00
Nicolas Boichat
3f24796c8d
uucore: format: Use Option for Float precision
...
The default precision for float actually depends on the format.
It's _usually_ 6, but it's architecture-specific for hexadecimal
floats.
Set the precision as an Option, so that:
- We don't need to sprinkle `6` in callers
- We can actually handle unspecified precision correctly in
float printing (next change).
2025-04-01 15:04:47 +02:00
Nicolas Boichat
3ab68bad10
uucore: format: Fix hexadecimal uppercase print (again)
...
When '%A' format is specified, we also need to capitalize the
`0x`, i.e. `0XEP-3`, not `0xEP-3`.
2025-04-01 15:04:47 +02:00
Daniel Hofstetter
eaa8332be4
Bump bigdecimal from 0.4.7 to 0.4.8
2025-04-01 15:02:30 +02:00
Dorian Péron
17d81bb9a1
Merge pull request #7623 from drinkcat/parse-bigdecimal-smallfixes
...
uucore: format: Collection of small parser fixes
2025-04-01 12:36:28 +02:00
Dorian Péron
fb165850a4
Merge pull request #7567 from MoSal/faster_sort_n
...
sort: immediately compare whole lines if they parse as numbers
2025-04-01 12:14:29 +02:00
Dorian Péron
e4fa68c57d
Merge pull request #7629 from cakebaker/uptime_fix_unused_import_warning
...
uptime: fix "unused import" warning in test
2025-04-01 12:09:39 +02:00
Nicolas Boichat
bdc8cd12a1
uucore: format: Remove TODO
...
Not much more that can be easily simplified now.
2025-04-01 11:20:17 +02:00
Nicolas Boichat
a46da8d0b9
uucore: format: num_parser: Allow uppercase exponent
...
1E3 and 0x1P3 are acceptable numbers.
Sprinkle uppercase values in the tests.
2025-04-01 11:20:17 +02:00
Nicolas Boichat
16131b8d7b
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).
2025-04-01 11:20:17 +02:00
Nicolas Boichat
1e104b7ef9
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 .
2025-04-01 11:20:17 +02:00
Nicolas Boichat
9872263a96
uucore: format: Fix i64::MIN printing
...
-i64::MIN overflows i64, so cast to i128 first.
2025-04-01 11:20:17 +02:00
Nicolas Boichat
5bea6ff013
uucore: format: num_parser: Carve out part of parse function
...
We'll need more logic in there.
2025-04-01 11:20:17 +02:00
Nicolas Boichat
0cb37c83b9
uucore: format: num_parser: "infinity" string parsing
...
Not just "inf" is allowed, also "infinity".
2025-04-01 11:20:17 +02:00
Nicolas Boichat
5c06dd580b
uucore: format: extendedbigdecimal: Implement Neg trait
...
This is useful and will simplify some of the parsing logic later.
2025-04-01 11:20:17 +02:00
Dorian Péron
ace92dcca1
Merge pull request #7556 from drinkcat/parse-bigdecimal
...
uucore: format: num_parser: Use ExtendedBigDecimal
2025-04-01 10:52:50 +02:00
Daniel Hofstetter
1fe764230f
Merge pull request #7611 from drinkcat/stat-disable-macosx
...
test_stat: Disable test_stdin_pipe_fifo1/2 on Mac OS X
2025-04-01 09:42:01 +02:00
Daniel Hofstetter
7b6d05f81d
uptime: fix "unused import" warning in test
2025-04-01 09:21:38 +02:00
Daniel Hofstetter
3fded2a12e
deny.toml: update comments
2025-04-01 08:15:18 +02:00
Daniel Hofstetter
2b31be039c
deny.toml: add windows-core to skip list
2025-04-01 08:07:50 +02:00
Daniel Hofstetter
aa3b3a7eac
Bump iana-time-zone from 0.1.62 to 0.1.63
2025-04-01 08:03:00 +02:00
Dorian Péron
6675460d1d
Merge pull request #7580 from GTimothy/cksum_no_regex
...
cksum: take out regex pattern matching
2025-04-01 02:10:42 +02:00
Jan Verbeek
1a7759586a
cut: Make Write
arguments generic instead of dyn
...
We pass a `&mut dyn Write` in anyway, but now that's entirely up to
the caller.
2025-03-31 18:28:18 +02:00
GTimothy
09a9dc72b9
checksum/cksum: fix: filename that include separator should parse + add tests
...
fixes this non-regex implementation's flaw with file_names containing
the separator's pattern:
- replaces left-to-right greedy separator match with right-to-left one.
- added bugfix tests
fixes secondary bug: positive match on hybrid posix-openssl format
adds secondary bugfix tests
Co-authored-by: Dorian Péron
<72708393+RenjiSann@users.noreply.github.com>
2025-03-31 17:18:18 +02:00
GTimothy
04ad55510b
checksum/cksum: update tests to test new parsers not regex
2025-03-31 17:18:18 +02:00
GTimothy
621f2b5c7a
checksum/cksum: rewrite lineformat parsing without regex
...
removes dependency on the regex crate for LineFormat detection and
parsing, resulting in a faster and lighter cksum binary.
2025-03-31 17:18:18 +02:00
Jan Verbeek
a9cd3f132e
uniq: Flush BufWriter
, make error context GNU-like
2025-03-31 13:46:33 +02:00
Jan Verbeek
181844eafa
tr: Flush BufWriter
, fix double error context
...
Write errors led with `tr: tr: write error:`.
2025-03-31 13:46:33 +02:00
Jan Verbeek
cf50952325
tail: Flush BufWriter
2025-03-31 13:46:33 +02:00
Jan Verbeek
11ef1522ca
tac: Flush BufWriter
2025-03-31 13:46:24 +02:00
Jan Verbeek
d456e90596
sort: Flush BufWriter
, don't panic on write errors
2025-03-31 13:46:15 +02:00
Jan Verbeek
bfdde70309
ptx: Flush BufWriter
, add context to errors
2025-03-31 13:46:05 +02:00
Jan Verbeek
cba48c0284
cut: Flush BufWriter
, centralize output file logic
2025-03-31 13:45:10 +02:00
Nicolas Boichat
30c89af9ac
uucore: format: num_parser: Make it clear that scale can only be positive
...
After scratching my head a bit about why the hexadecimal code works,
seems better to do make scale an u64 to clarify.
Note that this may u64 may exceed i64 capacity, but that can only
happen if the number of digits provided > 2**63 (impossible).
2025-03-31 10:04:08 +02:00
Nicolas Boichat
bd68eb8beb
uucore: format: num_parser: Parse exponent part of floating point numbers
...
Parse numbers like 123.15e15 and 0xfp-2, and add some tests
for that.
`parse` is becoming more and more of a monster: we should consider
splitting it into multiple parts.
Fixes #7474 .
2025-03-31 10:04:08 +02:00
Nicolas Boichat
55773e9d35
uucore: format: num_parser: Fix large hexadecimal float parsing
...
Large numbers can overflow u64 when doing 16u64.pow(scale):
do the operation on BigInt/BigDecimal instead.
Also, add a test. Wolfram Alpha can help confirm the decimal number
is correct (16-16**-21).
2025-03-31 10:04:08 +02:00
Nicolas Boichat
b5a658528b
uucore: format: Use ExtendedBigDecimal in argument code
...
Provides arbitrary precision for float parsing in printf.
Also add a printf test for that.
2025-03-31 10:04:08 +02:00
Nicolas Boichat
71a285468b
uucore: format: num_parser: Add parser for ExtendedBigDecimal
...
Very simple as the f64 parser actually uses that as intermediary
value.
Add a few tests too.
2025-03-31 10:04:08 +02:00
Nicolas Boichat
d7502e4b2e
uucore: format: num_parser: Disallow binary number parsing for floats
...
Fixes #7487 .
Also, add more tests for leading zeros not getting parsed as octal
when dealing with floats.
2025-03-31 10:04:08 +02:00
Nicolas Boichat
97e333c6d9
uucore: format: num_parser: allow leading + sign when parsing
...
Leading plus signs are allowed for all formats.
Add tests (including some tests for negative i64 values, and mixed
case special values that springed to mind).
Fixes #7473 .
2025-03-31 10:04:08 +02:00
Nicolas Boichat
40a7c65980
uucore: format: num_parser: Turn parser into a trait
...
We call the function extended_parse, so that we do not clash
with other parsing functions in other traits.
- Also implement parser for ExtendedBigDecimal (straightforward).
- Base doesn't need to be public anymore.
- Rename the error to ExtendedParserError.
2025-03-31 10:04:08 +02:00
Nicolas Boichat
8bbec16115
uucore: format: num_parser: Fold special value parsing in main parsing function
2025-03-31 10:04:08 +02:00
Nicolas Boichat
20add88afc
uucore: format: num_parser: Use ExtendedBigDecimal for internal representation
...
ExtendedBigDecimal already provides everything we need, use that
instead of a custom representation.
2025-03-31 10:04:08 +02:00
Daniel Hofstetter
07cce029cb
Merge pull request #7621 from uutils/renovate/blake3-1.x-lockfile
...
chore(deps): update rust crate blake3 to v1.8.0
2025-03-31 08:46:31 +02:00
renovate[bot]
b89be8c9a7
chore(deps): update rust crate blake3 to v1.8.0
2025-03-31 05:52:26 +00:00
Solomon Victorino
e20500d1e5
numfmt: move to thiserror
2025-03-30 21:15:21 +02:00
Solomon Victorino
4f1d33fec3
dd: move to thiserror
2025-03-30 21:15:21 +02:00
Solomon Victorino
047d9a930b
wc/BufReadDecoderError: move to thiserror
2025-03-30 21:15:21 +02:00
Solomon Victorino
9099f342e0
unexpand: move to thiserror
2025-03-30 21:15:21 +02:00