Clean up __exit_thread.
[glibc.git] / posix / bug-regex33.c
blob626a6812741ca60e816bc46f386f8cff0fb80db6
1 /* Test re_search with multi-byte characters in EUC-JP.
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Stanislav Brabec <sbrabec@suse.cz>, 2012.
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 #define _GNU_SOURCE 1
21 #include <locale.h>
22 #include <regex.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include "regex_internal.h"
28 static int
29 do_test (void)
31 struct re_pattern_buffer r;
32 struct re_registers s;
33 int e, rc = 0;
34 if (setlocale (LC_CTYPE, "ja_JP.EUC-JP") == NULL)
36 puts ("setlocale failed");
37 return 1;
39 memset (&r, 0, sizeof (r));
40 memset (&s, 0, sizeof (s));
42 /* The bug cannot be reproduced without initialized fastmap. */
43 r.fastmap = malloc (SBC_MAX);
45 /* 圭 */
46 re_compile_pattern ("\xb7\xbd", 2, &r);
48 /* aaaaa件a新処, \xb7\xbd constitutes a false match */
49 e = re_search (&r, "\x61\x61\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
50 12, 0, 12, &s);
51 if (e != -1)
53 printf ("bug-regex33.1: false match or error: re_search() returned %d, should return -1\n", e);
54 rc = 1;
57 /* aaaa件a新処, \xb7\xbd constitutes a false match,
58 * this is a reproducer of BZ #13637 */
59 e = re_search (&r, "\x61\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
60 11, 0, 11, &s);
61 if (e != -1)
63 printf ("bug-regex33.2: false match or error: re_search() returned %d, should return -1\n", e);
64 rc = 1;
67 /* aaa件a新処, \xb7\xbd constitutes a false match,
68 * this is a reproducer of BZ #13637 */
69 e = re_search (&r, "\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
70 10, 0, 10, &s);
71 if (e != -1)
73 printf ("bug-regex33.3: false match or error: re_search() returned %d, should return -1\n", e);
74 rc = 1;
77 /* aa件a新処, \xb7\xbd constitutes a false match */
78 e = re_search (&r, "\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
79 9, 0, 9, &s);
80 if (e != -1)
82 printf ("bug-regex33.4: false match or error: re_search() returned %d, should return -1\n", e);
83 rc = 1;
86 /* a件a新処, \xb7\xbd constitutes a false match */
87 e = re_search (&r, "\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
88 8, 0, 8, &s);
89 if (e != -1)
91 printf ("bug-regex33.5: false match or error: re_search() returned %d, should return -1\n", e);
92 rc = 1;
95 /* 新処圭新処, \xb7\xbd here really matches 圭, but second occurrence is a false match,
96 * this is a reproducer of bug-regex25 and BZ #13637 */
97 e = re_search (&r, "\xbf\xb7\xbd\xe8\xb7\xbd\xbf\xb7\xbd\xe8",
98 10, 0, 10, &s);
99 if (e != 4)
101 printf ("bug-regex33.6: no match or false match: re_search() returned %d, should return 4\n", e);
102 rc = 1;
105 /* 新処圭新, \xb7\xbd here really matches 圭,
106 * this is a reproducer of bug-regex25 */
107 e = re_search (&r, "\xbf\xb7\xbd\xe8\xb7\xbd\xbf\xb7",
108 10, 0, 10, &s);
109 if (e != 4)
111 printf ("bug-regex33.7: no match or false match: re_search() returned %d, should return 4\n", e);
112 rc = 1;
115 return rc;
118 #define TEST_FUNCTION do_test ()
119 #include "../test-skeleton.c"