1 /* Test program for nl_langinfo() function.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
32 #define VAL(name) { #name, name }
55 VAL (CURRENCY_SYMBOL),
73 VAL (INT_CURR_SYMBOL),
74 VAL (INT_FRAC_DIGITS),
87 VAL (MON_DECIMAL_POINT),
89 VAL (MON_THOUSANDS_SEP),
112 map_paramstr (const char *str)
115 int high = sizeof (map) / sizeof (map[0]);
119 int med = (low + high) / 2;
122 cmpres = strcmp (str, map[med].str);
136 # define REASON(str) printf ("\"%s\" ignored: %s\n", buf, str)
146 while (! feof (stdin))
156 if (fgets (buf, sizeof (buf), stdin) == NULL)
159 /* Split the fields. There are three is them:
161 2. langinfo() parameter
162 3. expected result; this can be a string with white space etc.
165 while (*rp == ' ' || *rp == '\t')
170 /* It's a comment line. Ignore it. */
176 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
178 if (*rp == '\0' || *rp == '\n')
180 /* Incomplete line. */
181 REASON ("incomplete line");
186 while (*rp == ' ' || *rp == '\t')
190 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
192 if (*rp == '\0' || *rp == '\n')
194 /* Incomplete line. */
195 REASON ("incomplete line");
200 while (*rp == ' ' || *rp == '\t')
207 expected = wp = ++rp;
208 while (*rp != '"' && *rp != '\n' && *rp != '\0')
215 if (*rp >= '\0' && *rp <= 'p')
218 if (rp[1] >= '0' && rp[1] <= '9')
223 if (rp[1] >= '0' && rp[1] <= '9')
238 REASON ("missing '\"'");
247 while (*rp != '\0' && *rp != '\n')
252 param = map_paramstr (paramstr);
255 /* Invalid parameter. */
256 REASON ("invalid parameter");
260 /* Set the locale and check whether it worked. */
261 printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
262 setlocale (LC_ALL, locale);
263 if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
265 puts (": failed to set locale");
270 actual = nl_langinfo (param);
271 printf (" = \"%s\", ", actual);
273 if (strcmp (actual, expected) == 0)
277 printf ("FAILED (expected: %s)\n", expected);