[Pcre-svn] [1682] code/trunk: Fix recognition of (? # style …

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1682] code/trunk: Fix recognition of (? # style comment between quantifier and '+' or '?'.
Revision: 1682
          http://vcs.pcre.org/viewvc?view=rev&revision=1682
Author:   ph10
Date:     2017-02-20 17:45:21 +0000 (Mon, 20 Feb 2017)
Log Message:
-----------
Fix recognition of (?# style comment between quantifier and '+' or '?'.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testoutput1


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-02-15 07:19:34 UTC (rev 1681)
+++ code/trunk/ChangeLog    2017-02-20 17:45:21 UTC (rev 1682)
@@ -17,7 +17,10 @@


3. Fix a missing else in the JIT compiler reported by 'idaifish'.

+4. A (?# style comment is now ignored between a basic quantifier and a
+following '+' or '?' (example: /X+(?#comment)?Y/.

+
Version 8.40 11-January-2017
----------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2017-02-15 07:19:34 UTC (rev 1681)
+++ code/trunk/pcre_compile.c    2017-02-20 17:45:21 UTC (rev 1682)
@@ -5739,6 +5739,21 @@
       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,


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2017-02-15 07:19:34 UTC (rev 1681)
+++ code/trunk/testdata/testinput1    2017-02-20 17:45:21 UTC (rev 1682)
@@ -5739,4 +5739,7 @@
 /(?=.*X)X$/ 
     \  X


+/X+(?#comment)?/
+    >XXX<
+
 /-- End of testinput1 --/


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2017-02-15 07:19:34 UTC (rev 1681)
+++ code/trunk/testdata/testoutput1    2017-02-20 17:45:21 UTC (rev 1682)
@@ -9442,4 +9442,8 @@
     \  X
  0: X


+/X+(?#comment)?/
+    >XXX<
+ 0: X
+
 /-- End of testinput1 --/