Repository navigation
sed: write the newline a file's last line lacks before the next file's output, as GNU sed does - #596
DePasqualeOrg wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #596 +/- ##
==========================================
+ Coverage 94.85% 94.98% +0.13%
==========================================
Files 14 14
Lines 7230 7265 +35
Branches 432 432
==========================================
+ Hits 6858 6901 +43
+ Misses 371 363 -8
Partials 1 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:
|
Merging this PR will regress 1 benchmark
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | access_log_append |
1 s | 1 s | -2.01% |
| ⚡ | access_log_translit |
1,019.5 ms | 989.7 ms | +3.02% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing DePasqualeOrg:fix-separator-between-files (2a6a4c7) with main (96afb29)
f23aa4b to
f00be9e
Compare
…s output, as GNU sed does
f00be9e to
d572850
Compare
When an input file's last line has no final newline and another file follows, GNU sed writes the missing newline before the next output. uutils sed drops it, so the last line of one file runs into the first output of the next: with
printf a > 1andprintf 'b\n' > 2,sed '' 1 2printsabinstead ofaandbon separate lines. The same happens inwandWfiles.This PR carries the deferred newline from one file's output buffer to the next, and gives
NamedWriterthe same deferred newline forw,Wands///wfiles.Wnow passes its first line without the newline, so that the writer knows whether the line ended. With-i, each file keeps its own output, so nothing is carried between files.0rnow writes its file before a newline carried over from the previous file, which then comes before that file's first line, as in GNU sed.copy_filegains a variant that leaves the deferred newline in place for this.-zis still ignored, so with-zthe files also get a newline between them, as they do without it.