Update.
[platform/upstream/glibc.git] / localedata / tst-wctype.c
1 #include <error.h>
2 #include <locale.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <wchar.h>
6 #include <wctype.h>
7
8 int
9 main (void)
10 {
11   wctype_t wct;
12   wchar_t buf[1000];
13   int result = 1;
14
15   setlocale (LC_ALL, "");
16   wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL));
17
18   wct = wctype ("jhira");
19   if (wct == 0)
20     error (EXIT_FAILURE, 0, "jhira: no such character class");
21
22   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
23     {
24       int n;
25
26       wprintf (L"buf[] = \"%ls\"\n", buf);
27
28       result = 0;
29
30       for (n = 0; buf[n] != L'\0'; ++n)
31         {
32           wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
33                    iswctype (buf[n], wct));
34           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
35                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
36         }
37     }
38
39   return result;
40 }