Repository navigation
sed: support the \` and \' buffer anchors - #613
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
GNU sed's \` and \' match only at the start and end of the pattern space, also in M mode. They were passed to the regex engine as is, which reads them as a literal backtick and quote, so s/\`./X/ never matched. Spell them as \A and \z, which also sends the pattern to the regex matcher instead of the literal one.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #613 +/- ##
=======================================
Coverage 94.93% 94.94%
=======================================
Files 14 14
Lines 7292 7295 +3
Branches 434 434
=======================================
+ Hits 6923 6926 +3
Misses 368 368
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:
|
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.
GNU sed's
\`and\'match only at the start and end of the pattern space, also with theMflag where^and$match at every line. Here they are passed to the regex engine as is, which reads them as an escaped backtick and quote, so they never match:The parser now writes them as
\Aand\z, which both regex engines know. That also sends patterns likes/\`a/X/to the regex matcher instead of the literal one, the same way\balready does. Inside brackets, in the replacement, as the delimiter and with--posixthey stay literal characters, as before.Tests:
test_buffer_start_and_end_anchorscoverss/\`./X/g, theMflag case (N;s/\`/>/Mg;s/\'/</Mggives>ab\ncd<) and the literal-only case, with GNU sed 4.9's output. It fails without the change.cargo test: 747 passed (746 on main plus the new one), clippy and rustfmt clean. I also checked ERE mode, addresses, the C locale, back-references next to an anchor,`and'as delimiters and--posixagainst GNU sed: all the same.