| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
Codecov Report❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #842 +/- ##
==========================================
+ Coverage 91.93% 92.05% +0.12%
==========================================
Files 35 35
Lines 7251 7353 +102
Branches 378 381 +3
==========================================
+ Hits 6666 6769 +103
+ Misses 443 441 -2
- Partials 142 143 +1 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
|
Commit f4f13ff has test result changes: bfs testsuite: Test results comparison: Current: TOTAL: 312 / PASSED: 266 / FAILED: 40 / SKIPPED: 6 Reference: TOTAL: 314 / PASSED: 266 / FAILED: 42 / SKIPPED: 6 Changes from main branch: TOTAL: -2 PASSED: +0 FAILED: -2 Test improvements (2): + gnu/files0_from_ok + gnu/okdir_path_empty |
Sorry, something went wrong.
| /// | ||
| /// 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)] |
There was a problem hiding this comment.
why only unix ?
Sorry, something went wrong.
There was a problem hiding this comment.
@MsfPablo ping?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I was diffing our find against GNU findutils 4.11 across the -printf directives and %S came out differently on every file that isn't a round ratio.
GNU prints the sparseness ratio with %g; we use {:.1}:
So %g differs 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 small format_g helper and routes %S through it. The zero-length and non-unix branches returned the literal "1.0" and are now "1", matching the ./empty line above.
The unit test's expected values are the output of C's printf("%g", ...) under glibc with LC_ALL=C, including the rounding-changes-the-exponent case (999999.9 -> 1e+06) and the exponent-form case (1234567 -> 1.23457e+06). After the change find -printf '%S %p\n' is byte-identical to GNU on my test tree.
One thing I deliberately left alone: GNU honours LC_NUMERIC for %S (it prints 1365,33 in a comma-decimal locale) while we always emit .. That's a separate matter from the formatting itself, so it felt out of scope here.