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

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

  ViewVC Help
Powered by ViewVC 1.1.5