Blob Blame History Raw
From 17a94e8c64fac96d8c95403f80b7ed61e8c8ff77 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Tue, 9 Jun 2015 17:45:25 +0000
Subject: [PATCH] Fix group empty match bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Ported to 8.32:

commit 382ca2bb4ffd423aceab05c4b1c1885cd3a48958
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date:   Tue Jun 9 17:45:25 2015 +0000

    Fix group empty match bug.

    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1566 2f5784b3-3f2a-0410-8824-cb99058d5e15

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 pcre_compile.c       |  2 +-
 testdata/testinput2  |  2 ++
 testdata/testoutput2 | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/pcre_compile.c b/pcre_compile.c
index 7d203eb..d570447 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -2477,7 +2477,7 @@ for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
   if (c == OP_BRA  || c == OP_BRAPOS ||
       c == OP_CBRA || c == OP_CBRAPOS ||
       c == OP_ONCE || c == OP_ONCE_NC ||
-      c == OP_COND)
+      c == OP_COND || c == OP_SCOND)
     {
     BOOL empty_branch;
     if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */
diff --git a/testdata/testinput2 b/testdata/testinput2
index 1b83cf2..fc6fe2f 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -3825,4 +3825,6 @@ settings of the anchored and startline bits. --/
 ".*?\h.+.\.+\R*?\xd(?i)(?=!(?=b`b`b`\`b\xa9b!)`\a`bbbbbbbbbbbbb`bbbbbbbbbbbb*R\x85bbbbbbb\C?{((?2)(?))((
 \H){8(?<=(?1){29}\xa8bbbb\x16\xd\xc6^($(?<! )(\xa9H4){4}h}1)B))\x15')"
 
+/^(?:(?(1)x|)+)+$()/BZ
+
 /-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index e33b4e2..63b39c2 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -12522,4 +12522,22 @@ No match
 ".*?\h.+.\.+\R*?\xd(?i)(?=!(?=b`b`b`\`b\xa9b!)`\a`bbbbbbbbbbbbb`bbbbbbbbbbbb*R\x85bbbbbbb\C?{((?2)(?))((
 \H){8(?<=(?1){29}\xa8bbbb\x16\xd\xc6^($(?<! )(\xa9H4){4}h}1)B))\x15')"
 
+/^(?:(?(1)x|)+)+$()/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        SBra
+        SCond
+      1 Cond ref
+        x
+        Alt
+        KetRmax
+        KetRmax
+        $
+        CBra 1
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput2 --/
-- 
2.5.5