1 /*
2 * This program was generated by testconv.rb.
3 */
4 #include "config.h"
5 #ifdef ONIG_ESCAPE_UCHAR_COLLISION
6 #undef ONIG_ESCAPE_UCHAR_COLLISION
7 #endif
8 #include <stdio.h>
9
10 #ifdef POSIX_TEST
11 #include "onigposix.h"
12 #else
13 #include "oniguruma.h"
14 #endif
15
16 #ifdef HAVE_STRING_H
17 # include <string.h>
18 #else
19 # include <strings.h>
20 #endif
21
22 #define SLEN(s) strlen(s)
23
24 static int nsucc = 0;
25 static int nfail = 0;
26 static int nerror = 0;
27
28 static FILE* err_file;
29
30 #ifndef POSIX_TEST
31 static OnigRegion* region;
32 #endif
33
xx(char * pattern,char * str,int from,int to,int mem,int not)34 static void xx(char* pattern, char* str, int from, int to, int mem, int not)
35 {
36 int r;
37
38 #ifdef POSIX_TEST
39 regex_t reg;
40 char buf[200];
41 regmatch_t pmatch[25];
42
43 r = regcomp(®, pattern, REG_EXTENDED | REG_NEWLINE);
44 if (r) {
45 regerror(r, ®, buf, sizeof(buf));
46 fprintf(err_file, "ERROR: %s\n", buf);
47 nerror++;
48 return ;
49 }
50
51 r = regexec(®, str, reg.re_nsub + 1, pmatch, 0);
52 if (r != 0 && r != REG_NOMATCH) {
53 regerror(r, ®, buf, sizeof(buf));
54 fprintf(err_file, "ERROR: %s\n", buf);
55 nerror++;
56 return ;
57 }
58
59 if (r == REG_NOMATCH) {
60 if (not) {
61 fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str);
62 nsucc++;
63 }
64 else {
65 fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str);
66 nfail++;
67 }
68 }
69 else {
70 if (not) {
71 fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str);
72 nfail++;
73 }
74 else {
75 if (pmatch[mem].rm_so == from && pmatch[mem].rm_eo == to) {
76 fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str);
77 nsucc++;
78 }
79 else {
80 fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str,
81 from, to, pmatch[mem].rm_so, pmatch[mem].rm_eo);
82 nfail++;
83 }
84 }
85 }
86 regfree(®);
87
88 #else
89 regex_t* reg;
90 OnigErrorInfo einfo;
91
92 r = onig_new(®, (UChar* )pattern, (UChar* )(pattern + SLEN(pattern)),
93 ONIG_OPTION_DEFAULT, ONIG_ENCODING_EUC_JP, ONIG_SYNTAX_DEFAULT, &einfo);
94 if (r) {
95 char s[ONIG_MAX_ERROR_MESSAGE_LEN];
96 onig_error_code_to_str((UChar* )s, r, &einfo);
97 fprintf(err_file, "ERROR: %s\n", s);
98 nerror++;
99 return ;
100 }
101
102 r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)),
103 (UChar* )str, (UChar* )(str + SLEN(str)),
104 region, ONIG_OPTION_NONE);
105 if (r < ONIG_MISMATCH) {
106 char s[ONIG_MAX_ERROR_MESSAGE_LEN];
107 onig_error_code_to_str((UChar* )s, r);
108 fprintf(err_file, "ERROR: %s\n", s);
109 nerror++;
110 return ;
111 }
112
113 if (r == ONIG_MISMATCH) {
114 if (not) {
115 fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str);
116 nsucc++;
117 }
118 else {
119 fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str);
120 nfail++;
121 }
122 }
123 else {
124 if (not) {
125 fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str);
126 nfail++;
127 }
128 else {
129 if (region->beg[mem] == from && region->end[mem] == to) {
130 fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str);
131 nsucc++;
132 }
133 else {
134 fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str,
135 from, to, region->beg[mem], region->end[mem]);
136 nfail++;
137 }
138 }
139 }
140 onig_free(reg);
141 #endif
142 }
143
x2(char * pattern,char * str,int from,int to)144 static void x2(char* pattern, char* str, int from, int to)
145 {
146 xx(pattern, str, from, to, 0, 0);
147 }
148
x3(char * pattern,char * str,int from,int to,int mem)149 static void x3(char* pattern, char* str, int from, int to, int mem)
150 {
151 xx(pattern, str, from, to, mem, 0);
152 }
153
n(char * pattern,char * str)154 static void n(char* pattern, char* str)
155 {
156 xx(pattern, str, 0, 0, 0, 1);
157 }
158
main(int argc,char * argv[])159 extern int main(int argc, char* argv[])
160 {
161 err_file = stdout;
162
163 #ifdef POSIX_TEST
164 reg_set_encoding(REG_POSIX_ENCODING_EUC_JP);
165 #else
166 region = onig_region_new();
167 #endif
168
169 x2("", "", 0, 0);
170 x2("^", "", 0, 0);
171 x2("$", "", 0, 0);
172 x2("\\G", "", 0, 0);
173 x2("\\A", "", 0, 0);
174 x2("\\Z", "", 0, 0);
175 x2("\\z", "", 0, 0);
176 x2("^$", "", 0, 0);
177 x2("\\ca", "\001", 0, 1);
178 x2("\\C-b", "\002", 0, 1);
179 x2("\\c\\\\", "\034", 0, 1);
180 x2("q[\\c\\\\]", "q\034", 0, 2);
181 x2("", "a", 0, 0);
182 x2("a", "a", 0, 1);
183 x2("\\x61", "a", 0, 1);
184 x2("aa", "aa", 0, 2);
185 x2("aaa", "aaa", 0, 3);
186 x2("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, 35);
187 x2("ab", "ab", 0, 2);
188 x2("b", "ab", 1, 2);
189 x2("bc", "abc", 1, 3);
190 x2("(?i:#RET#)", "#INS##RET#", 5, 10);
191 x2("\\17", "\017", 0, 1);
192 x2("\\x1f", "\x1f", 0, 1);
193 x2("a(?#....\\\\JJJJ)b", "ab", 0, 2);
194 x2("(?x) G (o O(?-x)oO) g L", "GoOoOgLe", 0, 7);
195 x2(".", "a", 0, 1);
196 n(".", "");
197 x2("..", "ab", 0, 2);
198 x2("\\w", "e", 0, 1);
199 n("\\W", "e");
200 x2("\\s", " ", 0, 1);
201 x2("\\S", "b", 0, 1);
202 x2("\\d", "4", 0, 1);
203 n("\\D", "4");
204 x2("\\b", "z ", 0, 0);
205 x2("\\b", " z", 1, 1);
206 x2("\\B", "zz ", 1, 1);
207 x2("\\B", "z ", 2, 2);
208 x2("\\B", " z", 0, 0);
209 x2("[ab]", "b", 0, 1);
210 n("[ab]", "c");
211 x2("[a-z]", "t", 0, 1);
212 n("[^a]", "a");
213 x2("[^a]", "\n", 0, 1);
214 x2("[]]", "]", 0, 1);
215 n("[^]]", "]");
216 x2("[\\^]+", "0^^1", 1, 3);
217 x2("[b-]", "b", 0, 1);
218 x2("[b-]", "-", 0, 1);
219 x2("[\\w]", "z", 0, 1);
220 n("[\\w]", " ");
221 x2("[\\W]", "b$", 1, 2);
222 x2("[\\d]", "5", 0, 1);
223 n("[\\d]", "e");
224 x2("[\\D]", "t", 0, 1);
225 n("[\\D]", "3");
226 x2("[\\s]", " ", 0, 1);
227 n("[\\s]", "a");
228 x2("[\\S]", "b", 0, 1);
229 n("[\\S]", " ");
230 x2("[\\w\\d]", "2", 0, 1);
231 n("[\\w\\d]", " ");
232 x2("[[:upper:]]", "B", 0, 1);
233 x2("[*[:xdigit:]+]", "+", 0, 1);
234 x2("[*[:xdigit:]+]", "GHIKK-9+*", 6, 7);
235 x2("[*[:xdigit:]+]", "-@^+", 3, 4);
236 n("[[:upper]]", "A");
237 x2("[[:upper]]", ":", 0, 1);
238 x2("[\\044-\\047]", "\046", 0, 1);
239 x2("[\\x5a-\\x5c]", "\x5b", 0, 1);
240 x2("[\\x6A-\\x6D]", "\x6c", 0, 1);
241 n("[\\x6A-\\x6D]", "\x6E");
242 n("^[0-9A-F]+ 0+ UNDEF ", "75F 00000000 SECT14A notype () External | _rb_apply");
243 x2("[\\[]", "[", 0, 1);
244 x2("[\\]]", "]", 0, 1);
245 x2("[&]", "&", 0, 1);
246 x2("[[ab]]", "b", 0, 1);
247 x2("[[ab]c]", "c", 0, 1);
248 n("[[^a]]", "a");
249 n("[^[a]]", "a");
250 x2("[[ab]&&bc]", "b", 0, 1);
251 n("[[ab]&&bc]", "a");
252 n("[[ab]&&bc]", "c");
253 x2("[a-z&&b-y&&c-x]", "w", 0, 1);
254 n("[^a-z&&b-y&&c-x]", "w");
255 x2("[[^a&&a]&&a-z]", "b", 0, 1);
256 n("[[^a&&a]&&a-z]", "a");
257 x2("[[^a-z&&bcdef]&&[^c-g]]", "h", 0, 1);
258 n("[[^a-z&&bcdef]&&[^c-g]]", "c");
259 x2("[^[^abc]&&[^cde]]", "c", 0, 1);
260 x2("[^[^abc]&&[^cde]]", "e", 0, 1);
261 n("[^[^abc]&&[^cde]]", "f");
262 x2("[a-&&-a]", "-", 0, 1);
263 n("[a\\-&&\\-a]", "&");
264 n("\\wabc", " abc");
265 x2("a\\Wbc", "a bc", 0, 4);
266 x2("a.b.c", "aabbc", 0, 5);
267 x2(".\\wb\\W..c", "abb bcc", 0, 7);
268 x2("\\s\\wzzz", " zzzz", 0, 5);
269 x2("aa.b", "aabb", 0, 4);
270 n(".a", "ab");
271 x2(".a", "aa", 0, 2);
272 x2("^a", "a", 0, 1);
273 x2("^a$", "a", 0, 1);
274 x2("^\\w$", "a", 0, 1);
275 n("^\\w$", " ");
276 x2("^\\wab$", "zab", 0, 3);
277 x2("^\\wabcdef$", "zabcdef", 0, 7);
278 x2("^\\w...def$", "zabcdef", 0, 7);
279 x2("\\w\\w\\s\\Waaa\\d", "aa aaa4", 0, 8);
280 x2("\\A\\Z", "", 0, 0);
281 x2("\\Axyz", "xyz", 0, 3);
282 x2("xyz\\Z", "xyz", 0, 3);
283 x2("xyz\\z", "xyz", 0, 3);
284 x2("a\\Z", "a", 0, 1);
285 x2("\\Gaz", "az", 0, 2);
286 n("\\Gz", "bza");
287 n("az\\G", "az");
288 n("az\\A", "az");
289 n("a\\Az", "az");
290 x2("\\^\\$", "^$", 0, 2);
291 x2("^x?y", "xy", 0, 2);
292 x2("^(x?y)", "xy", 0, 2);
293 x2("\\w", "_", 0, 1);
294 n("\\W", "_");
295 x2("(?=z)z", "z", 0, 1);
296 n("(?=z).", "a");
297 x2("(?!z)a", "a", 0, 1);
298 n("(?!z)a", "z");
299 x2("(?i:a)", "a", 0, 1);
300 x2("(?i:a)", "A", 0, 1);
301 x2("(?i:A)", "a", 0, 1);
302 n("(?i:A)", "b");
303 x2("(?i:[A-Z])", "a", 0, 1);
304 x2("(?i:[f-m])", "H", 0, 1);
305 x2("(?i:[f-m])", "h", 0, 1);
306 n("(?i:[f-m])", "e");
307 x2("(?i:[A-c])", "D", 0, 1);
308 n("(?i:[^a-z])", "A");
309 n("(?i:[^a-z])", "a");
310 x2("(?i:[!-k])", "Z", 0, 1);
311 x2("(?i:[!-k])", "7", 0, 1);
312 x2("(?i:[T-}])", "b", 0, 1);
313 x2("(?i:[T-}])", "{", 0, 1);
314 x2("(?i:\\?a)", "?A", 0, 2);
315 x2("(?i:\\*A)", "*a", 0, 2);
316 n(".", "\n");
317 x2("(?m:.)", "\n", 0, 1);
318 x2("(?m:a.)", "a\n", 0, 2);
319 x2("(?m:.b)", "a\nb", 1, 3);
320 x2(".*abc", "dddabdd\nddabc", 8, 13);
321 x2("(?m:.*abc)", "dddabddabc", 0, 10);
322 n("(?i)(?-i)a", "A");
323 n("(?i)(?-i:a)", "A");
324 x2("a?", "", 0, 0);
325 x2("a?", "b", 0, 0);
326 x2("a?", "a", 0, 1);
327 x2("a*", "", 0, 0);
328 x2("a*", "a", 0, 1);
329 x2("a*", "aaa", 0, 3);
330 x2("a*", "baaaa", 0, 0);
331 n("a+", "");
332 x2("a+", "a", 0, 1);
333 x2("a+", "aaaa", 0, 4);
334 x2("a+", "aabbb", 0, 2);
335 x2("a+", "baaaa", 1, 5);
336 x2(".?", "", 0, 0);
337 x2(".?", "f", 0, 1);
338 x2(".?", "\n", 0, 0);
339 x2(".*", "", 0, 0);
340 x2(".*", "abcde", 0, 5);
341 x2(".+", "z", 0, 1);
342 x2(".+", "zdswer\n", 0, 6);
343 x2("(.*)a\\1f", "babfbac", 0, 4);
344 x2("(.*)a\\1f", "bacbabf", 3, 7);
345 x2("((.*)a\\2f)", "bacbabf", 3, 7);
346 x2("(.*)a\\1f", "baczzzzzz\nbazz\nzzzzbabf", 19, 23);
347 x2("a|b", "a", 0, 1);
348 x2("a|b", "b", 0, 1);
349 x2("|a", "a", 0, 0);
350 x2("(|a)", "a", 0, 0);
351 x2("ab|bc", "ab", 0, 2);
352 x2("ab|bc", "bc", 0, 2);
353 x2("z(?:ab|bc)", "zbc", 0, 3);
354 x2("a(?:ab|bc)c", "aabc", 0, 4);
355 x2("ab|(?:ac|az)", "az", 0, 2);
356 x2("a|b|c", "dc", 1, 2);
357 x2("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "pqr", 0, 2);
358 n("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "mn");
359 x2("a|^z", "ba", 1, 2);
360 x2("a|^z", "za", 0, 1);
361 x2("a|\\Gz", "bza", 2, 3);
362 x2("a|\\Gz", "za", 0, 1);
363 x2("a|\\Az", "bza", 2, 3);
364 x2("a|\\Az", "za", 0, 1);
365 x2("a|b\\Z", "ba", 1, 2);
366 x2("a|b\\Z", "b", 0, 1);
367 x2("a|b\\z", "ba", 1, 2);
368 x2("a|b\\z", "b", 0, 1);
369 x2("\\w|\\s", " ", 0, 1);
370 n("\\w|\\w", " ");
371 x2("\\w|%", "%", 0, 1);
372 x2("\\w|[&$]", "&", 0, 1);
373 x2("[b-d]|[^e-z]", "a", 0, 1);
374 x2("(?:a|[c-f])|bz", "dz", 0, 1);
375 x2("(?:a|[c-f])|bz", "bz", 0, 2);
376 x2("abc|(?=zz)..f", "zzf", 0, 3);
377 x2("abc|(?!zz)..f", "abf", 0, 3);
378 x2("(?=za)..a|(?=zz)..a", "zza", 0, 3);
379 n("(?>a|abd)c", "abdc");
380 x2("(?>abd|a)c", "abdc", 0, 4);
381 x2("a?|b", "a", 0, 1);
382 x2("a?|b", "b", 0, 0);
383 x2("a?|b", "", 0, 0);
384 x2("a*|b", "aa", 0, 2);
385 x2("a*|b*", "ba", 0, 0);
386 x2("a*|b*", "ab", 0, 1);
387 x2("a+|b*", "", 0, 0);
388 x2("a+|b*", "bbb", 0, 3);
389 x2("a+|b*", "abbb", 0, 1);
390 n("a+|b+", "");
391 x2("(a|b)?", "b", 0, 1);
392 x2("(a|b)*", "ba", 0, 2);
393 x2("(a|b)+", "bab", 0, 3);
394 x2("(ab|ca)+", "caabbc", 0, 4);
395 x2("(ab|ca)+", "aabca", 1, 5);
396 x2("(ab|ca)+", "abzca", 0, 2);
397 x2("(a|bab)+", "ababa", 0, 5);
398 x2("(a|bab)+", "ba", 1, 2);
399 x2("(a|bab)+", "baaaba", 1, 4);
400 x2("(?:a|b)(?:a|b)", "ab", 0, 2);
401 x2("(?:a*|b*)(?:a*|b*)", "aaabbb", 0, 3);
402 x2("(?:a*|b*)(?:a+|b+)", "aaabbb", 0, 6);
403 x2("(?:a+|b+){2}", "aaabbb", 0, 6);
404 x2("h{0,}", "hhhh", 0, 4);
405 x2("(?:a+|b+){1,2}", "aaabbb", 0, 6);
406 n("ax{2}*a", "0axxxa1");
407 n("a.{0,2}a", "0aXXXa0");
408 n("a.{0,2}?a", "0aXXXa0");
409 n("a.{0,2}?a", "0aXXXXa0");
410 x2("^a{2,}?a$", "aaa", 0, 3);
411 x2("^[a-z]{2,}?$", "aaa", 0, 3);
412 x2("(?:a+|\\Ab*)cc", "cc", 0, 2);
413 n("(?:a+|\\Ab*)cc", "abcc");
414 x2("(?:^a+|b+)*c", "aabbbabc", 6, 8);
415 x2("(?:^a+|b+)*c", "aabbbbc", 0, 7);
416 x2("a|(?i)c", "C", 0, 1);
417 x2("(?i)c|a", "C", 0, 1);
418 x2("(?i)c|a", "A", 0, 1);
419 x2("(?i:c)|a", "C", 0, 1);
420 n("(?i:c)|a", "A");
421 x2("[abc]?", "abc", 0, 1);
422 x2("[abc]*", "abc", 0, 3);
423 x2("[^abc]*", "abc", 0, 0);
424 n("[^abc]+", "abc");
425 x2("a?\?", "aaa", 0, 0);
426 x2("ba?\?b", "bab", 0, 3);
427 x2("a*?", "aaa", 0, 0);
428 x2("ba*?", "baa", 0, 1);
429 x2("ba*?b", "baab", 0, 4);
430 x2("a+?", "aaa", 0, 1);
431 x2("ba+?", "baa", 0, 2);
432 x2("ba+?b", "baab", 0, 4);
433 x2("(?:a?)?\?", "a", 0, 0);
434 x2("(?:a?\?)?", "a", 0, 0);
435 x2("(?:a?)+?", "aaa", 0, 1);
436 x2("(?:a+)?\?", "aaa", 0, 0);
437 x2("(?:a+)?\?b", "aaab", 0, 4);
438 x2("(?:ab)?{2}", "", 0, 0);
439 x2("(?:ab)?{2}", "ababa", 0, 4);
440 x2("(?:ab)*{0}", "ababa", 0, 0);
441 x2("(?:ab){3,}", "abababab", 0, 8);
442 n("(?:ab){3,}", "abab");
443 x2("(?:ab){2,4}", "ababab", 0, 6);
444 x2("(?:ab){2,4}", "ababababab", 0, 8);
445 x2("(?:ab){2,4}?", "ababababab", 0, 4);
446 x2("(?:ab){,}", "ab{,}", 0, 5);
447 x2("(?:abc)+?{2}", "abcabcabc", 0, 6);
448 x2("(?:X*)(?i:xa)", "XXXa", 0, 4);
449 x2("(d+)([^abc]z)", "dddz", 0, 4);
450 x2("([^abc]*)([^abc]z)", "dddz", 0, 4);
451 x2("(\\w+)(\\wz)", "dddz", 0, 4);
452 x3("(a)", "a", 0, 1, 1);
453 x3("(ab)", "ab", 0, 2, 1);
454 x2("((ab))", "ab", 0, 2);
455 x3("((ab))", "ab", 0, 2, 1);
456 x3("((ab))", "ab", 0, 2, 2);
457 x3("((((((((((((((((((((ab))))))))))))))))))))", "ab", 0, 2, 20);
458 x3("(ab)(cd)", "abcd", 0, 2, 1);
459 x3("(ab)(cd)", "abcd", 2, 4, 2);
460 x3("()(a)bc(def)ghijk", "abcdefghijk", 3, 6, 3);
461 x3("(()(a)bc(def)ghijk)", "abcdefghijk", 3, 6, 4);
462 x2("(^a)", "a", 0, 1);
463 x3("(a)|(a)", "ba", 1, 2, 1);
464 x3("(^a)|(a)", "ba", 1, 2, 2);
465 x3("(a?)", "aaa", 0, 1, 1);
466 x3("(a*)", "aaa", 0, 3, 1);
467 x3("(a*)", "", 0, 0, 1);
468 x3("(a+)", "aaaaaaa", 0, 7, 1);
469 x3("(a+|b*)", "bbbaa", 0, 3, 1);
470 x3("(a+|b?)", "bbbaa", 0, 1, 1);
471 x3("(abc)?", "abc", 0, 3, 1);
472 x3("(abc)*", "abc", 0, 3, 1);
473 x3("(abc)+", "abc", 0, 3, 1);
474 x3("(xyz|abc)+", "abc", 0, 3, 1);
475 x3("([xyz][abc]|abc)+", "abc", 0, 3, 1);
476 x3("((?i:abc))", "AbC", 0, 3, 1);
477 x2("(abc)(?i:\\1)", "abcABC", 0, 6);
478 x3("((?m:a.c))", "a\nc", 0, 3, 1);
479 x3("((?=az)a)", "azb", 0, 1, 1);
480 x3("abc|(.abd)", "zabd", 0, 4, 1);
481 x2("(?:abc)|(ABC)", "abc", 0, 3);
482 x3("(?i:(abc))|(zzz)", "ABC", 0, 3, 1);
483 x3("a*(.)", "aaaaz", 4, 5, 1);
484 x3("a*?(.)", "aaaaz", 0, 1, 1);
485 x3("a*?(c)", "aaaac", 4, 5, 1);
486 x3("[bcd]a*(.)", "caaaaz", 5, 6, 1);
487 x3("(\\Abb)cc", "bbcc", 0, 2, 1);
488 n("(\\Abb)cc", "zbbcc");
489 x3("(^bb)cc", "bbcc", 0, 2, 1);
490 n("(^bb)cc", "zbbcc");
491 x3("cc(bb$)", "ccbb", 2, 4, 1);
492 n("cc(bb$)", "ccbbb");
493 n("(\\1)", "");
494 n("\\1(a)", "aa");
495 n("(a(b)\\1)\\2+", "ababb");
496 n("(?:(?:\\1|z)(a))+$", "zaa");
497 x2("(?:(?:\\1|z)(a))+$", "zaaa", 0, 4);
498 x2("(a)(?=\\1)", "aa", 0, 1);
499 n("(a)$|\\1", "az");
500 x2("(a)\\1", "aa", 0, 2);
501 n("(a)\\1", "ab");
502 x2("(a?)\\1", "aa", 0, 2);
503 x2("(a?\?)\\1", "aa", 0, 0);
504 x2("(a*)\\1", "aaaaa", 0, 4);
505 x3("(a*)\\1", "aaaaa", 0, 2, 1);
506 x2("a(b*)\\1", "abbbb", 0, 5);
507 x2("a(b*)\\1", "ab", 0, 1);
508 x2("(a*)(b*)\\1\\2", "aaabbaaabb", 0, 10);
509 x2("(a*)(b*)\\2", "aaabbbb", 0, 7);
510 x2("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 8);
511 x3("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 3, 7);
512 x2("(a)(b)(c)\\2\\1\\3", "abcbac", 0, 6);
513 x2("([a-d])\\1", "cc", 0, 2);
514 x2("(\\w\\d\\s)\\1", "f5 f5 ", 0, 6);
515 n("(\\w\\d\\s)\\1", "f5 f5");
516 x2("(who|[a-c]{3})\\1", "whowho", 0, 6);
517 x2("...(who|[a-c]{3})\\1", "abcwhowho", 0, 9);
518 x2("(who|[a-c]{3})\\1", "cbccbc", 0, 6);
519 x2("(^a)\\1", "aa", 0, 2);
520 n("(^a)\\1", "baa");
521 n("(a$)\\1", "aa");
522 n("(ab\\Z)\\1", "ab");
523 x2("(a*\\Z)\\1", "a", 1, 1);
524 x2(".(a*\\Z)\\1", "ba", 1, 2);
525 x3("(.(abc)\\2)", "zabcabc", 0, 7, 1);
526 x3("(.(..\\d.)\\2)", "z12341234", 0, 9, 1);
527 x2("((?i:az))\\1", "AzAz", 0, 4);
528 n("((?i:az))\\1", "Azaz");
529 x2("(?<=a)b", "ab", 1, 2);
530 n("(?<=a)b", "bb");
531 x2("(?<=a|b)b", "bb", 1, 2);
532 x2("(?<=a|bc)b", "bcb", 2, 3);
533 x2("(?<=a|bc)b", "ab", 1, 2);
534 x2("(?<=a|bc||defghij|klmnopq|r)z", "rz", 1, 2);
535 x2("(a)\\g<1>", "aa", 0, 2);
536 x2("(?<!a)b", "cb", 1, 2);
537 n("(?<!a)b", "ab");
538 x2("(?<!a|bc)b", "bbb", 0, 1);
539 n("(?<!a|bc)z", "bcz");
540 x2("(?<name1>a)", "a", 0, 1);
541 x2("(?<name_2>ab)\\g<name_2>", "abab", 0, 4);
542 x2("(?<name_3>.zv.)\\k<name_3>", "azvbazvb", 0, 8);
543 x2("(?<=\\g<ab>)|-\\zEND (?<ab>XyZ)", "XyZ", 3, 3);
544 x2("(?<n>|a\\g<n>)+", "", 0, 0);
545 x2("(?<n>|\\(\\g<n>\\))+$", "()(())", 0, 6);
546 x3("\\g<n>(?<n>.){0}", "X", 0, 1, 1);
547 x2("\\g<n>(abc|df(?<n>.YZ){2,8}){0}", "XYZ", 0, 3);
548 x2("\\A(?<n>(a\\g<n>)|)\\z", "aaaa", 0, 4);
549 x2("(?<n>|\\g<m>\\g<n>)\\z|\\zEND (?<m>a|(b)\\g<m>)", "bbbbabba", 0, 8);
550 x2("(?<name1240>\\w+\\sx)a+\\k<name1240>", " fg xaaaaaaaafg x", 2, 18);
551 x3("(z)()()(?<_9>a)\\g<_9>", "zaa", 2, 3, 1);
552 x2("(.)(((?<_>a)))\\k<_>", "zaa", 0, 3);
553 x2("((?<name1>\\d)|(?<name2>\\w))(\\k<name1>|\\k<name2>)", "ff", 0, 2);
554 x2("(?:(?<x>)|(?<x>efg))\\k<x>", "", 0, 0);
555 x2("(?:(?<x>abc)|(?<x>efg))\\k<x>", "abcefgefg", 3, 9);
556 n("(?:(?<x>abc)|(?<x>efg))\\k<x>", "abcefg");
557 x2("(?:(?<n1>.)|(?<n1>..)|(?<n1>...)|(?<n1>....)|(?<n1>.....)|(?<n1>......)|(?<n1>.......)|(?<n1>........)|(?<n1>.........)|(?<n1>..........)|(?<n1>...........)|(?<n1>............)|(?<n1>.............)|(?<n1>..............))\\k<n1>$", "a-pyumpyum", 2, 10);
558 x3("(?:(?<n1>.)|(?<n1>..)|(?<n1>...)|(?<n1>....)|(?<n1>.....)|(?<n1>......)|(?<n1>.......)|(?<n1>........)|(?<n1>.........)|(?<n1>..........)|(?<n1>...........)|(?<n1>............)|(?<n1>.............)|(?<n1>..............))\\k<n1>$", "xxxxabcdefghijklmnabcdefghijklmn", 4, 18, 14);
559 x3("(?<name1>)(?<name2>)(?<name3>)(?<name4>)(?<name5>)(?<name6>)(?<name7>)(?<name8>)(?<name9>)(?<name10>)(?<name11>)(?<name12>)(?<name13>)(?<name14>)(?<name15>)(?<name16>aaa)(?<name17>)$", "aaa", 0, 3, 16);
560 x2("(?<foo>a|\\(\\g<foo>\\))", "a", 0, 1);
561 x2("(?<foo>a|\\(\\g<foo>\\))", "((((((a))))))", 0, 13);
562 x3("(?<foo>a|\\(\\g<foo>\\))", "((((((((a))))))))", 0, 17, 1);
563 x2("\\g<bar>|\\zEND(?<bar>.*abc$)", "abcxxxabc", 0, 9);
564 x2("\\g<1>|\\zEND(.a.)", "bac", 0, 3);
565 x3("\\g<_A>\\g<_A>|\\zEND(.a.)(?<_A>.b.)", "xbxyby", 3, 6, 1);
566 x2("\\A(?:\\g<pon>|\\g<pan>|\\zEND (?<pan>a|c\\g<pon>c)(?<pon>b|d\\g<pan>d))$", "cdcbcdc", 0, 7);
567 x2("\\A(?<n>|a\\g<m>)\\z|\\zEND (?<m>\\g<n>)", "aaaa", 0, 4);
568 x2("(?<n>(a|b\\g<n>c){3,5})", "baaaaca", 1, 5);
569 x2("(?<n>(a|b\\g<n>c){3,5})", "baaaacaaaaa", 0, 10);
570 x2("(?<pare>\\(([^\\(\\)]++|\\g<pare>)*+\\))", "((a))", 0, 5);
571 x2("()*\\1", "", 0, 0);
572 x2("(?:()|())*\\1\\2", "", 0, 0);
573 x3("(?:\\1a|())*", "a", 0, 0, 1);
574 x2("x((.)*)*x", "0x1x2x3", 1, 6);
575 x2("x((.)*)*x(?i:\\1)\\Z", "0x1x2x1X2", 1, 9);
576 x2("(?:()|()|()|()|()|())*\\2\\5", "", 0, 0);
577 x2("(?:()|()|()|(x)|()|())*\\2b\\5", "b", 0, 1);
578 x2("\\xED\\xF2", "\xed\xf2", 0, 2);
579 x2("", "��", 0, 0);
580 x2("��", "��", 0, 2);
581 n("��", "��");
582 x2("����", "����", 0, 4);
583 x2("������", "������", 0, 6);
584 x2("����������������������������������������������������������������������", "����������������������������������������������������������������������", 0, 70);
585 x2("��", "����", 2, 4);
586 x2("����", "������", 2, 6);
587 x2("\\xca\\xb8", "\xca\xb8", 0, 2);
588 x2(".", "��", 0, 2);
589 x2("..", "����", 0, 4);
590 x2("\\w", "��", 0, 2);
591 n("\\W", "��");
592 x2("[\\W]", "��$", 2, 3);
593 x2("\\S", "��", 0, 2);
594 x2("\\S", "��", 0, 2);
595 x2("\\b", "�� ", 0, 0);
596 x2("\\b", " ��", 1, 1);
597 x2("\\B", "���� ", 2, 2);
598 x2("\\B", "�� ", 3, 3);
599 x2("\\B", " ��", 0, 0);
600 x2("[����]", "��", 0, 2);
601 n("[�ʤ�]", "��");
602 x2("[��-��]", "��", 0, 2);
603 n("[^��]", "��");
604 x2("[\\w]", "��", 0, 2);
605 n("[\\d]", "��");
606 x2("[\\D]", "��", 0, 2);
607 n("[\\s]", "��");
608 x2("[\\S]", "��", 0, 2);
609 x2("[\\w\\d]", "��", 0, 2);
610 x2("[\\w\\d]", " ��", 3, 5);
611 n("\\w����", " ����");
612 x2("��\\W��", "�� ��", 0, 5);
613 x2("��.��.��", "����������", 0, 10);
614 x2(".\\w��\\W..��", "������ ������", 0, 13);
615 x2("\\s\\w������", " ��������", 0, 9);
616 x2("����.��", "��������", 0, 8);
617 n(".��", "����");
618 x2(".��", "����", 0, 4);
619 x2("^��", "��", 0, 2);
620 x2("^��$", "��", 0, 2);
621 x2("^\\w$", "��", 0, 2);
622 x2("^\\w����������$", "z����������", 0, 11);
623 x2("^\\w...������$", "z������������", 0, 13);
624 x2("\\w\\w\\s\\W������\\d", "a�� ������4", 0, 12);
625 x2("\\A������", "������", 0, 6);
626 x2("����\\Z", "����", 0, 6);
627 x2("������\\z", "������", 0, 6);
628 x2("������\\Z", "������\n", 0, 6);
629 x2("\\G�ݤ�", "�ݤ�", 0, 4);
630 n("\\G��", "������");
631 n("�Ȥ�\\G", "�Ȥ�");
632 n("�ޤ�\\A", "�ޤ�");
633 n("��\\A��", "�ޤ�");
634 x2("(?=��)��", "��", 0, 2);
635 n("(?=��).", "��");
636 x2("(?!��)��", "��", 0, 2);
637 n("(?!��)��", "��");
638 x2("(?i:��)", "��", 0, 2);
639 x2("(?i:�֤�)", "�֤�", 0, 4);
640 n("(?i:��)", "��");
641 x2("(?m:��.)", "��\n", 0, 3);
642 x2("(?m:.��)", "��\n��", 2, 5);
643 x2("��?", "", 0, 0);
644 x2("��?", "��", 0, 0);
645 x2("��?", "��", 0, 2);
646 x2("��*", "", 0, 0);
647 x2("��*", "��", 0, 2);
648 x2("��*", "�һһ�", 0, 6);
649 x2("��*", "����������", 0, 0);
650 n("��+", "");
651 x2("��+", "��", 0, 2);
652 x2("��+", "��������", 0, 8);
653 x2("��+", "����������", 0, 4);
654 x2("��+", "����������", 2, 10);
655 x2(".?", "��", 0, 2);
656 x2(".*", "�ѤԤפ�", 0, 8);
657 x2(".+", "��", 0, 2);
658 x2(".+", "��������\n", 0, 8);
659 x2("��|��", "��", 0, 2);
660 x2("��|��", "��", 0, 2);
661 x2("����|����", "����", 0, 4);
662 x2("����|����", "����", 0, 4);
663 x2("��(?:����|����)", "��", 0, 6);
664 x2("��(?:����|����)��", "����", 0, 8);
665 x2("����|(?:����|����)", "����", 0, 4);
666 x2("��|��|��", "����", 2, 4);
667 x2("��|��|����|������|��|������|������|��|����|�ĤƤȤʤ�|�̤�", "������", 0, 6);
668 n("��|��|����|������|��|������|������|��|����|�ĤƤȤʤ�|�̤�", "����");
669 x2("��|^��", "�֤�", 2, 4);
670 x2("��|^��", "��", 0, 2);
671 x2("��|\\G��", "���ֵ�", 4, 6);
672 x2("��|\\G��", "�ֵ�", 0, 2);
673 x2("��|\\A��", "b�ֵ�", 3, 5);
674 x2("��|\\A��", "��", 0, 2);
675 x2("��|��\\Z", "�ֵ�", 2, 4);
676 x2("��|��\\Z", "��", 0, 2);
677 x2("��|��\\Z", "��\n", 0, 2);
678 x2("��|��\\z", "�ֵ�", 2, 4);
679 x2("��|��\\z", "��", 0, 2);
680 x2("\\w|\\s", "��", 0, 2);
681 x2("\\w|%", "%��", 0, 1);
682 x2("\\w|[&$]", "��&", 0, 2);
683 x2("[��-��]", "��", 0, 2);
684 x2("[��-��]|[^��-��]", "��", 0, 2);
685 x2("[��-��]|[^��-��]", "��", 0, 2);
686 x2("[^��]", "\n", 0, 1);
687 x2("(?:��|[��-��])|����", "����", 0, 2);
688 x2("(?:��|[��-��])|����", "����", 0, 4);
689 x2("������|(?=����)..��", "������", 0, 6);
690 x2("������|(?!����)..��", "������", 0, 6);
691 x2("(?=��)..��|(?=���)..��", "���", 0, 6);
692 x2("(?<=��|����)��", "������", 4, 6);
693 n("(?>��|������)��", "��������");
694 x2("(?>������|��)��", "��������", 0, 8);
695 x2("��?|��", "��", 0, 2);
696 x2("��?|��", "��", 0, 0);
697 x2("��?|��", "", 0, 0);
698 x2("��*|��", "����", 0, 4);
699 x2("��*|��*", "����", 0, 0);
700 x2("��*|��*", "����", 0, 2);
701 x2("[a��]*|��*", "a��������", 0, 3);
702 x2("��+|��*", "", 0, 0);
703 x2("��+|��*", "������", 0, 6);
704 x2("��+|��*", "��������", 0, 2);
705 x2("��+|��*", "a��������", 0, 0);
706 n("��+|��+", "");
707 x2("(��|��)?", "��", 0, 2);
708 x2("(��|��)*", "����", 0, 4);
709 x2("(��|��)+", "������", 0, 6);
710 x2("(����|����)+", "������������", 0, 8);
711 x2("(����|����)+", "������������", 4, 12);
712 x2("(����|����)+", "����������", 2, 10);
713 x2("(����|����)+", "������", 0, 4);
714 x2("(����|����)+", "$$zzzz������", 6, 10);
715 x2("(��|������)+", "����������", 0, 10);
716 x2("(��|������)+", "����", 2, 4);
717 x2("(��|������)+", "������������", 2, 8);
718 x2("(?:��|��)(?:��|��)", "����", 0, 4);
719 x2("(?:��*|��*)(?:��*|��*)", "������������", 0, 6);
720 x2("(?:��*|��*)(?:��+|��+)", "������������", 0, 12);
721 x2("(?:��+|��+){2}", "������������", 0, 12);
722 x2("(?:��+|��+){1,2}", "������������", 0, 12);
723 x2("(?:��+|\\A��*)����", "����", 0, 4);
724 n("(?:��+|\\A��*)����", "��������");
725 x2("(?:^��+|��+)*��", "����������������", 12, 16);
726 x2("(?:^��+|��+)*��", "��������������", 0, 14);
727 x2("��{0,}", "��������", 0, 8);
728 x2("��|(?i)c", "C", 0, 1);
729 x2("(?i)c|��", "C", 0, 1);
730 x2("(?i:��)|a", "a", 0, 1);
731 n("(?i:��)|a", "A");
732 x2("[������]?", "������", 0, 2);
733 x2("[������]*", "������", 0, 6);
734 x2("[^������]*", "������", 0, 0);
735 n("[^������]+", "������");
736 x2("��?\?", "������", 0, 0);
737 x2("����?\?��", "������", 0, 6);
738 x2("��*?", "������", 0, 0);
739 x2("����*?", "������", 0, 2);
740 x2("����*?��", "��������", 0, 8);
741 x2("��+?", "������", 0, 2);
742 x2("����+?", "������", 0, 4);
743 x2("����+?��", "��������", 0, 8);
744 x2("(?:ŷ?)?\?", "ŷ", 0, 0);
745 x2("(?:ŷ?\?)?", "ŷ", 0, 0);
746 x2("(?:̴?)+?", "̴̴̴", 0, 2);
747 x2("(?:��+)?\?", "������", 0, 0);
748 x2("(?:��+)?\?��", "��������", 0, 8);
749 x2("(?:����)?{2}", "", 0, 0);
750 x2("(?:����)?{2}", "���ֵ��ֵ�", 0, 8);
751 x2("(?:����)*{0}", "���ֵ��ֵ�", 0, 0);
752 x2("(?:����){3,}", "���ֵ��ֵ��ֵ���", 0, 16);
753 n("(?:����){3,}", "���ֵ���");
754 x2("(?:����){2,4}", "���ֵ��ֵ���", 0, 12);
755 x2("(?:����){2,4}", "���ֵ��ֵ��ֵ��ֵ���", 0, 16);
756 x2("(?:����){2,4}?", "���ֵ��ֵ��ֵ��ֵ���", 0, 8);
757 x2("(?:����){,}", "����{,}", 0, 7);
758 x2("(?:������)+?{2}", "������������������", 0, 12);
759 x3("(��)", "��", 0, 2, 1);
760 x3("(�п�)", "�п�", 0, 4, 1);
761 x2("((����))", "����", 0, 4);
762 x3("((����))", "����", 0, 4, 1);
763 x3("((����))", "����", 0, 4, 2);
764 x3("((((((((((((((((((((�̻�))))))))))))))))))))", "�̻�", 0, 4, 20);
765 x3("(����)(����)", "��������", 0, 4, 1);
766 x3("(����)(����)", "��������", 4, 8, 2);
767 x3("()(��)����(������)��������", "��������������������", 6, 12, 3);
768 x3("(()(��)����(������)��������)", "��������������������", 6, 12, 4);
769 x3(".*(�ե�)��(��()���奿)����", "�ե��ޥ奿����", 10, 18, 2);
770 x2("(^��)", "��", 0, 2);
771 x3("(��)|(��)", "����", 2, 4, 1);
772 x3("(^��)|(��)", "����", 2, 4, 2);
773 x3("(��?)", "������", 0, 2, 1);
774 x3("(��*)", "�ޤޤ�", 0, 6, 1);
775 x3("(��*)", "", 0, 0, 1);
776 x3("(��+)", "��������", 0, 14, 1);
777 x3("(��+|��*)", "�դդդؤ�", 0, 6, 1);
778 x3("(��+|��?)", "����������", 0, 2, 1);
779 x3("(������)?", "������", 0, 6, 1);
780 x3("(������)*", "������", 0, 6, 1);
781 x3("(������)+", "������", 0, 6, 1);
782 x3("(������|������)+", "������", 0, 6, 1);
783 x3("([�ʤˤ�][������]|������)+", "������", 0, 6, 1);
784 x3("((?i:������))", "������", 0, 6, 1);
785 x3("((?m:��.��))", "��\n��", 0, 5, 1);
786 x3("((?=����)��)", "����", 0, 2, 1);
787 x3("������|(.������)", "����", 0, 8, 1);
788 x3("��*(.)", "����������", 8, 10, 1);
789 x3("��*?(.)", "����������", 0, 2, 1);
790 x3("��*?(��)", "����������", 8, 10, 1);
791 x3("[������]��*(.)", "������������", 10, 12, 1);
792 x3("(\\A����)����", "��������", 0, 4, 1);
793 n("(\\A����)����", "������");
794 x3("(^����)����", "��������", 0, 4, 1);
795 n("(^����)����", "������");
796 x3("���(���$)", "�����", 4, 8, 1);
797 n("���(���$)", "������");
798 x2("(̵)\\1", "̵̵", 0, 4);
799 n("(̵)\\1", "̵��");
800 x2("(��?)\\1", "����", 0, 4);
801 x2("(��?\?)\\1", "����", 0, 0);
802 x2("(��*)\\1", "����������", 0, 8);
803 x3("(��*)\\1", "����������", 0, 4, 1);
804 x2("��(��*)\\1", "����������", 0, 10);
805 x2("��(��*)\\1", "����", 0, 2);
806 x2("(��*)(��*)\\1\\2", "��������������������", 0, 20);
807 x2("(��*)(��*)\\2", "��������������", 0, 14);
808 x3("(��*)(��*)\\2", "��������������", 6, 10, 2);
809 x2("(((((((��*)��))))))��\\7", "�ݤݤݤڤԤݤݤ�", 0, 16);
810 x3("(((((((��*)��))))))��\\7", "�ݤݤݤڤԤݤݤ�", 0, 6, 7);
811 x2("(��)(��)(��)\\2\\1\\3", "�ϤҤդҤϤ�", 0, 12);
812 x2("([��-��])\\1", "����", 0, 4);
813 x2("(\\w\\d\\s)\\1", "��5 ��5 ", 0, 8);
814 n("(\\w\\d\\s)\\1", "��5 ��5");
815 x2("(�|[��-��]{3})\\1", "��", 0, 8);
816 x2("...(�|[��-��]{3})\\1", "��a����", 0, 13);
817 x2("(�|[��-��]{3})\\1", "������������", 0, 12);
818 x2("(^��)\\1", "����", 0, 4);
819 n("(^��)\\1", "����");
820 n("(��$)\\1", "����");
821 n("(����\\Z)\\1", "����");
822 x2("(��*\\Z)\\1", "��", 2, 2);
823 x2(".(��*\\Z)\\1", "����", 2, 4);
824 x3("(.(�䤤��)\\2)", "z�䤤��䤤��", 0, 13, 1);
825 x3("(.(..\\d.)\\2)", "��12341234", 0, 10, 1);
826 x2("((?i:��v��))\\1", "��v����v��", 0, 10);
827 x2("(?<��>��|\\(\\g<��>\\))", "((((((��))))))", 0, 14);
828 x2("\\A(?:\\g<��_1>|\\g<��_2>|\\z��λ (?<��_1>��|��\\g<��_2>��)(?<��_2>��|�\\g<��_1>�))$", "������������", 0, 26);
829 x2("[[�Ҥ�]]", "��", 0, 2);
830 x2("[[������]��]", "��", 0, 2);
831 n("[[^��]]", "��");
832 n("[^[��]]", "��");
833 x2("[^[^��]]", "��", 0, 2);
834 x2("[[������]&&����]", "��", 0, 2);
835 n("[[������]&&����]", "��");
836 n("[[������]&&����]", "��");
837 x2("[��-��&&��-��&&��-��]", "��", 0, 2);
838 n("[^��-��&&��-��&&��-��]", "��");
839 x2("[[^��&&��]&&��-��]", "��", 0, 2);
840 n("[[^��&&��]&&��-��]", "��");
841 x2("[[^��-��&&��������]&&[^��-��]]", "��", 0, 2);
842 n("[[^��-��&&��������]&&[^��-��]]", "��");
843 x2("[^[^������]&&[^������]]", "��", 0, 2);
844 x2("[^[^������]&&[^������]]", "��", 0, 2);
845 n("[^[^������]&&[^������]]", "��");
846 x2("[��-&&-��]", "-", 0, 1);
847 x2("[^[^a-z������]&&[^bcdefg������]q-w]", "��", 0, 2);
848 x2("[^[^a-z������]&&[^bcdefg������]g-w]", "f", 0, 1);
849 x2("[^[^a-z������]&&[^bcdefg������]g-w]", "g", 0, 1);
850 n("[^[^a-z������]&&[^bcdefg������]g-w]", "2");
851 x2("a<b>�С������Υ��������<\\/b>", "a<b>�С������Υ��������</b>", 0, 32);
852 x2(".<b>�С������Υ��������<\\/b>", "a<b>�С������Υ��������</b>", 0, 32);
853 fprintf(stdout,
854 "\nRESULT SUCC: %d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n",
855 nsucc, nfail, nerror, onig_version());
856
857 #ifndef POSIX_TEST
858 onig_region_free(region, 1);
859 onig_end();
860 #endif
861
862 return ((nfail == 0 && nerror == 0) ? 0 : -1);
863 }
864