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
* 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
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.
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.
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.
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.
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).
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.