]> git.ipfire.org Git - thirdparty/glibc.git/blame - posix/bug-regex1.c
build-many-glibcs.py: Add openrisc hard float glibc variant
[thirdparty/glibc.git] / posix / bug-regex1.c
CommitLineData
672fd41b
UD
1#include <locale.h>
2#include <stdio.h>
3#include <string.h>
4#include <regex.h>
0e37b504 5#include <wchar.h>
672fd41b
UD
6
7int
8main (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");
69623c0d 25 s = re_compile_pattern ("[an\371]*n", 7, &regex);
672fd41b
UD
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
466f2be6
CD
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
672fd41b
UD
63 puts ("in de_DE.ISO-8859-1 locale");
64 setlocale (LC_ALL, "de_DE.ISO-8859-1");
69623c0d 65 s = re_compile_pattern ("[an\371]*n", 7, &regex);
672fd41b
UD
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}