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