Conversation
The -z (--null-data) option was accepted but ignored. Keep the line separator in the processing context and use it to split input lines (including those read by R), to terminate output lines (including those of =, F, i, c, l and the w and W files), and to join lines in N, G and H and split them in D, P and W, as GNU sed does. As in GNU sed, text appended by a, and the output of e, are written unchanged, and l lists a newline in the pattern space as \n. Fixes uutils#530
|
Before this PR was submitted, I already developed my own patch to fix the same issue. I won't open it as a competing PR unless requested, but Claude Code found some cases where this PR's output differs from GNU sed 4.10 and my patch's output matches it (
1 and 2 are older bugs that also occur without |
Merging this PR will regress 3 benchmarks
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | access_log_translit |
1 s | 1 s | -3.31% |
| ❌ | access_log_subst |
2.3 s | 2.4 s | -3.2% |
| ❌ | number_fix |
1.2 s | 1.3 s | -2.12% |
| ⚡ | no_op_short |
2.5 s | 2.4 s | +3.97% |
| ⚡ | access_log_no_op |
1.7 s | 1.7 s | +2.83% |
| ⚡ | access_log_no_subst |
1.1 s | 1.1 s | +2.11% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing sap1110:fix-zero-terminated-separator (05b8c9d) with main (0554c50)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #585 +/- ##
==========================================
+ Coverage 83.67% 84.32% +0.65%
==========================================
Files 14 14
Lines 7067 7349 +282
Branches 413 428 +15
==========================================
+ Hits 5913 6197 +284
+ Misses 1149 1146 -3
- Partials 5 6 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
GNU sed testsuite comparison: |
|
GNU sed testsuite comparison: |
- Keep a mmapped line's NUL terminator when the line is modified, so that records emptied by z keep their separator with -z. - Strip a trailing NUL rather than \n from the output of e with -z. - Output the separator missing at the end of one input file before the next file's output, and don't add one to an unterminated line left by N at the end of input. - Make Q output nothing more, not even appended text or a missing separator, as in GNU sed.
|
@DePasqualeOrg thanks for checking this against GNU sed. All four are fixed in 05b8c9d:
Fixing 1 exposed one more case: |
|
GNU sed testsuite comparison: |
sed -z was accepted but ignored, so input was still split on newlines. This PR makes -z work as it does in GNU sed.
Fixes #530