* sysdeps/generic/allocrtsig.c: Include <testrtsig.h>, not
[glibc.git] / posix / bug-regex5.c
blob9d0eef1e2f04dceb91852b627f3ff599c2d6c5f9
1 #include <stdio.h>
2 #include <string.h>
3 #include <locale.h>
4 #include <locale/localeinfo.h>
6 int
7 main (void)
9 int32_t table_size, idx, i, found;
10 const int32_t *symb_table;
11 const unsigned char *extra;
12 uint32_t nrules;
13 char *ca;
14 union locale_data_value u;
16 ca = setlocale (LC_ALL, "da_DK.ISO-8859-1");
17 if (ca == NULL)
19 printf ("cannot set locale: %m\n");
20 return 1;
22 printf ("current locale : %s\n", ca);
24 nrules = (size_t) nl_langinfo (_NL_COLLATE_NRULES);
25 if (nrules == 0)
27 printf("No rule\n");
28 return 1;
31 u.string = nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB);
32 table_size = u.word;
33 symb_table = (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB);
34 extra = (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB);
36 found = 0;
37 for (i = 0; i < table_size; ++i)
39 if (symb_table[2 * i] != 0)
41 char elem[256];
42 idx = symb_table[2 * i + 1];
43 strncpy (elem, extra + idx + 1, extra[idx]);
44 elem[extra[idx]] = '\0';
45 printf ("Found a collating element: %s\n", elem);
46 ++found;
49 if (found == 0)
51 printf ("No collating element!\n");
52 return 1;
54 else if (found != 4)
56 printf ("expected 4 collating elements, found %d\n", found);
57 return 1;
60 return 0;