[Pcre-svn] [1719] code/trunk: Fix wrong first character when…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [1719] code/trunk: Fix wrong first character when a backreference with a zero repeat is first
Revision: 1719
          http://vcs.pcre.org/viewvc?view=rev&revision=1719
Author:   ph10
Date:     2017-12-12 15:07:18 +0000 (Tue, 12 Dec 2017)
Log Message:
-----------
Fix wrong first character when a backreference with a zero repeat is first 
(apart from assersions) in a pattern.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-12-08 14:09:22 UTC (rev 1718)
+++ code/trunk/ChangeLog    2017-12-12 15:07:18 UTC (rev 1719)
@@ -31,7 +31,12 @@
 lines were processed (assuming 32-bit ints). They have all been changed to 
 unsigned long ints.


+7. If a backreference with a minimum repeat count of zero was first in a
+pattern, apart from assertions, an incorrect first matching character could be
+recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set
+as the first character of a match.

+
Version 8.41 05-July-2017
-------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2017-12-08 14:09:22 UTC (rev 1718)
+++ code/trunk/pcre_compile.c    2017-12-12 15:07:18 UTC (rev 1719)
@@ -8060,7 +8060,7 @@
         single group (i.e. not to a duplicated name. */


         HANDLE_REFERENCE:
-        if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
+        if (firstcharflags == REQ_UNSET) zerofirstcharflags = firstcharflags = REQ_NONE;
         previous = code;
         item_hwm_offset = cd->hwm - cd->start_workspace;
         *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2017-12-08 14:09:22 UTC (rev 1718)
+++ code/trunk/testdata/testinput2    2017-12-12 15:07:18 UTC (rev 1719)
@@ -4249,4 +4249,12 @@


/(?=.*[A-Z])/I

+"(?<=(a))\1?b"
+    ab
+    aaab 
+
+"(?=(a))\1?b"
+    ab
+    aaab 
+
 /-- End of testinput2 --/


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2017-12-08 14:09:22 UTC (rev 1718)
+++ code/trunk/testdata/testoutput2    2017-12-12 15:07:18 UTC (rev 1719)
@@ -14705,4 +14705,20 @@
 No first char
 No need char


+"(?<=(a))\1?b"
+    ab
+ 0: b
+ 1: a
+    aaab 
+ 0: ab
+ 1: a
+
+"(?=(a))\1?b"
+    ab
+ 0: ab
+ 1: a
+    aaab 
+ 0: ab
+ 1: a
+
 /-- End of testinput2 --/