2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 @PRAGMA_SYSTEM_HEADER@
22 #if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
23 || defined _GL_ALREADY_INCLUDING_LOCALE_H
25 /* Special invocation convention:
26 - Inside mingw header files,
27 - To handle Solaris header files (through Solaris 10) when combined
28 with gettext's libintl.h. */
30 #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
33 /* Normal invocation convention. */
35 #ifndef _@GUARD_PREFIX@_LOCALE_H
37 #define _GL_ALREADY_INCLUDING_LOCALE_H
39 /* The include_next requires a split double-inclusion guard. */
40 #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
42 #undef _GL_ALREADY_INCLUDING_LOCALE_H
44 #ifndef _@GUARD_PREFIX@_LOCALE_H
45 #define _@GUARD_PREFIX@_LOCALE_H
47 /* NetBSD 5.0 mis-defines NULL. */
50 /* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
55 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
57 /* The definition of _GL_ARG_NONNULL is copied here. */
59 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
62 On systems that don't define it, use the same value as GNU libintl. */
63 #if !defined LC_MESSAGES
64 # define LC_MESSAGES 1729
67 /* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
68 int_n_*. Instead of overriding 'struct lconv', merely define these member
69 names as macros. This avoids trouble in C++ mode. */
71 # define int_p_cs_precedes p_cs_precedes
72 # define int_p_sign_posn p_sign_posn
73 # define int_p_sep_by_space p_sep_by_space
74 # define int_n_cs_precedes n_cs_precedes
75 # define int_n_sign_posn n_sign_posn
76 # define int_n_sep_by_space n_sep_by_space
79 /* Bionic libc's 'struct lconv' is just a dummy. */
80 #if @REPLACE_STRUCT_LCONV@
81 # define lconv rpl_lconv
84 /* All 'char *' are actually 'const char *'. */
86 /* Members that depend on the LC_NUMERIC category of the locale. See
87 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
89 /* Symbol used as decimal point. */
91 /* Symbol used to separate groups of digits to the left of the decimal
94 /* Definition of the size of groups of digits to the left of the decimal
98 /* Members that depend on the LC_MONETARY category of the locale. See
99 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
101 /* Symbol used as decimal point. */
102 char *mon_decimal_point
;
103 /* Symbol used to separate groups of digits to the left of the decimal
105 char *mon_thousands_sep
;
106 /* Definition of the size of groups of digits to the left of the decimal
109 /* Sign used to indicate a value >= 0. */
111 /* Sign used to indicate a value < 0. */
114 /* For formatting local currency. */
115 /* Currency symbol (3 characters) followed by separator (1 character). */
116 char *currency_symbol
;
117 /* Number of digits after the decimal point. */
119 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
120 comes after the number. */
122 /* For values >= 0: Position of the sign. */
124 /* For values >= 0: Placement of spaces between currency symbol, sign, and
127 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
128 comes after the number. */
130 /* For values < 0: Position of the sign. */
132 /* For values < 0: Placement of spaces between currency symbol, sign, and
136 /* For formatting international currency. */
137 /* Currency symbol (3 characters) followed by separator (1 character). */
138 char *int_curr_symbol
;
139 /* Number of digits after the decimal point. */
140 char int_frac_digits
;
141 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
142 comes after the number. */
143 char int_p_cs_precedes
;
144 /* For values >= 0: Position of the sign. */
145 char int_p_sign_posn
;
146 /* For values >= 0: Placement of spaces between currency symbol, sign, and
148 char int_p_sep_by_space
;
149 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
150 comes after the number. */
151 char int_n_cs_precedes
;
152 /* For values < 0: Position of the sign. */
153 char int_n_sign_posn
;
154 /* For values < 0: Placement of spaces between currency symbol, sign, and
156 char int_n_sep_by_space
;
160 #if @GNULIB_LOCALECONV@
161 # if @REPLACE_LOCALECONV@
162 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
164 # define localeconv rpl_localeconv
166 _GL_FUNCDECL_RPL (localeconv
, struct lconv
*, (void));
167 _GL_CXXALIAS_RPL (localeconv
, struct lconv
*, (void));
169 _GL_CXXALIAS_SYS (localeconv
, struct lconv
*, (void));
172 _GL_CXXALIASWARN (localeconv
);
174 #elif @REPLACE_STRUCT_LCONV@
176 # define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
177 #elif defined GNULIB_POSIXCHECK
179 # if HAVE_RAW_DECL_LOCALECONV
180 _GL_WARN_ON_USE (localeconv
,
181 "localeconv returns too few information on some platforms - "
182 "use gnulib module localeconv for portability");
186 #if @GNULIB_SETLOCALE@
187 # if @REPLACE_SETLOCALE@
188 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
190 # define setlocale rpl_setlocale
191 # define GNULIB_defined_setlocale 1
193 _GL_FUNCDECL_RPL (setlocale
, char *, (int category
, const char *locale
));
194 _GL_CXXALIAS_RPL (setlocale
, char *, (int category
, const char *locale
));
196 _GL_CXXALIAS_SYS (setlocale
, char *, (int category
, const char *locale
));
199 _GL_CXXALIASWARN (setlocale
);
201 #elif defined GNULIB_POSIXCHECK
203 # if HAVE_RAW_DECL_SETLOCALE
204 _GL_WARN_ON_USE (setlocale
, "setlocale works differently on native Windows - "
205 "use gnulib module setlocale for portability");
209 #if @GNULIB_SETLOCALE_NULL@
210 /* Recommended size of a buffer for a locale name for a single category.
211 On glibc systems, you can have locale names that are relative file names;
212 assume a maximum length 256.
213 In native Windows, in 2018 the longest locale name was of length 58
214 ("FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251"). */
215 # define SETLOCALE_NULL_MAX (256+1)
216 /* Recommended size of a buffer for a locale name with all categories.
217 On glibc systems, you can have locale names that are relative file names;
218 assume maximum length 256 for each. There are 12 categories; so, the
219 maximum total length is 148+12*256.
220 In native Windows, there are 5 categories, and the maximum total length is
222 # define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
223 /* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
225 - it is guaranteed to be multithread-safe,
226 - it returns the resulting locale category name or locale name in the
227 user-supplied buffer BUF, which must be BUFSIZE bytes long.
228 The recommended minimum buffer size is
229 - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and
230 - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL.
231 The return value is an error code: 0 if the call is successful, EINVAL if
232 CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed
233 size (including the trailing NUL byte). In the latter case, a truncated
234 result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
235 For this call to be multithread-safe, *all* calls to
236 setlocale (CATEGORY, NULL) in all other threads must have been converted
237 to use setlocale_null_r or setlocale_null as well, and the other threads
238 must not make other setlocale invocations (since changing the global locale
239 has side effects on all threads). */
240 _GL_FUNCDECL_SYS (setlocale_null_r
, int,
241 (int category
, char *buf
, size_t bufsize
)
242 _GL_ARG_NONNULL ((2)));
243 _GL_CXXALIAS_SYS (setlocale_null_r
, int,
244 (int category
, char *buf
, size_t bufsize
));
245 _GL_CXXALIASWARN (setlocale_null_r
);
246 /* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that
247 it is guaranteed to be multithread-safe.
248 The return value is NULL if CATEGORY is invalid.
249 For this call to be multithread-safe, *all* calls to
250 setlocale (CATEGORY, NULL) in all other threads must have been converted
251 to use setlocale_null_r or setlocale_null as well, and the other threads
252 must not make other setlocale invocations (since changing the global locale
253 has side effects on all threads). */
254 _GL_FUNCDECL_SYS (setlocale_null
, const char *, (int category
));
255 _GL_CXXALIAS_SYS (setlocale_null
, const char *, (int category
));
256 _GL_CXXALIASWARN (setlocale_null
);
259 #if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
260 # if @REPLACE_NEWLOCALE@
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
263 # define newlocale rpl_newlocale
264 # define GNULIB_defined_newlocale 1
266 _GL_FUNCDECL_RPL (newlocale
, locale_t
,
267 (int category_mask
, const char *name
, locale_t base
)
268 _GL_ARG_NONNULL ((2)));
269 _GL_CXXALIAS_RPL (newlocale
, locale_t
,
270 (int category_mask
, const char *name
, locale_t base
));
272 # if @HAVE_NEWLOCALE@
273 _GL_CXXALIAS_SYS (newlocale
, locale_t
,
274 (int category_mask
, const char *name
, locale_t base
));
277 # if @HAVE_NEWLOCALE@
278 _GL_CXXALIASWARN (newlocale
);
280 # if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
281 # ifndef HAVE_WORKING_NEWLOCALE
282 # define HAVE_WORKING_NEWLOCALE 1
285 #elif defined GNULIB_POSIXCHECK
287 # if HAVE_RAW_DECL_NEWLOCALE
288 _GL_WARN_ON_USE (newlocale
, "newlocale is not portable");
292 #if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
293 # if @REPLACE_DUPLOCALE@
294 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296 # define duplocale rpl_duplocale
297 # define GNULIB_defined_duplocale 1
299 _GL_FUNCDECL_RPL (duplocale
, locale_t
, (locale_t locale
) _GL_ARG_NONNULL ((1)));
300 _GL_CXXALIAS_RPL (duplocale
, locale_t
, (locale_t locale
));
302 # if @HAVE_DUPLOCALE@
303 _GL_CXXALIAS_SYS (duplocale
, locale_t
, (locale_t locale
));
306 # if @HAVE_DUPLOCALE@
307 _GL_CXXALIASWARN (duplocale
);
309 # if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
310 # ifndef HAVE_WORKING_DUPLOCALE
311 # define HAVE_WORKING_DUPLOCALE 1
314 #elif defined GNULIB_POSIXCHECK
316 # if HAVE_RAW_DECL_DUPLOCALE
317 _GL_WARN_ON_USE (duplocale
, "duplocale is buggy on some glibc systems - "
318 "use gnulib module duplocale for portability");
322 #if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
323 # if @REPLACE_FREELOCALE@
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
326 # define freelocale rpl_freelocale
327 # define GNULIB_defined_freelocale 1
329 _GL_FUNCDECL_RPL (freelocale
, void, (locale_t locale
) _GL_ARG_NONNULL ((1)));
330 _GL_CXXALIAS_RPL (freelocale
, void, (locale_t locale
));
332 # if @HAVE_FREELOCALE@
333 /* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
335 _GL_CXXALIAS_SYS_CAST (freelocale
, void, (locale_t locale
));
338 # if @HAVE_FREELOCALE@
339 _GL_CXXALIASWARN (freelocale
);
341 #elif defined GNULIB_POSIXCHECK
343 # if HAVE_RAW_DECL_FREELOCALE
344 _GL_WARN_ON_USE (freelocale
, "freelocale is not portable");
348 #endif /* _@GUARD_PREFIX@_LOCALE_H */
349 #endif /* _@GUARD_PREFIX@_LOCALE_H */
350 #endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */