12 #define VAL(name) { #name, name }
35 VAL (CURRENCY_SYMBOL),
53 VAL (INT_CURR_SYMBOL),
54 VAL (INT_FRAC_DIGITS),
67 VAL (MON_DECIMAL_POINT),
69 VAL (MON_THOUSANDS_SEP),
92 map_paramstr (const char *str)
95 int high = sizeof (map) / sizeof (map[0]);
99 int med = (low + high) / 2;
102 cmpres = strcmp (str, map[med].str);
116 # define REASON(str) printf ("\"%s\" ignored: %s\n", buf, str)
126 while (! feof (stdin))
136 if (fgets (buf, sizeof (buf), stdin) == NULL)
139 /* Split the fields. There are three is them:
141 2. langinfo() parameter
142 3. expected result; this can be a string with white space etc.
145 while (*rp == ' ' || *rp == '\t')
150 /* It's a comment line. Ignore it. */
156 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
158 if (*rp == '\0' || *rp == '\n')
160 /* Incomplete line. */
161 REASON ("incomplete line");
166 while (*rp == ' ' || *rp == '\t')
170 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
172 if (*rp == '\0' || *rp == '\n')
174 /* Incomplete line. */
175 REASON ("incomplete line");
180 while (*rp == ' ' || *rp == '\t')
187 expected = wp = ++rp;
188 while (*rp != '"' && *rp != '\n' && *rp != '\0')
195 if (*rp >= '\0' && *rp <= 'p')
198 if (rp[1] >= '0' && rp[1] <= '9')
203 if (rp[1] >= '0' && rp[1] <= '9')
218 REASON ("missing '\"'");
227 while (*rp != '\0' && *rp != '\n')
232 param = map_paramstr (paramstr);
235 /* Invalid parameter. */
236 REASON ("invalid parameter");
240 /* Set the locale and check whether it worked. */
241 printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
242 setlocale (LC_ALL, locale);
243 if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
245 puts (": failed to set locale");
250 actual = nl_langinfo (param);
251 printf (" = \"%s\", ", actual);
253 if (strcmp (actual, expected) == 0)
257 printf ("FAILED (expected: %s)\n", expected);