source: vendor/glibc-tests/2005-06-14/posix/bug-regex1.c

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1/* Test case by Jim Meyering <jim@meyering.net>. */
2#include <locale.h>
3#include <stdio.h>
4#include <string.h>
5#include <regex.h>
6#include <wchar.h>
7
8int
9main (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 (&regex, '\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ù]*n", 7, &regex);
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 (&regex, "an", 2, 0, &regs);
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ù]*n", 7, &regex);
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 (&regex, "an", 2, 0, &regs);
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}
Note: See TracBrowser for help on using the repository browser.