Skip to content

Conversation

@LoukasPap
Copy link
Contributor

@LoukasPap LoukasPap commented Jan 12, 2026

Fixes issue 234

  • Add GNU extension for 2 supported addresses for a, i and = commands

UPDATE
The PR now solves the problem where invalid POSIX commands with address range were being allowed when they shouldn't. These commands are: a, i, =, l, q, r (maybe there are some more I missed).

@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

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 75.60976% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.97%. Comparing base (a6207cb) to head (ff0dbc2).

Files with missing lines Patch % Lines
src/sed/compiler.rs 75.60% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   82.03%   81.97%   -0.07%     
==========================================
  Files          13       13              
  Lines        5423     5454      +31     
  Branches      291      292       +1     
==========================================
+ Hits         4449     4471      +22     
- Misses        972      981       +9     
  Partials        2        2              
Flag Coverage Δ
macos_latest 82.41% <75.60%> (-0.07%) ⬇️
ubuntu_latest 82.53% <75.60%> (-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

Thank you! This is a GNU extension, so the feature should not be available under --posix. Please also squash all commits into one.

@LoukasPap
Copy link
Contributor Author

Got it! I'll fix these and push again.

@LoukasPap
Copy link
Contributor Author

LoukasPap commented Jan 20, 2026

Found out that the problem happens with the l (list) command too (we allow address range with --posix enabled but it should not be allowed). Should I fix it here or open a different issue for this?

@dspinellis
Copy link
Collaborator

I'd suggest one commit for all commands. Try to unify the check for POSIX.

@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

2 similar comments
@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

@LoukasPap LoukasPap force-pushed the main branch 2 times, most recently from 81e0901 to 698f2b7 Compare January 21, 2026 17:07
@LoukasPap
Copy link
Contributor Author

LoukasPap commented Jan 21, 2026

Squashed all my commits having removed the merge commit which was not mine.

The POSIX check now happens in one place. I will update the README.md too.

@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

I see you're progressing! Try running the various CI tasks locally to avoid CI failures. Please also close the PRs that you've folded into this one.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 22, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing LoukasPap:main (ff0dbc2) with main (a6207cb)

Summary

✅ 11 untouched benchmarks

@LoukasPap
Copy link
Contributor Author

These two tests are failing because the supported addresses are now 2 and not 1 (like the tests assert):

  1. test_lookup_text_command

    sed/src/sed/compiler.rs

    Lines 1309 to 1314 in 398ee76

    #[test]
    fn test_lookup_text_command() {
    let (lines, line) = make_providers("123abc");
    let cmd = get_cmd_spec(&lines, &line, 'a').unwrap();
    assert_eq!(cmd.n_addr, 1);
    }
  2. test_valid_command_spec

    sed/src/sed/compiler.rs

    Lines 1416 to 1425 in 398ee76

    #[test]
    fn test_valid_command_spec() {
    let lines = ScriptLineProvider::with_active_state("input.sed", 4);
    let line = char_provider_from("a"); // valid command
    let result = get_verified_cmd_spec(&lines, &line, 1);
    assert!(result.is_ok());
    let spec = result.unwrap();
    assert_eq!(spec.n_addr, 1);
    }

Would it be "correct" to change the tests to check for 2 addresses; What I mean is, do these tests represent the standard sed behavior (1 address) and not the 'GNU-extended' behavior (with 2 addresses) and thus changing them would be wrong?

I hope I am clear :)

@dspinellis
Copy link
Collaborator

I would expect that rather than storing / returning a number you would store

These two tests are failing because the supported addresses are now 2 and not 1 (like the tests assert):

1. `test_lookup_text_command`
   https://github.com/uutils/sed/blob/398ee76b79ba52768c1df214d516b2ad5c173882/src/sed/compiler.rs#L1309-L1314

2. `test_valid_command_spec`
   https://github.com/uutils/sed/blob/398ee76b79ba52768c1df214d516b2ad5c173882/src/sed/compiler.rs#L1416-L1425

Would it be "correct" to change the tests to check for 2 addresses; What I mean is, do these tests represent the standard sed behavior (1 address) and not the 'GNU-extended' behavior (with 2 addresses) and thus changing them would be wrong?

I hope I am clear :)

I suggest that you also store and process n_addr_posix and add corresponding tests.

Copy link
Collaborator

@dspinellis dspinellis left a comment

Choose a reason for hiding this comment

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

Please consider the initial comments I made on the code and fix the CI errors. Will then follow-up with a more complete review.

@LoukasPap LoukasPap changed the title Fix address range difference for line number command Add support for address range (GNU extension) Jan 24, 2026
@LoukasPap LoukasPap changed the title Add support for address range (GNU extension) Add support for address range commands (GNU extension) Jan 24, 2026
@LoukasPap
Copy link
Contributor Author

LoukasPap commented Jan 24, 2026

I see you're progressing! Try running the various CI tasks locally to avoid CI failures. Please also close the PRs that you've folded into this one.

Thank you for helping me out! Indeed, I recently noticed I could run the CI tasks locally. It will be much faster than pushing and then checking for errors.

Please consider the initial comments I made on the code and fix the CI errors. Will then follow-up with a more complete review.

Yes, I will finish this issue before moving to another. For a reason, I hadn't noticed your new comments and I was searching for another issue while I was waiting.

@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

@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

…flag usage with GNU-only extensions

- Update check for invalid address range in POSIX mode by adding `n_add_posix` field in CommandSpec struct which specifies what is the number of addresses allowed for each command in POSIX mode
- Add integration and unit tests
- Update README.md
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.

Address range validation difference for line number command

2 participants