1 /* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
19 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
22 #ifndef _@GUARD_PREFIX@_LANGINFO_H
25 @PRAGMA_SYSTEM_HEADER@
29 /* The include_next requires a split double-inclusion guard. */
31 # @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
34 #ifndef _@GUARD_PREFIX@_LANGINFO_H
35 #define _@GUARD_PREFIX@_LANGINFO_H
37 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
38 #if !_GL_CONFIG_H_INCLUDED
39 #error "Please include config.h first."
43 #if !@HAVE_LANGINFO_H@
45 /* A platform that lacks <langinfo.h>. */
47 /* Assume that it also lacks <nl_types.h> and the nl_item type. */
48 # if !GNULIB_defined_nl_item
50 # define GNULIB_defined_nl_item 1
53 /* nl_langinfo items of the LC_CTYPE category */
54 # define CODESET 10000
55 /* nl_langinfo items of the LC_NUMERIC category */
56 # define RADIXCHAR 10001
57 # define DECIMAL_POINT RADIXCHAR
58 # define THOUSEP 10002
59 # define THOUSANDS_SEP THOUSEP
60 # define GROUPING 10114
61 /* nl_langinfo items of the LC_TIME category */
62 # define D_T_FMT 10003
65 # define T_FMT_AMPM 10006
69 # define DAY_2 (DAY_1 + 1)
70 # define DAY_3 (DAY_1 + 2)
71 # define DAY_4 (DAY_1 + 3)
72 # define DAY_5 (DAY_1 + 4)
73 # define DAY_6 (DAY_1 + 5)
74 # define DAY_7 (DAY_1 + 6)
75 # define ABDAY_1 10016
76 # define ABDAY_2 (ABDAY_1 + 1)
77 # define ABDAY_3 (ABDAY_1 + 2)
78 # define ABDAY_4 (ABDAY_1 + 3)
79 # define ABDAY_5 (ABDAY_1 + 4)
80 # define ABDAY_6 (ABDAY_1 + 5)
81 # define ABDAY_7 (ABDAY_1 + 6)
83 # define MON_2 (MON_1 + 1)
84 # define MON_3 (MON_1 + 2)
85 # define MON_4 (MON_1 + 3)
86 # define MON_5 (MON_1 + 4)
87 # define MON_6 (MON_1 + 5)
88 # define MON_7 (MON_1 + 6)
89 # define MON_8 (MON_1 + 7)
90 # define MON_9 (MON_1 + 8)
91 # define MON_10 (MON_1 + 9)
92 # define MON_11 (MON_1 + 10)
93 # define MON_12 (MON_1 + 11)
94 # define ALTMON_1 10200
95 # define ALTMON_2 (ALTMON_1 + 1)
96 # define ALTMON_3 (ALTMON_1 + 2)
97 # define ALTMON_4 (ALTMON_1 + 3)
98 # define ALTMON_5 (ALTMON_1 + 4)
99 # define ALTMON_6 (ALTMON_1 + 5)
100 # define ALTMON_7 (ALTMON_1 + 6)
101 # define ALTMON_8 (ALTMON_1 + 7)
102 # define ALTMON_9 (ALTMON_1 + 8)
103 # define ALTMON_10 (ALTMON_1 + 9)
104 # define ALTMON_11 (ALTMON_1 + 10)
105 # define ALTMON_12 (ALTMON_1 + 11)
106 # define ABMON_1 10035
107 # define ABMON_2 (ABMON_1 + 1)
108 # define ABMON_3 (ABMON_1 + 2)
109 # define ABMON_4 (ABMON_1 + 3)
110 # define ABMON_5 (ABMON_1 + 4)
111 # define ABMON_6 (ABMON_1 + 5)
112 # define ABMON_7 (ABMON_1 + 6)
113 # define ABMON_8 (ABMON_1 + 7)
114 # define ABMON_9 (ABMON_1 + 8)
115 # define ABMON_10 (ABMON_1 + 9)
116 # define ABMON_11 (ABMON_1 + 10)
117 # define ABMON_12 (ABMON_1 + 11)
119 # define ERA_D_FMT 10048
120 # define ERA_D_T_FMT 10049
121 # define ERA_T_FMT 10050
122 # define ALT_DIGITS 10051
123 /* nl_langinfo items of the LC_MONETARY category */
124 # define CRNCYSTR 10052
125 # define CURRENCY_SYMBOL CRNCYSTR
126 # define INT_CURR_SYMBOL 10100
127 # define MON_DECIMAL_POINT 10101
128 # define MON_THOUSANDS_SEP 10102
129 # define MON_GROUPING 10103
130 # define POSITIVE_SIGN 10104
131 # define NEGATIVE_SIGN 10105
132 # define FRAC_DIGITS 10106
133 # define INT_FRAC_DIGITS 10107
134 # define P_CS_PRECEDES 10108
135 # define N_CS_PRECEDES 10109
136 # define P_SEP_BY_SPACE 10110
137 # define N_SEP_BY_SPACE 10111
138 # define P_SIGN_POSN 10112
139 # define N_SIGN_POSN 10113
140 /* nl_langinfo items of the LC_MESSAGES category */
141 # define YESEXPR 10053
142 # define NOEXPR 10054
146 /* A platform that has <langinfo.h>. */
148 # if !@HAVE_LANGINFO_CODESET@
149 # define CODESET 10000
150 # define GNULIB_defined_CODESET 1
153 # if !@HAVE_LANGINFO_T_FMT_AMPM@
154 # define T_FMT_AMPM 10006
155 # define GNULIB_defined_T_FMT_AMPM 1
158 # if !@HAVE_LANGINFO_ALTMON@
159 # define ALTMON_1 10200
160 # define ALTMON_2 (ALTMON_1 + 1)
161 # define ALTMON_3 (ALTMON_1 + 2)
162 # define ALTMON_4 (ALTMON_1 + 3)
163 # define ALTMON_5 (ALTMON_1 + 4)
164 # define ALTMON_6 (ALTMON_1 + 5)
165 # define ALTMON_7 (ALTMON_1 + 6)
166 # define ALTMON_8 (ALTMON_1 + 7)
167 # define ALTMON_9 (ALTMON_1 + 8)
168 # define ALTMON_10 (ALTMON_1 + 9)
169 # define ALTMON_11 (ALTMON_1 + 10)
170 # define ALTMON_12 (ALTMON_1 + 11)
171 # define GNULIB_defined_ALTMON 1
174 # if !@HAVE_LANGINFO_ERA@
176 # define ERA_D_FMT 10048
177 # define ERA_D_T_FMT 10049
178 # define ERA_T_FMT 10050
179 # define ALT_DIGITS 10051
180 # define GNULIB_defined_ERA 1
183 # if !@HAVE_LANGINFO_YESEXPR@
184 # define YESEXPR 10053
185 # define NOEXPR 10054
186 # define GNULIB_defined_YESEXPR 1
191 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
193 /* The definition of _GL_WARN_ON_USE is copied here. */
195 /* Declare overridden functions. */
198 /* Return a piece of locale dependent information.
199 Note: The difference between nl_langinfo (CODESET) and locale_charset ()
200 is that the latter normalizes the encoding names to GNU conventions. */
202 #if @GNULIB_NL_LANGINFO@
203 # if @REPLACE_NL_LANGINFO@
204 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
206 # define nl_langinfo rpl_nl_langinfo
208 _GL_FUNCDECL_RPL (nl_langinfo
, char *, (nl_item item
), );
209 _GL_CXXALIAS_RPL (nl_langinfo
, char *, (nl_item item
));
211 # if !@HAVE_NL_LANGINFO@
212 _GL_FUNCDECL_SYS (nl_langinfo
, char *, (nl_item item
), );
214 _GL_CXXALIAS_SYS (nl_langinfo
, char *, (nl_item item
));
217 _GL_CXXALIASWARN (nl_langinfo
);
219 #elif defined GNULIB_POSIXCHECK
221 # if HAVE_RAW_DECL_NL_LANGINFO
222 _GL_WARN_ON_USE (nl_langinfo
, "nl_langinfo is not portable - "
223 "use gnulib module nl_langinfo for portability");
228 #endif /* _@GUARD_PREFIX@_LANGINFO_H */
229 #endif /* _@GUARD_PREFIX@_LANGINFO_H */