/[pcre]/code/trunk/pcre_jit_test.c
ViewVC logotype

Diff of /code/trunk/pcre_jit_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 698 by ph10, Mon Sep 19 15:43:02 2011 UTC revision 1464 by zherczeg, Fri Mar 14 11:45:56 2014 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                    Main Library written by Philip Hazel                    Main Library written by Philip Hazel
9             Copyright (c) 1997-2011 University of Cambridge             Copyright (c) 1997-2012 University of Cambridge
10    
11    This JIT compiler regression test program was written by Zoltan Herczeg    This JIT compiler regression test program was written by Zoltan Herczeg
12                        Copyright (c) 2010-2011                        Copyright (c) 2010-2012
13    
14  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
15  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 48  POSSIBILITY OF SUCH DAMAGE. Line 48  POSSIBILITY OF SUCH DAMAGE.
48  #include <string.h>  #include <string.h>
49  #include "pcre.h"  #include "pcre.h"
50    
51    
52    #include "pcre_internal.h"
53    
54  #define PCRE_BUG 0x80000000  #define PCRE_BUG 0x80000000
55    
56  /*  /*
57   Hungarian utf8 characters   Letter characters:
58   \xc3\xa9 = 0xe9 = 233 (e') \xc3\x89 = 0xc9 = 201 (E')     \xe6\x92\xad = 0x64ad = 25773 (kanji)
59   \xc3\xa1 = 0xe1 = 225 (a') \xc3\x81 = 0xc1 = 193 (A')   Non-letter characters:
60   \xe6\x92\xad = 0x64ad = 25773 (a valid kanji)     \xc2\xa1 = 0xa1 =  (Inverted Exclamation Mark)
61   \xc2\x85 = 0x85 (NExt Line = NEL)     \xf3\xa9\xb7\x80 = 0xe9dc0 = 957888
62   \xc2\xa1 = 0xa1 (Inverted Exclamation Mark)     \xed\xa0\x80 = 55296 = 0xd800 (Invalid UTF character)
63   \xe2\x80\xa8 = 0x2028 (Line Separator)     \xed\xb0\x80 = 56320 = 0xdc00 (Invalid UTF character)
64   \xc8\xba = 570 \xe2\xb1\xa5 = 11365 (lowercase length != uppercase length)   Newlines:
65   \xcc\x8d = 781 (Something with Mark property)     \xc2\x85 = 0x85 = 133 (NExt Line = NEL)
66       \xe2\x80\xa8 = 0x2028 = 8232 (Line Separator)
67     Othercase pairs:
68       \xc3\xa9 = 0xe9 = 233 (e')
69          \xc3\x89 = 0xc9 = 201 (E')
70       \xc3\xa1 = 0xe1 = 225 (a')
71          \xc3\x81 = 0xc1 = 193 (A')
72       \xc8\xba = 0x23a = 570
73          \xe2\xb1\xa5 = 0x2c65 = 11365
74       \xe1\xbd\xb8 = 0x1f78 = 8056
75          \xe1\xbf\xb8 = 0x1ff8 = 8184
76       \xf0\x90\x90\x80 = 0x10400 = 66560
77          \xf0\x90\x90\xa8 = 0x10428 = 66600
78       \xc7\x84 = 0x1c4 = 452
79         \xc7\x85 = 0x1c5 = 453
80         \xc7\x86 = 0x1c6 = 454
81    
82     Mark property:
83       \xcc\x8d = 0x30d = 781
84     Special:
85       \xc2\x80 = 0x80 = 128 (lowest 2 byte character)
86       \xdf\xbf = 0x7ff = 2047 (highest 2 byte character)
87       \xe0\xa0\x80 = 0x800 = 2048 (lowest 2 byte character)
88       \xef\xbf\xbf = 0xffff = 65535 (highest 3 byte character)
89       \xf0\x90\x80\x80 = 0x10000 = 65536 (lowest 4 byte character)
90       \xf4\x8f\xbf\xbf = 0x10ffff = 1114111 (highest allowed utf character)
91  */  */
92    
 static void setstack(pcre_extra *extra);  
