Sophie

Sophie

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

pcre-8.12-9.fc16.src.rpm

From 50f01d47c8d09258b523ea19951abb7c8649eb61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 22 Nov 2011 17:06:59 +0100
Subject: [PATCH] Fix repeated forward reference needed character bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From:
r762 | ph10 | 2011-11-22 14:36:51 +0100 (Út, 22 lis 2011) | 2 lines

16. A repeated forward reference in a pattern such as (a)(?2){2}(.) was
    incorrectly expecting the subject to contain another "a" after the start.

Petr Pisar: Changelog removed.
See <http://lists.pcre.org/lurker/message/20111121.203922.3cfd476e.en.html>.
---
 pcre_compile.c        |    8 ++++++--
 testdata/testinput11  |    3 +++
 testdata/testoutput11 |    6 ++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/pcre_compile.c b/pcre_compile.c
index 694ddce..859c0c7 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -4577,7 +4577,8 @@ for (;; ptr++)
             *lengthptr += delta;
             }
 
-          /* This is compiling for real */
+          /* This is compiling for real. If there is a set first byte for
+          the group, and we have not yet set a "required byte", set it. */
 
           else
             {
@@ -5591,7 +5592,9 @@ for (;; ptr++)
 
           /* Insert the recursion/subroutine item, automatically wrapped inside
           "once" brackets. Set up a "previous group" length so that a
-          subsequent quantifier will work. */
+          subsequent quantifier will work. It does not have a set first
+          byte (relevant if it is repeated, because it will then be wrapped 
+          with ONCE brackets). */
 
           *code = OP_ONCE;
           PUT(code, 1, 2 + 2*LINK_SIZE);
@@ -5600,6 +5603,7 @@ for (;; ptr++)
           *code = OP_RECURSE;
           PUT(code, 1, (int)(called - cd->start_code));
           code += 1 + LINK_SIZE;
+          groupsetfirstbyte = FALSE;
 
           *code = OP_KET;
           PUT(code, 1, 2 + 2*LINK_SIZE);
diff --git a/testdata/testinput11 b/testdata/testinput11
index 79ebd08..4e764fa 100644
--- a/testdata/testinput11
+++ b/testdata/testinput11
@@ -507,4 +507,7 @@ however, we need the complication for Perl. ---/
 /(?P<abn>(?P=abn)xxx|)+/
     xxx
 
+/(a)(?2){2}(.)/
+    abcd
+
 /-- End of testinput11 --/
diff --git a/testdata/testoutput11 b/testdata/testoutput11
index dbd22e7..73739ac 100644
--- a/testdata/testoutput11
+++ b/testdata/testoutput11
@@ -975,4 +975,10 @@ No match
  0: 
  1: 
 
+/(a)(?2){2}(.)/
+    abcd
+ 0: abcd
+ 1: a
+ 2: d
+
 /-- End of testinput11 --/
-- 
1.7.7.3