Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #842 +/- ##
==========================================
+ Coverage 93.07% 93.10% +0.03%
==========================================
Files 37 37
Lines 8131 8168 +37
Branches 404 407 +3
==========================================
+ Hits 7568 7605 +37
+ Misses 424 423 -1
- Partials 139 140 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performanceWarning uutils has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 1 warning
Comparing |
|
Commit f4f13ff has test result changes: bfs testsuite: |
| /// | ||
| /// GNU find prints `%S` with `%g`, so a ratio of exactly 2048 comes out as | ||
| /// `2048` rather than `2048.0`, and 512*8/6 as `682.667` rather than `682.7`. | ||
| #[cfg(unix)] |
|
@MsfPablo last ping before i close it |
| let decimals = (PRECISION - 1 - exponent).max(0) as usize; | ||
| trim(&format!("{value:.decimals$}")).to_string() | ||
| } else { | ||
| let formatted = format!("{:.*e}", (PRECISION - 1) as usize, value); |
There was a problem hiding this comment.
same format! as line 45, could be reused, no?
| format_g((meta.blocks() * STANDARD_BLOCK_SIZE) as f64 / (meta.len() as f64)).into() | ||
| } else { | ||
| "1.0".into() | ||
| "1".into() |
There was a problem hiding this comment.
please add a test running -printf '%S' through the matcher too (an empty file giving 1 is easy)
| /// Expected values come from C's `printf("%g", value)` (glibc, LC_ALL=C). | ||
| #[cfg(unix)] | ||
| #[test] | ||
| fn format_g_matches_c_printf() { |
There was a problem hiding this comment.
please move this test below the use lines
f4f13ff to
1901f04
Compare
|
hi, any news on the 4 comments above? thanks |
GNU find prints the sparseness ratio with %g, so a file with 8 blocks
and 2 bytes shows as 2048 and one with 6 bytes as 682.667. We printed
{:.1} instead, giving 2048.0 and 682.7, and 1.0 instead of 1 for the
zero-length case.
1901f04 to
35f1f59
Compare
I was diffing our
findagainst GNU findutils 4.11 across the-printfdirectives and%Scame out differently on every file that isn't a round ratio.GNU prints the sparseness ratio with
%g; we use{:.1}:So
%gdiffers from{:.1}in three ways that all show up here: 6 significant digits rather than 1 decimal place, trailing zeros and a trailing.stripped, and a switch to exponent form outside[1e-4, 1e6).Rust has no
%g, so this adds a smallformat_ghelper and routes%Sthrough it. The zero-length and non-unix branches returned the literal"1.0"and are now"1", matching the./emptyline above.The unit test's expected values are the output of C's
printf("%g", ...)under glibc withLC_ALL=C, including the rounding-changes-the-exponent case (999999.9->1e+06) and the exponent-form case (1234567->1.23457e+06). After the changefind -printf '%S %p\n'is byte-identical to GNU on my test tree.One thing I deliberately left alone: GNU honours
LC_NUMERICfor%S(it prints1365,33in a comma-decimal locale) while we always emit.. That's a separate matter from the formatting itself, so it felt out of scope here.