1 /* Test re_search with multi-byte characters in EUC-JP.
2 Copyright (C) 2012-2022 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/>. */
29 struct re_pattern_buffer r
;
30 struct re_registers s
;
32 if (setlocale (LC_CTYPE
, "ja_JP.EUC-JP") == NULL
)
34 puts ("setlocale failed");
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);
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",
52 printf ("bug-regex33.1: false match or error: re_search() returned %d, should return -1\n", e
);
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",
62 printf ("bug-regex33.2: false match or error: re_search() returned %d, should return -1\n", e
);
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",
72 printf ("bug-regex33.3: false match or error: re_search() returned %d, should return -1\n", e
);
76 /* aa件a新処, \xb7\xbd constitutes a false match */
77 e
= re_search (&r
, "\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
81 printf ("bug-regex33.4: false match or error: re_search() returned %d, should return -1\n", e
);
85 /* a件a新処, \xb7\xbd constitutes a false match */
86 e
= re_search (&r
, "\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
90 printf ("bug-regex33.5: false match or error: re_search() returned %d, should return -1\n", e
);
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",
100 printf ("bug-regex33.6: no match or false match: re_search() returned %d, should return 4\n", e
);
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",
110 printf ("bug-regex33.7: no match or false match: re_search() returned %d, should return 4\n", e
);
117 #define TEST_FUNCTION do_test ()
118 #include "../test-skeleton.c"