1 /* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009, 2010 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, or (at your option)
7 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /*
19 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
20 * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
21 */
23 #ifndef _GL_LANGINFO_H
25 #if __GNUC__ >= 3
26 @PRAGMA_SYSTEM_HEADER@
27 #endif
29 /* The include_next requires a split double-inclusion guard. */
30 #if @HAVE_LANGINFO_H@
31 # @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
32 #endif
34 #ifndef _GL_LANGINFO_H
35 #define _GL_LANGINFO_H
38 #if !@HAVE_LANGINFO_H@
40 /* A platform that lacks <langinfo.h>. */
42 /* Assume that it also lacks <nl_types.h> and the nl_item type. */
43 typedef int nl_item;
45 /* nl_langinfo items of the LC_CTYPE category */
46 # define CODESET 10000
47 /* nl_langinfo items of the LC_NUMERIC category */
48 # define RADIXCHAR 10001
49 # define THOUSEP 10002
50 /* nl_langinfo items of the LC_TIME category */
51 # define D_T_FMT 10003
52 # define D_FMT 10004
53 # define T_FMT 10005
54 # define T_FMT_AMPM 10006
55 # define AM_STR 10007
56 # define PM_STR 10008
57 # define DAY_1 10009
58 # define DAY_2 (DAY_1 + 1)
59 # define DAY_3 (DAY_1 + 2)
60 # define DAY_4 (DAY_1 + 3)
61 # define DAY_5 (DAY_1 + 4)
62 # define DAY_6 (DAY_1 + 5)
63 # define DAY_7 (DAY_1 + 6)
64 # define ABDAY_1 10016
65 # define ABDAY_2 (ABDAY_1 + 1)
66 # define ABDAY_3 (ABDAY_1 + 2)
67 # define ABDAY_4 (ABDAY_1 + 3)
68 # define ABDAY_5 (ABDAY_1 + 4)
69 # define ABDAY_6 (ABDAY_1 + 5)
70 # define ABDAY_7 (ABDAY_1 + 6)
71 # define MON_1 10023
72 # define MON_2 (MON_1 + 1)
73 # define MON_3 (MON_1 + 2)
74 # define MON_4 (MON_1 + 3)
75 # define MON_5 (MON_1 + 4)
76 # define MON_6 (MON_1 + 5)
77 # define MON_7 (MON_1 + 6)
78 # define MON_8 (MON_1 + 7)
79 # define MON_9 (MON_1 + 8)
80 # define MON_10 (MON_1 + 9)
81 # define MON_11 (MON_1 + 10)
82 # define MON_12 (MON_1 + 11)
83 # define ABMON_1 10035
84 # define ABMON_2 (ABMON_1 + 1)
85 # define ABMON_3 (ABMON_1 + 2)
86 # define ABMON_4 (ABMON_1 + 3)
87 # define ABMON_5 (ABMON_1 + 4)
88 # define ABMON_6 (ABMON_1 + 5)
89 # define ABMON_7 (ABMON_1 + 6)
90 # define ABMON_8 (ABMON_1 + 7)
91 # define ABMON_9 (ABMON_1 + 8)
92 # define ABMON_10 (ABMON_1 + 9)
93 # define ABMON_11 (ABMON_1 + 10)
94 # define ABMON_12 (ABMON_1 + 11)
95 # define ERA 10047
96 # define ERA_D_FMT 10048
97 # define ERA_D_T_FMT 10049
98 # define ERA_T_FMT 10050
99 # define ALT_DIGITS 10051
100 /* nl_langinfo items of the LC_MONETARY category */
101 # define CRNCYSTR 10052
102 /* nl_langinfo items of the LC_MESSAGES category */
103 # define YESEXPR 10053
104 # define NOEXPR 10054
106 #else
108 /* A platform that has <langinfo.h>. */
110 # if !@HAVE_LANGINFO_CODESET@
111 # define CODESET 10000
112 # define GNULIB_defined_CODESET 1
113 # endif
115 # if !@HAVE_LANGINFO_ERA@
116 # define ERA 10047
117 # define ERA_D_FMT 10048
118 # define ERA_D_T_FMT 10049
119 # define ERA_T_FMT 10050
120 # define ALT_DIGITS 10051
121 # define GNULIB_defined_ERA 1
122 # endif
124 #endif
126 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
128 /* The definition of _GL_WARN_ON_USE is copied here. */
130 /* Declare overridden functions. */
133 /* Return a piece of locale dependent information.
134 Note: The difference between nl_langinfo (CODESET) and locale_charset ()
135 is that the latter normalizes the encoding names to GNU conventions. */
137 #if @GNULIB_NL_LANGINFO@
138 # if @REPLACE_NL_LANGINFO@
139 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
140 # undef nl_langinfo
141 # define nl_langinfo rpl_nl_langinfo
142 # endif
143 _GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item));
144 _GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
145 # else
146 # if !@HAVE_NL_LANGINFO@
147 _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
148 # endif
149 _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
150 # endif
151 _GL_CXXALIASWARN (nl_langinfo);
152 #elif defined GNULIB_POSIXCHECK
153 # undef nl_langinfo
154 # if HAVE_RAW_DECL_NL_LANGINFO
155 _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
156 "use gnulib module nl_langinfo for portability");
157 # endif
158 #endif
161 #endif /* _GL_LANGINFO_H */
162 #endif /* _GL_LANGINFO_H */