OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [extra/] [locale/] [tst_nl_langinfo.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.