]>
Commit | Line | Data |
---|---|---|
036cc82f | 1 | /* Handle special requests. |
04277e02 | 2 | Copyright (C) 1996-2019 Free Software Foundation, Inc. |
c84142e8 UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. | |
5 | ||
43bc8ac6 | 6 | This program is free software; you can redistribute it and/or modify |
2e2efe65 RM |
7 | it under the terms of the GNU General Public License as published |
8 | by the Free Software Foundation; version 2 of the License, or | |
9 | (at your option) any later version. | |
c84142e8 | 10 | |
43bc8ac6 | 11 | This program is distributed in the hope that it will be useful, |
c84142e8 | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
43bc8ac6 UD |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | |
c84142e8 | 15 | |
43bc8ac6 | 16 | You should have received a copy of the GNU General Public License |
5a82c748 | 17 | along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
036cc82f RM |
18 | |
19 | #ifdef HAVE_CONFIG_H | |
20 | # include <config.h> | |
21 | #endif | |
22 | ||
2c5c07f5 AS |
23 | #include <error.h> |
24 | #include <libintl.h> | |
036cc82f RM |
25 | #include <stdio.h> |
26 | #include <string.h> | |
27 | #include <wchar.h> | |
28 | ||
29 | #include "localeinfo.h" | |
30 | ||
31 | ||
32 | /* We provide support for some special names. This helps debugging | |
33 | and may be useful for advanced usage of the provided information | |
34 | outside C. */ | |
35 | void | |
36 | locale_special (const char *name, int show_category_name, | |
37 | int show_keyword_name) | |
38 | { | |
b06c53e7 | 39 | #if 0 |
036cc82f RM |
40 | /* "collate-elements": print collation elements of locale. */ |
41 | if (strcmp (name, "collate-elements") == 0) | |
42 | { | |
43 | size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE); | |
44 | ||
45 | if (show_category_name) | |
46 | puts ("LC_COLLATE"); | |
47 | if (show_keyword_name) | |
48 | fputs ("collate-elements=", stdout); | |
49 | ||
50 | if (nelem != 0) | |
51 | { | |
52 | int first = 1; | |
53 | size_t cnt; | |
54 | ||
55 | for (cnt = 0; cnt < nelem; ++cnt) | |
d9fee042 | 56 | if (__collate_element_hash[2 * cnt] != (~((uint32_t) 0))) |
036cc82f RM |
57 | { |
58 | size_t idx = __collate_element_hash[2 * cnt]; | |
59 | ||
60 | printf ("%s<%s>", first ? "" : ";", | |
61 | &__collate_element_strings[idx]); | |
62 | ||
036cc82f RM |
63 | /* We don't print the string. This is only confusing |
64 | because only the programs have to know the | |
65 | encoding. The code is left in place because it | |
66 | shows how to get the information. */ | |
67 | { | |
68 | const wchar_t *wp; | |
69 | ||
70 | idx = __collate_element_hash[2 * cnt + 1]; | |
71 | wp = &__collate_element_values[idx]; | |
72 | while (*wp != L'\0') | |
73 | { | |
74 | /********************************************\ | |
75 | |* XXX The element values are really wide *| | |
76 | |* chars. But we are currently not able to *| | |
77 | |* print these so fake here. *| | |
78 | \********************************************/ | |
79 | int ch = wctob (*wp++); | |
80 | if (ch != EOF) | |
81 | putchar (ch); | |
82 | else | |
b1418d8f | 83 | fputs ("<??\?>", stdout); |
036cc82f RM |
84 | } |
85 | ||
86 | putchar ('"'); | |
87 | } | |
036cc82f RM |
88 | first = 0; |
89 | } | |
90 | } | |
91 | putchar ('\n'); | |
92 | return; | |
93 | } | |
ce7a5ef4 RM |
94 | |
95 | if (strcmp (name, "collate-classes") == 0) | |
96 | { | |
97 | size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE); | |
98 | size_t cnt; | |
99 | int first = 1; | |
100 | ||
101 | if (show_category_name) | |
102 | puts ("LC_COLLATE"); | |
103 | if (show_keyword_name) | |
104 | fputs ("collate-classes=", stdout); | |
105 | ||
106 | for (cnt = 0; cnt < nelem; ++cnt) | |
107 | if (__collate_symbol_hash[2 * cnt] != 0xffffffff) | |
108 | { | |
109 | printf ("%s<%s>", first ? "" : ",", | |
110 | &__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]); | |
4b10dd6c | 111 | #if 0 |
ce7a5ef4 RM |
112 | { |
113 | size_t idx = __collate_symbol_hash[2 * cnt + 1]; | |
114 | size_t cls; | |
115 | ||
116 | putchar ('='); | |
117 | for (cls = 0; cls < __collate_symbol_classes[idx]; ++cls) | |
118 | printf ("%s%d", cls == 0 ? "" : ":", | |
119 | __collate_symbol_classes[idx + 1 + cls]); | |
120 | } | |
121 | #endif | |
122 | first = 0; | |
123 | } | |
124 | putchar ('\n'); | |
125 | return; | |
126 | } | |
b06c53e7 | 127 | #endif |
9d076f21 UD |
128 | |
129 | /* If nothing matches, fail. */ | |
130 | error (1, 0, gettext ("unknown name \"%s\""), name); | |
036cc82f | 131 | } |