68 lines
1.9 KiB
Diff
68 lines
1.9 KiB
Diff
From 63f1aabcabdc7ace28c649657fe2a4f880a87c5a Mon Sep 17 00:00:00 2001
|
|
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
|
|
Date: Mon, 20 Feb 2017 17:45:21 +0000
|
|
Subject: [PATCH] Fix recognition of (?# style comment between quantifier and
|
|
'+' or '?'.
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1682 2f5784b3-3f2a-0410-8824-cb99058d5e15
|
|
|
|
Petr Písař: Ported to 8.40.
|
|
|
|
diff --git a/pcre_compile.c b/pcre_compile.c
|
|
index de92313..c787813 100644
|
|
--- a/pcre_compile.c
|
|
+++ b/pcre_compile.c
|
|
@@ -5739,6 +5739,21 @@ for (;; ptr++)
|
|
ptr = p - 1; /* Character before the next significant one. */
|
|
}
|
|
|
|
+ /* We also need to skip over (?# comments, which are not dependent on
|
|
+ extended mode. */
|
|
+
|
|
+ if (ptr[1] == CHAR_LEFT_PARENTHESIS && ptr[2] == CHAR_QUESTION_MARK &&
|
|
+ ptr[3] == CHAR_NUMBER_SIGN)
|
|
+ {
|
|
+ ptr += 4;
|
|
+ while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
|
|
+ if (*ptr == CHAR_NULL)
|
|
+ {
|
|
+ *errorcodeptr = ERR18;
|
|
+ goto FAILED;
|
|
+ }
|
|
+ }
|
|
+
|
|
/* If the next character is '+', we have a possessive quantifier. This
|
|
implies greediness, whatever the setting of the PCRE_UNGREEDY option.
|
|
If the next character is '?' this is a minimizing repeat, by default,
|
|
diff --git a/testdata/testinput1 b/testdata/testinput1
|
|
index 93abab3..5c23f41 100644
|
|
--- a/testdata/testinput1
|
|
+++ b/testdata/testinput1
|
|
@@ -5739,4 +5739,7 @@ AbcdCBefgBhiBqz
|
|
/(?=.*X)X$/
|
|
\ X
|
|
|
|
+/X+(?#comment)?/
|
|
+ >XXX<
|
|
+
|
|
/-- End of testinput1 --/
|
|
diff --git a/testdata/testoutput1 b/testdata/testoutput1
|
|
index a2b3cff..eff8ecc 100644
|
|
--- a/testdata/testoutput1
|
|
+++ b/testdata/testoutput1
|
|
@@ -9442,4 +9442,8 @@ No match
|
|
\ X
|
|
0: X
|
|
|
|
+/X+(?#comment)?/
|
|
+ >XXX<
|
|
+ 0: X
|
|
+
|
|
/-- End of testinput1 --/
|
|
--
|
|
2.7.4
|
|
|