Skip to content

sed: match first~step on the line number alone - #691

Open
Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:fix/step-address-line-number
Open

Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:fix/step-address-line-number

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

first~step was compiled to addr1 = first plus addr2 = StepMatch(step), a range, so it only started once line first reached the command. If line 1 is deleted or joined by N, 1~2 selected lines 2, 4, ... instead of 3, 5, ..., and c printed its text only at the end of that "range".

Rebased on main: #619 added StepStart(first, step), matched on the line number alone, for first~step,addr2. This compiles a plain first~step to that same single address too (as suggested in review), so the special cases are gone. StepMatch stays only for a regex first address.

Tests: test_step_address_counts_from_its_first_line (1d;1~2…, /b/d;1~2…, N;1~2…, 0~2, 3~0) and test_step_address_change_prints_text_for_each_line; both fail on main. The range tests from #619 still pass. Checked against GNU sed 4.9.

AI disclosure: written with help from Claude Code.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:15

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.14%. Comparing base (76faef8) to head (0ea2552).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #691      +/-   ##
==========================================
- Coverage   94.17%   94.14%   -0.04%     
==========================================
  Files          14       14              
  Lines        5768     5770       +2     
  Branches      470      470              
==========================================
  Hits         5432     5432              
- Misses        335      337       +2     
  Partials        1        1              
Flag Coverage Δ
macos_latest 96.10% <100.00%> (-0.04%) ⬇️
ubuntu_latest 95.98% <100.00%> (-0.04%) ⬇️
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.

Comment thread src/sed/processor.rs Outdated
if command.addr2.is_none() || context.last_address || reader.last_line()? {
// `first~step` selects single lines, so each one gets the text.
if command.addr2.is_none()
|| matches!(command.addr2, Some(Address::StepMatch(_)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could first~step be compiled into its own single address instead (e.g. Address::Step(first, step) in addr1, no addr2)?
then neither this special case nor the one in applies would be needed

@Xnadir
Xnadir force-pushed the fix/step-address-line-number branch from 163abac to dfa6933 Compare November 26, 2026 01:34
Copilot AI balanced review requested due to automatic review settings November 26, 2026 01:34

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codspeed

codspeed Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 11 untouched benchmarks


Comparing Xnadir:fix/step-address-line-number (0ea2552) with main (76faef8)

Open in CodSpeed

@Xnadir
Xnadir force-pushed the fix/step-address-line-number branch from dfa6933 to 8d885f5 Compare November 26, 2026 19:01
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:01

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

first~step depends on the line number alone, so compile it to the single
StepStart address that uutils#619 introduced for range starts, instead of
addr1 Line plus addr2 StepMatch. It no longer starts late when line
first never reaches the command (deleted, or joined by N), and c prints
its text on every selected line. StepMatch stays for a regex first
address.
@Xnadir
Xnadir force-pushed the fix/step-address-line-number branch from 8d885f5 to 0ea2552 Compare November 28, 2026 18:16
Copilot AI balanced review requested due to automatic review settings November 28, 2026 18:16

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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.

3 participants