Repository navigation
Conversation
Contributor
Author
|
@yegor256 CI is green and the branch is up to date with |
sherenkov
force-pushed
the
bug/#2255/sed-back-reference
branch
from
November 7, 2026 09:01
23eb238 to
21019a6
Compare
Contributor
Benchmark comparisonMedian of 5 round(s) per side, interleaved on the same runner against the PR merge-base, with the bench fixture frozen across both builds. Noise is the spread between the fastest and the slowest round, taken from the noisier side.
ScalingEach sized case against its
No case moved by more than 20% beyond its own noise. |
This branch has not been deployed
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.
A
sedreplacement written the unix way,s/([0-9]+)/\\1!/g, put the digit1in place of the group, so the rule of #2255 turned"Hello, 2025"into"Hello, 1!", with no error.nextUntilSlashreads the replacement withescapeon and dropped the backslash before any character (src/Functions.hs:171), so\1reachedsubstituteGroupsofsrc/Regexp.hsas a plain1, and there only$followed by digits named a group.Now
nextUntilSlashkeeps the backslash in the replacement when a digit or another backslash follows it, andsubstituteGroupsreads\1to\9as the group of that one digit, as sed does, so\10is group one followed by0, and reads\\as one backslash, so\\1stays a literal\1. An escaped slash or brace is read as before, and so is$1. A back reference to a group the pattern does not have is kept as it is, the way$9already is. The README now says that\1to\9and$1name the groups.FunctionsSpecruns the rule of the issue throughsedand expects"Hello, 2025!", and checks that\\1stays a backslash and a1;RegexpSpecchecks the back reference, the single digit it takes, one out of bounds and the escaped backslash insubstituteGroups. The first of them gives"Hello, 1!"without the change.Fixes #2255