-printf: warn on unrecognized directives/escapes instead of dropping or erroring - #818
Open
MsfPablo wants to merge 1 commit into
Open
-printf: warn on unrecognized directives/escapes instead of dropping or erroring#818MsfPablo wants to merge 1 commit into
MsfPablo wants to merge 1 commit into
Conversation
…or erroring Two divergences from GNU find: - An unrecognized %X directive silently dropped the '%' and printed only the following character. - An unrecognized \X escape was a hard parse error (exit 1) instead of a warning. Both now print a "find: warning: ..." message to stderr and emit the directive/escape literally (with its '%' or '\' prefix), matching GNU find's behavior and exit code (0). Also fixes advance_one(), which sliced the remaining format string at a fixed 1-byte offset and panicked on multibyte characters (e.g. '€') immediately after '%' or '\' — using char::len_utf8() instead. Fixes uutils#815
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #818 +/- ##
=======================================
Coverage 91.93% 91.93%
=======================================
Files 35 35
Lines 7251 7256 +5
Branches 378 378
=======================================
+ Hits 6666 6671 +5
Misses 443 443
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit bdea188 has test result changes: GNU findutils testsuite: bfs testsuite: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GNU findutils treats an unrecognized
-printfdirective/escape as awarning and prints it literally, exiting 0. This diverged in two ways:
%X— the%was silently dropped\X— uutils errored instead of warningBoth cases now print a
find: warning: ...message to stderr and emitthe directive/escape literally (with its
%/\prefix), matching GNU.Along the way, fixed
advance_one(): it sliced the remaining formatstring at a fixed 1-byte offset, which panics on multibyte characters
(e.g.
€, as in the issue's own repro) immediately after%or\.Switched to
char::len_utf8().Test plan
%€,\€) andthe plain-ASCII unrecognized-directive case
test_parse_escapes,test_parse_formatting) that asserted the old (incorrect) behaviorcargo test— full suite green (226 unit + 61 integration tests)cargo fmt --checkcleanFixes #815