Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #343

Merged
merged 6 commits into from Feb 18, 2017
Merged

Fixes #343

merged 6 commits into from Feb 18, 2017

Conversation

BurntSushi
Copy link
Member

This PR contains a series of commits that fixes several minor bugs.

Fixes #321, Fixes #334, Fixes #326, Fixes #333, Fixes #338

When doing literal extraction, a non-empty concatenation should always be
cut when a `^` (for prefixes) or a `$` (for suffixes) is seen. If a counted
repetition is used, e.g., `${2}`, then the cut detection fails. We add in
a special case to handle it.

Fixes rust-lang#321
When searching for captures, we first use the DFA to find the start and
end of the match. We then pass just the matched region of text to the
NFA engine to find sub-capture locations. This is a key optimization
that prevents the NFA engine from searching a lot more text than what is
necessary in some cases.

One problem with this is that some instructions determine their match
state based on whether the engine is at the boundary of the search text.
For example, `$` matches if and only if the engine is at EOF. If we only
provide the matched text region, then assertions like `\b` might not
work, since it needs to examine at least one character past the end of
the match. If we provide the matched text region plus one character,
then `$` may match when it shouldn't. Therefore, we provide the matched
text plus (at most) two characters.

Fixes rust-lang#334
This shows how to use curly braces in the replacement string, and more
specifically, explains why they are sometimes necessary.

Fixes rust-lang#333
The example shows how to get the matched text of any capture group while
defaulting to the empty string if that particular group didn't participate
in the match.

Fixes rust-lang#338
@BurntSushi
Copy link
Member Author

@bors r+

@bors
Copy link
Contributor

bors commented Feb 18, 2017

📌 Commit 9ae9418 has been approved by BurntSushi

@BurntSushi
Copy link
Member Author

@bors retry

@bors
Copy link
Contributor

bors commented Feb 18, 2017

⌛ Testing commit 9ae9418 with merge 7297f23...

bors added a commit that referenced this pull request Feb 18, 2017
Fixes

This PR contains a series of commits that fixes several minor bugs.

Fixes #321, Fixes #334, Fixes #326, Fixes #333, Fixes #338
@bors
Copy link
Contributor

bors commented Feb 18, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: BurntSushi
Pushing 7297f23 to master...

@bors bors merged commit 9ae9418 into rust-lang:master Feb 18, 2017
@BurntSushi BurntSushi deleted the fixes branch February 18, 2017 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment