file tst-cputimer1.c was initially added on branch fedora-branch.
[glibc/history.git] / locale / programs / locale-spec.c
blob6ad3d95efed36e5029ad407dab4f7ebd7d2fe364
1 /* Handle special requests.
2 Copyright (C) 1996, 1997, 1999, 2005 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 version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
23 #include <stdio.h>
24 #include <string.h>
25 #include <wchar.h>
27 #include "localeinfo.h"
30 /* We provide support for some special names. This helps debugging
31 and may be useful for advanced usage of the provided information
32 outside C. */
33 void
34 locale_special (const char *name, int show_category_name,
35 int show_keyword_name)
37 #if 0
38 /* "collate-elements": print collation elements of locale. */
39 if (strcmp (name, "collate-elements") == 0)
41 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE);
43 if (show_category_name)
44 puts ("LC_COLLATE");
45 if (show_keyword_name)
46 fputs ("collate-elements=", stdout);
48 if (nelem != 0)
50 int first = 1;
51 size_t cnt;
53 for (cnt = 0; cnt < nelem; ++cnt)
54 if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0)))
56 size_t idx = __collate_element_hash[2 * cnt];
58 printf ("%s<%s>", first ? "" : ";",
59 &__collate_element_strings[idx]);
61 /* We don't print the string. This is only confusing
62 because only the programs have to know the
63 encoding. The code is left in place because it
64 shows how to get the information. */
66 const wchar_t *wp;
68 idx = __collate_element_hash[2 * cnt + 1];
69 wp = &__collate_element_values[idx];
70 while (*wp != L'\0')
72 /********************************************\
73 |* XXX The element values are really wide *|
74 |* chars. But we are currently not able to *|
75 |* print these so fake here. *|
76 \********************************************/
77 int ch = wctob (*wp++);
78 if (ch != EOF)
79 putchar (ch);
80 else
81 fputs ("<??\?>", stdout);
84 putchar ('"');
86 first = 0;
89 putchar ('\n');
90 return;
93 if (strcmp (name, "collate-classes") == 0)
95 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE);
96 size_t cnt;
97 int first = 1;
99 if (show_category_name)
100 puts ("LC_COLLATE");
101 if (show_keyword_name)
102 fputs ("collate-classes=", stdout);
104 for (cnt = 0; cnt < nelem; ++cnt)
105 if (__collate_symbol_hash[2 * cnt] != 0xffffffff)
107 printf ("%s<%s>", first ? "" : ",",
108 &__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]);
109 #if 0
111 size_t idx = __collate_symbol_hash[2 * cnt + 1];
112 size_t cls;
114 putchar ('=');
115 for (cls = 0; cls < __collate_symbol_classes[idx]; ++cls)
116 printf ("%s%d", cls == 0 ? "" : ":",
117 __collate_symbol_classes[idx + 1 + cls]);
119 #endif
120 first = 0;
122 putchar ('\n');
123 return;
125 #endif