Skip to content

Conversation

@dspinellis
Copy link
Collaborator

@dspinellis dspinellis commented Jan 18, 2026

Before this commit, the output of sed was lagging one line behind, as it was always checking whether each line was the last one ($). This change modifies the behavior to perform this check only when actually needed. This brings sed's interactive behavior (when reading from a terminal) in line with the GNU and FreeBSD implementations.

In addition this PR adds support for the GNU address 0 extension and for ~step ranges. To support this it refactors the address representation.

@sylvestre
Copy link
Contributor

a few tests are failing :)

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 74.25743% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.03%. Comparing base (c6479b4) to head (88c25a3).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/sed/processor.rs 0.00% 58 Missing ⚠️
src/sed/compiler.rs 90.00% 19 Missing ⚠️
src/sed/fast_io.rs 98.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
- Coverage   82.11%   82.03%   -0.08%     
==========================================
  Files          13       13              
  Lines        5327     5423      +96     
  Branches      294      291       -3     
==========================================
+ Hits         4374     4449      +75     
- Misses        951      972      +21     
  Partials        2        2              
Flag Coverage Δ
macos_latest 82.48% <74.50%> (-0.07%) ⬇️
ubuntu_latest 82.59% <74.50%> (-0.07%) ⬇️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@dspinellis
Copy link
Collaborator Author

On it.

@dspinellis dspinellis force-pushed the last-line branch 2 times, most recently from 8ad52fb to 2bf6a94 Compare January 18, 2026 22:13
@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@dspinellis
Copy link
Collaborator Author

@sylvestre I fixed the issue.

@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@dspinellis dspinellis changed the title Improve interactive output Improve command range handling Jan 20, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 20, 2026

Merging this PR will degrade performance by 3.47%

❌ 1 regressed benchmark
✅ 10 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
access_log_translit 784.3 ms 812.5 ms -3.47%

Comparing dspinellis:last-line (88c25a3) with main (398ee76)

Open in CodSpeed

@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

Before this commit, the output of sed was lagging one line behind, as it
was always checking whether each line was the last one ($).  This change
modifies the behavior to make this check only when actually needed.
This brings sed's interactive behavior (when reading from a terminal) in
line with the GNU and FreeBSD implementations.
This is a GNU extension that starts the range as latched.
While at it, also fix the handling of ranges straddling independent
files.
This removes invalid states and simplifies pattern matching.
It also makes it easier to add further address extensions.
@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

1 similar comment
@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@github-actions
Copy link

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@dspinellis
Copy link
Collaborator Author

@sylvestre This PR is now ready for review. I don't have anything related to add to it. Will work on further GNU compatibility improvements once this gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants