manual: Clarify undefined behavior of feenableexcept (BZ 31019)
[glibc.git] / posix / bug-regex1.c
blob99357e359e7bedeffa9fc76c9d1d131843cc5b1c
1 #include <locale.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <regex.h>
5 #include <wchar.h>
7 int
8 main (void)
10 struct re_pattern_buffer regex;
11 struct re_registers regs;
12 const char *s;
13 int match;
14 int result = 0;
16 memset (&regex, '\0', sizeof (regex));
18 setlocale (LC_ALL, "de_DE.ISO-8859-1");
19 fwide (stdout, -1);
21 re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_DEBUG);
23 puts ("in C locale");
24 setlocale (LC_ALL, "C");
25 s = re_compile_pattern ("[an\371]*n", 7, &regex);
26 if (s != NULL)
28 puts ("re_compile_pattern return non-NULL value");
29 result = 1;
31 else
33 match = re_match (&regex, "an", 2, 0, &regs);
34 if (match != 2)
36 printf ("re_match returned %d, expected 2\n", match);
37 result = 1;
39 else
40 puts (" -> OK");
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)
48 puts ("re_compile_pattern return non-NULL value");
49 result = 1;
51 else
53 match = re_match (&regex, "an", 2, 0, &regs);
54 if (match != 2)
56 printf ("re_match returned %d, expected 2\n", match);
57 result = 1;
59 else
60 puts (" -> OK");
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)
68 puts ("re_compile_pattern return non-NULL value");
69 result = 1;
71 else
73 match = re_match (&regex, "an", 2, 0, &regs);
74 if (match != 2)
76 printf ("re_match returned %d, expected 2\n", match);
77 result = 1;
79 else
80 puts (" -> OK");
83 return result;