1 /* Handle special requests.
2 Copyright (C) 1996 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 Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 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 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If
18 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
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
36 locale_special (const char *name, int show_category_name,
37 int show_keyword_name)
39 /* "collate-elements": print collation elements of locale. */
40 if (strcmp (name, "collate-elements") == 0)
42 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE);
44 if (show_category_name)
46 if (show_keyword_name)
47 fputs ("collate-elements=", stdout);
54 for (cnt = 0; cnt < nelem; ++cnt)
55 if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0)))
57 size_t idx = __collate_element_hash[2 * cnt];
59 printf ("%s<%s>", first ? "" : ";",
60 &__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. */
70 idx = __collate_element_hash[2 * cnt + 1];
71 wp = &__collate_element_values[idx];
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++);
83 fputs ("<???>", stdout);
96 if (strcmp (name, "collate-classes") == 0)
98 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE);
102 if (show_category_name)
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]]);
114 size_t idx = __collate_symbol_hash[2 * cnt + 1];
118 for (cls = 0; cls < __collate_symbol_classes[idx]; ++cls)
119 printf ("%s%d", cls == 0 ? "" : ":",
120 __collate_symbol_classes[idx + 1 + cls]);