25 #include <setlocale.h> 30 #define SETLOCALE_FUNCTION_NAME pedigree_setlocale 32 #define SETLOCALE_FUNCTION_NAME setlocale 35 #pragma GCC diagnostic ignored "-Wcast-qual" 39 #define MAX_LOCALE_LENGTH 32 43 int __nlocale_changed = 0;
44 int __mlocale_changed = 0;
45 char *_PathLocale = NULL;
48 static const struct lconv lconv = {
49 (
char *)
".", (
char *)
"", (
char *)
"", (
char *)
"", (
char *)
"",
50 (
char *)
"", (
char *)
"", (
char *)
"", (
char *)
"", (
char *)
"",
51 CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
52 CHAR_MAX, CHAR_MAX, CHAR_MAX,
55 static char __locale_charset_value[ENCODING_LEN] =
"ISO-8859-1";
57 #define NUM_LOCALES LC_MESSAGES 59 static char __locale_all[NUM_LOCALES * MAX_LOCALE_LENGTH] =
"LC_COLLATE=C";
60 static char __locale_collate[MAX_LOCALE_LENGTH] =
"C";
61 static char __locale_ctype[MAX_LOCALE_LENGTH] =
"C";
62 static char __locale_monetary[MAX_LOCALE_LENGTH] =
"C";
63 static char __locale_numeric[MAX_LOCALE_LENGTH] =
"C";
64 static char __locale_time[MAX_LOCALE_LENGTH] =
"C";
65 static char __locale_messages[MAX_LOCALE_LENGTH] =
"C";
67 static char __locale_last_all[MAX_LOCALE_LENGTH] =
"C";
68 static char __locale_last_collate[MAX_LOCALE_LENGTH] =
"C";
69 static char __locale_last_ctype[MAX_LOCALE_LENGTH] =
"C";
70 static char __locale_last_monetary[MAX_LOCALE_LENGTH] =
"C";
71 static char __locale_last_numeric[MAX_LOCALE_LENGTH] =
"C";
72 static char __locale_last_time[MAX_LOCALE_LENGTH] =
"C";
73 static char __locale_last_messages[MAX_LOCALE_LENGTH] =
"C";
76 char *__lc_ctype = __locale_ctype;
78 static char *__locale_entry[] = {
84 __locale_last_collate,
90 __locale_last_monetary,
93 __locale_last_numeric,
102 static const char *__locale_env[] = {
103 "LC_ALL",
"LC_COLLATE",
"LC_CTYPE",
"LC_MONETARY",
104 "LC_NUMERIC",
"LC_TIME",
"LC_MESSAGES",
107 #define SET_LAST(cat) \ 108 strncpy(__locale_last_##cat, __locale_##cat, MAX_LOCALE_LENGTH) 109 #define SET_TO(cat, val) strncpy(__locale_##cat, val, MAX_LOCALE_LENGTH) 111 char *SETLOCALE_FUNCTION_NAME(
int category,
const char *locale)
113 const char *new_locale_arg =
"C";
114 char new_locale[MAX_LOCALE_LENGTH];
119 if (category < LC_ALL || category > LC_MESSAGES)
124 return __locale_entry[category * 2];
127 else if (!strcmp(locale,
""))
132 else if (!strcmp(locale,
"C") || !strcmp(locale,
"POSIX"))
142 strncpy(new_locale, new_locale_arg, MAX_LOCALE_LENGTH);
146 strcpy(__locale_charset_value,
"ISO-8859-1");
148 if (category == LC_ALL)
158 SET_TO(all, new_locale);
159 SET_TO(collate, new_locale);
160 SET_TO(ctype, new_locale);
161 SET_TO(monetary, new_locale);
162 SET_TO(numeric, new_locale);
163 SET_TO(time, new_locale);
164 SET_TO(messages, new_locale);
166 else if (category == LC_COLLATE)
169 SET_TO(collate, new_locale);
171 else if (category == LC_CTYPE)
174 SET_TO(ctype, new_locale);
176 else if (category == LC_MONETARY)
179 SET_TO(monetary, new_locale);
181 else if (category == LC_NUMERIC)
184 SET_TO(numeric, new_locale);
186 else if (category == LC_TIME)
189 SET_TO(time, new_locale);
191 else if (category == LC_MESSAGES)
194 SET_TO(messages, new_locale);
198 _REENT->_current_category = category;
199 _REENT->_current_locale = locale;
200 return __locale_entry[(category + 1) * 2];
203 struct lconv *_localeconv_r(
struct _reent *data)
205 return (
struct lconv *) &lconv;
208 struct lconv *localeconv()
210 return _localeconv_r(_REENT);
213 char *__locale_charset()
215 return __locale_charset_value;