summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub.adam.wieczorek@gmail.com>2019-09-05 13:39:08 +0000
committerAndrew Gallant <jamslam@gmail.com>2020-02-17 17:16:28 -0500
commitb435eaafc805b1edb12b04d72de0e0ce113059f9 (patch)
tree764b68ae6ef5d328cff5b074debbcdeb77dbe797 /tests
parentf8e70294d5741391521f638b80ba786888896b94 (diff)
grep-regex: fix inner literal extraction bug
This appears to be another transcription bug from copying this code from the prefix literal detection from inside the regex crate. Namely, when it comes to inner literals, we only want to treat counted repetition as two separate cases: the case when the minimum match is 0 and the case when the minimum match is more than 0. In the former case, we treat `e{0,n}` as `e*` and in the latter we treat `e{m,n}` where `m >= 1` as just `e`. We could definitely do better here. e.g., This means regexes like `(foo){10}` will only have `foo` extracted as a literal, where searching for the full literal would likely be faster. The actual bug here was that we were not implementing this logic correctly. Namely, we weren't always "cutting" the literals in the second case to prevent them from being expanded. Fixes #1319, Closes #1367
Diffstat (limited to 'tests')
-rw-r--r--tests/regression.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs
index 6d925744..72f58590 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -729,6 +729,14 @@ rgtest!(r1259_drop_last_byte_nonl, |dir: Dir, mut cmd: TestCommand| {
eqnice!("fz\n", cmd.arg("-f").arg("patterns-nl").arg("test").stdout());
});
+// See: https://github.com/BurntSushi/ripgrep/issues/1319
+rgtest!(r1319, |dir: Dir, mut cmd: TestCommand| {
+ dir.create("input", "CCAGCTACTCGGGAGGCTGAGGCTGGAGGATCGCTTGAGTCCAGGAGTTC");
+ eqnice!(
+ "input:CCAGCTACTCGGGAGGCTGAGGCTGGAGGATCGCTTGAGTCCAGGAGTTC\n",
+ cmd.arg("TTGAGTCCAGGAG[ATCG]{2}C").stdout());
+});
+
// See: https://github.com/BurntSushi/ripgrep/issues/1334
rgtest!(r1334_crazy_literals, |dir: Dir, mut cmd: TestCommand| {
dir.create("patterns", &"1.208.0.0/12\n".repeat(40));