Commit graph

7853 commits

Author SHA1 Message Date
Solomon Victorino
4aba193c9c expand: move to thiserror 2025-03-30 21:15:21 +02:00
Solomon Victorino
4cb23dd840 ptx: move to thiserror 2025-03-30 21:15:21 +02:00
ValentinBoudevin
aea23408fd
env: Move to "thiserror" + added errors test case (#7584)
Solved Issue #7535 : Removed parse_errors to follow other commands standard with thiserror
2025-03-30 11:21:57 +02:00
Sylvestre Ledru
903fa6ae88
Merge pull request #7514 from drinkcat/format-bigdecimal-tests
uucore: format: num_format: add `fmt` function tests, and workaround 0e10 printing.
2025-03-29 15:43:14 +01:00
Sylvestre Ledru
f5241e9d7a
Merge pull request #7605 from karlmcdowall/sum_error_handling
sum: Rework some error handling
2025-03-29 09:16:47 +01:00
Karl McDowall
912dc47bef sum: Rework some error handling
Update sum to properly propagate errors from file-reads,
including implementing a retry on ErrorKind::Interrupted.
Also switch to using writeln! rather than println! to prevent
crashes if stdout is directed to /dev/full
2025-03-28 19:22:31 -06:00
cerdelen
8c8beb96e4
echo: fixed double hyphen as argument (#7581)
* Fixes #7558 Added check to only insert addition double hyphen if at start of arguments to correctly prepend addition hyphens for clap as well as additional test case

* additional comment

* fixes issue where flags precedes "--" as arguments
2025-03-28 13:31:48 +01:00
Sylvestre Ledru
1c75854d2f
Merge pull request #7576 from drinkcat/ci-macos
Test workspace CI on macos
2025-03-28 11:54:58 +01:00
Nicolas Boichat
4cecad3e35 uucore: format: num_format: add fmt function tests
All the other tests directly called format_float_* functions,
bypassing the additional logic in `fmt` (negative numbers, padding,
etc.).

This also tests the `parse` function in `mod.rs`, which calls back
into `try_from_spec` here. This also makes it easier to test a lot
of different format combinations without having to do end-to-end
tests in `test_printf.rs`.

Also add broken tests for the issues in #7509 and #7510.
2025-03-27 14:41:26 +01:00
Nicolas Boichat
afbab45350 uucore: format: Workaround BigDecimal printing bug with 0
This is a bigdecimal issue, see
https://github.com/akubera/bigdecimal-rs/issues/144 .

Also add a few tests, including a disabled one (our workaround
is _before_ the call to format_float_decimal).
2025-03-27 14:41:26 +01:00
Nicolas Boichat
59396e32bc chcon/runcon: Only build on Linux
chcon/runcon rely on the selinux crate, that is empty on
non-Linux platforms.

This doesn't matter for normal builds that use the default features
for the platform (explicitly trying to build them will fail though).

This is a problem when using `cargo test --workspace` though,
as that tries to build all packages, including uu_chcon/uu_runcon.

Just prevent compilation of these source files when target_os != linux.
2025-03-27 10:29:46 +01:00
Nicolas Boichat
3d0c59ae97 stat: Print what kind of "weird" mode it is, if it's "weird"
Maybe useful to (partially) understand what is going on in #7583.
2025-03-26 20:20:50 +01:00
Sylvestre Ledru
d33d731804
Merge pull request #7548 from lewisboon/bugfix/date-negative-offset
date: allow negative date offsets
2025-03-26 08:49:46 +01:00
Sylvestre Ledru
2488e17aef
Merge pull request #7571 from cakebaker/hostid_use_libc
hostid: use `gethostid` from Rust `libc`
2025-03-25 13:20:24 +01:00
Nicolas Boichat
5d53da9f3e uudoc: Fix for edition 2024
This change is documented here: https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html

I'm... not sure to understand everything, but this change is what
`cargo fix --edition --features="uudoc" --allow-dirty`
suggests.

Fixes #7572.
2025-03-25 12:16:28 +01:00
Daniel Hofstetter
2a0bfb8bd5 hostid: use gethostid from Rust libc 2025-03-25 10:40:51 +01:00
Lewis Boon
b02e3d587d date: allow negative date offsets
Issue #7515
Clap needs to be specifically configured to allow values
with a leading hyphen.
2025-03-24 22:03:38 +00:00
Sylvestre Ledru
b4ac10769d add some missing unsafe 2025-03-24 21:33:16 +01:00
Sylvestre Ledru
d671849b7f uucore: set the unsafe at the right place 2025-03-24 21:33:16 +01:00
Sylvestre Ledru
a85539f530 Run cargo fmt on the tree 2025-03-24 21:33:12 +01:00
Sylvestre Ledru
36dd968c9a head: fix an iterator 2025-03-24 21:03:58 +01:00
Sylvestre Ledru
39f5c394a7 Fix 'does not live long enough' 2025-03-24 21:03:10 +01:00
Sylvestre Ledru
b1d676d3b5 add missing unsafe around extern 2025-03-24 21:03:00 +01:00
Sylvestre Ledru
5b1b40bfd8 Fix 'binding modifiers may only be written when the default binding mode is' 2025-03-24 21:02:48 +01:00
Sylvestre Ledru
95b2de78e1 Fix 'extern blocks must be unsafe' 2025-03-24 21:02:40 +01:00
Sylvestre Ledru
2739c19330 Fix unsafe attribute used without unsafe 2025-03-24 21:00:53 +01:00
Sylvestre Ledru
e0fbced116 rust edition 2021 => 2024 2025-03-24 21:00:35 +01:00
Sylvestre Ledru
f5eff9517f Bump MSRV to 1.85.0 2025-03-24 21:00:16 +01:00
Sylvestre Ledru
39706be414
Merge pull request #7512 from dlrobertson/issue-7505
printf: trim leading whitespace when parsing numeric values
2025-03-24 19:11:15 +01:00
Sylvestre Ledru
1ee8092826
Merge pull request #7525 from sylvestre/thiserror4
Move more programs to thiserror
2025-03-24 19:06:13 +01:00
Sylvestre Ledru
36231f7551
Merge pull request #7562 from drinkcat/seq-perf-1
seq: Directly write separator string, instead of using format
2025-03-24 19:05:14 +01:00
Nicolas Boichat
66745427cb seq: Directly write separator string, instead of using format
Doing `stdout.write_all(separator.as_bytes())?` is quite a bit
faster than using format to do the same operation:
`write!(stdout, "{separator}")?`.

This speeds up by about 10% on simple cases.

We do the same for the terminator even though this has no measurable
performance impact.
2025-03-24 18:02:06 +01:00
Dan Robertson
1a0bc30f17 printf: trim leading whitespace when parsing numeric values
Trim leading whitespace from numeric input to printf.
2025-03-24 16:27:58 +00:00
lbellomo
d561ee8f16 doc: escape RE with '`' 2025-03-24 12:01:16 -03:00
Sylvestre Ledru
ffe8762ee6 Fix the GNU test
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
2025-03-24 14:22:25 +01:00
Sylvestre Ledru
305be09403 ls: move to thiserror 2025-03-24 14:22:25 +01:00
Sylvestre Ledru
9d123febb3 install: move to thiserror 2025-03-24 14:22:25 +01:00
Sylvestre Ledru
c1bb57fd1e ln: move to thiserror 2025-03-24 14:22:25 +01:00
Sylvestre Ledru
d0e6a6271c join: move to thiserror 2025-03-24 14:22:25 +01:00
Sylvestre Ledru
8931d2c26e
Merge pull request #7521 from usamoi/ptx
ptx: fixes
2025-03-23 09:28:20 +01:00
Sylvestre Ledru
eed5c81060
Merge pull request #7463 from blyxxyz/clean-shuf
Make `shuf` OsStr-compliant and bring newline handling in line with GNU
2025-03-22 22:29:49 +01:00
Sylvestre Ledru
b540e18dec
Merge pull request #7519 from karlmcdowall/cat_perf
cat: Improve performance of formatting.
2025-03-22 21:54:13 +01:00
Nicolas Boichat
d678e5320f uucore: format: Fix uppercase hex floating point printing
Accidentally broke this use case when refactoring.

Added a test as well.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
e6c24b245a uucore: format: Small optimizations in num_format for seq
In most common use cases:
 - We can bypass a lot of `write_output` when width == 0.
 - Simplify format_float_decimal when the input is an integer.

Also document another interesting case in src/uu/seq/BENCHMARKING.md.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
f31ba2bd28 seq: Make use of uucore::format to print in all cases
Now that uucore format functions take in an ExtendedBigDecimal,
we can use those in all cases.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
25c492ee19 uucore: format: Pad non-finite numbers with spaces, not zeros
`printf "%05.2f" inf` should print `  inf`, not `00inf`.

Add a test to cover that case, too.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
ec450d602a uucode: format: format_float_hexadecimal: Take in &BigDecimal
Display hexadecimal floats with arbitrary precision.

Note that some of the logic will produce extremely large
BitInt as intermediate values: there is some optimization
possible here, but the current implementation appears to work
fine for reasonable numbers (e.g. whatever would previously
fit in a f64, and even with somewhat large precision).
2025-03-22 21:13:18 +01:00
Nicolas Boichat
f0e9b8621f uucode: format: format_float_shortest: Take in &BigDecimal
Similar logic to scientific printing. Also add a few more tests
around corner cases where we switch from decimal to scientific
printing.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
7f0e5eb473 uucode: format: format_float_scientific: Take in &BigDecimal
No more f64 operations needed, we just trim (or extend) BigDecimal to
appropriate precision, get the digits as a string, then add the
decimal point.

Similar to what BigDecimal::write_scientific_notation does, but
we need a little bit more control.
2025-03-22 21:13:18 +01:00
Nicolas Boichat
edaccc88b9 uucode: format: format_float_decimal: Take in &BigDecimal
Also add a few unit tests to make sure precision is not lost anymore.
2025-03-22 21:13:18 +01:00