/[pcre]/code/branches/pcre16/pcre_jit_test.c
ViewVC logotype

Contents of /code/branches/pcre16/pcre_jit_test.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 795 - (show annotations)
Sat Dec 10 02:20:06 2011 UTC (7 years, 8 months ago) by zherczeg
File MIME type: text/plain
File size: 42626 byte(s)
extending the 16 bit API, mode check, and fixes
1 /*************************************************
2 * Perl-Compatible Regular Expressions *
3 *************************************************/
4
5 /* PCRE is a library of functions to support regular expressions whose syntax
6 and semantics are as close as possible to those of the Perl 5 language.
7
8 Main Library written by Philip Hazel
9 Copyright (c) 1997-2011 University of Cambridge
10
11 This JIT compiler regression test program was written by Zoltan Herczeg
12 Copyright (c) 2010-2011
13
14 -----------------------------------------------------------------------------
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions are met:
17
18 * Redistributions of source code must retain the above copyright notice,
19 this list of conditions and the following disclaimer.
20
21 * Redistributions in binary form must reproduce the above copyright
22 notice, this list of conditions and the following disclaimer in the
23 documentation and/or other materials provided with the distribution.
24
25 * Neither the name of the University of Cambridge nor the names of its
26 contributors may be used to endorse or promote products derived from
27 this software without specific prior written permission.
28
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
40 -----------------------------------------------------------------------------
41 */
42
43 #ifdef HAVE_CONFIG_H
44 #include "config.h"
45 #endif
46
47 #include <stdio.h>
48 #include <string.h>
49 #include "pcre.h"
50
51 #define PCRE_BUG 0x80000000
52
53 /*
54 Letter characters:
55 \xe6\x92\xad = 0x64ad = 25773 (kanji)
56 Non-letter characters:
57 \xc2\xa1 = 0xa1 = (Inverted Exclamation Mark)
58 \xf3\xa9\xb7\x80 = 0xe9dc0 = 957888
59 \xed\xa0\x80 = 55296 = 0xd800 (Invalid UTF character)
60 \xed\xb0\x80 = 56320 = 0xdc00 (Invalid UTF character)
61 Newlines:
62 \xc2\x85 = 0x85 = 133 (NExt Line = NEL)
63 \xe2\x80\xa8 = 0x2028 = 8232 (Line Separator)
64 Othercase pairs:
65 \xc3\xa9 = 0xe9 = 233 (e')
66 \xc3\x89 = 0xc9 = 201 (E')
67 \xc3\xa1 = 0xe1 = 225 (a')
68 \xc3\x81 = 0xc1 = 193 (A')
69 \xc8\xba = 0x23a = 570
70 \xe2\xb1\xa5 = 0x2c65 = 11365
71 \xe1\xbd\xb8 = 0x1f78 = 8056
72 \xe1\xbf\xb8 = 0x1ff8 = 8184
73 \xf0\x90\x90\x80 = 0x10400 = 66560
74 \xf0\x90\x90\xa8 = 0x10428 = 66600
75 Mark property:
76 \xcc\x8d = 0x30d = 781
77 Special:
78 \xdf\xbf = 0x7ff = 2047 (highest 2 byte character)
79 \xe0\xa0\x80 = 0x800 = 2048 (lowest 2 byte character)
80 \xef\xbf\xbf = 0xffff = 65535 (highest 3 byte character)
81 \xf0\x90\x80\x80 = 0x10000 = 65536 (lowest 4 byte character)
82 \xf4\x8f\xbf\xbf = 0x10ffff = 1114111 (highest allowed utf character)
83 */
84
85 static int regression_tests(void);
86
87 int main(void)
88 {
89 int jit = 0;
90 pcre_config(PCRE_CONFIG_JIT, &jit);
91 if (!jit) {
92 printf("JIT must be enabled to run pcre_jit_test\n");
93 return 1;
94 }
95 return regression_tests();
96 }
97
98 /* --------------------------------------------------------------------------------------- */
99
100 #if !(defined SUPPORT_PCRE8) && !(defined SUPPORT_PCRE16)
101 #error SUPPORT_PCRE8 or SUPPORT_PCRE16 must be defined
102 #endif
103
104 #define MUA (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
105 #define MUAP (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
106 #define CMUA (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
107 #define CMUAP (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
108 #define MA (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
109 #define MAP (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
110 #define CMA (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
111
112 #define OFFSET_MASK 0xffff
113 #define F_DIFF 0x010000
114 #define F_FORCECONV 0x020000
115 #define F_NO8 0x100000
116 #define F_NO16 0x200000
117
118 struct regression_test_case {
119 int flags;
120 int start_offset;
121 const char *pattern;
122 const char *input;
123 };
124
125 static struct regression_test_case regression_test_cases[] = {
126 /* Constant strings. */
127 { MUA, 0, "AbC", "AbAbC" },
128 { MUA, 0, "ACCEPT", "AACACCACCEACCEPACCEPTACCEPTT" },
129 { CMUA, 0, "aA#\xc3\xa9\xc3\x81", "aA#Aa#\xc3\x89\xc3\xa1" },
130 { MA, 0, "[^a]", "aAbB" },
131 { CMA, 0, "[^m]", "mMnN" },
132 { MA, 0, "a[^b][^#]", "abacd" },
133 { CMA, 0, "A[^B][^E]", "abacd" },
134 { CMUA, 0, "[^x][^#]", "XxBll" },
135 { MUA, 0, "[^a]", "aaa\xc3\xa1#Ab" },
136 { CMUA, 0, "[^A]", "aA\xe6\x92\xad" },
137 { MUA, 0, "\\W(\\W)?\\w", "\r\n+bc" },
138 { MUA, 0, "\\W(\\W)?\\w", "\n\r+bc" },
139 { MUA, 0, "\\W(\\W)?\\w", "\r\r+bc" },
140 { MUA, 0, "\\W(\\W)?\\w", "\n\n+bc" },
141 { MUA, 0, "[axd]", "sAXd" },
142 { CMUA, 0, "[axd]", "sAXd" },
143 { CMUA, 0, "[^axd]", "DxA" },
144 { MUA, 0, "[a-dA-C]", "\xe6\x92\xad\xc3\xa9.B" },
145 { MUA, 0, "[^a-dA-C]", "\xe6\x92\xad\xc3\xa9" },
146 { CMUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },
147 { MUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },
148 { MUA, 0, "[^a]", "\xc2\x80[]" },
149 { CMUA, 0, "\xf0\x90\x90\xa7", "\xf0\x90\x91\x8f" },
150 { CMA, 0, "1a2b3c4", "1a2B3c51A2B3C4" },
151 { PCRE_CASELESS, 0, "\xff#a", "\xff#\xff\xfe##\xff#A" },
152 { PCRE_CASELESS, 0, "\xfe", "\xff\xfc#\xfe\xfe" },
153 { PCRE_CASELESS, 0, "a1", "Aa1" },
154 { MA, 0, "\\Ca", "cda" },
155 { CMA, 0, "\\Ca", "CDA" },
156 { MA, 0, "\\Cx", "cda" },
157 { CMA, 0, "\\Cx", "CDA" },
158 { CMUAP, 0, "\xf0\x90\x90\x80\xf0\x90\x90\xa8", "\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
159 { CMUAP, 0, "\xf0\x90\x90\x80{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
160 { CMUAP, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
161 { CMUAP, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
162
163 /* Assertions. */
164 { MUA, 0, "\\b[^A]", "A_B#" },
165 { MA, 0, "\\b\\W", "\n*" },
166 { MUA, 0, "\\B[^,]\\b[^s]\\b", "#X" },
167 { MAP, 0, "\\B", "_\xa1" },
168 { MAP, 0, "\\b_\\b[,A]\\B", "_," },
169 { MUAP, 0, "\\b", "\xe6\x92\xad!" },
170 { MUAP, 0, "\\B", "_\xc2\xa1\xc3\xa1\xc2\x85" },
171 { MUAP, 0, "\\b[^A]\\B[^c]\\b[^_]\\B", "_\xc3\xa1\xe2\x80\xa8" },
172 { MUAP, 0, "\\b\\w+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
173 { MUA, 0, "\\b.", "\xcd\xbe" },
174 { CMUAP, 0, "\\By", "\xf0\x90\x90\xa8y" },
175 { MA, 0, "\\R^", "\n" },
176 { MA, 1, "^", "\n" },
177 { 0, 0, "^ab", "ab" },
178 { 0, 0, "^ab", "aab" },
179 { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "^a", "\r\raa\n\naa\r\naa" },
180 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "^-", "\xe2\x80\xa8--\xc2\x85-\r\n-" },
181 { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^-", "a--b--\x85--" },
182 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xe2\x80\xa8--" },
183 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xc2\x85--" },
184 { 0, 0, "ab$", "ab" },
185 { 0, 0, "ab$", "ab\r\n" },
186 { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "a$", "\r\raa\n\naa\r\naa" },
187 { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aaa" },
188 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "#$", "#\xc2\x85###\r#" },
189 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "#$", "#\xe2\x80\xa9" },
190 { PCRE_NOTBOL | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },
191 { PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },
192 { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },
193 { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0, "a$", "aa\r\n" },
194 { PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0, "\\p{Any}{2,}$", "aa\r\n" },
195 { PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },
196 { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },
197 { PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },
198 { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa\n" },
199 { PCRE_NEWLINE_CRLF, 0, ".\\Z", "aaa\r" },
200 { PCRE_NEWLINE_CRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
201 { PCRE_NEWLINE_CRLF, 0, ".\\Z", "aaa\r\n" },
202 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa" },
203 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r" },
204 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
205 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r\n" },
206 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },
207 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa" },
208 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r" },
209 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
210 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r\n" },
211 { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xc2\x85" },
212 { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },
213 { MA, 0, "\\Aa", "aaa" },
214 { MA, 1, "\\Aa", "aaa" },
215 { MA, 1, "\\Ga", "aaa" },
216 { MA, 1, "\\Ga", "aba" },
217 { MA, 0, "a\\z", "aaa" },
218 { MA, 0, "a\\z", "aab" },
219
220 /* Brackets. */
221 { MUA, 0, "(ab|bb|cd)", "bacde" },
222 { MUA, 0, "(?:ab|a)(bc|c)", "ababc" },
223 { MUA, 0, "((ab|(cc))|(bb)|(?:cd|efg))", "abac" },
224 { CMUA, 0, "((aB|(Cc))|(bB)|(?:cd|EFg))", "AcCe" },
225 { MUA, 0, "((ab|(cc))|(bb)|(?:cd|ebg))", "acebebg" },
226 { MUA, 0, "(?:(a)|(?:b))(cc|(?:d|e))(a|b)k", "accabdbbccbk" },
227
228 /* Greedy and non-greedy ? operators. */
229 { MUA, 0, "(?:a)?a", "laab" },
230 { CMUA, 0, "(A)?A", "llaab" },
231 { MUA, 0, "(a)?\?a", "aab" }, /* ?? is the prefix of trygraphs in GCC. */
232 { MUA, 0, "(a)?a", "manm" },
233 { CMUA, 0, "(a|b)?\?d((?:e)?)", "ABABdx" },
234 { MUA, 0, "(a|b)?\?d((?:e)?)", "abcde" },
235 { MUA, 0, "((?:ab)?\?g|b(?:g(nn|d)?\?)?)?\?(?:n)?m", "abgnbgnnbgdnmm" },
236
237 /* Greedy and non-greedy + operators */
238 { MUA, 0, "(aa)+aa", "aaaaaaa" },
239 { MUA, 0, "(aa)+?aa", "aaaaaaa" },
240 { MUA, 0, "(?:aba|ab|a)+l", "ababamababal" },
241 { MUA, 0, "(?:aba|ab|a)+?l", "ababamababal" },
242 { MUA, 0, "(a(?:bc|cb|b|c)+?|ss)+e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
243 { MUA, 0, "(a(?:bc|cb|b|c)+|ss)+?e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
244 { MUA, 0, "(?:(b(c)+?)+)?\?(?:(bc)+|(cb)+)+(?:m)+", "bccbcccbcbccbcbPbccbcccbcbccbcbmmn" },
245
246 /* Greedy and non-greedy * operators */
247 { CMUA, 0, "(?:AA)*AB", "aaaaaaamaaaaaaab" },
248 { MUA, 0, "(?:aa)*?ab", "aaaaaaamaaaaaaab" },
249 { MUA, 0, "(aa|ab)*ab", "aaabaaab" },
250 { CMUA, 0, "(aa|Ab)*?aB", "aaabaaab" },
251 { MUA, 0, "(a|b)*(?:a)*(?:b)*m", "abbbaaababanabbbaaababamm" },
252 { MUA, 0, "(a|b)*?(?:a)*?(?:b)*?m", "abbbaaababanabbbaaababamm" },
253 { MA, 0, "a(a(\\1*)a|(b)b+){0}a", "aa" },
254 { MA, 0, "((?:a|)*){0}a", "a" },
255
256 /* Combining ? + * operators */
257 { MUA, 0, "((bm)+)?\?(?:a)*(bm)+n|((am)+?)?(?:a)+(am)*n", "bmbmabmamaaamambmaman" },
258 { MUA, 0, "(((ab)?cd)*ef)+g", "abcdcdefcdefefmabcdcdefcdefefgg" },
259 { MUA, 0, "(((ab)?\?cd)*?ef)+?g", "abcdcdefcdefefmabcdcdefcdefefgg" },
260 { MUA, 0, "(?:(ab)?c|(?:ab)+?d)*g", "ababcdccababddg" },
261 { MUA, 0, "(?:(?:ab)?\?c|(ab)+d)*?g", "ababcdccababddg" },
262
263 /* Single character iterators. */
264 { MUA, 0, "(a+aab)+aaaab", "aaaabcaaaabaabcaabcaaabaaaab" },
265 { MUA, 0, "(a*a*aab)+x", "aaaaabaabaaabmaabx" },
266 { MUA, 0, "(a*?(b|ab)a*?)+x", "aaaabcxbbaabaacbaaabaabax" },
267 { MUA, 0, "(a+(ab|ad)a+)+x", "aaabaaaadaabaaabaaaadaaax" },
268 { MUA, 0, "(a?(a)a?)+(aaa)", "abaaabaaaaaaaa" },
269 { MUA, 0, "(a?\?(a)a?\?)+(b)", "aaaacaaacaacacbaaab" },
270 { MUA, 0, "(a{0,4}(b))+d", "aaaaaabaabcaaaaabaaaaabd" },
271 { MUA, 0, "(a{0,4}?[^b])+d+(a{0,4}[^b])d+", "aaaaadaaaacaadddaaddd" },
272 { MUA, 0, "(ba{2})+c", "baabaaabacbaabaac" },
273 { MUA, 0, "(a*+bc++)+", "aaabbcaaabcccab" },
274 { MUA, 0, "(a?+[^b])+", "babaacacb" },
275 { MUA, 0, "(a{0,3}+b)(a{0,3}+b)(a{0,3}+)[^c]", "abaabaaacbaabaaaac" },
276 { CMUA, 0, "([a-c]+[d-f]+?)+?g", "aBdacdehAbDaFgA" },
277 { CMUA, 0, "[c-f]+k", "DemmFke" },
278 { MUA, 0, "([DGH]{0,4}M)+", "GGDGHDGMMHMDHHGHM" },
279 { MUA, 0, "([a-c]{4,}s)+", "abasabbasbbaabsbba" },
280 { CMUA, 0, "[ace]{3,7}", "AcbDAcEEcEd" },
281 { CMUA, 0, "[ace]{3,7}?", "AcbDAcEEcEd" },
282 { CMUA, 0, "[ace]{3,}", "AcbDAcEEcEd" },
283 { CMUA, 0, "[ace]{3,}?", "AcbDAcEEcEd" },
284 { MUA, 0, "[ckl]{2,}?g", "cdkkmlglglkcg" },
285 { CMUA, 0, "[ace]{5}?", "AcCebDAcEEcEd" },
286 { MUA, 0, "([AbC]{3,5}?d)+", "BACaAbbAEAACCbdCCbdCCAAbb" },
287 { MUA, 0, "([^ab]{0,}s){2}", "abaabcdsABamsDDs" },
288 { MUA, 0, "\\b\\w+\\B", "x,a_cd" },
289 { MUAP, 0, "\\b[^\xc2\xa1]+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
290 { CMUA, 0, "[^b]+(a*)([^c]?d{3})", "aaaaddd" },
291 { CMUAP, 0, "\xe1\xbd\xb8{2}", "\xe1\xbf\xb8#\xe1\xbf\xb8\xe1\xbd\xb8" },
292
293 /* Basic character sets. */
294 { MUA, 0, "(?:\\s)+(?:\\S)+", "ab \t\xc3\xa9\xe6\x92\xad " },
295 { MUA, 0, "(\\w)*(k)(\\W)?\?", "abcdef abck11" },
296 { MUA, 0, "\\((\\d)+\\)\\D", "a() (83 (8)2 (9)ab" },
297 { MUA, 0, "\\w(\\s|(?:\\d)*,)+\\w\\wb", "a 5, 4,, bb 5, 4,, aab" },
298 { MUA, 0, "(\\v+)(\\V+)", "\x0e\xc2\x85\xe2\x80\xa8\x0b\x09\xe2\x80\xa9" },
299 { 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" },
300
301 /* Unicode properties. */
302 { MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },
303 { MUAP, 0, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },
304 { MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },
305 { MUAP, 0, "[\\P{Any}]", "abc" },
306 { MUAP, 0, "[^\\p{Any}]", "abc" },
307 { MUAP, 0, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },
308 { MUAP, 0, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },
309 { MUAP, 0, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
310 { MUAP, 0, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
311 { MUAP, 0, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
312 { MUAP, 0, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
313 { MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },
314 { CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },
315 { MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },
316 { MUAP, 0, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },
317 { MUA, 0, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },
318 { 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" },
319 { 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" },
320 { 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#" },
321 { PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB baaa" },
322
323 /* Possible empty brackets. */
324 { MUA, 0, "(?:|ab||bc|a)+d", "abcxabcabd" },
325 { MUA, 0, "(|ab||bc|a)+d", "abcxabcabd" },
326 { MUA, 0, "(?:|ab||bc|a)*d", "abcxabcabd" },
327 { MUA, 0, "(|ab||bc|a)*d", "abcxabcabd" },
328 { MUA, 0, "(?:|ab||bc|a)+?d", "abcxabcabd" },
329 { MUA, 0, "(|ab||bc|a)+?d", "abcxabcabd" },
330 { MUA, 0, "(?:|ab||bc|a)*?d", "abcxabcabd" },
331 { MUA, 0, "(|ab||bc|a)*?d", "abcxabcabd" },
332 { MUA, 0, "(((a)*?|(?:ba)+)+?|(?:|c|ca)*)*m", "abaacaccabacabalabaacaccabacabamm" },
333 { MUA, 0, "(?:((?:a)*|(ba)+?)+|(|c|ca)*?)*?m", "abaacaccabacabalabaacaccabacabamm" },
334
335 /* Start offset. */
336 { MUA, 3, "(\\d|(?:\\w)*\\w)+", "0ac01Hb" },
337 { MUA, 4, "(\\w\\W\\w)+", "ab#d" },
338 { MUA, 2, "(\\w\\W\\w)+", "ab#d" },
339 { MUA, 1, "(\\w\\W\\w)+", "ab#d" },
340
341 /* Newline. */
342 { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
343 { PCRE_MULTILINE | PCRE_NEWLINE_CR, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
344 { PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{1,3}[^#]", "\r\n##...." },
345
346 /* Any character except newline or any newline. */
347 { PCRE_NEWLINE_CRLF, 0, ".", "\r" },
348 { PCRE_NEWLINE_CRLF | PCRE_UTF8, 0, ".(.).", "a\xc3\xa1\r\n\n\r\r" },
349 { PCRE_NEWLINE_ANYCRLF, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
350 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
351 { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.).", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa9$de" },
352 { PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.).", "\xe2\x80\xa8\nb\r" },
353 { PCRE_NEWLINE_ANY, 0, "(.)(.)", "#\x85#\r#\n#\r\n#\x84" },
354 { PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.+)#", "#\rMn\xc2\x85#\n###" },
355 { PCRE_BSR_ANYCRLF, 0, "\\R", "\r" },
356 { PCRE_BSR_ANYCRLF, 0, "\\R", "\x85#\r\n#" },
357 { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\xe2\x80\xa8#c" },
358 { PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\r\nc" },
359 { PCRE_NEWLINE_CRLF | PCRE_BSR_UNICODE | PCRE_UTF8, 0, "(\\R.)+", "\xc2\x85\r\n#\xe2\x80\xa8\n\r\n\r" },
360 { MUA, 0, "\\R+", "ab" },
361 { MUA, 0, "\\R+", "ab\r\n\r" },
362 { MUA, 0, "\\R*", "ab\r\n\r" },
363 { MUA, 0, "\\R*", "\r\n\r" },
364 { MUA, 0, "\\R{2,4}", "\r\nab\r\r" },
365 { MUA, 0, "\\R{2,4}", "\r\nab\n\n\n\r\r\r" },
366 { MUA, 0, "\\R{2,}", "\r\nab\n\n\n\r\r\r" },
367 { MUA, 0, "\\R{0,3}", "\r\n\r\n\r\n\r\n\r\n" },
368 { MUA, 0, "\\R+\\R\\R", "\r\n\r\n" },
369 { MUA, 0, "\\R+\\R\\R", "\r\r\r" },
370 { MUA, 0, "\\R*\\R\\R", "\n\r" },
371 { MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r" },
372 { MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r\r" },
373
374 /* Atomic groups (no fallback from "next" direction). */
375 { MUA, 0, "(?>ab)ab", "bab" },
376 { MUA, 0, "(?>(ab))ab", "bab" },
377 { MUA, 0, "(?>ab)+abc(?>de)*def(?>gh)?ghe(?>ij)+?k(?>lm)*?n(?>op)?\?op",
378 "bababcdedefgheijijklmlmnop" },
379 { MUA, 0, "(?>a(b)+a|(ab)?\?(b))an", "abban" },
380 { MUA, 0, "(?>ab+a|(?:ab)?\?b)an", "abban" },
381 { MUA, 0, "((?>ab|ad|)*?)(?>|c)*abad", "abababcababad" },
382 { MUA, 0, "(?>(aa|b|)*+(?>(##)|###)*d|(aa)(?>(baa)?)m)", "aabaa#####da" },
383 { MUA, 0, "((?>a|)+?)b", "aaacaaab" },
384 { MUA, 0, "(?>x|)*$", "aaa" },
385 { MUA, 0, "(?>(x)|)*$", "aaa" },
386 { MUA, 0, "(?>x|())*$", "aaa" },
387 { MUA, 0, "((?>[cxy]a|[a-d])*?)b", "aaa+ aaab" },
388 { MUA, 0, "((?>[cxy](a)|[a-d])*?)b", "aaa+ aaab" },
389 { MUA, 0, "(?>((?>(a+))))bab|(?>((?>(a+))))bb", "aaaabaaabaabab" },
390 { MUA, 0, "(?>(?>a+))bab|(?>(?>a+))bb", "aaaabaaabaabab" },
391 { MUA, 0, "(?>(a)c|(?>(c)|(a))a)b*?bab", "aaaabaaabaabab" },
392 { MUA, 0, "(?>ac|(?>c|a)a)b*?bab", "aaaabaaabaabab" },
393 { MUA, 0, "(?>(b)b|(a))*b(?>(c)|d)?x", "ababcaaabdbx" },
394 { MUA, 0, "(?>bb|a)*b(?>c|d)?x", "ababcaaabdbx" },
395 { MUA, 0, "(?>(bb)|a)*b(?>c|(d))?x", "ababcaaabdbx" },
396 { MUA, 0, "(?>(a))*?(?>(a))+?(?>(a))??x", "aaaaaacccaaaaabax" },
397 { MUA, 0, "(?>a)*?(?>a)+?(?>a)??x", "aaaaaacccaaaaabax" },
398 { MUA, 0, "(?>(a)|)*?(?>(a)|)+?(?>(a)|)??x", "aaaaaacccaaaaabax" },
399 { MUA, 0, "(?>a|)*?(?>a|)+?(?>a|)??x", "aaaaaacccaaaaabax" },
400 { MUA, 0, "(?>a(?>(a{0,2}))*?b|aac)+b", "aaaaaaacaaaabaaaaacaaaabaacaaabb" },
401 { CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },
402 { MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
403 { MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
404 { MUA, 0, "\\X", "\xcc\x8d\xcc\x8d" },
405 { MUA, 0, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },
406 { MUA, 0, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },
407 { MUA, 0, "\\X{2,4}", "abcdef" },
408 { MUA, 0, "\\X{2,4}?", "abcdef" },
409 { MUA, 0, "\\X{2,4}..", "#\xcc\x8d##" },
410 { MUA, 0, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },
411 { MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },
412 { MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },
413
414 /* Possessive quantifiers. */
415 { MUA, 0, "(?:a|b)++m", "mababbaaxababbaam" },
416 { MUA, 0, "(?:a|b)*+m", "mababbaaxababbaam" },
417 { MUA, 0, "(?:a|b)*+m", "ababbaaxababbaam" },
418 { MUA, 0, "(a|b)++m", "mababbaaxababbaam" },
419 { MUA, 0, "(a|b)*+m", "mababbaaxababbaam" },
420 { MUA, 0, "(a|b)*+m", "ababbaaxababbaam" },
421 { MUA, 0, "(a|b(*ACCEPT))++m", "maaxab" },
422 { MUA, 0, "(?:b*)++m", "bxbbxbbbxm" },
423 { MUA, 0, "(?:b*)++m", "bxbbxbbbxbbm" },
424 { MUA, 0, "(?:b*)*+m", "bxbbxbbbxm" },
425 { MUA, 0, "(?:b*)*+m", "bxbbxbbbxbbm" },
426 { MUA, 0, "(b*)++m", "bxbbxbbbxm" },
427 { MUA, 0, "(b*)++m", "bxbbxbbbxbbm" },
428 { MUA, 0, "(b*)*+m", "bxbbxbbbxm" },
429 { MUA, 0, "(b*)*+m", "bxbbxbbbxbbm" },
430 { MUA, 0, "(?:a|(b))++m", "mababbaaxababbaam" },
431 { MUA, 0, "(?:(a)|b)*+m", "mababbaaxababbaam" },
432 { MUA, 0, "(?:(a)|(b))*+m", "ababbaaxababbaam" },
433 { MUA, 0, "(a|(b))++m", "mababbaaxababbaam" },
434 { MUA, 0, "((a)|b)*+m", "mababbaaxababbaam" },
435 { MUA, 0, "((a)|(b))*+m", "ababbaaxababbaam" },
436 { MUA, 0, "(a|(b)(*ACCEPT))++m", "maaxab" },
437 { MUA, 0, "(?:(b*))++m", "bxbbxbbbxm" },
438 { MUA, 0, "(?:(b*))++m", "bxbbxbbbxbbm" },
439 { MUA, 0, "(?:(b*))*+m", "bxbbxbbbxm" },
440 { MUA, 0, "(?:(b*))*+m", "bxbbxbbbxbbm" },
441 { MUA, 0, "((b*))++m", "bxbbxbbbxm" },
442 { MUA, 0, "((b*))++m", "bxbbxbbbxbbm" },
443 { MUA, 0, "((b*))*+m", "bxbbxbbbxm" },
444 { MUA, 0, "((b*))*+m", "bxbbxbbbxbbm" },
445 { MUA, 0, "(?>(b{2,4}))(?:(?:(aa|c))++m|(?:(aa|c))+n)", "bbaacaaccaaaacxbbbmbn" },
446 { MUA, 0, "((?:b)++a)+(cd)*+m", "bbababbacdcdnbbababbacdcdm" },
447 { MUA, 0, "((?:(b))++a)+((c)d)*+m", "bbababbacdcdnbbababbacdcdm" },
448 { MUA, 0, "(?:(?:(?:ab)*+k)++(?:n(?:cd)++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },
449 { MUA, 0, "(?:((ab)*+(k))++(n(?:c(d))++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },
450
451 /* Back references. */
452 { MUA, 0, "(aa|bb)(\\1*)(ll|)(\\3*)bbbbbbc", "aaaaaabbbbbbbbc" },
453 { CMUA, 0, "(aa|bb)(\\1+)(ll|)(\\3+)bbbbbbc", "bBbbBbCbBbbbBbbcbbBbbbBBbbC" },
454 { CMA, 0, "(a{2,4})\\1", "AaAaaAaA" },
455 { MUA, 0, "(aa|bb)(\\1?)aa(\\1?)(ll|)(\\4+)bbc", "aaaaaaaabbaabbbbaabbbbc" },
456 { MUA, 0, "(aa|bb)(\\1{0,5})(ll|)(\\3{0,5})cc", "bbxxbbbbxxaaaaaaaaaaaaaaaacc" },
457 { MUA, 0, "(aa|bb)(\\1{3,5})(ll|)(\\3{3,5})cc", "bbbbbbbbbbbbaaaaaaccbbbbbbbbbbbbbbcc" },
458 { MUA, 0, "(aa|bb)(\\1{3,})(ll|)(\\3{3,})cc", "bbbbbbbbbbbbaaaaaaccbbbbbbbbbbbbbbcc" },
459 { MUA, 0, "(\\w+)b(\\1+)c", "GabGaGaDbGaDGaDc" },
460 { MUA, 0, "(?:(aa)|b)\\1?b", "bb" },
461 { CMUA, 0, "(aa|bb)(\\1*?)aa(\\1+?)", "bBBbaaAAaaAAaa" },
462 { MUA, 0, "(aa|bb)(\\1*?)(dd|)cc(\\3+?)", "aaaaaccdd" },
463 { CMUA, 0, "(?:(aa|bb)(\\1?\?)cc){2}(\\1?\?)", "aAaABBbbAAaAcCaAcCaA" },
464 { MUA, 0, "(?:(aa|bb)(\\1{3,5}?)){2}(dd|)(\\3{3,5}?)", "aaaaaabbbbbbbbbbaaaaaaaaaaaaaa" },
465 { CMA, 0, "(?:(aa|bb)(\\1{3,}?)){2}(dd|)(\\3{3,}?)", "aaaaaabbbbbbbbbbaaaaaaaaaaaaaa" },
466 { MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },
467 { MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },
468 { 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" },
469 { MUAP, 0, "(\\P{N})\\1{2,}", ".www." },
470 { MUAP, 0, "(\\P{N})\\1{0,2}", "wwwww." },
471 { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwww" },
472 { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwwww" },
473 { PCRE_UCP, 0, "(\\P{N})\\1{2,}", ".www." },
474 { CMUAP, 0, "(\xf0\x90\x90\x80)\\1", "\xf0\x90\x90\xa8\xf0\x90\x90\xa8" },
475
476 /* Assertions. */
477 { MUA, 0, "(?=xx|yy|zz)\\w{4}", "abczzdefg" },
478 { MUA, 0, "(?=((\\w+)b){3}|ab)", "dbbbb ab" },
479 { MUA, 0, "(?!ab|bc|cd)[a-z]{2}", "Xabcdef" },
480 { MUA, 0, "(?<=aaa|aa|a)a", "aaa" },
481 { MUA, 2, "(?<=aaa|aa|a)a", "aaa" },
482 { MA, 0, "(?<=aaa|aa|a)a", "aaa" },
483 { MA, 2, "(?<=aaa|aa|a)a", "aaa" },
484 { MUA, 0, "(\\d{2})(?!\\w+c|(((\\w?)m){2}n)+|\\1)", "x5656" },
485 { MUA, 0, "((?=((\\d{2,6}\\w){2,}))\\w{5,20}K){2,}", "567v09708K12l00M00 567v09708K12l00M00K45K" },
486 { MUA, 0, "(?=(?:(?=\\S+a)\\w*(b)){3})\\w+\\d", "bba bbab nbbkba nbbkba0kl" },
487 { MUA, 0, "(?>a(?>(b+))a(?=(..)))*?k", "acabbcabbaabacabaabbakk" },
488 { MUA, 0, "((?(?=(a))a)+k)", "bbak" },
489 { MUA, 0, "((?(?=a)a)+k)", "bbak" },
490 { MUA, 0, "(?=(?>(a))m)amk", "a k" },
491 { MUA, 0, "(?!(?>(a))m)amk", "a k" },
492 { MUA, 0, "(?>(?=(a))am)amk", "a k" },
493 { MUA, 0, "(?=(?>a|(?=(?>(b+))a|c)[a-c]+)*?m)[a-cm]+k", "aaam bbam baaambaam abbabba baaambaamk" },
494 { MUA, 0, "(?> ?\?\\b(?(?=\\w{1,4}(a))m)\\w{0,8}bc){2,}?", "bca ssbc mabd ssbc mabc" },
495 { MUA, 0, "(?:(?=ab)?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },
496 { MUA, 0, "(?:(?=a(b))?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },
497 { MUA, 0, "(?:(?=.(.))??\\1.)+m", "aabbbcbacccanaabbbcbacccam" },
498 { MUA, 0, "(?:(?=.)??[a-c])+m", "abacdcbacacdcaccam" },
499 { MUA, 0, "((?!a)?(?!([^a]))?)+$", "acbab" },
500 { MUA, 0, "((?!a)?\?(?!([^a]))?\?)+$", "acbab" },
501
502 /* Not empty, ACCEPT, FAIL */
503 { MUA | PCRE_NOTEMPTY, 0, "a*", "bcx" },
504 { MUA | PCRE_NOTEMPTY, 0, "a*", "bcaad" },
505 { MUA | PCRE_NOTEMPTY, 0, "a*?", "bcaad" },
506 { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*", "bcaad" },
507 { MUA, 0, "a(*ACCEPT)b", "ab" },
508 { MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcx" },
509 { MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcaad" },
510 { MUA | PCRE_NOTEMPTY, 0, "a*?(*ACCEPT)b", "bcaad" },
511 { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcx" },
512 { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcaad" },
513 { MUA | PCRE_NOTEMPTY, 0, "(?:z|a*?(*ACCEPT)b)", "bcaad" },
514 { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "bcx" },
515 { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "" },
516 { MUA, 0, "((a(*ACCEPT)b))", "ab" },
517 { MUA, 0, "(a(*FAIL)a|a)", "aaa" },
518 { MUA, 0, "(?=ab(*ACCEPT)b)a", "ab" },
519 { MUA, 0, "(?=(?:x|ab(*ACCEPT)b))", "ab" },
520 { MUA, 0, "(?=(a(b(*ACCEPT)b)))a", "ab" },
521 { MUA | PCRE_NOTEMPTY, 0, "(?=a*(*ACCEPT))c", "c" },
522
523 /* Conditional blocks. */
524 { MUA, 0, "(?(?=(a))a|b)+k", "ababbalbbadabak" },
525 { MUA, 0, "(?(?!(b))a|b)+k", "ababbalbbadabak" },
526 { MUA, 0, "(?(?=a)a|b)+k", "ababbalbbadabak" },
527 { MUA, 0, "(?(?!b)a|b)+k", "ababbalbbadabak" },
528 { MUA, 0, "(?(?=(a))a*|b*)+k", "ababbalbbadabak" },
529 { MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },
530 { MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
531 { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
532 { MUA, 0 | F_DIFF, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
533 { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
534 { MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },
535 { MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },
536 { MUA, 0, "(?(?=a)ab)", "a" },
537 { MUA, 0, "(?(?<!b)c)", "b" },
538 { MUA, 0, "(?(DEFINE)a(b))", "a" },
539 { MUA, 0, "a(?(DEFINE)(?:b|(?:c?)+)*)", "a" },
540 { MUA, 0, "(?(?=.[a-c])[k-l]|[A-D])", "kdB" },
541 { MUA, 0, "(?(?!.{0,4}[cd])(aa|bb)|(cc|dd))+", "aabbccddaa" },
542 { MUA, 0, "(?(?=[^#@]*@)(aaab|aa|aba)|(aba|aab)){3,}", "aaabaaaba#aaabaaaba#aaabaaaba@" },
543 { MUA, 0, "((?=\\w{5})\\w(?(?=\\w*k)\\d|[a-f_])*\\w\\s)+", "mol m10kk m088k _f_a_ mbkkl" },
544 { MUA, 0, "(c)?\?(?(1)a|b)", "cdcaa" },
545 { MUA, 0, "(c)?\?(?(1)a|b)", "cbb" },
546 { MUA, 0 | F_DIFF, "(?(?=(a))(aaaa|a?))+aak", "aaaaab aaaaak" },
547 { MUA, 0, "(?(?=a)(aaaa|a?))+aak", "aaaaab aaaaak" },
548 { MUA, 0, "(?(?!(b))(aaaa|a?))+aak", "aaaaab aaaaak" },
549 { MUA, 0, "(?(?!b)(aaaa|a?))+aak", "aaaaab aaaaak" },
550 { MUA, 0 | F_DIFF, "(?(?=(a))a*)+aak", "aaaaab aaaaak" },
551 { MUA, 0, "(?(?=a)a*)+aak", "aaaaab aaaaak" },
552 { MUA, 0, "(?(?!(b))a*)+aak", "aaaaab aaaaak" },
553 { MUA, 0, "(?(?!b)a*)+aak", "aaaaab aaaaak" },
554 { MUA, 0, "(?(?=(?=(?!(x))a)aa)aaa|(?(?=(?!y)bb)bbb))*k", "abaabbaaabbbaaabbb abaabbaaabbbaaabbbk" },
555 { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)*l", "bc ddd abccabccl" },
556 { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)+?dd", "bcabcacdb bdddd" },
557 { MUA, 0, "(?P<Name>a)?(?P<Name2>b)?(?(Name)c|d)+l", "ababccddabdbccd abcccl" },
558
559 /* Set start of match. */
560 { MUA, 0, "(?:\\Ka)*aaaab", "aaaaaaaa aaaaaaabb" },
561 { MUA, 0, "(?>\\Ka\\Ka)*aaaab", "aaaaaaaa aaaaaaaaaabb" },
562 { MUA, 0, "a+\\K(?<=\\Gaa)a", "aaaaaa" },
563 { MUA | PCRE_NOTEMPTY, 0, "a\\K(*ACCEPT)b", "aa" },
564 { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },
565
566 /* First line. */
567 { MUA | PCRE_FIRSTLINE, 0, "\\p{Any}a", "bb\naaa" },
568 { MUA | PCRE_FIRSTLINE, 0, "\\p{Any}a", "bb\r\naaa" },
569 { MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },
570 { MUA | PCRE_FIRSTLINE, 0, "[^a][^b]", "ab" },
571 { MUA | PCRE_FIRSTLINE, 0, "a", "\na" },
572 { MUA | PCRE_FIRSTLINE, 0, "[abc]", "\na" },
573 { MUA | PCRE_FIRSTLINE, 0, "^a", "\na" },
574 { MUA | PCRE_FIRSTLINE, 0, "^(?<=\n)", "\na" },
575 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "#", "\xc2\x85#" },
576 { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "#", "\x85#" },
577 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0, "^#", "\xe2\x80\xa8#" },
578 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "\\p{Any}", "\r\na" },
579 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },
580 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },
581 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "ba", "bbb\r\nba" },
582 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "\\p{Any}{4}|a", "\r\na" },
583 { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },
584
585 /* Recurse. */
586 { MUA, 0, "(a)(?1)", "aa" },
587 { MUA, 0, "((a))(?1)", "aa" },
588 { MUA, 0, "(b|a)(?1)", "aa" },
589 { MUA, 0, "(b|(a))(?1)", "aa" },
590 { MUA, 0, "((a)(b)(?:a*))(?1)", "aba" },
591 { MUA, 0, "((a)(b)(?:a*))(?1)", "abab" },
592 { MUA, 0, "((a+)c(?2))b(?1)", "aacaabaca" },
593 { MUA, 0, "((?2)b|(a)){2}(?1)", "aabab" },
594 { MUA, 0, "(?1)(a)*+(?2)(b(?1))", "aababa" },
595 { MUA, 0, "(?1)(((a(*ACCEPT)))b)", "axaa" },
596 { MUA, 0, "(?1)(?(DEFINE) (((ac(*ACCEPT)))b) )", "akaac" },
597 { MUA, 0, "(a+)b(?1)b\\1", "abaaabaaaaa" },
598 { MUA, 0, "(?(DEFINE)(aa|a))(?1)ab", "aab" },
599 { MUA, 0, "(?(DEFINE)(a\\Kb))(?1)+ababc", "abababxabababc" },
600 { MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababc" },
601 { MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababxc" },
602 { MUA, 0, "b|<(?R)*>", "<<b>" },
603 { MUA, 0, "(a\\K){0}(?:(?1)b|ac)", "ac" },
604 { MUA, 0, "(?(DEFINE)(a(?2)|b)(b(?1)|(a)))(?:(?1)|(?2))m", "ababababnababababaam" },
605 { MUA, 0, "(a)((?(R)a|b))(?2)", "aabbabaa" },
606 { MUA, 0, "(a)((?(R2)a|b))(?2)", "aabbabaa" },
607 { MUA, 0, "(a)((?(R1)a|b))(?2)", "ababba" },
608 { MUA, 0, "(?(R0)aa|bb(?R))", "abba aabb bbaa" },
609 { MUA, 0, "((?(R)(?:aaaa|a)|(?:(aaaa)|(a)))+)(?1)$", "aaaaaaaaaa aaaa" },
610 { MUA, 0, "(?P<Name>a(?(R&Name)a|b))(?1)", "aab abb abaa" },
611
612 /* 16 bit specific tests. */
613 { CMA, 0 | F_FORCECONV, "\xc3\xa1", "\xc3\x81\xc3\xa1" },
614 { CMA, 0 | F_FORCECONV, "\xe1\xbd\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
615 { CMA, 0 | F_FORCECONV, "[\xc3\xa1]", "\xc3\x81\xc3\xa1" },
616 { CMA, 0 | F_FORCECONV, "[\xe1\xbd\xb8]", "\xe1\xbf\xb8\xe1\xbd\xb8" },
617 { CMA, 0 | F_FORCECONV | F_NO8, "\xed\xa0\x80\\x{d800}\xed\xb0\x80\\x{dc00}", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80" },
618 { CMA, 0 | F_FORCECONV | F_NO8, "[\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#" },
619 { 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" },
620 { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\x9f\xbf\xed\xa0\x83" },
621 { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\xb4\x80\xed\xb3\xb0" },
622 { CMA, 0 | F_FORCECONV | F_NO8, "[\\x{d800}-\\x{dcff}]", "\xed\x9f\xbf\xed\xa0\x83" },
623 { CMA, 0 | F_FORCECONV | F_NO8, "[\\x{d800}-\\x{dcff}]", "\xed\xb4\x80\xed\xb3\xb0" },
624 { 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#" },
625
626 /* Deep recursion. */
627 { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
628 { MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },
629 { MUA, 0, "((a?)+)+b", "aaaaaaaaaaaaa b" },
630
631 /* Deep recursion: Stack limit reached. */
632 { 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" },
633 { MA, 0, "(?:a+)+b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
634 { MA, 0, "(?:a+?)+?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
635 { MA, 0, "(?:a*)*b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
636 { MA, 0, "(?:a*?)*?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
637
638 { 0, 0, NULL, NULL }
639 };
640
641 static pcre_jit_stack* callback(void *arg)
642 {
643 return (pcre_jit_stack *)arg;
644 }
645
646 static void setstack(pcre_extra *extra, int alloc_again)
647 {
648 static pcre_jit_stack *stack;
649
650 if (alloc_again) {
651 if (stack)
652 pcre_jit_stack_free(stack);
653 stack = pcre_jit_stack_alloc(1, 1024 * 1024);
654 }
655 /* Extra can be NULL. */
656 pcre_assign_jit_stack(extra, callback, stack);
657 }
658
659 #ifdef SUPPORT_PCRE16
660
661 static int convert_utf8_to_utf16(const char *input, PCRE_SCHAR16 *output, int *offsetmap, int max_length)
662 {
663 unsigned char *iptr = (unsigned char*)input;
664 unsigned short *optr = (unsigned short *)output;
665 unsigned int c;
666
667 if (max_length == 0)
668 return 0;
669
670 while (*iptr && max_length > 1) {
671 c = 0;
672 if (offsetmap)
673 *offsetmap++ = (int)(iptr - (unsigned char*)input);
674
675 if (!(*iptr & 0x80))
676 c = *iptr++;
677 else if (!(*iptr & 0x20)) {
678 c = ((iptr[0] & 0x1f) << 6) | (iptr[1] & 0x3f);
679 iptr += 2;
680 } else if (!(*iptr & 0x10)) {
681 c = ((iptr[0] & 0x0f) << 12) | ((iptr[1] & 0x3f) << 6) | (iptr[2] & 0x3f);
682 iptr += 3;
683 } else if (!(*iptr & 0x08)) {
684 c = ((iptr[0] & 0x07) << 18) | ((iptr[1] & 0x3f) << 12) | ((iptr[2] & 0x3f) << 6) | (iptr[3] & 0x3f);
685 iptr += 4;
686 }
687
688 if (c < 65536) {
689 *optr++ = c;
690 max_length--;
691 } else if (max_length <= 2) {
692 *optr = '\0';
693 return (int)(optr - (unsigned short *)output);
694 } else {
695 c -= 0x10000;
696 *optr++ = 0xd800 | ((c >> 10) & 0x3ff);
697 *optr++ = 0xdc00 | (c & 0x3ff);
698 max_length -= 2;
699 if (offsetmap)
700 offsetmap++;
701 }
702 }
703 if (offsetmap)
704 *offsetmap = (int)(iptr - (unsigned char*)input);
705 *optr = '\0';
706 return (int)(optr - (unsigned short *)output);
707 }
708
709 static int copy_char8_to_char16(const char *input, PCRE_SCHAR16 *output, int max_length)
710 {
711 unsigned char *iptr = (unsigned char*)input;
712 unsigned short *optr = (unsigned short *)output;
713
714 if (max_length == 0)
715 return 0;
716
717 while (*iptr && max_length > 1) {
718 *optr++ = *iptr++;
719 max_length--;
720 }
721 *optr = '\0';
722 return (int)(optr - (unsigned short *)output);
723 }
724
725 #define REGTEST_MAX_LENGTH 4096
726 static PCRE_SCHAR16 regtest_buf[REGTEST_MAX_LENGTH];
727 static int regtest_offsetmap[REGTEST_MAX_LENGTH];
728
729 #endif /* SUPPORT_PCRE16 */
730
731 static int regression_tests(void)
732 {
733 struct regression_test_case *current = regression_test_cases;
734 const char *error;
735 int i, err_offs, is_succesful;
736 int total = 0;
737 int succesful = 0;
738 int counter = 0;
739 #ifdef SUPPORT_PCRE8
740 pcre *re8;
741 pcre_extra *extra8;
742 int ovector8_1[32];
743 int ovector8_2[32];
744 int return_value8_1, return_value8_2;
745 int utf8 = 0, ucp8 = 0;
746 int disabled_flags8 = 0;
747 #endif
748 #ifdef SUPPORT_PCRE16
749 pcre *re16;
750 pcre_extra *extra16;
751 int ovector16_1[32];
752 int ovector16_2[32];
753 int return_value16_1, return_value16_2;
754 int utf16 = 0, ucp16 = 0;
755 int disabled_flags16 = 0;
756 int length16;
757 #endif
758
759 /* This test compares the behaviour of interpreter and JIT. Although disabling
760 utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is
761 still considered successful from pcre_jit_test point of view. */
762
763 printf("Running JIT regression\n");
764
765 #ifdef SUPPORT_PCRE8
766 pcre_config(PCRE_CONFIG_UTF8, &utf8);
767 pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp8);
768 if (!utf8)
769 disabled_flags8 |= PCRE_UTF8;
770 if (!ucp8)
771 disabled_flags8 |= PCRE_UCP;
772 printf(" in 8 bit mode with utf8 %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled");
773 #endif
774 #ifdef SUPPORT_PCRE16
775 pcre16_config(PCRE_CONFIG_UTF16, &utf16);
776 pcre16_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp16);
777 if (!utf16)
778 disabled_flags16 |= PCRE_UTF8;
779 if (!ucp16)
780 disabled_flags16 |= PCRE_UCP;
781 printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled");
782 #endif
783
784 while (current->pattern) {
785 /* printf("\nPattern: %s :\n", current->pattern); */
786 total++;
787
788 error = NULL;
789 #ifdef SUPPORT_PCRE8
790 re8 = NULL;
791 if (!(current->start_offset & F_NO8))
792 re8 = pcre_compile(current->pattern,
793 current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags8),
794 &error, &err_offs, NULL);
795
796 extra8 = NULL;
797 if (re8) {
798 error = NULL;
799 extra8 = pcre_study(re8, PCRE_STUDY_JIT_COMPILE, &error);
800 if (!extra8) {
801 printf("\n8 bit: Cannot study pattern: %s\n", current->pattern);
802 pcre_free(re8);
803 re8 = NULL;
804 }
805 if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
806 printf("\n8 bit: JIT compiler does not support: %s\n", current->pattern);
807 pcre_free_study(extra8);
808 pcre_free(re8);
809 re8 = NULL;
810 }
811 } else if (utf8 && ucp8 && !(current->start_offset & F_NO8))
812 printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern);
813 #endif
814 #ifdef SUPPORT_PCRE16
815 if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
816 convert_utf8_to_utf16(current->pattern, regtest_buf, NULL, REGTEST_MAX_LENGTH);
817 else
818 copy_char8_to_char16(current->pattern, regtest_buf, REGTEST_MAX_LENGTH);
819
820 re16 = NULL;
821 if (!(current->start_offset & F_NO16))
822 re16 = pcre16_compile(regtest_buf,
823 current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags16),
824 &error, &err_offs, NULL);
825
826 extra16 = NULL;
827 if (re16) {
828 error = NULL;
829 extra16 = pcre16_study(re16, PCRE_STUDY_JIT_COMPILE, &error);
830 if (!extra16) {
831 printf("\n16 bit: Cannot study pattern: %s\n", current->pattern);
832 pcre_free(re16);
833 re16 = NULL;
834 }
835 if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
836 printf("\n16 bit: JIT compiler does not support: %s\n", current->pattern);
837 pcre_free_study(extra16);
838 pcre_free(re16);
839 re16 = NULL;
840 }
841 } else if (utf16 && ucp16 && !(current->start_offset & F_NO16))
842 printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern);
843 #endif
844
845 counter++;
846 if ((counter & 0x3) != 0)
847 setstack(NULL, 1);
848
849 #ifdef SUPPORT_PCRE8
850 return_value8_1 = -1000;
851 return_value8_2 = -1000;
852 for (i = 0; i < 32; ++i)
853 ovector8_1[i] = -2;
854 for (i = 0; i < 32; ++i)
855 ovector8_2[i] = -2;
856 if (re8) {
857 setstack(extra8, 0);
858 return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
859 current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);
860 return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
861 current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_2, 32);
862 }
863 #endif
864
865 #ifdef SUPPORT_PCRE16
866 return_value16_1 = -1000;
867 return_value16_2 = -1000;
868 for (i = 0; i < 32; ++i)
869 ovector16_1[i] = -2;
870 for (i = 0; i < 32; ++i)
871 ovector16_2[i] = -2;
872 if (re16) {
873 setstack(extra16, 0);
874 if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
875 length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);
876 else
877 length16 = copy_char8_to_char16(current->input, regtest_buf, REGTEST_MAX_LENGTH);
878 return_value16_1 = pcre16_exec(re16, extra16, regtest_buf, length16, current->start_offset & OFFSET_MASK,
879 current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_1, 32);
880 return_value16_2 = pcre16_exec(re16, NULL, regtest_buf, length16, current->start_offset & OFFSET_MASK,
881 current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_2, 32);
882 }
883 #endif
884
885 /* If F_DIFF is set, just run the test, but do not compare the results.
886 Segfaults can still be captured. */
887
888 is_succesful = 1;
889 if (!(current->start_offset & F_DIFF)) {
890 #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
891 if (utf8 == utf16 && !(current->start_offset & F_FORCECONV)) {
892 /* All results must be the same. */
893 if (return_value8_1 != return_value8_2 || return_value8_1 != return_value16_1 || return_value8_1 != return_value16_2) {
894 printf("\n8 and 16 bit: Return value differs(%d:%d:%d:%d): [%d] '%s' @ '%s'\n",
895 return_value8_1, return_value8_2, return_value16_1, return_value16_2,
896 total, current->pattern, current->input);
897 is_succesful = 0;
898 } else if (return_value8_1 >= 0) {
899 return_value8_1 *= 2;
900 /* Transform back the results. */
901 if (current->flags & PCRE_UTF8) {
902 for (i = 0; i < return_value8_1; ++i) {
903 if (ovector16_1[i] >= 0)
904 ovector16_1[i] = regtest_offsetmap[ovector16_1[i]];
905 if (ovector16_2[i] >= 0)
906 ovector16_2[i] = regtest_offsetmap[ovector16_2[i]];
907 }
908 }
909
910 for (i = 0; i < return_value8_1; ++i)
911 if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector16_1[i] || ovector8_1[i] != ovector16_2[i]) {
912 printf("\n8 and 16 bit: Ovector[%d] value differs(%d:%d:%d:%d): [%d] '%s' @ '%s' \n",
913 i, ovector8_1[i], ovector8_2[i], ovector16_1[i], ovector16_2[i],
914 total, current->pattern, current->input);
915 is_succesful = 0;
916 }
917 }
918 } else {
919 #endif /* SUPPORT_PCRE8 && SUPPORT_PCRE16 */
920 /* Only the 8 bit and 16 bit results must be equal. */
921 #ifdef SUPPORT_PCRE8
922 if (return_value8_1 != return_value8_2) {
923 printf("\n8 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
924 return_value8_1, return_value8_2, total, current->pattern, current->input);
925 is_succesful = 0;
926 } else if (return_value8_1 >= 0) {
927 return_value8_1 *= 2;
928 for (i = 0; i < return_value8_1; ++i)
929 if (ovector8_1[i] != ovector8_2[i]) {
930 printf("\n8 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s' \n",
931 i, ovector8_1[i], ovector8_2[i], total, current->pattern, current->input);
932 is_succesful = 0;
933 }
934 }
935 #endif
936
937 #ifdef SUPPORT_PCRE16
938 if (return_value16_1 != return_value16_2) {
939 printf("\n16 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
940 return_value16_1, return_value16_2, total, current->pattern, current->input);
941 is_succesful = 0;
942 } else if (return_value16_1 >= 0) {
943 return_value16_1 *= 2;
944 for (i = 0; i < return_value16_1; ++i)
945 if (ovector16_1[i] != ovector16_2[i]) {
946 printf("\n16 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s' \n",
947 i, ovector16_1[i], ovector16_2[i], total, current->pattern, current->input);
948 is_succesful = 0;
949 }
950 }
951 #endif
952
953 #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
954 }
955 #endif /* SUPPORT_PCRE8 && SUPPORT_PCRE16 */
956 }
957
958 if (is_succesful)
959 succesful++;
960
961 #ifdef SUPPORT_PCRE8
962 if (re8) {
963 pcre_free_study(extra8);
964 pcre_free(re8);
965 }
966 #endif
967 #ifdef SUPPORT_PCRE16
968 if (re16) {
969 pcre16_free_study(extra16);
970 pcre_free(re16);
971 }
972 #endif
973
974 /* printf("[%d-%d|%d-%d]%s", ovector8_1[0], ovector8_1[1], ovector16_1[0], ovector16_1[1], (current->flags & PCRE_CASELESS) ? "C" : ""); */
975 printf(".");
976 fflush(stdout);
977 current++;
978 }
979
980 if (total == succesful) {
981 printf("\nAll JIT regression tests are successfully passed.\n");
982 return 0;
983 } else {
984 printf("\nSuccessful test ratio: %d%%\n", succesful * 100 / total);
985 return 1;
986 }
987 }
988
989 /* End of pcre_jit_test.c */

  ViewVC Help
Powered by ViewVC 1.1.5