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