Update.
[glibc/history.git] / locale / programs / locale-spec.c
bloba1a3aba47f7e1d8bab615cb9f79edcb78f3fc637
1 /* Handle special requests.
2 Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the 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 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
25 #include <stdio.h>
26 #include <string.h>
27 #include <wchar.h>
29 #include "localeinfo.h"
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)
39 #if 0
40 /* "collate-elements": print collation elements of locale. */
41 if (strcmp (name, "collate-elements") == 0)
43 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE);
45 if (show_category_name)
46 puts ("LC_COLLATE");
47 if (show_keyword_name)
48 fputs ("collate-elements=", stdout);
50 if (nelem != 0)
52 int first = 1;
53 size_t cnt;
55 for (cnt = 0; cnt < nelem; ++cnt)
56 if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0)))
58 size_t idx = __collate_element_hash[2 * cnt];
60 printf ("%s<%s>", first ? "" : ";",
61 &__collate_element_strings[idx]);
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. */
68 const wchar_t *wp;
70 idx = __collate_element_hash[2 * cnt + 1];
71 wp = &__collate_element_values[idx];
72 while (*wp != L'\0')
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
83 fputs ("<??\?>", stdout);
86 putchar ('"');
88 first = 0;
91 putchar ('\n');
92 return;
95 if (strcmp (name, "collate-classes") == 0)
97 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE);
98 size_t cnt;
99 int first = 1;
101 if (show_category_name)
102 puts ("LC_COLLATE");
103 if (show_keyword_name)
104 fputs ("collate-classes=", stdout);
106 for (cnt = 0; cnt < nelem; ++cnt)
107 if (__collate_symbol_hash[2 * cnt] != 0xffffffff)
109 printf ("%s<%s>", first ? "" : ",",
110 &__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]);
111 #if 0
113 size_t idx = __collate_symbol_hash[2 * cnt + 1];
114 size_t cls;
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]);
121 #endif
122 first = 0;
124 putchar ('\n');
125 return;
127 #endif