1 /* Test re_search with multi-byte characters in EUC-JP.
2 Copyright (C) 2012-2017 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/>. */
26 #include "regex_internal.h"
31 struct re_pattern_buffer r
;
32 struct re_registers s
;
34 if (setlocale (LC_CTYPE
, "ja_JP.EUC-JP") == NULL
)
36 puts ("setlocale failed");
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
);
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",
53 printf ("bug-regex33.1: false match or error: re_search() returned %d, should return -1\n", e
);
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",
63 printf ("bug-regex33.2: false match or error: re_search() returned %d, should return -1\n", e
);
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",
73 printf ("bug-regex33.3: false match or error: re_search() returned %d, should return -1\n", e
);
77 /* aa件a新処, \xb7\xbd constitutes a false match */
78 e
= re_search (&r
, "\x61\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
82 printf ("bug-regex33.4: false match or error: re_search() returned %d, should return -1\n", e
);
86 /* a件a新処, \xb7\xbd constitutes a false match */
87 e
= re_search (&r
, "\x61\xb7\xef\x61\xbf\xb7\xbd\xe8",
91 printf ("bug-regex33.5: false match or error: re_search() returned %d, should return -1\n", e
);
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",
101 printf ("bug-regex33.6: no match or false match: re_search() returned %d, should return 4\n", e
);
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",
111 printf ("bug-regex33.7: no match or false match: re_search() returned %d, should return 4\n", e
);
118 #define TEST_FUNCTION do_test ()
119 #include "../test-skeleton.c"