]> git.ipfire.org Git - thirdparty/glibc.git/blame - locale/programs/locale-spec.c
Handle future binutils versions correctly.
[thirdparty/glibc.git] / locale / programs / locale-spec.c
CommitLineData
036cc82f 1/* Handle special requests.
43bc8ac6 2 Copyright (C) 1996, 1997, 1999, 2005 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
UD
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. */
036cc82f
RM
19
20#ifdef HAVE_CONFIG_H
21# include <config.h>
22#endif
23
24#include <stdio.h>
25#include <string.h>
26#include <wchar.h>
27
28#include "localeinfo.h"
29
30
31/* We provide support for some special names. This helps debugging
32 and may be useful for advanced usage of the provided information
33 outside C. */
34void
35locale_special (const char *name, int show_category_name,
36 int show_keyword_name)
37{
b06c53e7 38#if 0
036cc82f
RM
39 /* "collate-elements": print collation elements of locale. */
40 if (strcmp (name, "collate-elements") == 0)
41 {
42 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE);
43
44 if (show_category_name)
45 puts ("LC_COLLATE");
46 if (show_keyword_name)
47 fputs ("collate-elements=", stdout);
48
49 if (nelem != 0)
50 {
51 int first = 1;
52 size_t cnt;
53
54 for (cnt = 0; cnt < nelem; ++cnt)
55 if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0)))
56 {
57 size_t idx = __collate_element_hash[2 * cnt];
58
59 printf ("%s<%s>", first ? "" : ";",
60 &__collate_element_strings[idx]);
61
036cc82f
RM
62 /* We don't print the string. This is only confusing
63 because only the programs have to know the
64 encoding. The code is left in place because it
65 shows how to get the information. */
66 {
67 const wchar_t *wp;
68
69 idx = __collate_element_hash[2 * cnt + 1];
70 wp = &__collate_element_values[idx];
71 while (*wp != L'\0')
72 {
73 /********************************************\
74 |* XXX The element values are really wide *|
75 |* chars. But we are currently not able to *|
76 |* print these so fake here. *|
77 \********************************************/
78 int ch = wctob (*wp++);
79 if (ch != EOF)
80 putchar (ch);
81 else
b1418d8f 82 fputs ("<??\?>", stdout);
036cc82f
RM
83 }
84
85 putchar ('"');
86 }
036cc82f
RM
87 first = 0;
88 }
89 }
90 putchar ('\n');
91 return;
92 }
ce7a5ef4
RM
93
94 if (strcmp (name, "collate-classes") == 0)
95 {
96 size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZE);
97 size_t cnt;
98 int first = 1;
99
100 if (show_category_name)
101 puts ("LC_COLLATE");
102 if (show_keyword_name)
103 fputs ("collate-classes=", stdout);
104
105 for (cnt = 0; cnt < nelem; ++cnt)
106 if (__collate_symbol_hash[2 * cnt] != 0xffffffff)
107 {
108 printf ("%s<%s>", first ? "" : ",",
109 &__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]);
4b10dd6c 110#if 0
ce7a5ef4
RM
111 {
112 size_t idx = __collate_symbol_hash[2 * cnt + 1];
113 size_t cls;
114
115 putchar ('=');
116 for (cls = 0; cls < __collate_symbol_classes[idx]; ++cls)
117 printf ("%s%d", cls == 0 ? "" : ":",
118 __collate_symbol_classes[idx + 1 + cls]);
119 }
120#endif
121 first = 0;
122 }
123 putchar ('\n');
124 return;
125 }
b06c53e7 126#endif
036cc82f 127}