Sophie

Sophie

distrib > Fedora > 16 > x86_64 > by-pkgid > 20ff4ff75433449222836d4ab1064b5b > files > 2

pcre-8.12-9.fc16.src.rpm

From efde8452d7312e69b776d7261782bd661ab315e2 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          |    7 ++++++-
 testdata/testinput1  |    6 ++++++
 testdata/testoutput1 |   10 ++++++++++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/pcre_exec.c b/pcre_exec.c
index 2b7c5bd..007e054 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -2326,9 +2326,14 @@ 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 e45c3c1..33a5112 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -4085,4 +4085,10 @@
 /(abc)\1/
    abc
 
+/(another)?(\1?)test/
+    hello world test
+
+/(another)?(\1+)test/
+    hello world test
+
 /-- End of testinput1 --/
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index f1d3274..3d62b65 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -6674,4 +6674,14 @@ No match
    abc
 No match
 
+/(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