93  static int regression_tests(void);  static int regression_tests(void);
94    
95  int main(void)  int main(void)
96  {  {
97          int jit = 0;          int jit = 0;
98    #if defined SUPPORT_PCRE8
99          pcre_config(PCRE_CONFIG_JIT, &jit);          pcre_config(PCRE_CONFIG_JIT, &jit);
100    #elif defined SUPPORT_PCRE16
101            pcre16_config(PCRE_CONFIG_JIT, &jit);
102    #elif defined SUPPORT_PCRE32
103            pcre32_config(PCRE_CONFIG_JIT, &jit);
104    #endif
105          if (!jit) {          if (!jit) {
106                  printf("JIT must be enabled to run pcre_jit_test\n");                  printf("JIT must be enabled to run pcre_jit_test\n");
107                  return 1;                  return 1;
# Line 76  int main(void) Line 109  int main(void)
109          return regression_tests();          return regression_tests();
110  }  }
111    
 static pcre_jit_stack* callback(void *arg)  
 {  
         return (pcre_jit_stack *)arg;  
 }  
   
 static void setstack(pcre_extra *extra)  
 {  
         static pcre_jit_stack *stack;  
         if (stack) pcre_jit_stack_free(stack);  
         stack = pcre_jit_stack_alloc(1, 1024 * 1024);  
         pcre_assign_jit_stack(extra, callback, stack);  
 }  
   
112  /* --------------------------------------------------------------------------------------- */  /* --------------------------------------------------------------------------------------- */
113    
114  #define MUA     (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)  #if !(defined SUPPORT_PCRE8) && !(defined SUPPORT_PCRE16) && !(defined SUPPORT_PCRE32)
115  #define MUAP    (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  #error SUPPORT_PCRE8 or SUPPORT_PCRE16 or SUPPORT_PCRE32 must be defined
116  #define CMUA    (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)  #endif
117  #define CMUAP   (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  
118  #define MA      (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)  #define MUA     (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
119  #define MAP     (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  #define MUAP    (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
120  #define CMA     (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)  #define CMUA    (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
121    #define CMUAP   (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
122    #define MA      (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
123    #define MAP     (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
124    #define CMA     (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
125    
126    #define OFFSET_MASK     0x00ffff
127    #define F_NO8           0x010000
128    #define F_NO16          0x020000
129    #define F_NO32          0x020000
130    #define F_NOMATCH       0x040000
131    #define F_DIFF          0x080000
132    #define F_FORCECONV     0x100000
133    #define F_PROPERTY      0x200000
134    #define F_STUDY         0x400000
135    
136  struct regression_test_case {  struct regression_test_case {
137          int flags;          int flags;
# Line 124  static struct regression_test_case regre Line 158  static struct regression_test_case regre
158          { MUA, 0, "\\W(\\W)?\\w", "\n\n+bc" },          { MUA, 0, "\\W(\\W)?\\w", "\n\n+bc" },
159          { MUA, 0, "[axd]", "sAXd" },          { MUA, 0, "[axd]", "sAXd" },
160          { CMUA, 0, "[axd]", "sAXd" },          { CMUA, 0, "[axd]", "sAXd" },
161          { CMUA, 0, "[^axd]", "DxA" },          { CMUA, 0 | F_NOMATCH, "[^axd]", "DxA" },
162          { MUA, 0, "[a-dA-C]", "\xe6\x92\xad\xc3\xa9.B" },          { MUA, 0, "[a-dA-C]", "\xe6\x92\xad\xc3\xa9.B" },
163          { MUA, 0, "[^a-dA-C]", "\xe6\x92\xad\xc3\xa9" },          { MUA, 0, "[^a-dA-C]", "\xe6\x92\xad\xc3\xa9" },
164          { CMUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },          { CMUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },
# Line 135  static struct regression_test_case regre Line 169  static struct regression_test_case regre
169          { PCRE_CASELESS, 0, "\xff#a", "\xff#\xff\xfe##\xff#A" },          { PCRE_CASELESS, 0, "\xff#a", "\xff#\xff\xfe##\xff#A" },
170          { PCRE_CASELESS, 0, "\xfe", "\xff\xfc#\xfe\xfe" },          { PCRE_CASELESS, 0, "\xfe", "\xff\xfc#\xfe\xfe" },
171          { PCRE_CASELESS, 0, "a1", "Aa1" },          { PCRE_CASELESS, 0, "a1", "Aa1" },
172            { MA, 0, "\\Ca", "cda" },
173            { CMA, 0, "\\Ca", "CDA" },
174            { MA, 0 | F_NOMATCH, "\\Cx", "cda" },
175            { CMA, 0 | F_NOMATCH, "\\Cx", "CDA" },
176            { CMUAP, 0, "\xf0\x90\x90\x80\xf0\x90\x90\xa8", "\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
177            { CMUAP, 0, "\xf0\x90\x90\x80{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
178            { CMUAP, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
179            { CMUAP, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
180    
181          /* Assertions. */          /* Assertions. */
182          { MUA, 0, "\\b[^A]", "A_B#" },          { MUA, 0, "\\b[^A]", "A_B#" },
183          { MA, 0, "\\b\\W", "\n*" },          { MA, 0 | F_NOMATCH, "\\b\\W", "\n*" },
184          { MUA, 0, "\\B[^,]\\b[^s]\\b", "#X" },          { MUA, 0, "\\B[^,]\\b[^s]\\b", "#X" },
185          { MAP, 0, "\\B", "_\xa1" },          { MAP, 0, "\\B", "_\xa1" },
186          { MAP, 0, "\\b_\\b[,A]\\B", "_," },          { MAP, 0, "\\b_\\b[,A]\\B", "_," },
# Line 146  static struct regression_test_case regre Line 188  static struct regression_test_case regre
188          { MUAP, 0, "\\B", "_\xc2\xa1\xc3\xa1\xc2\x85" },          { MUAP, 0, "\\B", "_\xc2\xa1\xc3\xa1\xc2\x85" },
189          { MUAP, 0, "\\b[^A]\\B[^c]\\b[^_]\\B", "_\xc3\xa1\xe2\x80\xa8" },          { MUAP, 0, "\\b[^A]\\B[^c]\\b[^_]\\B", "_\xc3\xa1\xe2\x80\xa8" },
190          { MUAP, 0, "\\b\\w+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },          { MUAP, 0, "\\b\\w+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
191          { MUA, 0, "\\b.", "\xcd\xbe" },          { MUA, 0 | F_NOMATCH, "\\b.", "\xcd\xbe" },
192          { MA, 0, "\\R^", "\n" },          { CMUAP, 0, "\\By", "\xf0\x90\x90\xa8y" },
193          { MA, 1, "^", "\n" },          { MA, 0 | F_NOMATCH, "\\R^", "\n" },
194            { MA, 1 | F_NOMATCH, "^", "\n" },
195          { 0, 0, "^ab", "ab" },          { 0, 0, "^ab", "ab" },
196          { 0, 0, "^ab", "aab" },          { 0, 0 | F_NOMATCH, "^ab", "aab" },
197          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "^a", "\r\raa\n\naa\r\naa" },          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "^a", "\r\raa\n\naa\r\naa" },
198          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "^-", "\xe2\x80\xa8--\xc2\x85-\r\n-" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "^-", "\xe2\x80\xa8--\xc2\x85-\r\n-" },
199          { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^-", "a--b--\x85--" },          { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^-", "a--b--\x85--" },
200          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xe2\x80\xa8--" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xe2\x80\xa8--" },
201          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xc2\x85--" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xc2\x85--" },
202          { 0, 0, "ab$", "ab" },          { 0, 0, "ab$", "ab" },
203          { 0, 0, "ab$", "ab\r\n" },          { 0, 0 | F_NOMATCH, "ab$", "abab\n\n" },
204            { PCRE_DOLLAR_ENDONLY, 0 | F_NOMATCH, "ab$", "abab\r\n" },
205          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "a$", "\r\raa\n\naa\r\naa" },          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "a$", "\r\raa\n\naa\r\naa" },
206          { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aaa" },          { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aaa" },
207          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "#$", "#\xc2\x85###\r#" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "#$", "#\xc2\x85###\r#" },
208          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "#$", "#\xe2\x80\xa9" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "#$", "#\xe2\x80\xa9" },
209          { PCRE_NOTBOL | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },          { PCRE_NOTBOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "^a", "aa\naa" },
210          { PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },          { PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },
211          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\naa" },
212          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0, "a$", "aa\r\n" },          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\r\n" },
213          { PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0, "\\p{Any}{2,}$", "aa\r\n" },          { PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0 | F_PROPERTY, "\\p{Any}{2,}$", "aa\r\n" },
214          { PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },          { PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },
215          { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },          { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },
216          { PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },          { PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },
# Line 186  static struct regression_test_case regre Line 230  static struct regression_test_case regre
230          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xc2\x85" },          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xc2\x85" },
231          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },
232          { MA, 0, "\\Aa", "aaa" },          { MA, 0, "\\Aa", "aaa" },
233          { MA, 1, "\\Aa", "aaa" },          { MA, 1 | F_NOMATCH, "\\Aa", "aaa" },
234          { MA, 1, "\\Ga", "aaa" },          { MA, 1, "\\Ga", "aaa" },
235          { MA, 1, "\\Ga", "aba" },          { MA, 1 | F_NOMATCH, "\\Ga", "aba" },
236          { MA, 0, "a\\z", "aaa" },          { MA, 0, "a\\z", "aaa" },
237          { MA, 0, "a\\z", "aab" },          { MA, 0 | F_NOMATCH, "a\\z", "aab" },
238    
239          /* Brackets. */          /* Brackets. */
240          { MUA, 0, "(ab|bb|cd)", "bacde" },          { MUA, 0, "(ab|bb|cd)", "bacde" },
# Line 263  static struct regression_test_case regre Line 307  static struct regression_test_case regre
307          { MUA, 0, "\\b\\w+\\B", "x,a_cd" },          { MUA, 0, "\\b\\w+\\B", "x,a_cd" },
308          { MUAP, 0, "\\b[^\xc2\xa1]+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },          { MUAP, 0, "\\b[^\xc2\xa1]+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
309          { CMUA, 0, "[^b]+(a*)([^c]?d{3})", "aaaaddd" },          { CMUA, 0, "[^b]+(a*)([^c]?d{3})", "aaaaddd" },
310            { CMUAP, 0, "\xe1\xbd\xb8{2}", "\xe1\xbf\xb8#\xe1\xbf\xb8\xe1\xbd\xb8" },
311            { CMUA, 0, "[^\xf0\x90\x90\x80]{2,4}@", "\xf0\x90\x90\xa8\xf0\x90\x90\x80###\xf0\x90\x90\x80@@@" },
312            { CMUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" },
313            { MUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" },
314            { MUA, 0, "[^\xe1\xbd\xb8]{3,}?", "##\xe1\xbd\xb8#\xe1\xbd\xb8#\xc3\x89#\xe1\xbd\xb8" },
315    
316            /* Bracket repeats with limit. */
317            { MUA, 0, "(?:(ab){2}){5}M", "abababababababababababM" },
318            { MUA, 0, "(?:ab|abab){1,5}M", "abababababababababababM" },
319            { MUA, 0, "(?>ab|abab){1,5}M", "abababababababababababM" },
320            { MUA, 0, "(?:ab|abab){1,5}?M", "abababababababababababM" },
321            { MUA, 0, "(?>ab|abab){1,5}?M", "abababababababababababM" },
322            { MUA, 0, "(?:(ab){1,4}?){1,3}?M", "abababababababababababababM" },
323            { MUA, 0, "(?:(ab){1,4}){1,3}abababababababababababM", "ababababababababababababM" },
324            { MUA, 0 | F_NOMATCH, "(?:(ab){1,4}){1,3}abababababababababababM", "abababababababababababM" },
325            { MUA, 0, "(ab){4,6}?M", "abababababababM" },
326    
327          /* Basic character sets. */          /* Basic character sets. */
328          { MUA, 0, "(?:\\s)+(?:\\S)+", "ab \t\xc3\xa9\xe6\x92\xad " },          { MUA, 0, "(?:\\s)+(?:\\S)+", "ab \t\xc3\xa9\xe6\x92\xad " },
# Line 271  static struct regression_test_case regre Line 331  static struct regression_test_case regre
331          { MUA, 0, "\\w(\\s|(?:\\d)*,)+\\w\\wb", "a 5, 4,, bb 5, 4,, aab" },          { MUA, 0, "\\w(\\s|(?:\\d)*,)+\\w\\wb", "a 5, 4,, bb 5, 4,, aab" },
332          { MUA, 0, "(\\v+)(\\V+)", "\x0e\xc2\x85\xe2\x80\xa8\x0b\x09\xe2\x80\xa9" },          { MUA, 0, "(\\v+)(\\V+)", "\x0e\xc2\x85\xe2\x80\xa8\x0b\x09\xe2\x80\xa9" },
333          { MUA, 0, "(\\h+)(\\H+)", "\xe2\x80\xa8\xe2\x80\x80\x20\xe2\x80\x8a\xe2\x81\x9f\xe3\x80\x80\x09\x20\xc2\xa0\x0a" },          { MUA, 0, "(\\h+)(\\H+)", "\xe2\x80\xa8\xe2\x80\x80\x20\xe2\x80\x8a\xe2\x81\x9f\xe3\x80\x80\x09\x20\xc2\xa0\x0a" },
334            { MUA, 0, "x[bcef]+", "xaxdxecbfg" },
335            { MUA, 0, "x[bcdghij]+", "xaxexfxdgbjk" },
336            { MUA, 0, "x[^befg]+", "xbxexacdhg" },
337            { MUA, 0, "x[^bcdl]+", "xlxbxaekmd" },
338            { MUA, 0, "x[^bcdghi]+", "xbxdxgxaefji" },
339            { MUA, 0, "x[B-Fb-f]+", "xaxAxgxbfBFG" },
340            { CMUA, 0, "\\x{e9}+", "#\xf0\x90\x90\xa8\xc3\xa8\xc3\xa9\xc3\x89\xc3\x88" },
341            { CMUA, 0, "[^\\x{e9}]+", "\xc3\xa9#\xf0\x90\x90\xa8\xc3\xa8\xc3\x88\xc3\x89" },
342            { MUA, 0, "[\\x02\\x7e]+", "\xc3\x81\xe1\xbf\xb8\xf0\x90\x90\xa8\x01\x02\x7e\x7f" },
343            { MUA, 0, "[^\\x02\\x7e]+", "\x02\xc3\x81\xe1\xbf\xb8\xf0\x90\x90\xa8\x01\x7f\x7e" },
344            { MUA, 0, "[\\x{81}-\\x{7fe}]+", "#\xe1\xbf\xb8\xf0\x90\x90\xa8\xc2\x80\xc2\x81\xdf\xbe\xdf\xbf" },
345            { MUA, 0, "[^\\x{81}-\\x{7fe}]+", "\xc2\x81#\xe1\xbf\xb8\xf0\x90\x90\xa8\xc2\x80\xdf\xbf\xdf\xbe" },
346            { MUA, 0, "[\\x{801}-\\x{fffe}]+", "#\xc3\xa9\xf0\x90\x90\x80\xe0\xa0\x80\xe0\xa0\x81\xef\xbf\xbe\xef\xbf\xbf" },
347            { MUA, 0, "[^\\x{801}-\\x{fffe}]+", "\xe0\xa0\x81#\xc3\xa9\xf0\x90\x90\x80\xe0\xa0\x80\xef\xbf\xbf\xef\xbf\xbe" },
348            { MUA, 0, "[\\x{10001}-\\x{10fffe}]+", "#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf0\x90\x80\x81\xf4\x8f\xbf\xbe\xf4\x8f\xbf\xbf" },
349            { MUA, 0, "[^\\x{10001}-\\x{10fffe}]+", "\xf0\x90\x80\x81#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbe" },
350    
351          /* Unicode properties. */          /* Unicode properties. */
352          { MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },          { MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },
353          { MUAP, 0, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },          { MUAP, 0 | F_PROPERTY, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },
354          { MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },          { MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },
355          { MUAP, 0, "[\\P{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}]", "abc" },
356          { MUAP, 0, "[^\\p{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}]", "abc" },
357          { MUAP, 0, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },
358          { MUAP, 0, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },
359          { MUAP, 0, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
360          { MUAP, 0, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
361          { MUAP, 0, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },          { MUAP, 0 | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
362          { MUAP, 0, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },          { MUAP, 0 | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
363          { MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },          { MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },
364          { CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },          { CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },
365          { MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },          { MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },
366          { MUAP, 0, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },          { MUAP, 0 | F_PROPERTY, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },
367          { MUA, 0, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },          { MUA, 0 | F_PROPERTY, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },
368          { CMUAP, 0, "[\xc3\xa1-\xc3\xa9_\xe2\x80\xa0-\xe2\x80\xaf]{1,5}[^\xe2\x80\xa0-\xe2\x80\xaf]", "\xc2\xa1\xc3\x89\xc3\x89\xe2\x80\xaf_\xe2\x80\xa0" },          { CMUAP, 0, "[\xc3\xa1-\xc3\xa9_\xe2\x80\xa0-\xe2\x80\xaf]{1,5}[^\xe2\x80\xa0-\xe2\x80\xaf]", "\xc2\xa1\xc3\x89\xc3\x89\xe2\x80\xaf_\xe2\x80\xa0" },
369          { MUAP, 0, "[\xc3\xa2-\xc3\xa6\xc3\x81-\xc3\x84\xe2\x80\xa8-\xe2\x80\xa9\xe6\x92\xad\\p{Zs}]{2,}", "\xe2\x80\xa7\xe2\x80\xa9\xe6\x92\xad \xe6\x92\xae" },          { MUAP, 0 | F_PROPERTY, "[\xc3\xa2-\xc3\xa6\xc3\x81-\xc3\x84\xe2\x80\xa8-\xe2\x80\xa9\xe6\x92\xad\\p{Zs}]{2,}", "\xe2\x80\xa7\xe2\x80\xa9\xe6\x92\xad \xe6\x92\xae" },
370          { MUAP, 0, "[\\P{L&}]{2}[^\xc2\x85-\xc2\x89\\p{Ll}\\p{Lu}]{2}", "\xc3\xa9\xe6\x92\xad.a\xe6\x92\xad|\xc2\x8a#" },          { MUAP, 0 | F_PROPERTY, "[\\P{L&}]{2}[^\xc2\x85-\xc2\x89\\p{Ll}\\p{Lu}]{2}", "\xc3\xa9\xe6\x92\xad.a\xe6\x92\xad|\xc2\x8a#" },
371          { PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB  baaa" },          { PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB  baaa" },
372    
373          /* Possible empty brackets. */          /* Possible empty brackets. */
# Line 308  static struct regression_test_case regre Line 384  static struct regression_test_case regre
384    
385          /* Start offset. */          /* Start offset. */
386          { MUA, 3, "(\\d|(?:\\w)*\\w)+", "0ac01Hb" },          { MUA, 3, "(\\d|(?:\\w)*\\w)+", "0ac01Hb" },
387          { MUA, 4, "(\\w\\W\\w)+", "ab#d" },          { MUA, 4 | F_NOMATCH, "(\\w\\W\\w)+", "ab#d" },
388          { MUA, 2, "(\\w\\W\\w)+", "ab#d" },          { MUA, 2 | F_NOMATCH, "(\\w\\W\\w)+", "ab#d" },
389          { MUA, 1, "(\\w\\W\\w)+", "ab#d" },          { MUA, 1, "(\\w\\W\\w)+", "ab#d" },
390    
391          /* Newline. */          /* Newline. */
392          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
393          { PCRE_MULTILINE | PCRE_NEWLINE_CR, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },          { PCRE_MULTILINE | PCRE_NEWLINE_CR, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
394          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{1,3}[^#]", "\r\n##...." },          { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{1,3}[^#]", "\r\n##...." },
395            { MUA | PCRE_NO_UTF8_CHECK, 1, "^.a", "\n\x80\nxa" },
396            { MUA, 1, "^", "\r\n" },
397            { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 1 | F_NOMATCH, "^", "\r\n" },
398            { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 1, "^", "\r\na" },
399    
400          /* Any character except newline or any newline. */          /* Any character except newline or any newline. */
401          { PCRE_NEWLINE_CRLF, 0, ".", "\r" },          { PCRE_NEWLINE_CRLF, 0, ".", "\r" },
# Line 323  static struct regression_test_case regre Line 403  static struct regression_test_case regre
403          { PCRE_NEWLINE_ANYCRLF, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },          { PCRE_NEWLINE_ANYCRLF, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
404          { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },          { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
405          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.).", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa9$de" },          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.).", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa9$de" },
406          { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.).", "\xe2\x80\xa8\nb\r" },          { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0 | F_NOMATCH, ".(.).", "\xe2\x80\xa8\nb\r" },
407          { PCRE_NEWLINE_ANY, 0, "(.)(.)", "#\x85#\r#\n#\r\n#\x84" },          { PCRE_NEWLINE_ANY, 0, "(.)(.)", "#\x85#\r#\n#\r\n#\x84" },
408          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.+)#", "#\rMn\xc2\x85#\n###" },          { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.+)#", "#\rMn\xc2\x85#\n###" },
409          { PCRE_BSR_ANYCRLF, 0, "\\R", "\r" },          { PCRE_BSR_ANYCRLF, 0, "\\R", "\r" },
# Line 331  static struct regression_test_case regre Line 411  static struct regression_test_case regre
411          { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\xe2\x80\xa8#c" },          { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\xe2\x80\xa8#c" },
412          { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\r\nc" },          { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\r\nc" },
413          { PCRE_NEWLINE_CRLF | PCRE_BSR_UNICODE | PCRE_UTF8, 0, "(\\R.)+", "\xc2\x85\r\n#\xe2\x80\xa8\n\r\n\r" },          { PCRE_NEWLINE_CRLF | PCRE_BSR_UNICODE | PCRE_UTF8, 0, "(\\R.)+", "\xc2\x85\r\n#\xe2\x80\xa8\n\r\n\r" },
414          { MUA, 0, "\\R+", "ab" },          { MUA, 0 | F_NOMATCH, "\\R+", "ab" },
415          { MUA, 0, "\\R+", "ab\r\n\r" },          { MUA, 0, "\\R+", "ab\r\n\r" },
416          { MUA, 0, "\\R*", "ab\r\n\r" },          { MUA, 0, "\\R*", "ab\r\n\r" },
417          { MUA, 0, "\\R*", "\r\n\r" },          { MUA, 0, "\\R*", "\r\n\r" },
# Line 339  static struct regression_test_case regre Line 419  static struct regression_test_case regre
419          { MUA, 0, "\\R{2,4}", "\r\nab\n\n\n\r\r\r" },          { MUA, 0, "\\R{2,4}", "\r\nab\n\n\n\r\r\r" },
420          { MUA, 0, "\\R{2,}", "\r\nab\n\n\n\r\r\r" },          { MUA, 0, "\\R{2,}", "\r\nab\n\n\n\r\r\r" },
421          { MUA, 0, "\\R{0,3}", "\r\n\r\n\r\n\r\n\r\n" },          { MUA, 0, "\\R{0,3}", "\r\n\r\n\r\n\r\n\r\n" },
422          { MUA, 0, "\\R+\\R\\R", "\r\n\r\n" },          { MUA, 0 | F_NOMATCH, "\\R+\\R\\R", "\r\n\r\n" },
423          { MUA, 0, "\\R+\\R\\R", "\r\r\r" },          { MUA, 0, "\\R+\\R\\R", "\r\r\r" },
424          { MUA, 0, "\\R*\\R\\R", "\n\r" },          { MUA, 0, "\\R*\\R\\R", "\n\r" },
425          { MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r" },          { MUA, 0 | F_NOMATCH, "\\R{2,4}\\R\\R", "\r\r\r" },
426          { MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r\r" },          { MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r\r" },
427    
428          /* Atomic groups (no fallback from "next" direction). */          /* Atomic groups (no fallback from "next" direction). */
429          { MUA, 0, "(?>ab)ab", "bab" },          { MUA, 0 | F_NOMATCH, "(?>ab)ab", "bab" },
430          { MUA, 0, "(?>(ab))ab", "bab" },          { MUA, 0 | F_NOMATCH, "(?>(ab))ab", "bab" },
431          { MUA, 0, "(?>ab)+abc(?>de)*def(?>gh)?ghe(?>ij)+?k(?>lm)*?n(?>op)?\?op",          { MUA, 0, "(?>ab)+abc(?>de)*def(?>gh)?ghe(?>ij)+?k(?>lm)*?n(?>op)?\?op",
432                          "bababcdedefgheijijklmlmnop" },                          "bababcdedefgheijijklmlmnop" },
433          { MUA, 0, "(?>a(b)+a|(ab)?\?(b))an", "abban" },          { MUA, 0, "(?>a(b)+a|(ab)?\?(b))an", "abban" },
# Line 375  static struct regression_test_case regre Line 455  static struct regression_test_case regre
455          { CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },          { CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },
456          { MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },          { MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
457          { MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },          { MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
458          { MUA, 0, "\\X", "\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d" },
459          { MUA, 0, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },
460          { MUA, 0, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_PROPERTY, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },
461          { MUA, 0, "\\X{2,4}", "abcdef" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}", "abcdef" },
462          { MUA, 0, "\\X{2,4}?", "abcdef" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}?", "abcdef" },
463          { MUA, 0, "\\X{2,4}..", "#\xcc\x8d##" },          { MUA, 0 | F_NOMATCH | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d##" },
464          { MUA, 0, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },
465          { MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },          { MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },
466          { MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },          { MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },
467    
# Line 416  static struct regression_test_case regre Line 496  static struct regression_test_case regre
496          { MUA, 0, "((b*))++m", "bxbbxbbbxbbm" },          { MUA, 0, "((b*))++m", "bxbbxbbbxbbm" },
497          { MUA, 0, "((b*))*+m", "bxbbxbbbxm" },          { MUA, 0, "((b*))*+m", "bxbbxbbbxm" },
498          { MUA, 0, "((b*))*+m", "bxbbxbbbxbbm" },          { MUA, 0, "((b*))*+m", "bxbbxbbbxbbm" },
499          { MUA, 0, "(?>(b{2,4}))(?:(?:(aa|c))++m|(?:(aa|c))+n)", "bbaacaaccaaaacxbbbmbn" },          { MUA, 0 | F_NOMATCH, "(?>(b{2,4}))(?:(?:(aa|c))++m|(?:(aa|c))+n)", "bbaacaaccaaaacxbbbmbn" },
500          { MUA, 0, "((?:b)++a)+(cd)*+m", "bbababbacdcdnbbababbacdcdm" },          { MUA, 0, "((?:b)++a)+(cd)*+m", "bbababbacdcdnbbababbacdcdm" },
501          { MUA, 0, "((?:(b))++a)+((c)d)*+m", "bbababbacdcdnbbababbacdcdm" },          { MUA, 0, "((?:(b))++a)+((c)d)*+m", "bbababbacdcdnbbababbacdcdm" },
502          { MUA, 0, "(?:(?:(?:ab)*+k)++(?:n(?:cd)++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },          { MUA, 0, "(?:(?:(?:ab)*+k)++(?:n(?:cd)++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },
# Line 440  static struct regression_test_case regre Line 520  static struct regression_test_case regre
520          { MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },          { MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },
521          { MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },          { MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },
522          { MA, 0, "(a?)b(\\1\\1*\\1+\\1?\\1*?\\1+?\\1??\\1*+\\1++\\1?+\\1{4}\\1{3,5}\\1{4,}\\1{0,5}\\1{3,5}?\\1{4,}?\\1{0,5}?\\1{3,5}+\\1{4,}+\\1{0,5}+#){2}d", "bb#b##d" },          { MA, 0, "(a?)b(\\1\\1*\\1+\\1?\\1*?\\1+?\\1??\\1*+\\1++\\1?+\\1{4}\\1{3,5}\\1{4,}\\1{0,5}\\1{3,5}?\\1{4,}?\\1{0,5}?\\1{3,5}+\\1{4,}+\\1{0,5}+#){2}d", "bb#b##d" },
523          { MUAP, 0, "(\\P{N})\\1{2,}", ".www." },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
524          { MUAP, 0, "(\\P{N})\\1{0,2}", "wwwww." },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{0,2}", "wwwww." },
525          { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwww" },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwww" },
526          { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwwww" },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwwww" },
527          { PCRE_UCP, 0, "(\\P{N})\\1{2,}", ".www." },          { PCRE_UCP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
528            { CMUAP, 0, "(\xf0\x90\x90\x80)\\1", "\xf0\x90\x90\xa8\xf0\x90\x90\xa8" },
529            { MUA | PCRE_DUPNAMES, 0 | F_NOMATCH, "\\k<A>{1,3}(?<A>aa)(?<A>bb)", "aabb" },
530            { MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k<A>{1,3}(?<A>aa)(?<A>bb)", "aabb" },
531            { MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k<A>*(?<A>aa)(?<A>bb)", "aabb" },
532            { MUA | PCRE_DUPNAMES, 0, "(?<A>aa)(?<A>bb)\\k<A>{0,3}aaaaaa", "aabbaaaaaa" },
533            { MUA | PCRE_DUPNAMES, 0, "(?<A>aa)(?<A>bb)\\k<A>{2,5}bb", "aabbaaaabb" },
534            { MUA | PCRE_DUPNAMES, 0, "(?:(?<A>aa)|(?<A>bb))\\k<A>{0,3}m", "aaaaaaaabbbbaabbbbm" },
535            { MUA | PCRE_DUPNAMES, 0 | F_NOMATCH, "\\k<A>{1,3}?(?<A>aa)(?<A>bb)", "aabb" },
536            { MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k<A>{1,3}?(?<A>aa)(?<A>bb)", "aabb" },
537            { MUA | PCRE_DUPNAMES, 0, "\\k<A>*?(?<A>aa)(?<A>bb)", "aabb" },
538            { MUA | PCRE_DUPNAMES, 0, "(?:(?<A>aa)|(?<A>bb))\\k<A>{0,3}?m", "aaaaaabbbbbbaabbbbbbbbbbm" },
539            { MUA | PCRE_DUPNAMES, 0, "(?:(?<A>aa)|(?<A>bb))\\k<A>*?m", "aaaaaabbbbbbaabbbbbbbbbbm" },
540            { MUA | PCRE_DUPNAMES, 0, "(?:(?<A>aa)|(?<A>bb))\\k<A>{2,3}?", "aaaabbbbaaaabbbbbbbbbb" },
541            { CMUA | PCRE_DUPNAMES, 0, "(?:(?<A>AA)|(?<A>BB))\\k<A>{0,3}M", "aaaaaaaabbbbaabbbbm" },
542            { CMUA | PCRE_DUPNAMES, 0, "(?:(?<A>AA)|(?<A>BB))\\k<A>{1,3}M", "aaaaaaaabbbbaabbbbm" },
543            { CMUA | PCRE_DUPNAMES, 0, "(?:(?<A>AA)|(?<A>BB))\\k<A>{0,3}?M", "aaaaaabbbbbbaabbbbbbbbbbm" },
544            { CMUA | PCRE_DUPNAMES, 0, "(?:(?<A>AA)|(?<A>BB))\\k<A>{2,3}?", "aaaabbbbaaaabbbbbbbbbb" },
545    
546          /* Assertions. */          /* Assertions. */
547          { MUA, 0, "(?=xx|yy|zz)\\w{4}", "abczzdefg" },          { MUA, 0, "(?=xx|yy|zz)\\w{4}", "abczzdefg" },
# Line 460  static struct regression_test_case regre Line 557  static struct regression_test_case regre
557          { MUA, 0, "(?>a(?>(b+))a(?=(..)))*?k", "acabbcabbaabacabaabbakk" },          { MUA, 0, "(?>a(?>(b+))a(?=(..)))*?k", "acabbcabbaabacabaabbakk" },
558          { MUA, 0, "((?(?=(a))a)+k)", "bbak" },          { MUA, 0, "((?(?=(a))a)+k)", "bbak" },
559          { MUA, 0, "((?(?=a)a)+k)", "bbak" },          { MUA, 0, "((?(?=a)a)+k)", "bbak" },
560          { MUA, 0, "(?=(?>(a))m)amk", "a k" },          { MUA, 0 | F_NOMATCH, "(?=(?>(a))m)amk", "a k" },
561          { MUA, 0, "(?!(?>(a))m)amk", "a k" },          { MUA, 0 | F_NOMATCH, "(?!(?>(a))m)amk", "a k" },
562          { MUA, 0, "(?>(?=(a))am)amk", "a k" },          { MUA, 0 | F_NOMATCH, "(?>(?=(a))am)amk", "a k" },
563          { MUA, 0, "(?=(?>a|(?=(?>(b+))a|c)[a-c]+)*?m)[a-cm]+k", "aaam bbam baaambaam abbabba baaambaamk" },          { MUA, 0, "(?=(?>a|(?=(?>(b+))a|c)[a-c]+)*?m)[a-cm]+k", "aaam bbam baaambaam abbabba baaambaamk" },
564          { MUA, 0, "(?> ?\?\\b(?(?=\\w{1,4}(a))m)\\w{0,8}bc){2,}?", "bca ssbc mabd ssbc mabc" },          { MUA, 0, "(?> ?\?\\b(?(?=\\w{1,4}(a))m)\\w{0,8}bc){2,}?", "bca ssbc mabd ssbc mabc" },
565          { MUA, 0, "(?:(?=ab)?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },          { MUA, 0, "(?:(?=ab)?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },
# Line 473  static struct regression_test_case regre Line 570  static struct regression_test_case regre
570          { MUA, 0, "((?!a)?\?(?!([^a]))?\?)+$", "acbab" },          { MUA, 0, "((?!a)?\?(?!([^a]))?\?)+$", "acbab" },
571    
572          /* Not empty, ACCEPT, FAIL */          /* Not empty, ACCEPT, FAIL */
573          { MUA | PCRE_NOTEMPTY, 0, "a*", "bcx" },          { MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a*", "bcx" },
574          { MUA | PCRE_NOTEMPTY, 0, "a*", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "a*", "bcaad" },
575          { MUA | PCRE_NOTEMPTY, 0, "a*?", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "a*?", "bcaad" },
576          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*", "bcaad" },          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*", "bcaad" },
577          { MUA, 0, "a(*ACCEPT)b", "ab" },          { MUA, 0, "a(*ACCEPT)b", "ab" },
578          { MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcx" },          { MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a*(*ACCEPT)b", "bcx" },
579          { MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcaad" },
580          { MUA | PCRE_NOTEMPTY, 0, "a*?(*ACCEPT)b", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "a*?(*ACCEPT)b", "bcaad" },
581          { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcx" },          { MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "(?:z|a*(*ACCEPT)b)", "bcx" },
582          { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcaad" },
583          { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*?(*ACCEPT)b)", "bcaad" },          { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*?(*ACCEPT)b)", "bcaad" },
584          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "bcx" },          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "bcx" },
585          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "" },          { MUA | PCRE_NOTEMPTY_ATSTART, 0 | F_NOMATCH, "a*(*ACCEPT)b", "" },
586          { MUA, 0, "((a(*ACCEPT)b))", "ab" },          { MUA, 0, "((a(*ACCEPT)b))", "ab" },
587          { MUA, 0, "(a(*FAIL)a|a)", "aaa" },          { MUA, 0, "(a(*FAIL)a|a)", "aaa" },
588          { MUA, 0, "(?=ab(*ACCEPT)b)a", "ab" },          { MUA, 0, "(?=ab(*ACCEPT)b)a", "ab" },
# Line 502  static struct regression_test_case regre Line 599  static struct regression_test_case regre
599          { MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },
600          { MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },          { MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
601          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
602          { MUA | PCRE_BUG, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },          { MUA, 0 | F_DIFF, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
603          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
604          { MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },
605          { MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },
# Line 516  static struct regression_test_case regre Line 613  static struct regression_test_case regre
613          { MUA, 0, "((?=\\w{5})\\w(?(?=\\w*k)\\d|[a-f_])*\\w\\s)+", "mol m10kk m088k _f_a_ mbkkl" },          { MUA, 0, "((?=\\w{5})\\w(?(?=\\w*k)\\d|[a-f_])*\\w\\s)+", "mol m10kk m088k _f_a_ mbkkl" },
614          { MUA, 0, "(c)?\?(?(1)a|b)", "cdcaa" },          { MUA, 0, "(c)?\?(?(1)a|b)", "cdcaa" },
615          { MUA, 0, "(c)?\?(?(1)a|b)", "cbb" },          { MUA, 0, "(c)?\?(?(1)a|b)", "cbb" },
616          { MUA | PCRE_BUG, 0, "(?(?=(a))(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0 | F_DIFF, "(?(?=(a))(aaaa|a?))+aak", "aaaaab aaaaak" },
617          { MUA, 0, "(?(?=a)(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?=a)(aaaa|a?))+aak", "aaaaab aaaaak" },
618          { MUA, 0, "(?(?!(b))(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!(b))(aaaa|a?))+aak", "aaaaab aaaaak" },
619          { MUA, 0, "(?(?!b)(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!b)(aaaa|a?))+aak", "aaaaab aaaaak" },
620          { MUA | PCRE_BUG, 0, "(?(?=(a))a*)+aak", "aaaaab aaaaak" },          { MUA, 0 | F_DIFF, "(?(?=(a))a*)+aak", "aaaaab aaaaak" },
621          { MUA, 0, "(?(?=a)a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?=a)a*)+aak", "aaaaab aaaaak" },
622          { MUA, 0, "(?(?!(b))a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!(b))a*)+aak", "aaaaab aaaaak" },
623          { MUA, 0, "(?(?!b)a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!b)a*)+aak", "aaaaab aaaaak" },
624          { MUA, 0, "(?(?=(?=(?!(x))a)aa)aaa|(?(?=(?!y)bb)bbb))*k", "abaabbaaabbbaaabbb abaabbaaabbbaaabbbk" },          { MUA, 0, "(?(?=(?=(?!(x))a)aa)aaa|(?(?=(?!y)bb)bbb))*k", "abaabbaaabbbaaabbb abaabbaaabbbaaabbbk" },
625            { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)*l", "bc ddd abccabccl" },
626            { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)+?dd", "bcabcacdb bdddd" },
627            { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)+l", "ababccddabdbccd abcccl" },
628            { MUA, 0, "((?:a|aa)(?(1)aaa))x", "aax" },
629    
630          /* Set start of match. */          /* Set start of match. */
631          { MUA, 0, "(?:\\Ka)*aaaab", "aaaaaaaa aaaaaaabb" },          { MUA, 0, "(?:\\Ka)*aaaab", "aaaaaaaa aaaaaaabb" },
632          { MUA, 0, "(?>\\Ka\\Ka)*aaaab", "aaaaaaaa aaaaaaaaaabb" },          { MUA, 0, "(?>\\Ka\\Ka)*aaaab", "aaaaaaaa aaaaaaaaaabb" },
633          { MUA, 0, "a+\\K(?<=\\Gaa)a", "aaaaaa" },          { MUA, 0, "a+\\K(?<=\\Gaa)a", "aaaaaa" },
634          { MUA | PCRE_NOTEMPTY, 0, "a\\K(*ACCEPT)b", "aa" },          { MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a\\K(*ACCEPT)b", "aa" },
635          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },
636    
637          /* First line. */          /* First line. */
638          { MUA | PCRE_FIRSTLINE, 0, "\\p{Any}a", "bb\naaa" },          { MUA | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}a", "bb\naaa" },
639          { MUA | PCRE_FIRSTLINE, 0, "\\p{Any}a", "bb\r\naaa" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}a", "bb\r\naaa" },
640          { MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },          { MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },
641          { MUA | PCRE_FIRSTLINE, 0, "[^a][^b]", "ab" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[^a][^b]", "ab" },
642          { MUA | PCRE_FIRSTLINE, 0, "a", "\na" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "a", "\na" },
643          { MUA | PCRE_FIRSTLINE, 0, "[abc]", "\na" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[abc]", "\na" },
644          { MUA | PCRE_FIRSTLINE, 0, "^a", "\na" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^a", "\na" },
645          { MUA | PCRE_FIRSTLINE, 0, "^(?<=\n)", "\na" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^(?<=\n)", "\na" },
646          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "#", "\xc2\x85#" },          { MUA | PCRE_FIRSTLINE, 0, "\xf0\x90\x90\x80", "\xf0\x90\x90\x80" },
647          { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "#", "\x85#" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\xc2\x85#" },
648          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "^#", "\xe2\x80\xa8#" },          { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\x85#" },
649          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "\\p{Any}", "\r\na" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^#", "\xe2\x80\xa8#" },
650            { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}", "\r\na" },
651          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },
652          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },
653          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "ba", "bbb\r\nba" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "ba", "bbb\r\nba" },
654          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "\\p{Any}{4}|a", "\r\na" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}{4}|a", "\r\na" },
655          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },
656            { PCRE_FIRSTLINE | PCRE_NEWLINE_LF | PCRE_DOTALL, 0 | F_NOMATCH, "ab.", "ab" },
657            { MUA | PCRE_FIRSTLINE, 1 | F_NOMATCH, "^[a-d0-9]", "\nxx\nd" },
658    
659          /* Recurse. */          /* Recurse. */
660          { MUA, 0, "(a)(?1)", "aa" },          { MUA, 0, "(a)(?1)", "aa" },
661          { MUA, 0, "((a))(?1)", "aa" },          { MUA, 0, "((a))(?1)", "aa" },
662          { MUA, 0, "(b|a)(?1)", "aa" },          { MUA, 0, "(b|a)(?1)", "aa" },
663          { MUA, 0, "(b|(a))(?1)", "aa" },          { MUA, 0, "(b|(a))(?1)", "aa" },
664          { MUA, 0, "((a)(b)(?:a*))(?1)", "aba" },          { MUA, 0 | F_NOMATCH, "((a)(b)(?:a*))(?1)", "aba" },
665          { MUA, 0, "((a)(b)(?:a*))(?1)", "abab" },          { MUA, 0, "((a)(b)(?:a*))(?1)", "abab" },
666          { MUA, 0, "((a+)c(?2))b(?1)", "aacaabaca" },          { MUA, 0, "((a+)c(?2))b(?1)", "aacaabaca" },
667          { MUA, 0, "((?2)b|(a)){2}(?1)", "aabab" },          { MUA, 0, "((?2)b|(a)){2}(?1)", "aabab" },
# Line 565  static struct regression_test_case regre Line 669  static struct regression_test_case regre
669          { MUA, 0, "(?1)(((a(*ACCEPT)))b)", "axaa" },          { MUA, 0, "(?1)(((a(*ACCEPT)))b)", "axaa" },
670          { MUA, 0, "(?1)(?(DEFINE) (((ac(*ACCEPT)))b) )", "akaac" },          { MUA, 0, "(?1)(?(DEFINE) (((ac(*ACCEPT)))b) )", "akaac" },
671          { MUA, 0, "(a+)b(?1)b\\1", "abaaabaaaaa" },          { MUA, 0, "(a+)b(?1)b\\1", "abaaabaaaaa" },
672          { MUA, 0, "(?(DEFINE)(aa|a))(?1)ab", "aab" },          { MUA, 0 | F_NOMATCH, "(?(DEFINE)(aa|a))(?1)ab", "aab" },
673          { MUA, 0, "(?(DEFINE)(a\\Kb))(?1)+ababc", "abababxabababc" },          { MUA, 0, "(?(DEFINE)(a\\Kb))(?1)+ababc", "abababxabababc" },
674          { MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababc" },          { MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababc" },
675          { MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababxc" },          { MUA, 0 | F_NOMATCH, "(a\\Kb)(?1)+ababc", "abababxababababxc" },
676          { MUA, 0, "b|<(?R)*>", "<<b>" },          { MUA, 0, "b|<(?R)*>", "<<b>" },
677          { MUA, 0, "(a\\K){0}(?:(?1)b|ac)", "ac" },          { MUA, 0, "(a\\K){0}(?:(?1)b|ac)", "ac" },
678          { MUA, 0, "(?(DEFINE)(a(?2)|b)(b(?1)|(a)))(?:(?1)|(?2))m", "ababababnababababaam" },          { MUA, 0, "(?(DEFINE)(a(?2)|b)(b(?1)|(a)))(?:(?1)|(?2))m", "ababababnababababaam" },
679            { MUA, 0, "(a)((?(R)a|b))(?2)", "aabbabaa" },
680            { MUA, 0, "(a)((?(R2)a|b))(?2)", "aabbabaa" },
681            { MUA, 0, "(a)((?(R1)a|b))(?2)", "ababba" },
682            { MUA, 0, "(?(R0)aa|bb(?R))", "abba aabb bbaa" },
683            { MUA, 0, "((?(R)(?:aaaa|a)|(?:(aaaa)|(a)))+)(?1)$", "aaaaaaaaaa aaaa" },
684            { MUA, 0, "(?P<Name>a(?(R&Name)a|b))(?1)", "aab abb abaa" },
685            { MUA, 0, "((?(R)a|(?1)){3})", "XaaaaaaaaaX" },
686            { MUA, 0, "((?:(?(R)a|(?1))){3})", "XaaaaaaaaaX" },
687            { MUA, 0, "((?(R)a|(?1)){1,3})aaaaaa", "aaaaaaaaXaaaaaaaaa" },
688            { MUA, 0, "((?(R)a|(?1)){1,3}?)M", "aaaM" },
689    
690            /* 16 bit specific tests. */
691            { CMA, 0 | F_FORCECONV, "\xc3\xa1", "\xc3\x81\xc3\xa1" },
692            { CMA, 0 | F_FORCECONV, "\xe1\xbd\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
693            { CMA, 0 | F_FORCECONV, "[\xc3\xa1]", "\xc3\x81\xc3\xa1" },
694            { CMA, 0 | F_FORCECONV, "[\xe1\xbd\xb8]", "\xe1\xbf\xb8\xe1\xbd\xb8" },
695            { CMA, 0 | F_FORCECONV, "[a-\xed\xb0\x80]", "A" },
696            { CMA, 0 | F_NO8 | F_FORCECONV, "[a-\\x{dc00}]", "B" },
697            { CMA, 0 | F_NO8 | F_NOMATCH | F_FORCECONV, "[b-\\x{dc00}]", "a" },
698            { CMA, 0 | F_NO8 | F_FORCECONV, "\xed\xa0\x80\\x{d800}\xed\xb0\x80\\x{dc00}", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80" },
699            { CMA, 0 | F_NO8 | F_FORCECONV, "[\xed\xa0\x80\\x{d800}]{1,2}?[\xed\xb0\x80\\x{dc00}]{1,2}?#", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80#" },
700            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80\xed\xb0\x80#]{0,3}(?<=\xed\xb0\x80.)", "\xed\xa0\x80#\xed\xa0\x80##\xed\xb0\x80\xed\xa0\x80" },
701            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\x9f\xbf\xed\xa0\x83" },
702            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\xb4\x80\xed\xb3\xb0" },
703            { CMA, 0 | F_NO8 | F_FORCECONV, "[\\x{d800}-\\x{dcff}]", "\xed\x9f\xbf\xed\xa0\x83" },
704            { CMA, 0 | F_NO8 | F_FORCECONV, "[\\x{d800}-\\x{dcff}]", "\xed\xb4\x80\xed\xb3\xb0" },
705            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xef\xbf\xbf]+[\x1-\xed\xb0\x80]+#", "\xed\xa0\x85\xc3\x81\xed\xa0\x85\xef\xbf\xb0\xc2\x85\xed\xa9\x89#" },
706            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80][\xed\xb0\x80]{2,}", "\xed\xa0\x80\xed\xb0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80\xed\xb0\x80" },
707            { MA, 0 | F_FORCECONV, "[^\xed\xb0\x80]{3,}?", "##\xed\xb0\x80#\xed\xb0\x80#\xc3\x89#\xed\xb0\x80" },
708            { MA, 0 | F_NO8 | F_FORCECONV, "[^\\x{dc00}]{3,}?", "##\xed\xb0\x80#\xed\xb0\x80#\xc3\x89#\xed\xb0\x80" },
709            { CMA, 0 | F_FORCECONV, ".\\B.", "\xed\xa0\x80\xed\xb0\x80" },
710            { CMA, 0 | F_FORCECONV, "\\D+(?:\\d+|.)\\S+(?:\\s+|.)\\W+(?:\\w+|.)\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80" },
711            { CMA, 0 | F_FORCECONV, "\\d*\\s*\\w*\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80" },
712            { CMA, 0 | F_FORCECONV | F_NOMATCH, "\\d*?\\D*?\\s*?\\S*?\\w*?\\W*?##", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80#" },
713            { CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },
714            { CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },
715            { CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },
716            { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0 | F_NO8 | F_FORCECONV, "^-", "a--\xe2\x80\xa8--" },
717            { PCRE_BSR_UNICODE, 0 | F_NO8 | F_FORCECONV, "\\R", "ab\xe2\x80\xa8" },
718            { 0, 0 | F_NO8 | F_FORCECONV, "\\v", "ab\xe2\x80\xa9" },
719            { 0, 0 | F_NO8 | F_FORCECONV, "\\h", "ab\xe1\xa0\x8e" },
720            { 0, 0 | F_NO8 | F_FORCECONV, "\\v+?\\V+?#", "\xe2\x80\xa9\xe2\x80\xa9\xef\xbf\xbf\xef\xbf\xbf#" },
721            { 0, 0 | F_NO8 | F_FORCECONV, "\\h+?\\H+?#", "\xe1\xa0\x8e\xe1\xa0\x8e\xef\xbf\xbf\xef\xbf\xbf#" },
722    
723            /* Partial matching. */
724            { MUA | PCRE_PARTIAL_SOFT, 0, "ab", "a" },
725            { MUA | PCRE_PARTIAL_SOFT, 0, "ab|a", "a" },
726            { MUA | PCRE_PARTIAL_HARD, 0, "ab|a", "a" },
727            { MUA | PCRE_PARTIAL_SOFT, 0, "\\b#", "a" },
728            { MUA | PCRE_PARTIAL_SOFT, 0, "(?<=a)b", "a" },
729            { MUA | PCRE_PARTIAL_SOFT, 0, "abc|(?<=xxa)bc", "xxab" },
730            { MUA | PCRE_PARTIAL_SOFT, 0, "a\\B", "a" },
731            { MUA | PCRE_PARTIAL_HARD, 0, "a\\b", "a" },
732    
733            /* (*MARK) verb. */
734            { MUA, 0, "a(*MARK:aa)a", "ababaa" },
735            { MUA, 0 | F_NOMATCH, "a(*:aa)a", "abab" },
736            { MUA, 0, "a(*:aa)(b(*:bb)b|bc)", "abc" },
737            { MUA, 0 | F_NOMATCH, "a(*:1)x|b(*:2)y", "abc" },
738            { MUA, 0, "(?>a(*:aa))b|ac", "ac" },
739            { MUA, 0, "(?(DEFINE)(a(*:aa)))(?1)", "a" },
740            { MUA, 0 | F_NOMATCH, "(?(DEFINE)((a)(*:aa)))(?1)b", "aa" },
741            { MUA, 0, "(?(DEFINE)(a(*:aa)))a(?1)b|aac", "aac" },
742            { MUA, 0, "(a(*:aa)){0}(?:b(?1)b|c)+c", "babbab cc" },
743            { MUA, 0, "(a(*:aa)){0}(?:b(?1)b)+", "babba" },
744            { MUA, 0 | F_NOMATCH | F_STUDY, "(a(*:aa)){0}(?:b(?1)b)+", "ba" },
745            { MUA, 0, "(a\\K(*:aa)){0}(?:b(?1)b|c)+c", "babbab cc" },
746            { MUA, 0, "(a\\K(*:aa)){0}(?:b(?1)b)+", "babba" },
747            { MUA, 0 | F_NOMATCH | F_STUDY, "(a\\K(*:aa)){0}(?:b(?1)b)+", "ba" },
748            { MUA, 0 | F_NOMATCH | F_STUDY, "(*:mark)m", "a" },
749    
750            /* (*COMMIT) verb. */
751            { MUA, 0 | F_NOMATCH, "a(*COMMIT)b", "ac" },
752            { MUA, 0, "aa(*COMMIT)b", "xaxaab" },
753            { MUA, 0 | F_NOMATCH, "a(*COMMIT)(*:msg)b|ac", "ac" },
754            { MUA, 0 | F_NOMATCH, "(a(*COMMIT)b)++", "abac" },
755            { MUA, 0 | F_NOMATCH, "((a)(*COMMIT)b)++", "abac" },
756            { MUA, 0 | F_NOMATCH, "(?=a(*COMMIT)b)ab|ad", "ad" },
757    
758            /* (*PRUNE) verb. */
759            { MUA, 0, "aa\\K(*PRUNE)b", "aaab" },
760            { MUA, 0, "aa(*PRUNE:bb)b|a", "aa" },
761            { MUA, 0, "(a)(a)(*PRUNE)b|(a)", "aa" },
762            { MUA, 0, "(a)(a)(a)(a)(a)(a)(a)(a)(*PRUNE)b|(a)", "aaaaaaaa" },
763            { MUA | PCRE_PARTIAL_SOFT, 0, "a(*PRUNE)a|", "a" },
764            { MUA | PCRE_PARTIAL_SOFT, 0, "a(*PRUNE)a|m", "a" },
765            { MUA, 0 | F_NOMATCH, "(?=a(*PRUNE)b)ab|ad", "ad" },
766            { MUA, 0, "a(*COMMIT)(*PRUNE)d|bc", "abc" },
767            { MUA, 0, "(?=a(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
768            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?=a(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
769            { MUA, 0, "(?=(a)(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
770            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?=(a)(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
771            { MUA, 0, "(a(*COMMIT)b){0}a(?1)(*PRUNE)c|bc", "abc" },
772            { MUA, 0 | F_NOMATCH, "(a(*COMMIT)b){0}a(*COMMIT)(?1)(*PRUNE)c|bc", "abc" },
773            { MUA, 0, "(a(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
774            { MUA, 0 | F_NOMATCH, "(*COMMIT)(a(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
775            { MUA, 0, "((a)(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
776            { MUA, 0 | F_NOMATCH, "(*COMMIT)((a)(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
777            { MUA, 0, "(?>a(*COMMIT)b)*abab(*PRUNE)d|ba", "ababab" },
778            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)*abab(*PRUNE)d|ba", "ababab" },
779            { MUA, 0, "(?>a(*COMMIT)b)+abab(*PRUNE)d|ba", "ababab" },
780            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)+abab(*PRUNE)d|ba", "ababab" },
781            { MUA, 0, "(?>a(*COMMIT)b)?ab(*PRUNE)d|ba", "aba" },
782            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)?ab(*PRUNE)d|ba", "aba" },
783            { MUA, 0, "(?>a(*COMMIT)b)*?n(*PRUNE)d|ba", "abababn" },
784            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)*?n(*PRUNE)d|ba", "abababn" },
785            { MUA, 0, "(?>a(*COMMIT)b)+?n(*PRUNE)d|ba", "abababn" },
786            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)+?n(*PRUNE)d|ba", "abababn" },
787            { MUA, 0, "(?>a(*COMMIT)b)??n(*PRUNE)d|bn", "abn" },
788            { MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)??n(*PRUNE)d|bn", "abn" },
789    
790            /* (*SKIP) verb. */
791            { MUA, 0 | F_NOMATCH, "(?=a(*SKIP)b)ab|ad", "ad" },
792    
793            /* (*THEN) verb. */
794            { MUA, 0, "((?:a(*THEN)|aab)(*THEN)c|a+)+m", "aabcaabcaabcaabcnacm" },
795            { MUA, 0 | F_NOMATCH, "((?:a(*THEN)|aab)(*THEN)c|a+)+m", "aabcm" },
796            { MUA, 0, "((?:a(*THEN)|aab)c|a+)+m", "aabcaabcnmaabcaabcm" },
797            { MUA, 0, "((?:a|aab)(*THEN)c|a+)+m", "aam" },
798            { MUA, 0, "((?:a(*COMMIT)|aab)(*THEN)c|a+)+m", "aam" },
799            { MUA, 0, "(?(?=a(*THEN)b)ab|ad)", "ad" },
800            { MUA, 0, "(?(?!a(*THEN)b)ad|add)", "add" },
801            { MUA, 0 | F_NOMATCH, "(?(?=a)a(*THEN)b|ad)", "ad" },
802            { MUA, 0, "(?!(?(?=a)ab|b(*THEN)d))bn|bnn", "bnn" },
803    
804          /* Deep recursion. */          /* Deep recursion. */
805          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
806          { MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },          { MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },
807          { MUA, 0, "((a?)+)+b", "aaaaaaaaaaaaa b" },          { MUA, 0, "((a?)+)+b", "aaaaaaaaaaaa b" },
808    
809          /* Deep recursion: Stack limit reached. */          /* Deep recursion: Stack limit reached. */
810          { MA, 0, "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaa" },          { MA, 0 | F_NOMATCH, "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaa" },
811          { MA, 0, "(?:a+)+b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },          { MA, 0 | F_NOMATCH, "(?:a+)+b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
812          { MA, 0, "(?:a+?)+?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },          { MA, 0 | F_NOMATCH, "(?:a+?)+?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
813          { MA, 0, "(?:a*)*b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },          { MA, 0 | F_NOMATCH, "(?:a*)*b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
814          { MA, 0, "(?:a*?)*?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },          { MA, 0 | F_NOMATCH, "(?:a*?)*?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
815    
816          { 0, 0, NULL, NULL }          { 0, 0, NULL, NULL }
817  };  };
818    
819    static const unsigned char *tables(int mode)
820    {
821            /* The purpose of this function to allow valgrind
822            for reporting invalid reads and writes. */
823            static unsigned char *tables_copy;
824            const char *errorptr;
825            int erroroffset;
826            unsigned char *default_tables;
827    #if defined SUPPORT_PCRE8
828            pcre *regex;
829            char null_str[1] = { 0 };
830    #elif defined SUPPORT_PCRE16
831            pcre16 *regex;
832            PCRE_UCHAR16 null_str[1] = { 0 };
833    #elif defined SUPPORT_PCRE32
834            pcre32 *regex;
835            PCRE_UCHAR32 null_str[1] = { 0 };
836    #endif
837    
838            if (mode) {
839                    if (tables_copy)
840                            free(tables_copy);
841                    tables_copy = NULL;
842                    return NULL;
843            }
844    
845            if (tables_copy)
846                    return tables_copy;
847    
848            default_tables = NULL;
849    #if defined SUPPORT_PCRE8
850            regex = pcre_compile(null_str, 0, &errorptr, &erroroffset, NULL);
851            if (regex) {
852                    pcre_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
853                    pcre_free(regex);
854            }
855    #elif defined SUPPORT_PCRE16
856            regex = pcre16_compile(null_str, 0, &errorptr, &erroroffset, NULL);
857            if (regex) {
858                    pcre16_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
859                    pcre16_free(regex);
860            }
861    #elif defined SUPPORT_PCRE32
862            regex = pcre32_compile(null_str, 0, &errorptr, &erroroffset, NULL);
863            if (regex) {
864                    pcre32_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
865                    pcre32_free(regex);
866            }
867    #endif
868            /* Shouldn't ever happen. */
869            if (!default_tables)
870                    return NULL;
871    
872            /* Unfortunately this value cannot get from pcre_fullinfo.
873            Since this is a test program, this is acceptable at the moment. */
874            tables_copy = (unsigned char *)malloc(1088);
875            if (!tables_copy)
876                    return NULL;
877    
878            memcpy(tables_copy, default_tables, 1088);
879            return tables_copy;
880    }
881    
882    #ifdef SUPPORT_PCRE8
883    static pcre_jit_stack* callback8(void *arg)
884    {
885            return (pcre_jit_stack *)arg;
886    }
887    #endif
888    
889    #ifdef SUPPORT_PCRE16
890    static pcre16_jit_stack* callback16(void *arg)
891    {
892            return (pcre16_jit_stack *)arg;
893    }
894    #endif
895    
896    #ifdef SUPPORT_PCRE32
897    static pcre32_jit_stack* callback32(void *arg)
898    {
899            return (pcre32_jit_stack *)arg;
900    }
901    #endif
902    
903    #ifdef SUPPORT_PCRE8
904    static pcre_jit_stack *stack8;
905    
906    static pcre_jit_stack *getstack8(void)
907    {
908            if (!stack8)
909                    stack8 = pcre_jit_stack_alloc(1, 1024 * 1024);
910            return stack8;
911    }
912    
913    static void setstack8(pcre_extra *extra)
914    {
915            if (!extra) {
916                    if (stack8)
917                            pcre_jit_stack_free(stack8);
918                    stack8 = NULL;
919                    return;
920            }
921    
922            pcre_assign_jit_stack(extra, callback8, getstack8());
923    }
924    #endif /* SUPPORT_PCRE8 */
925    
926    #ifdef SUPPORT_PCRE16
927    static pcre16_jit_stack *stack16;
928    
929    static pcre16_jit_stack *getstack16(void)
930    {
931            if (!stack16)
932                    stack16 = pcre16_jit_stack_alloc(1, 1024 * 1024);
933            return stack16;
934    }
935    
936    static void setstack16(pcre16_extra *extra)
937    {
938            if (!extra) {
939                    if (stack16)
940                            pcre16_jit_stack_free(stack16);
941                    stack16 = NULL;
942                    return;
943            }
944    
945            pcre16_assign_jit_stack(extra, callback16, getstack16());
946    }
947    #endif /* SUPPORT_PCRE8 */
948    
949    #ifdef SUPPORT_PCRE32
950    static pcre32_jit_stack *stack32;
951    
952    static pcre32_jit_stack *getstack32(void)
953    {
954            if (!stack32)
955                    stack32 = pcre32_jit_stack_alloc(1, 1024 * 1024);
956            return stack32;
957    }
958    
959    static void setstack32(pcre32_extra *extra)
960    {
961            if (!extra) {
962                    if (stack32)
963                            pcre32_jit_stack_free(stack32);
964                    stack32 = NULL;
965                    return;
966            }
967    
968            pcre32_assign_jit_stack(extra, callback32, getstack32());
969    }
970    #endif /* SUPPORT_PCRE8 */
971    
972    #ifdef SUPPORT_PCRE16
973    
974    static int convert_utf8_to_utf16(const char *input, PCRE_UCHAR16 *output, int *offsetmap, int max_length)
975    {
976            unsigned char *iptr = (unsigned char*)input;
977            PCRE_UCHAR16 *optr = output;
978            unsigned int c;
979    
980            if (max_length == 0)
981                    return 0;
982    
983            while (*iptr && max_length > 1) {
984                    c = 0;
985                    if (offsetmap)
986                            *offsetmap++ = (int)(iptr - (unsigned char*)input);
987    
988                    if (*iptr < 0xc0)
989                            c = *iptr++;
990                    else if (!(*iptr & 0x20)) {
991                            c = ((iptr[0] & 0x1f) << 6) | (iptr[1] & 0x3f);
992                            iptr += 2;
993                    } else if (!(*iptr & 0x10)) {
994                            c = ((iptr[0] & 0x0f) << 12) | ((iptr[1] & 0x3f) << 6) | (iptr[2] & 0x3f);
995                            iptr += 3;
996                    } else if (!(*iptr & 0x08)) {
997                            c = ((iptr[0] & 0x07) << 18) | ((iptr[1] & 0x3f) << 12) | ((iptr[2] & 0x3f) << 6) | (iptr[3] & 0x3f);
998                            iptr += 4;
999                    }
1000    
1001                    if (c < 65536) {
1002                            *optr++ = c;
1003                            max_length--;
1004                    } else if (max_length <= 2) {
1005                            *optr = '\0';
1006                            return (int)(optr - output);
1007                    } else {
1008                            c -= 0x10000;
1009                            *optr++ = 0xd800 | ((c >> 10) & 0x3ff);
1010                            *optr++ = 0xdc00 | (c & 0x3ff);
1011                            max_length -= 2;
1012                            if (offsetmap)
1013                                    offsetmap++;
1014                    }
1015            }
1016            if (offsetmap)
1017                    *offsetmap = (int)(iptr - (unsigned char*)input);
1018            *optr = '\0';
1019            return (int)(optr - output);
1020    }
1021    
1022    static int copy_char8_to_char16(const char *input, PCRE_UCHAR16 *output, int max_length)
1023    {
1024            unsigned char *iptr = (unsigned char*)input;
1025            PCRE_UCHAR16 *optr = output;
1026    
1027            if (max_length == 0)
1028                    return 0;
1029    
1030            while (*iptr && max_length > 1) {
1031                    *optr++ = *iptr++;
1032                    max_length--;
1033            }
1034            *optr = '\0';
1035            return (int)(optr - output);
1036    }
1037    
1038    #define REGTEST_MAX_LENGTH16 4096
1039    static PCRE_UCHAR16 regtest_buf16[REGTEST_MAX_LENGTH16];
1040    static int regtest_offsetmap16[REGTEST_MAX_LENGTH16];
1041    
1042    #endif /* SUPPORT_PCRE16 */
1043    
1044    #ifdef SUPPORT_PCRE32
1045    
1046    static int convert_utf8_to_utf32(const char *input, PCRE_UCHAR32 *output, int *offsetmap, int max_length)
1047    {
1048            unsigned char *iptr = (unsigned char*)input;
1049            PCRE_UCHAR32 *optr = output;
1050            unsigned int c;
1051    
1052            if (max_length == 0)
1053                    return 0;
1054    
1055            while (*iptr && max_length > 1) {
1056                    c = 0;
1057                    if (offsetmap)
1058                            *offsetmap++ = (int)(iptr - (unsigned char*)input);
1059    
1060                    if (*iptr < 0xc0)
1061                            c = *iptr++;
1062                    else if (!(*iptr & 0x20)) {
1063                            c = ((iptr[0] & 0x1f) << 6) | (iptr[1] & 0x3f);
1064                            iptr += 2;
1065                    } else if (!(*iptr & 0x10)) {
1066                            c = ((iptr[0] & 0x0f) << 12) | ((iptr[1] & 0x3f) << 6) | (iptr[2] & 0x3f);
1067                            iptr += 3;
1068                    } else if (!(*iptr & 0x08)) {
1069                            c = ((iptr[0] & 0x07) << 18) | ((iptr[1] & 0x3f) << 12) | ((iptr[2] & 0x3f) << 6) | (iptr[3] & 0x3f);
1070                            iptr += 4;
1071                    }
1072    
1073                    *optr++ = c;
1074                    max_length--;
1075            }
1076            if (offsetmap)
1077                    *offsetmap = (int)(iptr - (unsigned char*)input);
1078            *optr = 0;
1079            return (int)(optr - output);
1080    }
1081    
1082    static int copy_char8_to_char32(const char *input, PCRE_UCHAR32 *output, int max_length)
1083    {
1084            unsigned char *iptr = (unsigned char*)input;
1085            PCRE_UCHAR32 *optr = output;
1086    
1087            if (max_length == 0)
1088                    return 0;
1089    
1090            while (*iptr && max_length > 1) {
1091                    *optr++ = *iptr++;
1092                    max_length--;
1093            }
1094            *optr = '\0';
1095            return (int)(optr - output);
1096    }
1097    
1098    #define REGTEST_MAX_LENGTH32 4096
1099    static PCRE_UCHAR32 regtest_buf32[REGTEST_MAX_LENGTH32];
1100    static int regtest_offsetmap32[REGTEST_MAX_LENGTH32];
1101    
1102    #endif /* SUPPORT_PCRE32 */
1103    
1104    static int check_ascii(const char *input)
1105    {
1106            const unsigned char *ptr = (unsigned char *)input;
1107            while (*ptr) {
1108                    if (*ptr > 127)
1109                            return 0;
1110                    ptr++;
1111            }
1112            return 1;
1113    }
1114    
1115  static int regression_tests(void)  static int regression_tests(void)
1116  {  {
         pcre *re;  
1117          struct regression_test_case *current = regression_test_cases;          struct regression_test_case *current = regression_test_cases;
1118          const char *error;          const char *error;
1119          pcre_extra *extra;          char *cpu_info;
         int utf8 = 0, ucp = 0;  
         int ovector1[32];  
         int ovector2[32];  
         int return_value1, return_value2;  
1120          int i, err_offs;          int i, err_offs;
1121          int total = 0, succesful = 0;          int is_successful, is_ascii;
1122            int total = 0;
1123            int successful = 0;
1124            int successful_row = 0;
1125          int counter = 0;          int counter = 0;
1126          int disabled_flags = PCRE_BUG;          int study_mode;
1127            int utf = 0, ucp = 0;
1128            int disabled_flags = 0;
1129    #ifdef SUPPORT_PCRE8
1130            pcre *re8;
1131            pcre_extra *extra8;
1132            pcre_extra dummy_extra8;
1133            int ovector8_1[32];
1134            int ovector8_2[32];
1135            int return_value8[2];
1136            unsigned char *mark8_1, *mark8_2;
1137    #endif
1138    #ifdef SUPPORT_PCRE16
1139            pcre16 *re16;
1140            pcre16_extra *extra16;
1141            pcre16_extra dummy_extra16;
1142            int ovector16_1[32];
1143            int ovector16_2[32];
1144            int return_value16[2];
1145            PCRE_UCHAR16 *mark16_1, *mark16_2;
1146            int length16;
1147    #endif
1148    #ifdef SUPPORT_PCRE32
1149            pcre32 *re32;
1150            pcre32_extra *extra32;
1151            pcre32_extra dummy_extra32;
1152            int ovector32_1[32];
1153            int ovector32_2[32];
1154            int return_value32[2];
1155            PCRE_UCHAR32 *mark32_1, *mark32_2;
1156            int length32;
1157    #endif
1158    
1159          /* This test compares the behaviour of interpreter and JIT. Although disabling          /* This test compares the behaviour of interpreter and JIT. Although disabling
1160          utf8 or ucp may make tests fail, if the pcre_exec result is the SAME, it is          utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is
1161          still considered successful from pcre_jit_test point of view. */          still considered successful from pcre_jit_test point of view. */
1162    
1163          pcre_config(PCRE_CONFIG_UTF8, &utf8);  #if defined SUPPORT_PCRE8
1164            pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info);
1165    #elif defined SUPPORT_PCRE16
1166            pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info);
1167    #elif defined SUPPORT_PCRE32
1168            pcre32_config(PCRE_CONFIG_JITTARGET, &cpu_info);
1169    #endif
1170    
1171            printf("Running JIT regression tests\n");
1172            printf("  target CPU of SLJIT compiler: %s\n", cpu_info);
1173    
1174    #if defined SUPPORT_PCRE8
1175            pcre_config(PCRE_CONFIG_UTF8, &utf);
1176          pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);          pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
1177          if (!utf8)  #elif defined SUPPORT_PCRE16
1178                  disabled_flags |= PCRE_UTF8;          pcre16_config(PCRE_CONFIG_UTF16, &utf);
1179            pcre16_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
1180    #elif defined SUPPORT_PCRE16
1181            pcre32_config(PCRE_CONFIG_UTF32, &utf);
1182            pcre32_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
1183    #endif
1184    
1185            if (!utf)
1186                    disabled_flags |= PCRE_UTF8 | PCRE_UTF16 | PCRE_UTF32;
1187          if (!ucp)          if (!ucp)
1188                  disabled_flags |= PCRE_UCP;                  disabled_flags |= PCRE_UCP;
1189    #ifdef SUPPORT_PCRE8
1190            printf("  in  8 bit mode with UTF-8  %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
1191    #endif
1192    #ifdef SUPPORT_PCRE16
1193            printf("  in 16 bit mode with UTF-16 %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
1194    #endif
1195    #ifdef SUPPORT_PCRE32
1196            printf("  in 32 bit mode with UTF-32 %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
1197    #endif
1198    
         printf("Running JIT regression tests with utf8 %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp ? "enabled" : "disabled");  
1199          while (current->pattern) {          while (current->pattern) {
1200                  /* printf("\nPattern: %s :\n", current->pattern); */                  /* printf("\nPattern: %s :\n", current->pattern); */
1201                  total++;                  total++;
1202                    is_ascii = 0;
1203                    if (!(current->start_offset & F_PROPERTY))
1204                            is_ascii = check_ascii(current->pattern) && check_ascii(current->input);
1205    
1206                    if (current->flags & PCRE_PARTIAL_SOFT)
1207                            study_mode = PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE;
1208                    else if (current->flags & PCRE_PARTIAL_HARD)
1209                            study_mode = PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
1210                    else
1211                            study_mode = PCRE_STUDY_JIT_COMPILE;
1212                  error = NULL;                  error = NULL;
1213                  re = pcre_compile(current->pattern, current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags), &error, &err_offs, NULL);  #ifdef SUPPORT_PCRE8
1214                    re8 = NULL;
1215                  if (!re) {                  if (!(current->start_offset & F_NO8))
1216                          if (utf8 && ucp)                          re8 = pcre_compile(current->pattern,
1217                                  printf("\nCannot compile pattern: %s\n", current->pattern);                                  current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
1218                          else {                                  &error, &err_offs, tables(0));
1219                                  /* Some patterns cannot be compiled when either of utf8  
1220                                  or ucp is disabled. We just skip them. */                  extra8 = NULL;
1221                                  printf(".");                  if (re8) {
1222                                  succesful++;                          error = NULL;
1223                            extra8 = pcre_study(re8, study_mode, &error);
1224                            if (!extra8) {
1225                                    printf("\n8 bit: Cannot study pattern: %s\n", current->pattern);
1226                                    pcre_free(re8);
1227                                    re8 = NULL;
1228                          }                          }
1229                          current++;                          else if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
1230                          continue;                                  printf("\n8 bit: JIT compiler does not support: %s\n", current->pattern);
1231                  }                                  pcre_free_study(extra8);
1232                                    pcre_free(re8);
1233                                    re8 = NULL;
1234                            }
1235                            extra8->flags |= PCRE_EXTRA_MARK;
1236                    } else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO8))
1237                            printf("\n8 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
1238    #endif
1239    #ifdef SUPPORT_PCRE16
1240                    if ((current->flags & PCRE_UTF16) || (current->start_offset & F_FORCECONV))
1241                            convert_utf8_to_utf16(current->pattern, regtest_buf16, NULL, REGTEST_MAX_LENGTH16);
1242                    else
1243                            copy_char8_to_char16(current->pattern, regtest_buf16, REGTEST_MAX_LENGTH16);
1244    
1245                    re16 = NULL;
1246                    if (!(current->start_offset & F_NO16))
1247                            re16 = pcre16_compile(regtest_buf16,
1248                                    current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
1249                                    &error, &err_offs, tables(0));
1250    
1251                    extra16 = NULL;
1252                    if (re16) {
1253                            error = NULL;
1254                            extra16 = pcre16_study(re16, study_mode, &error);
1255                            if (!extra16) {
1256                                    printf("\n16 bit: Cannot study pattern: %s\n", current->pattern);
1257                                    pcre16_free(re16);
1258                                    re16 = NULL;
1259                            }
1260                            else if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
1261                                    printf("\n16 bit: JIT compiler does not support: %s\n", current->pattern);
1262                                    pcre16_free_study(extra16);
1263                                    pcre16_free(re16);
1264                                    re16 = NULL;
1265                            }
1266                            extra16->flags |= PCRE_EXTRA_MARK;
1267                    } else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO16))
1268                            printf("\n16 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
1269    #endif
1270    #ifdef SUPPORT_PCRE32
1271                    if ((current->flags & PCRE_UTF32) || (current->start_offset & F_FORCECONV))
1272                            convert_utf8_to_utf32(current->pattern, regtest_buf32, NULL, REGTEST_MAX_LENGTH32);
1273                    else
1274                            copy_char8_to_char32(current->pattern, regtest_buf32, REGTEST_MAX_LENGTH32);
1275    
1276                    re32 = NULL;
1277                    if (!(current->start_offset & F_NO32))
1278                            re32 = pcre32_compile(regtest_buf32,
1279                                    current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
1280                                    &error, &err_offs, tables(0));
1281    
1282                    extra32 = NULL;
1283                    if (re32) {
1284                            error = NULL;
1285                            extra32 = pcre32_study(re32, study_mode, &error);
1286                            if (!extra32) {
1287                                    printf("\n32 bit: Cannot study pattern: %s\n", current->pattern);
1288                                    pcre32_free(re32);
1289                                    re32 = NULL;
1290                            }
1291                            if (!(extra32->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
1292                                    printf("\n32 bit: JIT compiler does not support: %s\n", current->pattern);
1293                                    pcre32_free_study(extra32);
1294                                    pcre32_free(re32);
1295                                    re32 = NULL;
1296                            }
1297                            extra32->flags |= PCRE_EXTRA_MARK;
1298                    } else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO32))
1299                            printf("\n32 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
1300    #endif
1301    
1302                  error = NULL;                  counter++;
1303                  extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);                  if ((counter & 0x3) != 0) {
1304                  if (!extra) {  #ifdef SUPPORT_PCRE8
1305                          printf("\nCannot study pattern: %s\n", current->pattern);                          setstack8(NULL);
1306                          current++;  #endif
1307                          continue;  #ifdef SUPPORT_PCRE16
1308                            setstack16(NULL);
1309    #endif
1310    #ifdef SUPPORT_PCRE32
1311                            setstack32(NULL);
1312    #endif
1313                  }                  }
1314    
1315                  if (!(extra->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {  #ifdef SUPPORT_PCRE8
1316                          printf("\nJIT compiler does not support: %s\n", current->pattern);                  return_value8[0] = -1000;
1317                          current++;                  return_value8[1] = -1000;
1318                          continue;                  for (i = 0; i < 32; ++i)
1319                            ovector8_1[i] = -2;
1320                    for (i = 0; i < 32; ++i)
1321                            ovector8_2[i] = -2;
1322                    if (re8) {
1323                            mark8_1 = NULL;
1324                            mark8_2 = NULL;
1325                            extra8->mark = &mark8_1;
1326    
1327                            if ((counter & 0x1) != 0) {
1328                                    setstack8(extra8);
1329                                    return_value8[0] = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
1330                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_1, 32);
1331                            } else
1332                                    return_value8[0] = pcre_jit_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
1333                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_1, 32, getstack8());
1334                            memset(&dummy_extra8, 0, sizeof(pcre_extra));
1335                            dummy_extra8.flags = PCRE_EXTRA_MARK;
1336                            if (current->start_offset & F_STUDY) {
1337                                    dummy_extra8.flags |= PCRE_EXTRA_STUDY_DATA;
1338                                    dummy_extra8.study_data = extra8->study_data;
1339                            }
1340                            dummy_extra8.mark = &mark8_2;
1341                            return_value8[1] = pcre_exec(re8, &dummy_extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
1342                                    current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_2, 32);
1343                  }                  }
1344    #endif
1345    
1346                  counter++;  #ifdef SUPPORT_PCRE16
1347                  if ((counter & 0x3) != 0)                  return_value16[0] = -1000;
1348                          setstack(extra);                  return_value16[1] = -1000;
1349                    for (i = 0; i < 32; ++i)
1350                            ovector16_1[i] = -2;
1351                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
1352                          ovector1[i] = -2;                          ovector16_2[i] = -2;
1353                  return_value1 = pcre_exec(re, extra, current->input, strlen(current->input), current->start_offset, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector1, 32);                  if (re16) {
1354                            mark16_1 = NULL;
1355                            mark16_2 = NULL;
1356                            if ((current->flags & PCRE_UTF16) || (current->start_offset & F_FORCECONV))
1357                                    length16 = convert_utf8_to_utf16(current->input, regtest_buf16, regtest_offsetmap16, REGTEST_MAX_LENGTH16);
1358                            else
1359                                    length16 = copy_char8_to_char16(current->input, regtest_buf16, REGTEST_MAX_LENGTH16);
1360                            extra16->mark = &mark16_1;
1361                            if ((counter & 0x1) != 0) {
1362                                    setstack16(extra16);
1363                                    return_value16[0] = pcre16_exec(re16, extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
1364                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_1, 32);
1365                            } else
1366                                    return_value16[0] = pcre16_jit_exec(re16, extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
1367                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_1, 32, getstack16());
1368                            memset(&dummy_extra16, 0, sizeof(pcre16_extra));
1369                            dummy_extra16.flags = PCRE_EXTRA_MARK;
1370                            if (current->start_offset & F_STUDY) {
1371                                    dummy_extra16.flags |= PCRE_EXTRA_STUDY_DATA;
1372                                    dummy_extra16.study_data = extra16->study_data;
1373                            }
1374                            dummy_extra16.mark = &mark16_2;
1375                            return_value16[1] = pcre16_exec(re16, &dummy_extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
1376                                    current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_2, 32);
1377                    }
1378    #endif
1379    
1380    #ifdef SUPPORT_PCRE32
1381                    return_value32[0] = -1000;
1382                    return_value32[1] = -1000;
1383                    for (i = 0; i < 32; ++i)
1384                            ovector32_1[i] = -2;
1385                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
1386                          ovector2[i] = -2;                          ovector32_2[i] = -2;
1387                  return_value2 = pcre_exec(re, NULL, current->input, strlen(current->input), current->start_offset, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector2, 32);                  if (re32) {
1388                            mark32_1 = NULL;
1389                            mark32_2 = NULL;
1390                            if ((current->flags & PCRE_UTF32) || (current->start_offset & F_FORCECONV))
1391                                    length32 = convert_utf8_to_utf32(current->input, regtest_buf32, regtest_offsetmap32, REGTEST_MAX_LENGTH32);
1392                            else
1393                                    length32 = copy_char8_to_char32(current->input, regtest_buf32, REGTEST_MAX_LENGTH32);
1394                            extra32->mark = &mark32_1;
1395                            if ((counter & 0x1) != 0) {
1396                                    setstack32(extra32);
1397                                    return_value32[0] = pcre32_exec(re32, extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
1398                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_1, 32);
1399                            } else
1400                                    return_value32[0] = pcre32_jit_exec(re32, extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
1401                                            current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_1, 32, getstack32());
1402                            memset(&dummy_extra32, 0, sizeof(pcre32_extra));
1403                            dummy_extra32.flags = PCRE_EXTRA_MARK;
1404                            if (current->start_offset & F_STUDY) {
1405                                    dummy_extra32.flags |= PCRE_EXTRA_STUDY_DATA;
1406                                    dummy_extra32.study_data = extra32->study_data;
1407                            }
1408                            dummy_extra32.mark = &mark32_2;
1409                            return_value32[1] = pcre32_exec(re32, &dummy_extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
1410                                    current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_2, 32);
1411                    }
1412    #endif
1413    
1414                    /* printf("[%d-%d-%d|%d-%d|%d-%d|%d-%d]%s",
1415                            return_value8[0], return_value16[0], return_value32[0],
1416                            ovector8_1[0], ovector8_1[1],
1417                            ovector16_1[0], ovector16_1[1],
1418                            ovector32_1[0], ovector32_1[1],
1419                            (current->flags & PCRE_CASELESS) ? "C" : ""); */
1420    
1421                  /* If PCRE_BUG is set, just run the test, but do not compare the results.                  /* If F_DIFF is set, just run the test, but do not compare the results.
1422                  Segfaults can still be captured. */                  Segfaults can still be captured. */
                 if (!(current->flags & PCRE_BUG)) {  
                         if (return_value1 != return_value2) {  
                                 printf("\nReturn value differs(%d:%d): '%s' @ '%s'\n", return_value1, return_value2, current->pattern, current->input);  
                                 current++;  
                                 continue;  
                         }  
1423    
1424                          if (return_value1 >= 0) {                  is_successful = 1;
1425                                  return_value1 *= 2;                  if (!(current->start_offset & F_DIFF)) {
1426                                  err_offs = 0;  #if defined SUPPORT_UTF && ((defined(SUPPORT_PCRE8) + defined(SUPPORT_PCRE16) + defined(SUPPORT_PCRE32)) >= 2)
1427                                  for (i = 0; i < return_value1; ++i)                          if (!(current->start_offset & F_FORCECONV)) {
1428                                          if (ovector1[i] != ovector2[i]) {                                  int return_value;
1429                                                  printf("\nOvector[%d] value differs(%d:%d): '%s' @ '%s' \n", i, ovector1[i], ovector2[i], current->pattern, current->input);  
1430                                                  err_offs = 1;                                  /* All results must be the same. */
1431    #ifdef SUPPORT_PCRE8
1432                                    if ((return_value = return_value8[0]) != return_value8[1]) {
1433                                            printf("\n8 bit: Return value differs(J8:%d,I8:%d): [%d] '%s' @ '%s'\n",
1434                                                    return_value8[0], return_value8[1], total, current->pattern, current->input);
1435                                            is_successful = 0;
1436                                    } else
1437    #endif
1438    #ifdef SUPPORT_PCRE16
1439                                    if ((return_value = return_value16[0]) != return_value16[1]) {
1440                                            printf("\n16 bit: Return value differs(J16:%d,I16:%d): [%d] '%s' @ '%s'\n",
1441                                                    return_value16[0], return_value16[1], total, current->pattern, current->input);
1442                                            is_successful = 0;
1443                                    } else
1444    #endif
1445    #ifdef SUPPORT_PCRE32
1446                                    if ((return_value = return_value32[0]) != return_value32[1]) {
1447                                            printf("\n32 bit: Return value differs(J32:%d,I32:%d): [%d] '%s' @ '%s'\n",
1448                                                    return_value32[0], return_value32[1], total, current->pattern, current->input);
1449                                            is_successful = 0;
1450                                    } else
1451    #endif
1452    #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
1453                                    if (return_value8[0] != return_value16[0]) {
1454                                            printf("\n8 and 16 bit: Return value differs(J8:%d,J16:%d): [%d] '%s' @ '%s'\n",
1455                                                    return_value8[0], return_value16[0],
1456                                                    total, current->pattern, current->input);
1457                                            is_successful = 0;
1458                                    } else
1459    #endif
1460    #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE32
1461                                    if (return_value8[0] != return_value32[0]) {
1462                                            printf("\n8 and 32 bit: Return value differs(J8:%d,J32:%d): [%d] '%s' @ '%s'\n",
1463                                                    return_value8[0], return_value32[0],
1464                                                    total, current->pattern, current->input);
1465                                            is_successful = 0;
1466                                    } else
1467    #endif
1468    #if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE32
1469                                    if (return_value16[0] != return_value32[0]) {
1470                                            printf("\n16 and 32 bit: Return value differs(J16:%d,J32:%d): [%d] '%s' @ '%s'\n",
1471                                                    return_value16[0], return_value32[0],
1472                                                    total, current->pattern, current->input);
1473                                            is_successful = 0;
1474                                    } else
1475    #endif
1476                                    if (return_value >= 0 || return_value == PCRE_ERROR_PARTIAL) {
1477                                            if (return_value == PCRE_ERROR_PARTIAL) {
1478                                                    return_value = 2;
1479                                            } else {
1480                                                    return_value *= 2;
1481                                            }
1482    #ifdef SUPPORT_PCRE8
1483                                            return_value8[0] = return_value;
1484    #endif
1485    #ifdef SUPPORT_PCRE16
1486                                            return_value16[0] = return_value;
1487    #endif
1488    #ifdef SUPPORT_PCRE32
1489                                            return_value32[0] = return_value;
1490    #endif
1491                                            /* Transform back the results. */
1492                                            if (current->flags & PCRE_UTF8) {
1493    #ifdef SUPPORT_PCRE16
1494                                                    for (i = 0; i < return_value; ++i) {
1495                                                            if (ovector16_1[i] >= 0)
1496                                                                    ovector16_1[i] = regtest_offsetmap16[ovector16_1[i]];
1497                                                            if (ovector16_2[i] >= 0)
1498                                                                    ovector16_2[i] = regtest_offsetmap16[ovector16_2[i]];
1499                                                    }
1500    #endif
1501    #ifdef SUPPORT_PCRE32
1502                                                    for (i = 0; i < return_value; ++i) {
1503                                                            if (ovector32_1[i] >= 0)
1504                                                                    ovector32_1[i] = regtest_offsetmap32[ovector32_1[i]];
1505                                                            if (ovector32_2[i] >= 0)
1506                                                                    ovector32_2[i] = regtest_offsetmap32[ovector32_2[i]];
1507                                                    }
1508    #endif
1509                                            }
1510    
1511                                            for (i = 0; i < return_value; ++i) {
1512    #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
1513                                                    if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector16_1[i] || ovector8_1[i] != ovector16_2[i]) {
1514                                                            printf("\n8 and 16 bit: Ovector[%d] value differs(J8:%d,I8:%d,J16:%d,I16:%d): [%d] '%s' @ '%s' \n",
1515                                                                    i, ovector8_1[i], ovector8_2[i], ovector16_1[i], ovector16_2[i],
1516                                                                    total, current->pattern, current->input);
1517                                                            is_successful = 0;
1518                                                    }
1519    #endif
1520    #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE32
1521                                                    if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector32_1[i] || ovector8_1[i] != ovector32_2[i]) {
1522                                                            printf("\n8 and 32 bit: Ovector[%d] value differs(J8:%d,I8:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n",
1523                                                                    i, ovector8_1[i], ovector8_2[i], ovector32_1[i], ovector32_2[i],
1524                                                                    total, current->pattern, current->input);
1525                                                            is_successful = 0;
1526                                                    }
1527    #endif
1528    #if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE16
1529                                                    if (ovector16_1[i] != ovector16_2[i] || ovector16_1[i] != ovector16_1[i] || ovector16_1[i] != ovector16_2[i]) {
1530                                                            printf("\n16 and 16 bit: Ovector[%d] value differs(J16:%d,I16:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n",
1531                                                                    i, ovector16_1[i], ovector16_2[i], ovector16_1[i], ovector16_2[i],
1532                                                                    total, current->pattern, current->input);
1533                                                            is_successful = 0;
1534                                                    }
1535    #endif
1536                                          }                                          }
                                 if (err_offs) {  
                                         current++;  
                                         continue;  
1537                                  }                                  }
1538                            } else
1539    #endif /* more than one of SUPPORT_PCRE8, SUPPORT_PCRE16 and SUPPORT_PCRE32 */
1540                            {
1541                                    /* Only the 8 bit and 16 bit results must be equal. */
1542    #ifdef SUPPORT_PCRE8
1543                                    if (return_value8[0] != return_value8[1]) {
1544                                            printf("\n8 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
1545                                                    return_value8[0], return_value8[1], total, current->pattern, current->input);
1546                                            is_successful = 0;
1547                                    } else if (return_value8[0] >= 0 || return_value8[0] == PCRE_ERROR_PARTIAL) {
1548                                            if (return_value8[0] == PCRE_ERROR_PARTIAL)
1549                                                    return_value8[0] = 2;
1550                                            else
1551                                                    return_value8[0] *= 2;
1552    
1553                                            for (i = 0; i < return_value8[0]; ++i)
1554                                                    if (ovector8_1[i] != ovector8_2[i]) {
1555                                                            printf("\n8 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
1556                                                                    i, ovector8_1[i], ovector8_2[i], total, current->pattern, current->input);
1557                                                            is_successful = 0;
1558                                                    }
1559                                    }
1560    #endif
1561    
1562    #ifdef SUPPORT_PCRE16
1563                                    if (return_value16[0] != return_value16[1]) {
1564                                            printf("\n16 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
1565                                                    return_value16[0], return_value16[1], total, current->pattern, current->input);
1566                                            is_successful = 0;
1567                                    } else if (return_value16[0] >= 0 || return_value16[0] == PCRE_ERROR_PARTIAL) {
1568                                            if (return_value16[0] == PCRE_ERROR_PARTIAL)
1569                                                    return_value16[0] = 2;
1570                                            else
1571                                                    return_value16[0] *= 2;
1572    
1573                                            for (i = 0; i < return_value16[0]; ++i)
1574                                                    if (ovector16_1[i] != ovector16_2[i]) {
1575                                                            printf("\n16 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
1576                                                                    i, ovector16_1[i], ovector16_2[i], total, current->pattern, current->input);
1577                                                            is_successful = 0;
1578                                                    }
1579                                    }
1580    #endif
1581    
1582    #ifdef SUPPORT_PCRE32
1583                                    if (return_value32[0] != return_value32[1]) {
1584                                            printf("\n32 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
1585                                                    return_value32[0], return_value32[1], total, current->pattern, current->input);
1586                                            is_successful = 0;
1587                                    } else if (return_value32[0] >= 0 || return_value32[0] == PCRE_ERROR_PARTIAL) {
1588                                            if (return_value32[0] == PCRE_ERROR_PARTIAL)
1589                                                    return_value32[0] = 2;
1590                                            else
1591                                                    return_value32[0] *= 2;
1592    
1593                                            for (i = 0; i < return_value32[0]; ++i)
1594                                                    if (ovector32_1[i] != ovector32_2[i]) {
1595                                                            printf("\n32 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
1596                                                                    i, ovector32_1[i], ovector32_2[i], total, current->pattern, current->input);
1597                                                            is_successful = 0;
1598                                                    }
1599                                    }
1600    #endif
1601                          }                          }
1602                  }                  }
1603    
1604                  pcre_free_study(extra);                  if (is_successful) {
1605                  pcre_free(re);  #ifdef SUPPORT_PCRE8
1606                            if (!(current->start_offset & F_NO8) && ((utf && ucp) || is_ascii)) {
1607                                    if (return_value8[0] < 0 && !(current->start_offset & F_NOMATCH)) {
1608                                            printf("8 bit: Test should match: [%d] '%s' @ '%s'\n",
1609                                                    total, current->pattern, current->input);
1610                                            is_successful = 0;
1611                                    }
1612    
1613                                    if (return_value8[0] >= 0 && (current->start_offset & F_NOMATCH)) {
1614                                            printf("8 bit: Test should not match: [%d] '%s' @ '%s'\n",
1615                                                    total, current->pattern, current->input);
1616                                            is_successful = 0;
1617                                    }
1618                            }
1619    #endif
1620    #ifdef SUPPORT_PCRE16
1621                            if (!(current->start_offset & F_NO16) && ((utf && ucp) || is_ascii)) {
1622                                    if (return_value16[0] < 0 && !(current->start_offset & F_NOMATCH)) {
1623                                            printf("16 bit: Test should match: [%d] '%s' @ '%s'\n",
1624                                                    total, current->pattern, current->input);
1625                                            is_successful = 0;
1626                                    }
1627    
1628                                    if (return_value16[0] >= 0 && (current->start_offset & F_NOMATCH)) {
1629                                            printf("16 bit: Test should not match: [%d] '%s' @ '%s'\n",
1630                                                    total, current->pattern, current->input);
1631                                            is_successful = 0;
1632                                    }
1633                            }
1634    #endif
1635    #ifdef SUPPORT_PCRE32
1636                            if (!(current->start_offset & F_NO32) && ((utf && ucp) || is_ascii)) {
1637                                    if (return_value32[0] < 0 && !(current->start_offset & F_NOMATCH)) {
1638                                            printf("32 bit: Test should match: [%d] '%s' @ '%s'\n",
1639                                                    total, current->pattern, current->input);
1640                                            is_successful = 0;
1641                                    }
1642    
1643                                    if (return_value32[0] >= 0 && (current->start_offset & F_NOMATCH)) {
1644                                            printf("32 bit: Test should not match: [%d] '%s' @ '%s'\n",
1645                                                    total, current->pattern, current->input);
1646                                            is_successful = 0;
1647                                    }
1648                            }
1649    #endif
1650                    }
1651    
1652                    if (is_successful) {
1653    #ifdef SUPPORT_PCRE8
1654                            if (mark8_1 != mark8_2) {
1655                                    printf("8 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
1656                                            total, current->pattern, current->input);
1657                                    is_successful = 0;
1658                            }
1659    #endif
1660    #ifdef SUPPORT_PCRE16
1661                            if (mark16_1 != mark16_2) {
1662                                    printf("16 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
1663                                            total, current->pattern, current->input);
1664                                    is_successful = 0;
1665                            }
1666    #endif
1667    #ifdef SUPPORT_PCRE32
1668                            if (mark32_1 != mark32_2) {
1669                                    printf("32 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
1670                                            total, current->pattern, current->input);
1671                                    is_successful = 0;
1672                            }
1673    #endif
1674                    }
1675    
1676    #ifdef SUPPORT_PCRE8
1677                    if (re8) {
1678                            pcre_free_study(extra8);
1679                            pcre_free(re8);
1680                    }
1681    #endif
1682    #ifdef SUPPORT_PCRE16
1683                    if (re16) {
1684                            pcre16_free_study(extra16);
1685                            pcre16_free(re16);
1686                    }
1687    #endif
1688    #ifdef SUPPORT_PCRE32
1689                    if (re32) {
1690                            pcre32_free_study(extra32);
1691                            pcre32_free(re32);
1692                    }
1693    #endif
1694    
1695                    if (is_successful) {
1696                            successful++;
1697                            successful_row++;
1698                            printf(".");
1699                            if (successful_row >= 60) {
1700                                    successful_row = 0;
1701                                    printf("\n");
1702                            }
1703                    } else
1704                            successful_row = 0;
1705    
                 /* printf("[%d-%d]%s", ovector1[0], ovector1[1], (current->flags & PCRE_CASELESS) ? "C" : ""); */  
                 printf(".");  
1706                  fflush(stdout);                  fflush(stdout);
1707                  current++;                  current++;
                 succesful++;  
1708          }          }
1709            tables(1);
1710    #ifdef SUPPORT_PCRE8
1711            setstack8(NULL);
1712    #endif
1713    #ifdef SUPPORT_PCRE16
1714            setstack16(NULL);
1715    #endif
1716    #ifdef SUPPORT_PCRE32
1717            setstack32(NULL);
1718    #endif
1719    
1720          if (total == succesful) {          if (total == successful) {
1721                  printf("\nAll JIT regression tests are successfully passed.\n");                  printf("\nAll JIT regression tests are successfully passed.\n");
1722                  return 0;                  return 0;
1723          } else {          } else {
1724                  printf("\nSuccessful test ratio: %d%%\n", succesful * 100 / total);                  printf("\nSuccessful test ratio: %d%% (%d failed)\n", successful * 100 / total, total - successful);
1725                  return 1;                  return 1;
1726          }          }
1727  }  }

Legend:
Removed from v.698  
changed lines
  Added in v.1464

  ViewVC Help
Powered by ViewVC 1.1.5