Repository navigation
Conversation
`s/x/y/2g` (replace the 2nd match and every later one) and `s/x/y/g2` are valid in GNU sed, but were rejected with "multiple 'g' or numeric flags". Track `g` separately from the occurrence number so the two can be combined; repeating either one is still an error.
Split "multiple 'g' or numeric flags in substitute command" into GNU's "multiple `g' options to `s' command" and "multiple number options to `s' command". The latter is raised at the second number, so the caret for `s/a/b/2g3` sits under the `3`, at char 9 like GNU.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #611 +/- ##
=======================================
Coverage 94.85% 94.85%
=======================================
Files 14 14
Lines 7230 7235 +5
Branches 432 432
=======================================
+ Hits 6858 6863 +5
Misses 371 371
Partials 1 1
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:
|
There was a problem hiding this comment.
🟢 Approval recommended
The final commit’s diagnostic changes and regression assertions are consistent, with no blocking issues identified.
No open issues 🎉
What changed in this PR
The final commit aligns repeated substitute-flag diagnostics with GNU sed, building on the combined numeric/g support from #610.
Changes:
- Distinguishes repeated
gflags from repeated numeric flags. - Adds regression assertions for error wording and the second number’s diagnostic position.
| File | Description |
|---|---|
| tests/by-util/test_sed.rs | Adds a regression test for the diagnostic underline. |
| src/sed/processor.rs | Contains prerequisite #610 substitution behavior; outside this review’s scope. |
| src/sed/compiler.rs | Updates diagnostic messages and unit assertions. |
| src/sed/command.rs | Contains prerequisite #610 global-flag state; outside this review’s scope. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #610: this branch contains its commit. Review only the last commit.
Splits "multiple 'g' or numeric flags in substitute command" into GNU's "multiple
g' options tos' command" and "multiple number options tos' command". The latter is raised at the second number, so the caret fors/a/b/2g3sits under the3(char 9, like GNU) instead of theg`.