74 lines
2.0 KiB
Diff
74 lines
2.0 KiB
Diff
From 1daa2332fb112a2868957e0ed42242e6115d0d72 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
Date: Mon, 2 Jan 2012 10:56:09 +0100
|
|
Subject: [PATCH] Do not make unmatched subpattern wildcard
|
|
|
|
Back-ported from:
|
|
r836 | ph10 | 2011-12-28 18:16:11 +0100 (St, 28 pro 2011) | 2 lines
|
|
Merging all the changes from the pcre16 branch into the trunk.
|
|
|
|
See <https://bugzilla.redhat.com/show_bug.cgi?id=769597> for more
|
|
details.
|
|
---
|
|
pcre_exec.c | 6 +++++-
|
|
testdata/testinput1 | 6 ++++++
|
|
testdata/testoutput1 | 10 ++++++++++
|
|
3 files changed, 21 insertions(+), 1 deletions(-)
|
|
|
|
diff --git a/pcre_exec.c b/pcre_exec.c
|
|
index 46498d5..a7cec30 100644
|
|
--- a/pcre_exec.c
|
|
+++ b/pcre_exec.c
|
|
@@ -2620,9 +2620,13 @@ for (;;)
|
|
}
|
|
|
|
/* Handle repeated back references. If the length of the reference is
|
|
- zero, just continue with the main loop. */
|
|
+ zero, just continue with the main loop. If the length is negative, it
|
|
+ means the reference is unset in non-Java-compatible mode. If the minimum is
|
|
+ zero, we can continue at the same level without recursion. For any other
|
|
+ minimum, carrying on will result in NOMATCH. */
|
|
|
|
if (length == 0) continue;
|
|
+ if (length < 0 && min == 0) continue;
|
|
|
|
/* First, ensure the minimum number of matches are present. We get back
|
|
the length of the reference string explicitly rather than passing the
|
|
diff --git a/testdata/testinput1 b/testdata/testinput1
|
|
index 36d7028..b41de5a 100644
|
|
--- a/testdata/testinput1
|
|
+++ b/testdata/testinput1
|
|
@@ -4318,4 +4318,10 @@
|
|
/a[\C-X]b/
|
|
aJb
|
|
|
|
+/(another)?(\1?)test/
|
|
+ hello world test
|
|
+
|
|
+/(another)?(\1+)test/
|
|
+ hello world test
|
|
+
|
|
/-- End of testinput1 --/
|
|
diff --git a/testdata/testoutput1 b/testdata/testoutput1
|
|
index bc237ab..2357ddb 100644
|
|
--- a/testdata/testoutput1
|
|
+++ b/testdata/testoutput1
|
|
@@ -7053,4 +7053,14 @@ No match
|
|
aJb
|
|
0: aJb
|
|
|
|
+/(another)?(\1?)test/
|
|
+ hello world test
|
|
+ 0: test
|
|
+ 1: <unset>
|
|
+ 2:
|
|
+
|
|
+/(another)?(\1+)test/
|
|
+ hello world test
|
|
+No match
|
|
+
|
|
/-- End of testinput1 --/
|
|
--
|
|
1.7.7.5
|
|
|