Merge remote branch 'origin/roland/hwcap_mask'
[glibc.git] / locale / programs / locale-spec.c
blob43df46bb38cf8f785a407e7049b0fb0516d603cd
1 /* Handle special requests.
2 Copyright (C) 1996, 1997, 1999, 2005, 2009 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 This program is free software; you can redistribute it and/or modify
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.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
24 #include <error.h>
25 #include <libintl.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <wchar.h>
30 #include "localeinfo.h"
33 /* We provide support for some special names. This helps debugging
34 and may be useful for advanced usage of the provided information
35 outside C. */
36 void
37 locale_special (const char *name, int show_category_name,
38 int show_keyword_name)
40 #if 0
41 /* "collate-elements": print collation elements of locale. */
42 if (strcmp (name, "collate-elements") == 0)
44 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE);
46 if (show_category_name)
47 puts ("LC_COLLATE");
48 if (show_keyword_name)
49 fputs ("collate-elements=", stdout);
51 if (nelem != 0)
53 int first = 1;
54 size_t cnt;
56 for (cnt = 0; cnt < nelem; ++cnt)
57 if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0)))
59 size_t idx = __collate_element_hash[2 * cnt];
61 printf ("%s<%s>", first ? "" : ";",
62 &__collate_element_strings[idx]);
64 /* We don't print the string. This is only confusing
65 because only the programs have to know the
66 encoding. The code is left in place because it
67 shows how to get the information. */
69 const wchar_t *wp;
71 idx = __collate_element_hash[2 * cnt + 1];
72 wp = &__collate_element_values[idx];
73 while (*wp != L'\0')
75 /********************************************\
76 |* XXX The element values are really wide *|
77 |* chars. But we are currently not able to *|
78 |* print these so fake here. *|
79 \********************************************/
80 int ch = wctob (*wp++);
81 if (ch != EOF)
82 putchar (ch);
83 else
84 fputs ("<??\?>", stdout);
87 putchar ('"');
89 first = 0;
92 putchar ('\n');
93 return;
96 if (strcmp (name, "collate-classes") == 0)
98 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE);
99 size_t cnt;
100 int first = 1;
102 if (show_category_name)
103 puts ("LC_COLLATE");
104 if (show_keyword_name)
105 fputs ("collate-classes=", stdout);
107 for (cnt = 0; cnt < nelem; ++cnt)
108 if (__collate_symbol_hash[2 * cnt] != 0xffffffff)
110 printf ("%s<%s>", first ? "" : ",",
111 &__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]);
112 #if 0
114 size_t idx = __collate_symbol_hash[2 * cnt + 1];
115 size_t cls;
117 putchar ('=');
118 for (cls = 0; cls < __collate_symbol_classes[idx]; ++cls)
119 printf ("%s%d", cls == 0 ? "" : ":",
120 __collate_symbol_classes[idx + 1 + cls]);
122 #endif
123 first = 0;
125 putchar ('\n');
126 return;
128 #endif
130 /* If nothing matches, fail. */
131 error (1, 0, gettext ("unknown name \"%s\""), name);