1 /* Test re.translate != NULL.
2 Copyright (C) 2004, 2005 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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30 struct re_pattern_buffer re
;
35 setlocale (LC_ALL
, "de_DE.ISO-8859-1");
37 for (i
= 0; i
< 256; ++i
)
38 trans
[i
] = tolower (i
);
40 re_set_syntax (RE_SYNTAX_POSIX_EGREP
);
42 memset (&re
, 0, sizeof (re
));
43 re
.translate
= (unsigned char *) trans
;
44 s
= re_compile_pattern ("\\W", 2, &re
);
48 printf ("failed to compile pattern \"\\W\": %s\n", s
);
53 int ret
= re_search (&re
, "abc.de", 6, 0, 6, NULL
);
56 printf ("1st re_search returned %d\n", ret
);
60 ret
= re_search (&re
, "\xc4\xd6\xae\xf7", 4, 0, 4, NULL
);
63 printf ("2nd re_search returned %d\n", ret
);
70 memset (&re
, 0, sizeof (re
));
71 re
.translate
= (unsigned char *) trans
;
72 s
= re_compile_pattern ("\\w", 2, &re
);
76 printf ("failed to compile pattern \"\\w\": %s\n", s
);
81 int ret
= re_search (&re
, ".,!abc", 6, 0, 6, NULL
);
84 printf ("3rd re_search returned %d\n", ret
);
88 ret
= re_search (&re
, "\xae\xf7\xc4\xd6", 4, 0, 4, NULL
);
91 printf ("4th re_search returned %d\n", ret
);
98 memset (&re
, 0, sizeof (re
));
99 re
.translate
= (unsigned char *) trans
;
100 s
= re_compile_pattern ("[[:DIGIT:]]", 11, &re
);
103 printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",
108 memset (&re
, 0, sizeof (re
));
109 re
.translate
= (unsigned char *) trans
;
110 s
= re_compile_pattern ("[[:DIGIT:]]", 2, &re
);
113 printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",