1 /* Test re.translate != NULL.
2 Copyright (C) 2004-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
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/>. */
29 struct re_pattern_buffer re
;
34 setlocale (LC_ALL
, "de_DE.ISO-8859-1");
36 for (i
= 0; i
< 256; ++i
)
37 trans
[i
] = tolower (i
);
39 re_set_syntax (RE_SYNTAX_POSIX_EGREP
);
41 memset (&re
, 0, sizeof (re
));
42 re
.translate
= (unsigned char *) trans
;
43 s
= re_compile_pattern ("\\W", 2, &re
);
47 printf ("failed to compile pattern \"\\W\": %s\n", s
);
52 int ret
= re_search (&re
, "abc.de", 6, 0, 6, NULL
);
55 printf ("1st re_search returned %d\n", ret
);
59 ret
= re_search (&re
, "\xc4\xd6\xae\xf7", 4, 0, 4, NULL
);
62 printf ("2nd re_search returned %d\n", ret
);
69 memset (&re
, 0, sizeof (re
));
70 re
.translate
= (unsigned char *) trans
;
71 s
= re_compile_pattern ("\\w", 2, &re
);
75 printf ("failed to compile pattern \"\\w\": %s\n", s
);
80 int ret
= re_search (&re
, ".,!abc", 6, 0, 6, NULL
);
83 printf ("3rd re_search returned %d\n", ret
);
87 ret
= re_search (&re
, "\xae\xf7\xc4\xd6", 4, 0, 4, NULL
);
90 printf ("4th re_search returned %d\n", ret
);
97 memset (&re
, 0, sizeof (re
));
98 re
.translate
= (unsigned char *) trans
;
99 s
= re_compile_pattern ("[[:DIGIT:]]", 11, &re
);
102 printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",
107 memset (&re
, 0, sizeof (re
));
108 re
.translate
= (unsigned char *) trans
;
109 s
= re_compile_pattern ("[[:DIGIT:]]", 2, &re
);
112 printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",