Repository navigation
regex: honor custom line terminators in the regex engine - #3542
Open
ArjunCodess wants to merge 1 commit into
Open
ArjunCodess wants to merge 1 commit into
ArjunCodess wants to merge 1 commit into
Conversation
The searcher's fast path searches a whole buffer at once, so `(?m:^)` and `(?m:$)` need the regex engine to treat NUL as a line boundary when `--null-data` is used. Without that, the searcher fell back to walking every NUL as its own empty record. Fixes BurntSushi#2832
Author
|
@BurntSushi the custom line terminator change is ready whenever you want to look. |
Author
|
@BurntSushi still happy to adjust the custom line terminator change if you want it shaped differently. |
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.
--null-data --no-mmapwas going through the slow line-by-line searcher. therefore a file of nuls with one needle in the middle was walking every nul as its own empty record.grep-regex never told the regex engine about the configured terminator, and hence
(?m:^)/(?m:$)only understood\n. the searcher worked around that by disabling the fast path when the terminator was nul. actually that workaround is what made the search so slow.i passed the terminator through to regex-automata.
--null-datastill means nul-separated records, and--line-regexpstill matches a whole record. a grep-searcher test counts matcher calls on a nul-heavy haystack so we can see the fast path is in use.Fixes #2832