1 /* $NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $ */
4 * Copyright (c)2008 Citrus Project,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 #if defined(LIBC_SCCS) && !defined(lint)
31 __RCSID("$NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $");
32 #endif /* LIBC_SCCS and not lint */
34 #include <sys/types.h>
35 #include <sys/ctype_bits.h>
36 #include <sys/localedef.h>
39 #define __SETLOCALE_SOURCE__
43 #include "runetype_local.h"
44 #include "setlocale_local.h"
47 #define NBCHAR_MAX (char)CHAR_MAX
50 static const _MessagesLocale _DefaultMessagesLocale
= {
57 static const _MonetaryLocale _DefaultMonetaryLocale
= {
81 static const _NumericLocale _DefaultNumericLocale
= {
87 static const _TimeLocale _DefaultTimeLocale
=
90 "Sun","Mon","Tue","Wed","Thu","Fri","Sat",
93 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
97 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
98 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
101 "January", "February", "March", "April", "May", "June", "July",
102 "August", "September", "October", "November", "December"
107 "%a %b %e %H:%M:%S %Y",
113 static const char _lc_C_locale_name
[] = _C_LOCALE
;
115 __dso_hidden
const struct _locale_cache_t _C_cache
= {
117 .decimal_point
= __UNCONST("."),
118 .thousands_sep
= __UNCONST(""),
119 .grouping
= __UNCONST(""),
120 .int_curr_symbol
= __UNCONST(""),
121 .currency_symbol
= __UNCONST(""),
122 .mon_decimal_point
= __UNCONST(""),
123 .mon_thousands_sep
= __UNCONST(""),
124 .mon_grouping
= __UNCONST(""),
125 .positive_sign
= __UNCONST(""),
126 .negative_sign
= __UNCONST(""),
127 .int_frac_digits
= NBCHAR_MAX
,
128 .frac_digits
= NBCHAR_MAX
,
129 .p_cs_precedes
= NBCHAR_MAX
,
130 .p_sep_by_space
= NBCHAR_MAX
,
131 .n_cs_precedes
= NBCHAR_MAX
,
132 .n_sep_by_space
= NBCHAR_MAX
,
133 .p_sign_posn
= NBCHAR_MAX
,
134 .n_sign_posn
= NBCHAR_MAX
,
135 .int_p_cs_precedes
= NBCHAR_MAX
,
136 .int_n_cs_precedes
= NBCHAR_MAX
,
137 .int_p_sep_by_space
= NBCHAR_MAX
,
138 .int_n_sep_by_space
= NBCHAR_MAX
,
139 .int_p_sign_posn
= NBCHAR_MAX
,
140 .int_n_sign_posn
= NBCHAR_MAX
,
142 .monetary_name
= _lc_C_locale_name
,
143 .numeric_name
= _lc_C_locale_name
,
146 __dso_protected
struct _locale _lc_global_locale
= {
148 .query
= { _C_LOCALE
},
150 [(size_t)LC_ALL
] = _lc_C_locale_name
,
151 [(size_t)LC_COLLATE
] = _lc_C_locale_name
,
152 [(size_t)LC_CTYPE
] = _lc_C_locale_name
,
153 [(size_t)LC_MONETARY
] = _lc_C_locale_name
,
154 [(size_t)LC_NUMERIC
] = _lc_C_locale_name
,
155 [(size_t)LC_TIME
] = _lc_C_locale_name
,
156 [(size_t)LC_MESSAGES
] = _lc_C_locale_name
,
159 [(size_t)LC_ALL
] = (_locale_part_t
)NULL
,
160 [(size_t)LC_COLLATE
] = (_locale_part_t
)NULL
,
161 [(size_t)LC_CTYPE
] = (_locale_part_t
)
162 __UNCONST(&_DefaultRuneLocale
),
163 [(size_t)LC_MONETARY
] = (_locale_part_t
)
164 __UNCONST(&_DefaultMonetaryLocale
),
165 [(size_t)LC_NUMERIC
] = (_locale_part_t
)
166 __UNCONST(&_DefaultNumericLocale
),
167 [(size_t)LC_MESSAGES
] = (_locale_part_t
)
168 __UNCONST(&_DefaultMessagesLocale
),
169 [(size_t)LC_TIME
] = (_locale_part_t
)
170 __UNCONST(&_DefaultTimeLocale
),
174 __dso_protected
const struct _locale _lc_C_locale
= {
176 .query
= { _C_LOCALE
},
178 [(size_t)LC_ALL
] = _lc_C_locale_name
,
179 [(size_t)LC_COLLATE
] = _lc_C_locale_name
,
180 [(size_t)LC_CTYPE
] = _lc_C_locale_name
,
181 [(size_t)LC_MONETARY
] = _lc_C_locale_name
,
182 [(size_t)LC_NUMERIC
] = _lc_C_locale_name
,
183 [(size_t)LC_TIME
] = _lc_C_locale_name
,
184 [(size_t)LC_MESSAGES
] = _lc_C_locale_name
,
187 [(size_t)LC_ALL
] = (_locale_part_t
)NULL
,
188 [(size_t)LC_COLLATE
] = (_locale_part_t
)NULL
,
189 [(size_t)LC_CTYPE
] = (_locale_part_t
)
190 __UNCONST(&_DefaultRuneLocale
),
191 [(size_t)LC_MONETARY
] = (_locale_part_t
)
192 __UNCONST(&_DefaultMonetaryLocale
),
193 [(size_t)LC_NUMERIC
] = (_locale_part_t
)
194 __UNCONST(&_DefaultNumericLocale
),
195 [(size_t)LC_MESSAGES
] = (_locale_part_t
)
196 __UNCONST(&_DefaultMessagesLocale
),
197 [(size_t)LC_TIME
] = (_locale_part_t
)
198 __UNCONST(&_DefaultTimeLocale
),