linux: Fix fstat64 on alpha and sparc64
[glibc.git] / posix / bug-regex33.c
blob1922474a49d7706a9083eb82969715fb239b1833
1 /* Test re_search with multi-byte characters in EUC-JP.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #define _GNU_SOURCE 1
20 #include <locale.h>
21 #include <regex.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 static int
27 do_test (void)
29 struct re_pattern_buffer r;
30 struct re_registers s;
31 int e, rc = 0;
32 if (setlocale (LC_CTYPE, "ja_JP.EUC-JP") == NULL)
34 puts ("setlocale failed");
35 return 1;
37 memset (&r, 0, sizeof (r));
38 memset (&s, 0, sizeof (s));
40 /* The bug cannot be reproduced without initialized fastmap (it is SBC_MAX
41 value from regex_internal.h). */
42 r.fastmap = malloc (UCHAR_MAX + 1);
44 /* 圭 */
45 re_compile_pattern ("\xb7\xbd", 2, &r);
47 /* aaaaa件a新処, \xb7\xbd constitutes a false match */
48 e = re_search (&r, "\x61\x61\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
49 12, 0, 12, &s);
50 if (e != -1)
52 printf ("bug-regex33.1: false match or error: re_search() returned %d, should return -1\n", e);
53 rc = 1;
56 /* aaaa件a新処, \xb7\xbd constitutes a false match,
57 * this is a reproducer of BZ #13637 */
58 e = re_search (&r, "\x61\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
59 11, 0, 11, &s);
60 if (e != -1)
62 printf ("bug-regex33.2: false match or error: re_search() returned %d, should return -1\n", e);
63 rc = 1;
66 /* aaa件a新処, \xb7\xbd constitutes a false match,
67 * this is a reproducer of BZ #13637 */
68 e = re_search (&r, "\x61\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
69 10, 0, 10, &s);
70 if (e != -1)
72 printf ("bug-regex33.3: false match or error: re_search() returned %d, should return -1\n", e);
73 rc = 1;
76 /* aa件a新処, \xb7\xbd constitutes a false match */
77 e = re_search (&r, "\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
78 9, 0, 9, &s);
79 if (e != -1)
81 printf ("bug-regex33.4: false match or error: re_search() returned %d, should return -1\n", e);
82 rc = 1;
85 /* a件a新処, \xb7\xbd constitutes a false match */
86 e = re_search (&r, "\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
87 8, 0, 8, &s);
88 if (e != -1)
90 printf ("bug-regex33.5: false match or error: re_search() returned %d, should return -1\n", e);
91 rc = 1;
94 /* 新処圭新処, \xb7\xbd here really matches 圭, but second occurrence is a false match,
95 * this is a reproducer of bug-regex25 and BZ #13637 */
96 e = re_search (&r, "\xbf\xb7\xbd\xe8\xb7\xbd\xbf\xb7\xbd\xe8",
97 10, 0, 10, &s);
98 if (e != 4)
100 printf ("bug-regex33.6: no match or false match: re_search() returned %d, should return 4\n", e);
101 rc = 1;
104 /* 新処圭新, \xb7\xbd here really matches 圭,
105 * this is a reproducer of bug-regex25 */
106 e = re_search (&r, "\xbf\xb7\xbd\xe8\xb7\xbd\xbf\xb7",
107 9, 0, 9, &s);
108 if (e != 4)
110 printf ("bug-regex33.7: no match or false match: re_search() returned %d, should return 4\n", e);
111 rc = 1;
114 return rc;
117 #define TEST_FUNCTION do_test ()
118 #include "../test-skeleton.c"