Testsuite: perl version oddity
[exim.git] / src / src / regex.c
index bb34e5b23f4ad1a63167c503e6cf87fa6e328ba9..285ab8dbd2582a3416f91a8cf0a0337a295b7be4 100644 (file)
@@ -24,8 +24,6 @@ typedef struct pcre_list {
   struct pcre_list *   next;
 } pcre_list;
 
-uschar regex_match_string_buffer[1024];
-
 extern FILE *mime_stream;
 extern uschar *mime_current_boundary;
 
@@ -85,9 +83,7 @@ for (pcre_list * ri = re_list_head; ri; ri = ri->next)
     int save_pool = store_pool;
     store_pool = POOL_PERM;
 
-    Ustrncpy(regex_match_string_buffer, ri->pcre_text,
-             sizeof(regex_match_string_buffer)-1);
-    regex_match_string = regex_match_string_buffer;
+    regex_match_string = string_copy(ri->pcre_text);
 
     for (int nn = 1; nn < n; nn++)
       {
@@ -122,10 +118,8 @@ regex(const uschar ** listptr, BOOL cacheable)
 unsigned long mbox_size;
 FILE * mbox_file;
 pcre_list * re_list_head;
-uschar * linebuffer;
 long f_pos = 0;
 int ret = FAIL, cnt, lcount = REGEX_LOOPCOUNT_STORE_RESET;
-rmark reset_point;
 
 regex_vars_clear();
 
@@ -149,22 +143,21 @@ else
   mbox_file = mime_stream;
   }
 
-reset_point = store_mark();
-  {
   /* precompile our regexes */
   if ((re_list_head = compile(*listptr, cacheable, &cnt)))
     {
+    rmark reset_point = store_mark();
+
     /* match each line against all regexes */
-    linebuffer = store_get(32767, GET_TAINTED);
-    while (fgets(CS linebuffer, 32767, mbox_file))
+    while (fgets(CS big_buffer, big_buffer_size, mbox_file))
       {
       if (  mime_stream && mime_current_boundary               /* check boundary */
-        && Ustrncmp(linebuffer, "--", 2) == 0
-        && Ustrncmp((linebuffer+2), mime_current_boundary,
+        && Ustrncmp(big_buffer, "--", 2) == 0
+        && Ustrncmp((big_buffer+2), mime_current_boundary,
                      Ustrlen(mime_current_boundary)) == 0)
        break;                                          /* found boundary */
 
-      if ((ret = matcher(re_list_head, linebuffer, (int)Ustrlen(linebuffer))) == OK)
+      if ((ret = matcher(re_list_head, big_buffer, (int)Ustrlen(big_buffer))) == OK)
        break;
 
       if ((lcount -= cnt) <= 0)
@@ -173,9 +166,9 @@ reset_point = store_mark();
        lcount = REGEX_LOOPCOUNT_STORE_RESET;
        }
       }
+
+    store_reset(reset_point);
     }
-  }
-store_reset(reset_point);
 
 if (!mime_stream)
   (void)fclose(mbox_file);