1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* nl_langinfo() replacement: query locale dependent information.
5 Copyright (C) 2007-2010 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #if REPLACE_NL_LANGINFO
27 /* Override nl_langinfo with support for added nl_item values. */
35 rpl_nl_langinfo (nl_item item)
39 # if GNULIB_defined_CODESET
43 static char buf[2 + 10 + 1];
45 locale = setlocale (LC_CTYPE, NULL);
46 if (locale != NULL && locale[0] != '\0')
48 /* If the locale name contains an encoding after the dot, return
50 const char *dot = strchr (locale, '.');
57 /* Look for the possible @... trailer and remove it, if any. */
58 modifier = strchr (dot, '@');
61 if (modifier - dot < sizeof (buf))
63 memcpy (buf, dot, modifier - dot);
64 buf [modifier - dot] = '\0';
72 # if GNULIB_defined_T_FMT_AMPM
76 # if GNULIB_defined_ERA
78 /* The format is not standardized. In glibc it is a sequence of strings
79 of the form "direction:offset:start_date:end_date:era_name:era_format"
80 with an empty string at the end. */
83 /* The %Ex conversion in strftime behaves like %x if the locale does not
84 have an alternative time format. */
88 /* The %Ec conversion in strftime behaves like %c if the locale does not
89 have an alternative time format. */
93 /* The %EX conversion in strftime behaves like %X if the locale does not
94 have an alternative time format. */
98 /* The format is not standardized. In glibc it is a sequence of 10
99 strings, appended in memory. */
100 return "\0\0\0\0\0\0\0\0\0\0";
102 # if GNULIB_defined_YESEXPR
111 return nl_langinfo (item);
116 /* Provide nl_langinfo from scratch. */
118 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
120 /* Native Windows platforms. */
122 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
123 # include <windows.h>
129 /* An old Unix platform without locales, such as Linux libc5 or BeOS. */
136 nl_langinfo (nl_item item)
140 /* nl_langinfo items of the LC_CTYPE category */
142 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
144 static char buf[2 + 10 + 1];
146 /* Woe32 has a function returning the locale's codepage as a number. */
147 sprintf (buf, "CP%u", GetACP ());
150 # elif defined __BEOS__
155 /* nl_langinfo items of the LC_NUMERIC category */
157 return localeconv () ->decimal_point;
159 return localeconv () ->thousands_sep;
160 /* nl_langinfo items of the LC_TIME category.
161 TODO: Really use the locale. */
164 return "%a %b %e %H:%M:%S %Y";
172 return "%I:%M:%S %p";
256 return "\0\0\0\0\0\0\0\0\0\0";
257 /* nl_langinfo items of the LC_MONETARY category
258 TODO: Really use the locale. */
261 /* nl_langinfo items of the LC_MESSAGES category
262 TODO: Really use the locale. */