NPTL/arc: notify kernel of the TP value
[uclibc-ng.git] / extra / locale / tst_nl_langinfo.c
blobfcf2fe2eb547826d6da1a3b6f1409c8608d74530
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <langinfo.h>
5 #include <nl_types.h>
7 #if !defined(__UCLIBC__) && 0
8 #define DO_EXTRA
9 #endif
11 int main(int argc, char **argv)
13 char *l;
14 const unsigned char *x;
15 /* const unsigned char *y; */
16 const unsigned char *p;
18 if (argc > 2) {
19 printf("invalid args\n");
20 return EXIT_FAILURE;
22 if (argc == 1) {
23 l = "";
24 } else {
25 l = *++argv;
28 if (!(x = setlocale(LC_ALL,l))) {
29 printf("couldn't set locale %s\n", l);
30 return EXIT_FAILURE;
33 /* printf("\nsetlocale returned:\n "); */
34 /* do { */
35 /* printf("\\x%02x", *x); */
36 /* } while (*x++); */
37 /* printf("\n"); */
39 #ifndef __BCC__
40 #define STR(X) #X
41 #else
42 #define STR(X) __STR(X)
43 #endif
44 #define __PASTE2(A,B) A.B
46 #define DO_NL_I(X) \
47 printf( STR(X) " = %d\n", (int) nl_langinfo(X) );
48 #define DO_NL_S(X) \
49 printf( STR(X) " = \"%s\"\n", nl_langinfo(X) );
50 #define DO_NL_C(X) \
51 printf( STR(X) " = \"\\x%02x\"\n", *((unsigned char *) nl_langinfo(X)) );
53 printf("ctype\n");
55 DO_NL_S(CODESET);
56 #ifdef DO_EXTRA
57 DO_NL_I(_NL_CTYPE_INDIGITS_MB_LEN);
58 DO_NL_S(_NL_CTYPE_INDIGITS0_MB);
59 DO_NL_S(_NL_CTYPE_INDIGITS1_MB);
60 DO_NL_S(_NL_CTYPE_INDIGITS2_MB);
61 DO_NL_S(_NL_CTYPE_INDIGITS3_MB);
62 DO_NL_S(_NL_CTYPE_INDIGITS4_MB);
63 DO_NL_S(_NL_CTYPE_INDIGITS5_MB);
64 DO_NL_S(_NL_CTYPE_INDIGITS6_MB);
65 DO_NL_S(_NL_CTYPE_INDIGITS7_MB);
66 DO_NL_S(_NL_CTYPE_INDIGITS8_MB);
67 DO_NL_S(_NL_CTYPE_INDIGITS9_MB);
68 #endif
69 DO_NL_S(_NL_CTYPE_OUTDIGIT0_MB);
70 DO_NL_S(_NL_CTYPE_OUTDIGIT1_MB);
71 DO_NL_S(_NL_CTYPE_OUTDIGIT2_MB);
72 DO_NL_S(_NL_CTYPE_OUTDIGIT3_MB);
73 DO_NL_S(_NL_CTYPE_OUTDIGIT4_MB);
74 DO_NL_S(_NL_CTYPE_OUTDIGIT5_MB);
75 DO_NL_S(_NL_CTYPE_OUTDIGIT6_MB);
76 DO_NL_S(_NL_CTYPE_OUTDIGIT7_MB);
77 DO_NL_S(_NL_CTYPE_OUTDIGIT8_MB);
78 DO_NL_S(_NL_CTYPE_OUTDIGIT9_MB);
81 printf("numeric\n");
83 DO_NL_S(RADIXCHAR); /* DECIMAL_POINT */
84 DO_NL_S(THOUSEP); /* THOUSANDS_SEP */
85 /* DO_NL_S(GROUPING); */
87 printf("GROUPING = \"");
88 for (p = (unsigned char *) nl_langinfo(GROUPING) ; *p ; p++) {
89 printf("\\x%02x", *p);
91 printf("\"\n\n");
93 printf("monetary\n");
95 DO_NL_S(INT_CURR_SYMBOL);
96 DO_NL_S(CURRENCY_SYMBOL);
97 DO_NL_S(MON_DECIMAL_POINT);
98 DO_NL_S(MON_THOUSANDS_SEP);
99 /* DO_NL_S(MON_GROUPING); */
101 printf("MON_GROUPING = \"");
102 for (p = (unsigned char *) nl_langinfo(MON_GROUPING) ; *p ; p++) {
103 printf("\\x%02x", *p);
105 printf("\"\n\n");
107 DO_NL_S(POSITIVE_SIGN);
108 DO_NL_S(NEGATIVE_SIGN);
109 DO_NL_C(INT_FRAC_DIGITS);
110 DO_NL_C(FRAC_DIGITS);
111 DO_NL_C(P_CS_PRECEDES);
112 DO_NL_C(P_SEP_BY_SPACE);
113 DO_NL_C(N_CS_PRECEDES);
114 DO_NL_C(N_SEP_BY_SPACE);
115 DO_NL_C(P_SIGN_POSN);
116 DO_NL_C(N_SIGN_POSN);
117 DO_NL_C(INT_P_CS_PRECEDES);
118 DO_NL_C(INT_P_SEP_BY_SPACE);
119 DO_NL_C(INT_N_CS_PRECEDES);
120 DO_NL_C(INT_N_SEP_BY_SPACE);
121 DO_NL_C(INT_P_SIGN_POSN);
122 DO_NL_C(INT_N_SIGN_POSN);
124 DO_NL_S(CRNCYSTR); /* CURRENCY_SYMBOL */
127 printf("time\n");
129 DO_NL_S(ABDAY_1);
130 DO_NL_S(ABDAY_2);
131 DO_NL_S(ABDAY_3);
132 DO_NL_S(ABDAY_4);
133 DO_NL_S(ABDAY_5);
134 DO_NL_S(ABDAY_6);
135 DO_NL_S(ABDAY_7);
137 DO_NL_S(DAY_1);
138 DO_NL_S(DAY_2);
139 DO_NL_S(DAY_3);
140 DO_NL_S(DAY_4);
141 DO_NL_S(DAY_5);
142 DO_NL_S(DAY_6);
143 DO_NL_S(DAY_7);
145 DO_NL_S(ABMON_1);
146 DO_NL_S(ABMON_2);
147 DO_NL_S(ABMON_3);
148 DO_NL_S(ABMON_4);
149 DO_NL_S(ABMON_5);
150 DO_NL_S(ABMON_6);
151 DO_NL_S(ABMON_7);
152 DO_NL_S(ABMON_8);
153 DO_NL_S(ABMON_9);
154 DO_NL_S(ABMON_10);
155 DO_NL_S(ABMON_11);
156 DO_NL_S(ABMON_12);
158 DO_NL_S(MON_1);
159 DO_NL_S(MON_2);
160 DO_NL_S(MON_3);
161 DO_NL_S(MON_4);
162 DO_NL_S(MON_5);
163 DO_NL_S(MON_6);
164 DO_NL_S(MON_7);
165 DO_NL_S(MON_8);
166 DO_NL_S(MON_9);
167 DO_NL_S(MON_10);
168 DO_NL_S(MON_11);
169 DO_NL_S(MON_12);
171 DO_NL_S(AM_STR);
172 DO_NL_S(PM_STR);
174 DO_NL_S(D_T_FMT);
175 DO_NL_S(D_FMT);
176 DO_NL_S(T_FMT);
177 DO_NL_S(T_FMT_AMPM);
178 /* DO_NL_S(ERA); */
180 const char *p = nl_langinfo(ERA);
181 if (!p || !*p) {
182 printf("ERA = (none)\n");
183 } else {
184 int i;
185 printf("ERA:\n");
186 for (i=0 ; i < 100 ; i++) {
187 printf(" %3d: \"%s\"\n", i, p);
188 while (*p) ++p;
189 ++p;
190 if (!*p) break;
195 DO_NL_S(ERA_YEAR); /* non SuSv3 */
196 DO_NL_S(ERA_D_FMT);
197 /* DO_NL_S(ALT_DIGITS); */
199 const char *p = nl_langinfo(ALT_DIGITS);
200 if (!p || !*p) {
201 printf("ALT_DIGITS = (none)\n");
202 } else {
203 int i;
204 printf("ALT_DIGITS:\n");
205 for (i=0 ; i < 100 ; i++) {
206 printf(" %3d: \"%s\"\n", i, p);
207 while (*p) ++p;
208 ++p;
212 DO_NL_S(ERA_D_T_FMT);
213 DO_NL_S(ERA_T_FMT);
215 #ifdef DO_EXTRA
216 DO_NL_C(_NL_TIME_WEEK_NDAYS);
217 DO_NL_I(_NL_TIME_WEEK_1STDAY); /* grr... this won't work with 16bit ptrs */
218 DO_NL_C(_NL_TIME_WEEK_1STWEEK);
219 DO_NL_C(_NL_TIME_FIRST_WEEKDAY);
220 DO_NL_C(_NL_TIME_FIRST_WORKDAY);
221 DO_NL_C(_NL_TIME_CAL_DIRECTION);
222 DO_NL_S(_NL_TIME_TIMEZONE);
223 DO_NL_S(_DATE_FMT);
224 #endif
226 printf("messages\n");
228 DO_NL_S(YESEXPR);
229 DO_NL_S(NOEXPR);
230 DO_NL_S(YESSTR);
231 DO_NL_S(NOSTR);
233 #ifdef DO_EXTRA
235 printf("paper\n");
237 DO_NL_I(_NL_PAPER_HEIGHT);
238 DO_NL_I(_NL_PAPER_WIDTH);
240 printf("name\n");
242 DO_NL_S(_NL_NAME_NAME_FMT);
243 DO_NL_S(_NL_NAME_NAME_GEN);
244 DO_NL_S(_NL_NAME_NAME_MR);
245 DO_NL_S(_NL_NAME_NAME_MRS);
246 DO_NL_S(_NL_NAME_NAME_MISS);
247 DO_NL_S(_NL_NAME_NAME_MS);
249 printf("address\n");
251 DO_NL_S(_NL_ADDRESS_POSTAL_FMT);
252 DO_NL_S(_NL_ADDRESS_COUNTRY_NAME);
253 DO_NL_S(_NL_ADDRESS_COUNTRY_POST);
254 DO_NL_S(_NL_ADDRESS_COUNTRY_AB2);
255 DO_NL_S(_NL_ADDRESS_COUNTRY_AB3);
256 DO_NL_S(_NL_ADDRESS_COUNTRY_CAR);
257 DO_NL_I(_NL_ADDRESS_COUNTRY_NUM);
258 DO_NL_S(_NL_ADDRESS_COUNTRY_ISBN);
259 DO_NL_S(_NL_ADDRESS_LANG_NAME);
260 DO_NL_S(_NL_ADDRESS_LANG_AB);
261 DO_NL_S(_NL_ADDRESS_LANG_TERM);
262 DO_NL_S(_NL_ADDRESS_LANG_LIB);
264 printf("telephone\n");
266 DO_NL_S(_NL_TELEPHONE_TEL_INT_FMT);
267 DO_NL_S(_NL_TELEPHONE_TEL_DOM_FMT);
268 DO_NL_S(_NL_TELEPHONE_INT_SELECT);
269 DO_NL_S(_NL_TELEPHONE_INT_PREFIX);
271 printf("measurement\n");
273 DO_NL_C(_NL_MEASUREMENT_MEASUREMENT); /* 1 is metric, 2 is US */
275 printf("identification\n");
277 DO_NL_S(_NL_IDENTIFICATION_TITLE);
278 DO_NL_S(_NL_IDENTIFICATION_SOURCE);
279 DO_NL_S(_NL_IDENTIFICATION_ADDRESS);
280 DO_NL_S(_NL_IDENTIFICATION_CONTACT);
281 DO_NL_S(_NL_IDENTIFICATION_EMAIL);
282 DO_NL_S(_NL_IDENTIFICATION_TEL);
283 DO_NL_S(_NL_IDENTIFICATION_FAX);
284 DO_NL_S(_NL_IDENTIFICATION_LANGUAGE);
285 DO_NL_S(_NL_IDENTIFICATION_TERRITORY);
286 DO_NL_S(_NL_IDENTIFICATION_AUDIENCE);
287 DO_NL_S(_NL_IDENTIFICATION_APPLICATION);
288 DO_NL_S(_NL_IDENTIFICATION_ABBREVIATION);
289 DO_NL_S(_NL_IDENTIFICATION_REVISION);
290 DO_NL_S(_NL_IDENTIFICATION_DATE);
291 DO_NL_S(_NL_IDENTIFICATION_CATEGORY);
293 #endif
295 return EXIT_SUCCESS;