sed: write appended text, R text and e output as GNU sed does - #589
DePasqualeOrg wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #589 +/- ##
==========================================
- Coverage 83.86% 83.79% -0.08%
==========================================
Files 14 14
Lines 7203 7219 +16
Branches 424 428 +4
==========================================
+ Hits 6041 6049 +8
- Misses 1157 1165 +8
Partials 5 5
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:
|
Merging this PR will improve performance by 36.51%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | access_log_append |
1.5 s | 1.1 s | +36.51% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing DePasqualeOrg:fix-r-separator-and-q-appends (ae5f8dc) with main (1113479)
3ab6bde to
ae5f8dc
Compare
Q|
GNU sed testsuite comparison: |
Please ignore this PR until it is marked as ready for review
This PR builds on #592, which fixes
n; only its last commit is new. It now also includes the change from #590, because each needed the other.When the last line of input has no final newline and the cycle ends with text queued by
a,rorR, GNU sed first writes the missing newline and then the queued text, even when anrfile is missing or empty. uutils sed joins them instead:printf a | sed 'r f'printsaimmediately followed by the contents off. This PR writes the missing newline before any text queued for the end of the cycle.GNU sed copies the line that
Rreads, and the output of thee commandform, exactly as they are. uutils sed treats them as lines and adds a newline when they lack one. With a filefthat containsxand no newline,printf 'a\nb\n' | sed 'R f'printsxandbon separate lines, while GNU sed printsxb. Likewise,printf 'a\n' | sed '1e printf hi'printshion a line of its own, while GNU sed printshia. This PR addsOutputBuffer::write_raw, which writes a newline that the previous output line lacks and then the bytes unchanged, and uses it for this text.Qnow discards text queued bya,randR, as GNU sed does. Before,printf 'x\n' | sed -e 'a A' -e QprintedA.qstill writes queued text. Finally,lnow prints$for an empty pattern space whose line lacked a newline.codecov/patchandcodecov/projectfail only because CI does not count the coverage of tests that run the sed binary; they should pass after #591 is merged.