Conversation
When a range command is first evaluated on a line after its numeric first address (inside a block, or after d, n, N, c or a branch skipped it), start the range on the current line, as GNU sed does, unless a numeric second address has also been passed. The range can start this way only once. Fixes uutils#541
|
GNU sed testsuite comparison: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #581 +/- ##
==========================================
- Coverage 83.67% 83.62% -0.05%
==========================================
Files 14 14
Lines 7067 7072 +5
Branches 413 415 +2
==========================================
+ Hits 5913 5914 +1
- Misses 1149 1153 +4
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| pub addr2: Option<Address>, // End address | ||
| pub non_select: bool, // True if '!' | ||
| pub start_line: Option<usize>, // Start line number (or None if unlatched) | ||
| pub range_started: bool, // True once the range has been entered |
There was a problem hiding this comment.
start_line + range_started could be a small enum (inactive / active(start) / closed), no?
not blocking
There was a problem hiding this comment.
I would be happy to change it now if you prefer
| // See if latch must start. | ||
| if match_address(addr1, reader, pattern, context, &command.location)? { | ||
| let starts = match addr1 { | ||
| // A numeric first address may already have been passed |
There was a problem hiding this comment.
5 lines is a lot here, could you please make it shorter?
something like "numeric start already passed (block, d, n, branch): start once here"
There was a problem hiding this comment.
It's done, the comment is now one line.
| // Check for address-spec line 0 pre-latch extension. | ||
| let pre_latched = matches!(cmd.addr1, Some(Address::Line(0))); | ||
| cmd.start_line = if pre_latched { Some(0) } else { None }; | ||
| cmd.range_started = pre_latched; |
There was a problem hiding this comment.
please add a test where this reset matters, e.g. with -s and two files, so range_started is cleared for the second file
There was a problem hiding this comment.
I added the test it runs the same range on two files with -s and checks that both files print lines 3 and 4, the same as GNU sed
|
GNU sed testsuite comparison: |
Summary
Fixes sed range handling when the command first runs after the range’s starting address has already been passed.
What changed
Closes #541