math: Update mips64 ulps
[glibc.git] / posix / bug-regex5.c
blob573da231e3a4de367ef4826464411c712d8c68f4
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdint.h>
4 #include <locale.h>
5 #include <locale/localeinfo.h>
7 int
8 main (void)
10 int32_t table_size, idx, i, found;
11 const int32_t *symb_table;
12 const unsigned char *extra;
13 uint32_t nrules;
14 char *ca;
15 union locale_data_value u;
17 ca = setlocale (LC_ALL, "da_DK.ISO-8859-1");
18 if (ca == NULL)
20 printf ("cannot set locale: %m\n");
21 return 1;
23 printf ("current locale : %s\n", ca);
25 u.string = nl_langinfo (_NL_COLLATE_NRULES);
26 nrules = u.word;
27 if (nrules == 0)
29 printf("No rule\n");
30 return 1;
33 u.string = nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB);
34 table_size = u.word;
35 symb_table = (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB);
36 extra = (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB);
38 found = 0;
39 for (i = 0; i < table_size; ++i)
41 if (symb_table[2 * i] != 0)
43 char elem[256];
44 idx = symb_table[2 * i + 1];
45 strncpy (elem, (const char *) (extra + idx + 1), extra[idx]);
46 elem[extra[idx]] = '\0';
47 printf ("Found a collating element: %s\n", elem);
48 ++found;
51 if (found == 0)
53 printf ("No collating element!\n");
54 return 1;
56 else if (found != 6)
58 printf ("expected 6 collating elements, found %d\n", found);
59 return 1;
62 return 0;