]>
Commit | Line | Data |
---|---|---|
cc9e536d UD |
1 | // BZ 12788 |
2 | #include <locale.h> | |
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | #include <string.h> | |
6 | #include <unistd.h> | |
7 | ||
8 | ||
9 | static int | |
9162c01d | 10 | do_test (void) |
cc9e536d | 11 | { |
cc9e536d UD |
12 | int result = 0; |
13 | ||
14 | char *a = setlocale (LC_ALL, ""); | |
15 | printf ("setlocale(LC_ALL, \"\") = %s\n", a); | |
16 | if (a == NULL) | |
17 | return 1; | |
18 | a = strdupa (a); | |
19 | ||
20 | char *b = setlocale (LC_CTYPE, ""); | |
21 | printf ("setlocale(LC_CTYPE, \"\") = %s\n", b); | |
22 | if (b == NULL) | |
23 | return 1; | |
24 | ||
25 | char *c = setlocale (LC_ALL, NULL); | |
26 | printf ("setlocale(LC_ALL, NULL) = %s\n", c); | |
27 | if (c == NULL) | |
28 | return 1; | |
29 | c = strdupa (c); | |
30 | ||
31 | if (strcmp (a, c) != 0) | |
32 | { | |
33 | puts ("*** first and third result do not match"); | |
34 | result = 1; | |
35 | } | |
36 | ||
37 | char *d = setlocale (LC_NUMERIC, ""); | |
38 | printf ("setlocale(LC_NUMERIC, \"\") = %s\n", d); | |
39 | if (d == NULL) | |
40 | return 1; | |
41 | ||
42 | if (strcmp (d, "C") != 0) | |
43 | { | |
44 | puts ("*** LC_NUMERIC not C"); | |
45 | result = 1; | |
46 | } | |
47 | ||
48 | char *e = setlocale (LC_ALL, NULL); | |
49 | printf ("setlocale(LC_ALL, NULL) = %s\n", e); | |
50 | if (e == NULL) | |
51 | return 1; | |
52 | ||
53 | if (strcmp (a, e) != 0) | |
54 | { | |
55 | puts ("*** first and fifth result do not match"); | |
56 | result = 1; | |
57 | } | |
58 | ||
59 | char *f = setlocale (LC_ALL, "C"); | |
60 | printf ("setlocale(LC_ALL, \"C\") = %s\n", f); | |
61 | if (f == NULL) | |
62 | return 1; | |
63 | ||
64 | if (strcmp (f, "C") != 0) | |
65 | { | |
66 | puts ("*** LC_ALL not C"); | |
67 | result = 1; | |
68 | } | |
69 | ||
70 | char *g = setlocale (LC_ALL, NULL); | |
71 | printf ("setlocale(LC_ALL, NULL) = %s\n", g); | |
72 | if (g == NULL) | |
73 | return 1; | |
74 | ||
75 | if (strcmp (g, "C") != 0) | |
76 | { | |
77 | puts ("*** LC_ALL not C"); | |
78 | result = 1; | |
79 | } | |
80 | ||
81 | char *h = setlocale (LC_CTYPE, NULL); | |
82 | printf ("setlocale(LC_CTYPE, NULL) = %s\n", h); | |
83 | if (h == NULL) | |
84 | return 1; | |
85 | ||
86 | if (strcmp (h, "C") != 0) | |
87 | { | |
88 | puts ("*** LC_CTYPE not C"); | |
89 | result = 1; | |
90 | } | |
91 | ||
92 | return result; | |
93 | } | |
94 | ||
9162c01d | 95 | #define TEST_FUNCTION do_test () |
cc9e536d | 96 | #include "../test-skeleton.c" |