Skip to content

find: -printf: fix %A+/%C+/%T+ fractional seconds to match GNU#757

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:find-fix-printf-plus-fractional
Open

find: -printf: fix %A+/%C+/%T+ fractional seconds to match GNU#757
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:find-fix-printf-plus-fractional

Conversation

@leeewee

@leeewee leeewee commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

-printf %A+/%C+/%T+ diverged from GNU on low-precision timestamps. The %+ format expanded to …%S%.f0, using chrono's %.f, which trims trailing zeros and omits the fraction entirely when it is zero. GNU always writes a fixed-width fraction (snprintf(".%09ld0", tv_nsec) in find/print.c).

Before:

$ touch -d @1700000000 a          # whole second, ns = 0
$ find a -printf '%A+\n'
2023-11-14+22:13:200              # missing ".NNNNNNNNN"
$ /usr/bin/find a -printf '%A+\n'
2023-11-14+22:13:20.0000000000

After — matches GNU byte-for-byte across ns = 0 / microsecond / full precision:

$ find a -printf '%A+\n'
2023-11-14+22:13:20.0000000000

The fix uses .%f (literal dot + fixed 9-digit %f), like the %S and ctime paths already do. As a side effect it makes the existing find_printf test's %A+ assertion deterministic (always .NNNNNNNNN0), which removes the intermittent Windows CI failure seen on that test.

The `%+` format used chrono's `%.f`, which trims trailing zeros and omits
the fraction when it is zero — so a whole-second timestamp printed `…:200`
instead of GNU's `…:20.0000000000`. Use fixed-width `.%f`, matching GNU's
`.%09ld0`.
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.88%. Comparing base (6ceb2a7) to head (98bfad2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #757   +/-   ##
=======================================
  Coverage   91.88%   91.88%           
=======================================
  Files          35       35           
  Lines        7159     7159           
  Branches      377      377           
=======================================
  Hits         6578     6578           
  Misses        437      437           
  Partials      144      144           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Commit 98bfad2 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 267 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 267 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +2
  PASSED: +0
  FAILED: +2

New test failures (2):
  - gnu/files0_from_ok
  - gnu/okdir_path_relative

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing leeewee:find-fix-printf-plus-fractional (98bfad2) with main (6ceb2a7)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant