Skip to content

Fix truncated pattern space problem - #263

Closed
LoukasPap wants to merge 2 commits into
uutils:mainfrom
LoukasPap:issue253
Closed

LoukasPap wants to merge 2 commits into
uutils:mainfrom
LoukasPap:issue253

Conversation

@LoukasPap

@LoukasPap LoukasPap commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Fix issue 253

  • If the hold space is empty, newline is being used
  • Also fix problem with --separate
  • Add test cases

The solution fixes the problem for the swap x command but also for replace g and append-replace G commands.

@github-actions

Copy link
Copy Markdown

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
Copy Markdown
Collaborator

Please fix the failing tests, ensuring the output is compatible with existing sed output. Also ensure and test that the behavior is correct under --separate.

Probably best to wait for the integration of this PR and then add the code in the following block.

        if index == 0 || context.separate {
            context.line_number = 0;
            reset_latched_address_ranges(&mut context.range_commands);
        }

@LoukasPap

LoukasPap commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Yes, I'll get back on this when the PR is accepted.

@sylvestre

Copy link
Copy Markdown
Contributor

@LoukasPap merged!

@LoukasPap

Copy link
Copy Markdown
Contributor Author

@sylvestre Thanks for the update! I'll look at it.

@codspeed

codspeed Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 2.27%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 9 untouched benchmarks

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

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ access_log_translit 784.5 ms 757.5 ms +3.56%
❌ no_op_short 955.6 ms 977.8 ms -2.27%

Comparing LoukasPap:issue253 (9792ce2) with main (16f1145)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (27da027) during the generation of this report, so 16f1145 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@LoukasPap

LoukasPap commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello and sorry for the inactivity these days. I am trying to install act so as to run CI checks locally, but I am facing issues with the installation. The problem is in my OS (Windows) where something is not working correctly. I am trying to find a solution to that. I will update you as soon as I start working on the issue again.

Thank you for your patience!

@dspinellis

Copy link
Copy Markdown
Collaborator

@LoukasPap Consider focusing on the test failures, not to replicate the entire CI.

@LoukasPap

LoukasPap commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@dspinellis I had tried running some tests alone but I was getting different error messages from the ones in the CI console. For example cargo test pi gives different errors locally and in the GitHub CI. Do I do something wrong?

@dspinellis

Copy link
Copy Markdown
Collaborator

Ensure your files don't contain carriage returns (\r). Consider installing WSL and trying the tests there.

@LoukasPap

Copy link
Copy Markdown
Contributor Author

I have WSL. I'll try there.

@sylvestre

Copy link
Copy Markdown
Contributor

could you please add a test to cover this? thanks

@LoukasPap

Copy link
Copy Markdown
Contributor Author

Yes, I'll add today.

@LoukasPap

LoukasPap commented Feb 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Moved to WSL and the tests are showing the correct error messages! I've added a test case and now I will try to fix the failing tests before pushing.

@LoukasPap

LoukasPap commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Finally corrected the problem with the newline. I also fixed a same-case problem with g and G commands. I am creating a few tests casing and make the last push. Should I squash the commits?

@dspinellis

Copy link
Copy Markdown
Collaborator

@LoukasPap Please squash related commits together. So each commit should address one case.

@LoukasPap
LoukasPap force-pushed the issue253 branch 2 times, most recently from 09805a5 to 15e16b8 Compare February 4, 2026 12:32
@LoukasPap

Copy link
Copy Markdown
Contributor Author

Just checked with --separate and is not working correctly so I'll try fix that. The rest are OK I believe.

@codecov

codecov Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.02%. Comparing base (27da027) to head (9792ce2).
⚠️ Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
src/sed/processor.rs 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #263      +/-   ##
==========================================
- Coverage   82.14%   82.02%   -0.13%     
==========================================
  Files          13       13              
  Lines        5437     5445       +8     
  Branches      300      303       +3     
==========================================
  Hits         4466     4466              
- Misses        969      977       +8     
  Partials        2        2              
Flag Coverage Δ
macos_latest 82.46% <0.00%> (-0.13%) ⬇️
ubuntu_latest 82.57% <0.00%> (-0.13%) ⬇️
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.

@LoukasPap

LoukasPap commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed --separate (added test case too). I don't know if it should be moved to another issue & PR. Anyway, I think this PR is now ready for review 🙂

@LoukasPap

LoukasPap commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello! I resolved conflicts with main branch. Is this OK to merge? (I see we don't have unit tests to cover processor.rs so I didn't add any).

@dspinellis dspinellis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Almost there! Please see the one comment and squash the commits into one rebased atop main.

Comment thread src/sed/processor.rs Resolved
@LoukasPap
LoukasPap requested a review from dspinellis March 14, 2026 12:42
- If hold space is empty, `x` and `g` replace the pattern with a newline and `G` first appends and then replaces with a newline.
@LoukasPap

LoukasPap commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@dspinellis I've addressed the comment. If everything is OK, should I squash the 2 commits into 1? It seems to me they solve different problems.

@LoukasPap

LoukasPap commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Probably this PR can now close in favor of #378 as it seems it has a more generic fix. I just don't know if it solves the problem with --separate not working, but we can easily address that in a new issue.

@pocopepe

Copy link
Copy Markdown
Contributor

thanks, appreciate it! My PR doesn't cover the --separate bit tho, happy to open a new issue for it like you mentioned.

@dspinellis

Copy link
Copy Markdown
Collaborator

Good point regarding --separate! Yes, please open a PR for that.

@LoukasPap LoukasPap closed this Apr 24, 2026
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.

handles multiple exchange commands differently from GNU (pattern space truncation)

5 participants