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
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.
Using an associated type in Formatter trait was quite nice, but, in
a follow-up change, we'd like to pass a _reference_ to the Float
Formatter, while just passing i64/u64 as a value to the Int
formatters. Associated type doesn't allow for that, so we turn
it into a generic instead.
This makes Format<> a bit more complicated though, as we need
to specify both the Formatter, _and_ the type to be formatted.
Will make it possible to directly print ExtendedBigDecimal in `seq`,
and gradually get rid of limited f64 precision in other tools
(e.g. `printf`).
Changes are mostly mechanical, we reexport ExtendedBigDecimal directly
in format to keep the imports slightly shorter.