1:
2: #include <locale.h>
3: #include <stdio.h>
4: #include <string.h>
5: #include <regex.h>
6: #include <wchar.h>
7:
8: int
9: main (void)
10: {
11: struct re_pattern_buffer regex;
12: struct re_registers regs;
13: const char *s;
14: int match;
15: int result = 0;
16:
17: memset (®ex, '\0', sizeof (regex));
18:
19: setlocale (LC_ALL, "de_DE.ISO-8859-1");
20: fwide (stdout, -1);
21:
22: re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_DEBUG);
23:
24: puts ("in C locale");
25: setlocale (LC_ALL, "C");
26: s = re_compile_pattern ("[an?, 7, ®ex);
27: if (s != NULL)
28: {
29: puts ("re_compile_pattern return non-NULL value");
30: result = 1;
31: }
32: else
33: {
34: match = re_match (®ex, "an", 2, 0, ®s);
35: if (match != 2)
36: {
37: printf ("re_match returned %d, expected 2\n", match);
38: result = 1;
39: }
40: else
41: puts (" -> OK");
42: }
43:
44: puts ("in de_DE.ISO-8859-1 locale");
45: setlocale (LC_ALL, "de_DE.ISO-8859-1");
46: s = re_compile_pattern ("[an?, 7, ®ex);
47: if (s != NULL)
48: {
49: puts ("re_compile_pattern return non-NULL value");
50: result = 1;
51: }
52: else
53: {
54: match = re_match (®ex, "an", 2, 0, ®s);
55: if (match != 2)
56: {
57: printf ("re_match returned %d, expected 2\n", match);
58: result = 1;
59: }
60: else
61: puts (" -> OK");
62: }
63:
64: return result;
65: }