[Pcre-svn] [798] code/trunk: Use atomic blocks after starsta…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [798] code/trunk: Use atomic blocks after starstar during conversion.
Revision: 798
          http://www.exim.org/viewvc/pcre2?view=rev&revision=798
Author:   zherczeg
Date:     2017-05-23 16:17:44 +0100 (Tue, 23 May 2017)
Log Message:
-----------
Use atomic blocks after starstar during conversion.


Modified Paths:
--------------
    code/trunk/src/pcre2_convert.c
    code/trunk/testdata/testinput24
    code/trunk/testdata/testoutput24


Modified: code/trunk/src/pcre2_convert.c
===================================================================
--- code/trunk/src/pcre2_convert.c    2017-05-22 18:06:55 UTC (rev 797)
+++ code/trunk/src/pcre2_convert.c    2017-05-23 15:17:44 UTC (rev 798)
@@ -729,6 +729,8 @@
 BOOL no_backslash = (options & PCRE2_CONVERT_GLOB_NO_BACKSLASH) != 0;
 BOOL no_wildsep = (options & PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR) != 0;
 BOOL no_starstar = (options & PCRE2_CONVERT_GLOB_NO_STARSTAR) != 0;
+BOOL in_atomic = FALSE;
+BOOL after_starstar = FALSE;
 BOOL with_escape, is_start;
 int result, len;


@@ -780,6 +782,12 @@
     {
     is_start = pattern == pattern_start + 1;


+    if (in_atomic)
+      {
+      convert_glob_write(&out, CHAR_RIGHT_PARENTHESIS);
+      in_atomic = FALSE;
+      }
+
     if (!no_starstar && pattern < pattern_end && *pattern == CHAR_ASTERISK)
       {
       if (!is_start && pattern[-2] != separator)
@@ -814,6 +822,7 @@
         }


       pattern++;
+      after_starstar = TRUE;


       if (is_start)
         {
@@ -825,7 +834,7 @@
         out.out_str[5] = CHAR_VERTICAL_LINE;
         convert_glob_write_str(&out, 6);


-        convert_glob_print_wildcard(&out, separator, with_escape);
+        convert_glob_print_separator(&out, separator, with_escape);
         convert_glob_write(&out, CHAR_RIGHT_PARENTHESIS);
         continue;
         }
@@ -875,7 +884,18 @@
       }


     if (!is_start)
-      convert_glob_print_commit(&out);
+      {
+      if (after_starstar)
+        {
+        out.out_str[0] = CHAR_LEFT_PARENTHESIS;
+        out.out_str[1] = CHAR_QUESTION_MARK;
+        out.out_str[2] = CHAR_GREATER_THAN_SIGN;
+        convert_glob_write_str(&out, 3);
+        in_atomic = TRUE;
+        }
+      else
+        convert_glob_print_commit(&out);
+      }


     if (no_wildsep)
       convert_glob_write(&out, CHAR_DOT);
@@ -923,19 +943,19 @@


 if (result == 0 || result == ERROR_NO_SLASH_Z)
   {
-  if (result == ERROR_NO_SLASH_Z)
+  if (result == 0)
     {
-    convert_glob_write(&out, CHAR_NULL);
-    result = 0;
-    }
-  else
-    {
     out.out_str[0] = CHAR_BACKSLASH;
     out.out_str[1] = CHAR_z;
-    out.out_str[2] = CHAR_NULL;
-    convert_glob_write_str(&out, 3);
+    convert_glob_write_str(&out, 2);
     }


+  if (in_atomic)
+    convert_glob_write(&out, CHAR_RIGHT_PARENTHESIS);
+
+  convert_glob_write(&out, CHAR_NULL);
+  result = 0;
+
   if (!dummyrun && out.output_size != (PCRE2_SIZE) (out.output - use_buffer))
     result = PCRE2_ERROR_NOMEMORY;
   }


Modified: code/trunk/testdata/testinput24
===================================================================
--- code/trunk/testdata/testinput24    2017-05-22 18:06:55 UTC (rev 797)
+++ code/trunk/testdata/testinput24    2017-05-23 15:17:44 UTC (rev 798)
@@ -245,6 +245,20 @@


/abc\/**\/abc/

+/**\/*a*b*g*n*t/
+ abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt
+
+/**\/*a*\/**/
+ xx/xx/xx/xax/xx/xb
+
+/**\/*a*/
+ xx/xx/xx/xax
+ xx/xx/xx/xax/xx
+
+/**\/*a*\/**\/*b*/
+ xx/xx/xx/xax/xx/xb
+ xx/xx/xx/xax/xx/x
+
#pattern convert=glob:glob_no_starstar

/***/

Modified: code/trunk/testdata/testoutput24
===================================================================
--- code/trunk/testdata/testoutput24    2017-05-22 18:06:55 UTC (rev 797)
+++ code/trunk/testdata/testoutput24    2017-05-23 15:17:44 UTC (rev 798)
@@ -367,7 +367,7 @@
 (?s)


/**\/abc/
-(?s)(?:\A|[^/])abc\z
+(?s)(?:\A|/)abc\z

/abc\/**/
(?s)\Aabc/
@@ -375,6 +375,30 @@
/abc\/**\/abc/
(?s)\Aabc/(*COMMIT)(?:.*?/)??abc\z

+/**\/*a*b*g*n*t/
+(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?b)(?>[^/]*?g)(?>[^/]*?n)(?>[^/]*?t\z)
+ abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt
+ 0: /abcdefghijklmnop.txt
+
+/**\/*a*\/**/
+(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?/)
+ xx/xx/xx/xax/xx/xb
+ 0: /xax/
+
+/**\/*a*/
+(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?\z)
+ xx/xx/xx/xax
+ 0: /xax
+ xx/xx/xx/xax/xx
+No match
+
+/**\/*a*\/**\/*b*/
+(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?/)(*COMMIT)(?:.*?/)??(?>[^/]*?b)(?>[^/]*?\z)
+ xx/xx/xx/xax/xx/xb
+ 0: /xax/xx/xb
+ xx/xx/xx/xax/xx/x
+No match
+
#pattern convert=glob:glob_no_starstar

/***/