Repository navigation
Conversation
In %b arguments, malformed \x, \u, and \U escape sequences were previously swallowed by parse_escape_only, printing a literal \x and exiting 0 while dropping consumed characters in \u and \U. Make parse_escape_only return Result<EscapedChar, FormatError> and propagate errors from %b argument parsing so printf reports missing hex numbers and invalid universal character names with exit code 1 to match GNU coreutils. Also ensure parse_unicode only consumes input when hex digits are present. Fixes uutils#14404
|
GNU testsuite comparison: |
|
some jobs are failing |
|
Hi — thanks for turnin so fast! Moving Two things came up testing your branch against GNU 9.7: Output produced before the bad escape is dropped. GNU writes everything it It scales with the argument — with 100,000 Out-of-range Same for The Separately, and not from this change: uutils' Measured on GNU coreutils 9.7 (Ubuntu 26.04) against 71a9079, |
…ut-of-range \U In %b arguments, valid converted bytes preceding a malformed escape sequence were discarded when parsing failed. Write converted bytes directly to the output writer so prefixes are preserved on error. Also pass through \U escape sequences whose numeric value exceeds 0x10FFFF verbatim with exit status 0, matching GNU coreutils. Format error is kept only for invalid universal character names (surrogate code points in 0xD800..=0xDFFF).
…rintf-b-escapes
|
I tested eae9778 against GNU coreutils 9.12. The four escapes in the #14404 table, the dropped-text examples and the well-formed escapes now match GNU in stdout and exit status, in the format string and in |
…rintf-b-escapes
Merging this PR will degrade performance by 3.65%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | factor_three_39_bit_primes |
942.2 ms | 1,250.4 ms | -24.64% |
| ⚡ | Simulation | factor_five_38_bit_primes |
1.8 s | 1.6 s | +11.11% |
| ⚡ | Simulation | factor_thirteen_39_bit_primes |
9.4 s | 8.8 s | +6.82% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing zfaustk:fix-printf-b-escapes (44d6422) with main (774cca5)2
Footnotes
-
70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(fb68e6c) during the generation of this report, so 774cca5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
In
%barguments, malformed\x,\u, and\Uescape sequences were previously swallowed byparse_escape_only, printing a literal\xand exiting 0 while dropping consumed characters in\uand\U.Make
parse_escape_onlyreturnResult<EscapedChar, FormatError>and propagate errors from%bargument parsing so printf reports missing hex numbers and invalid universal character names with exit code 1 to match GNU coreutils. Also ensureparse_unicodeonly consumes input when hex digits are present.Fixes #14404