You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.0 KiB

From 977cdd668535a54fc8a13ce4a92d9866503b21ea Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sat, 20 Oct 2018 09:28:02 +0000
Subject: [PATCH] Fix zero-repeated subroutine call at start of pattern bug,
which recorded an incorrect first code unit.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1032 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.32.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_compile.c | 8 +++++---
testdata/testinput1 | 15 +++++++++++++++
testdata/testoutput1 | 24 ++++++++++++++++++++++++
3 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c
index 6bb1de3..50dfd47 100644
--- a/src/pcre2_compile.c
+++ b/src/pcre2_compile.c
@@ -5901,7 +5901,7 @@ for (;; pptr++)
}
goto GROUP_PROCESS_NOTE_EMPTY;
- /* The DEFINE condition is always false. It's internal groups may never
+ /* The DEFINE condition is always false. Its internal groups may never
be called, so matched_char must remain false, hence the jump to
GROUP_PROCESS rather than GROUP_PROCESS_NOTE_EMPTY. */
@@ -6237,8 +6237,8 @@ for (;; pptr++)
groupnumber = ng->number;
/* For a recursion, that's all that is needed. We can now go to
- the code above that handles numerical recursion, applying it to
- the first group with the given name. */
+ the code that handles numerical recursion, applying it to the first
+ group with the given name. */
if (meta == META_RECURSE_BYNAME)
{
@@ -7286,6 +7286,8 @@ for (;; pptr++)
groupsetfirstcu = FALSE;
cb->had_recurse = TRUE;
if (firstcuflags == REQ_UNSET) firstcuflags = REQ_NONE;
+ zerofirstcu = firstcu;
+ zerofirstcuflags = firstcuflags;
break;
diff --git a/testdata/testinput1 b/testdata/testinput1
index d8615ee..fce38b2 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -6263,4 +6263,19 @@ ef) x/x,mark
aBCDEF
AbCDe f
+/ (?<word> \w+ )* \. /xi
+ pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
+ pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
+ pokus.
+
+/(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
+ pokus.
+
+/(?&word)* \. (?<word> \w+ )/xi
+ pokus.hokus
+
# End of testinput1
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index 77b9ff0..ff88775 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -9929,4 +9929,28 @@ No match
AbCDe f
No match
+/ (?<word> \w+ )* \. /xi
+ pokus.
+ 0: pokus.
+ 1: pokus
+
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
+ pokus.
+ 0: pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
+ pokus.
+ 0: pokus.
+ 1: <unset>
+ 2: pokus
+
+/(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
+ pokus.
+ 0: pokus.
+
+/(?&word)* \. (?<word> \w+ )/xi
+ pokus.hokus
+ 0: pokus.hokus
+ 1: hokus
+
# End of testinput1
--
2.17.2