[Pcre-svn] [90] code/trunk: Save compile-time work when PCR…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [90] code/trunk: Save compile-time work when PCRE2_NO_START_OPTIMIZE is set .
Revision: 90
          http://www.exim.org/viewvc/pcre2?view=rev&revision=90
Author:   ph10
Date:     2014-10-03 10:47:59 +0100 (Fri, 03 Oct 2014)


Log Message:
-----------
Save compile-time work when PCRE2_NO_START_OPTIMIZE is set.

Modified Paths:
--------------
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2
    code/trunk/testdata/testoutput6


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2014-10-03 09:25:57 UTC (rev 89)
+++ code/trunk/src/pcre2_compile.c    2014-10-03 09:47:59 UTC (rev 90)
@@ -7883,9 +7883,11 @@


/* If the pattern is still not anchored and we do not have a first code unit,
see if there is one that is asserted (these are not saved during the compile
-because they can cause conflicts with actual literals that follow). */
+because they can cause conflicts with actual literals that follow). This code
+need not be obeyed if PCRE2_NO_START_OPTIMIZE is set, as the data it would
+create will not be used. */

-if ((re->overall_options & PCRE2_ANCHORED) == 0)
+if ((re->overall_options & (PCRE2_ANCHORED|PCRE2_NO_START_OPTIMIZE)) == 0)
   {
   if (firstcuflags < 0)
     firstcu = find_firstassertedcu(codestart, &firstcuflags, FALSE);
@@ -7928,10 +7930,11 @@
   }


/* Handle the "required code unit", if one is set. In the case of an anchored
-pattern, do this only if it follows a variable length item in the pattern. */
+pattern, do this only if it follows a variable length item in the pattern.
+Again, skip this if PCRE2_NO_START_OPTIMIZE is set. */

 if (reqcuflags >= 0 &&
-     ((re->overall_options & PCRE2_ANCHORED) == 0 ||
+     ((re->overall_options & (PCRE2_ANCHORED|PCRE2_NO_START_OPTIMIZE)) == 0 ||
       (reqcuflags & REQ_VARY) != 0))
   {
   re->last_codeunit = reqcu;
@@ -7966,10 +7969,12 @@
   }
 while (*codestart == OP_ALT);


-/* Finally, study the compiled pattern to set up information such as a bitmap
-of starting code units and a minimum matching length. */
+/* Finally, unless PCRE2_NO_START_OPTIMIZE is set, study the compiled pattern
+to set up information such as a bitmap of starting code units and a minimum
+matching length. */

-if (PRIV(study)(re) != 0)
+if ((re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0 && 
+    PRIV(study)(re) != 0)
   {
   errorcode = ERR31;
   goto HAD_ERROR;


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2014-10-03 09:25:57 UTC (rev 89)
+++ code/trunk/testdata/testinput2    2014-10-03 09:47:59 UTC (rev 90)
@@ -4091,4 +4091,8 @@


/(?(VERSION>=10.0.0)yes|no)/

+/abcd/I
+
+/abcd/I,no_start_optimize
+
# End of testinput2

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2014-10-03 09:25:57 UTC (rev 89)
+++ code/trunk/testdata/testoutput2    2014-10-03 09:47:59 UTC (rev 90)
@@ -13769,4 +13769,15 @@
 /(?(VERSION>=10.0.0)yes|no)/
 Failed: error 179 at offset 16: syntax error in (?(VERSION condition


+/abcd/I
+Capturing subpattern count = 0
+First code unit = 'a'
+Last code unit = 'd'
+Subject length lower bound = 4
+
+/abcd/I,no_start_optimize
+Capturing subpattern count = 0
+Options: no_start_optimize
+Subject length lower bound = 0
+
# End of testinput2

Modified: code/trunk/testdata/testoutput6
===================================================================
(Binary files differ)