Skip to content

sed: fix panics and zero steps in ~ and , addresses - #578

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:fix-range-address-panics
Sep 27, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:fix-range-address-panics

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

A range address that ended early made the parser panic: 1~ read past the end of the line, and 1~p, 1,~p or 1,p handed a command letter to the address parser, which only knew how to panic on it. A missing ~step now counts as 0, and a comma with no address after it is reported as an unexpected `,'. The address parser returns an error instead of panicking.

A step of 0 was not handled either: 2,~0 ran to the end of the input instead of selecting line 2 alone, and 0~0, which can select no line, was accepted.

Copilot AI lite review requested due to automatic review settings September 27, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.76923% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.87%. Comparing base (cb9135d) to head (d9a3e63).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/sed/compiler.rs 80.76% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
- Coverage   83.88%   83.87%   -0.01%     
==========================================
  Files          14       14              
  Lines        6974     6977       +3     
  Branches      406      407       +1     
==========================================
+ Hits         5850     5852       +2     
  Misses       1121     1121              
- Partials        3        4       +1     
Flag Coverage Δ
macos_latest 85.03% <80.76%> (-0.01%) ⬇️
ubuntu_latest 85.22% <80.76%> (-0.01%) ⬇️
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 Harness.
📢 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.

A range address that ended early made the parser panic: `1~` read past
the end of the line, and `1~p`, `1,~p` or `1,p` handed a command letter
to the address parser, which only knew how to panic on it. A missing
~step now counts as 0, and a comma with no address after it is reported
as an unexpected `,'. The address parser returns an error instead of
panicking.

A step of 0 was not handled either: `2,~0` ran to the end of the input
instead of selecting line 2 alone, and `0~0`, which can select no line,
was accepted.
@sylvestre
sylvestre force-pushed the fix-range-address-panics branch from befb615 to d9a3e63 Compare September 27, 2026 12:19
Copilot AI review requested due to automatic review settings September 27, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 65 / PASSED: 15 / FAILED: 42 / SKIPPED: 8
  Reference: TOTAL: 65 / PASSED: 14 / FAILED: 43 / SKIPPED: 8

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + cmd-R

@sylvestre
sylvestre merged commit 72ed709 into uutils:main Sep 27, 2026
30 of 31 checks passed
SichenLiang added a commit to SichenLiang/sed that referenced this pull request Oct 2, 2026
The substitution and transliteration compilers read the delimiter with
ScriptCharProvider::current() even when the command letter was the last
character on the line. This indexed past the end of the line and
aborted.

Check for the end of the line first and report an unterminated command,
as GNU sed does. Scripts such as `s`, `1y`, and `p;s` now exit 1 with a
diagnostic instead of aborting.

The address-parser aborts from uutils#570 were fixed separately in uutils#578.
SichenLiang added a commit to SichenLiang/sed that referenced this pull request Oct 5, 2026
The substitution and transliteration compilers read the delimiter with
ScriptCharProvider::current() even when the command letter was the last
character on the line. This indexed past the end of the line and
aborted.

Check for the end of the line first and report an unterminated command,
as GNU sed does. Scripts such as `s`, `1y`, and `p;s` now exit 1 with a
diagnostic instead of aborting.

The address-parser aborts from uutils#570 were fixed separately in uutils#578.
sylvestre pushed a commit that referenced this pull request Oct 6, 2026
The substitution and transliteration compilers read the delimiter with
ScriptCharProvider::current() even when the command letter was the last
character on the line. This indexed past the end of the line and
aborted.

Check for the end of the line first and report an unterminated command,
as GNU sed does. Scripts such as `s`, `1y`, and `p;s` now exit 1 with a
diagnostic instead of aborting.

The address-parser aborts from #570 were fixed separately in #578.
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