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_ERA
74 /* The format is not standardized. In glibc it is a sequence of strings
75 of the form "direction:offset:start_date:end_date:era_name:era_format"
76 with an empty string at the end. */
79 /* The %Ex conversion in strftime behaves like %x if the locale does not
80 have an alternative time format. */
84 /* The %Ec conversion in strftime behaves like %c if the locale does not
85 have an alternative time format. */
89 /* The %EX conversion in strftime behaves like %X if the locale does not
90 have an alternative time format. */
94 /* The format is not standardized. In glibc it is a sequence of 10
95 strings, appended in memory. */
96 return "\0\0\0\0\0\0\0\0\0\0";
101 return nl_langinfo (item);
106 /* Provide nl_langinfo from scratch. */
108 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
110 /* Native Windows platforms. */
112 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
113 # include <windows.h>
119 /* An old Unix platform without locales, such as Linux libc5 or BeOS. */
126 nl_langinfo (nl_item item)
130 /* nl_langinfo items of the LC_CTYPE category */
132 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
134 static char buf[2 + 10 + 1];
136 /* Woe32 has a function returning the locale's codepage as a number. */
137 sprintf (buf, "CP%u", GetACP ());
140 # elif defined __BEOS__
145 /* nl_langinfo items of the LC_NUMERIC category */
147 return localeconv () ->decimal_point;
149 return localeconv () ->thousands_sep;
150 /* nl_langinfo items of the LC_TIME category.
151 TODO: Really use the locale. */
154 return "%a %b %e %H:%M:%S %Y";
162 return "%I:%M:%S %p";
246 return "\0\0\0\0\0\0\0\0\0\0";
247 /* nl_langinfo items of the LC_MONETARY category
248 TODO: Really use the locale. */
251 /* nl_langinfo items of the LC_MESSAGES category
252 TODO: Really use the locale. */