delete ksh checks
[glibc.git] / posix / bug-regex18.c
blobfac7ff2873fe54888640bcd55cd1344baa61a713
1 /* Turkish regular expression tests.
2 Copyright (C) 2002-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sys/types.h>
21 #include <mcheck.h>
22 #include <regex.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <locale.h>
27 /* Tests supposed to match. */
28 struct
30 const char *pattern;
31 const char *string;
32 int flags, nmatch;
33 regmatch_t rm[5];
34 } tests[] = {
35 /* \xc4\xb0 LATIN CAPITAL LETTER I WITH DOT ABOVE
36 \xc4\xb1 LATIN SMALL LETTER DOTLESS I
37 \xe2\x80\x94 EM DASH */
38 { "\xc4\xb0I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
39 { { 2, 8 }, { -1, -1 } } },
40 { "[\xc4\xb0x]I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
41 { { 2, 8 }, { -1, -1 } } },
42 { "[^x]I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
43 { { 2, 8 }, { -1, -1 } } },
44 { "([[:alpha:]]i[[:xdigit:]])(\xc4\xb1*)(\xc4\xb0{2})",
45 "\xe2\x80\x94\xc4\xb1\xc4\xb0""fIi\xc4\xb0ii", REG_ICASE | REG_EXTENDED,
46 4, { { 3, 12 }, { 3, 8 }, { 8, 9 }, { 9, 12 } } },
47 { "\xc4\xb1i(i)*()(\\s\xc4\xb0|\\SI)", "SIi\xc4\xb0\xc4\xb0 is",
48 REG_ICASE | REG_EXTENDED, 4, { { 1, 9 }, { 5, 7 }, { 7, 7 }, { 7, 9 } } },
49 { "\xc4\xb1i(i)*()(\\s\xc4\xb0|\\SI)", "\xc4\xb1\xc4\xb0\xc4\xb0iJ\xc4\xb1",
50 REG_ICASE | REG_EXTENDED, 4,
51 { { 0, 10 }, { 6, 7 }, { 7, 7 }, { 7, 10 } } },
54 int
55 main (void)
57 regex_t re;
58 regmatch_t rm[5];
59 size_t i;
60 int n, ret = 0;
62 setlocale (LC_ALL, "tr_TR.UTF-8");
63 for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
65 n = regcomp (&re, tests[i].pattern, tests[i].flags);
66 if (n != 0)
68 char buf[500];
69 regerror (n, &re, buf, sizeof (buf));
70 printf ("regcomp %zd failed: %s\n", i, buf);
71 ret = 1;
72 continue;
75 if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
77 printf ("regexec %zd failed\n", i);
78 ret = 1;
79 regfree (&re);
80 continue;
83 for (n = 0; n < tests[i].nmatch; ++n)
84 if (rm[n].rm_so != tests[i].rm[n].rm_so
85 || rm[n].rm_eo != tests[i].rm[n].rm_eo)
87 if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
88 break;
89 printf ("regexec match failure rm[%d] %d..%d\n",
90 n, rm[n].rm_so, rm[n].rm_eo);
91 ret = 1;
92 break;
95 regfree (&re);
98 return ret;