• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1999
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 
19 /* This is a "stub" implementation of the "c_locale.h" interface,
20    intended for operating systems where we have not yet written
21    a real implementation.  A C++ library using this stub implementation
22    is still standard-conforming, since the C++ standard does not require
23    that any locales other than "C" be supported.
24 */
25 
26 #include <string.h>
27 #include <wchar.h>
28 #include <ctype.h>
29 #include <wctype.h>
30 #include <limits.h>
31 
32 #if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
33 #  define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C)
34 #  if !defined (_STLP_NO_WCHAR_T)
35 #    define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C)
36 #  endif
37 #else
38 #  define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C)
39 #  if !defined (_STLP_NO_WCHAR_T)
40 #    define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C)
41 #  endif
42 #endif
43 
44 #define UNUSED __attribute__((__unused__))
45 
46 static const char *_C_name = "C";
47 static const char *_empty_str = "";
48 #ifndef _STLP_NO_WCHAR_T
49 #if defined(WCHAR_MAX) && WCHAR_MAX == 255
50 static const wchar_t *_empty_wstr = "";
51 #else
52 static const wchar_t *_empty_wstr = L"";
53 #endif
54 #endif
55 
56 static _Locale_mask_t ctable[256];
57 
58 /* Framework functions */
59 
_Locale_init(void)60 void _Locale_init(void) {
61   /* Ctype table for the ASCII character set. */
62   char c;
63   /* We might never reach 128 when char is signed. */
64   for (c = 0; /* c != 128 */; ++c) {
65     if (isalpha(c)) ctable[(unsigned char)c] |= _Locale_ALPHA;
66     if (iscntrl(c)) ctable[(unsigned char)c] |= _Locale_CNTRL;
67     if (isdigit(c)) ctable[(unsigned char)c] |= _Locale_DIGIT;
68     if (isprint(c)) ctable[(unsigned char)c] |= _Locale_PRINT;
69     if (ispunct(c)) ctable[(unsigned char)c] |= _Locale_PUNCT;
70     if (isspace(c)) ctable[(unsigned char)c] |= _Locale_SPACE;
71     if (isxdigit(c)) ctable[(unsigned char)c] |= _Locale_XDIGIT;
72     if (isupper(c)) ctable[(unsigned char)c] |= _Locale_UPPER;
73     if (islower(c)) ctable[(unsigned char)c] |= _Locale_LOWER;
74     if (c == 127) break;
75   }
76 
77   /* ASCII is a 7-bit code, so everything else is non-ASCII. */
78   memset(&(ctable[128]), 0, 128 * sizeof(_Locale_mask_t));
79 }
80 
_Locale_final(void)81 void _Locale_final(void)
82 {}
83 
_Locale_create(const char * name,int * __err_code)84 void* _Locale_create(const char* name, int *__err_code) {
85   if (name[0] == 'C' && name[1] == 0)
86   { return (void*)0x1; }
87   *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
88 }
89 
_Locale_ctype_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)90 struct _Locale_ctype* _Locale_ctype_create(const char *name,
91                                            struct _Locale_name_hint* hint UNUSED,
92                                            int *__err_code)
93 { return (struct _Locale_ctype*)_Locale_create(name, __err_code); }
94 
_Locale_codecvt_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)95 struct _Locale_codecvt* _Locale_codecvt_create(const char *name,
96                                                struct _Locale_name_hint* hint UNUSED,
97                                                int *__err_code)
98 { return (struct _Locale_codecvt*)_Locale_create(name, __err_code); }
99 
_Locale_numeric_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)100 struct _Locale_numeric* _Locale_numeric_create(const char *name,
101                                                struct _Locale_name_hint* hint UNUSED,
102                                                int *__err_code)
103 { return (struct _Locale_numeric*)_Locale_create(name, __err_code); }
104 
_Locale_time_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)105 struct _Locale_time* _Locale_time_create(const char *name,
106                                          struct _Locale_name_hint* hint UNUSED,
107                                          int *__err_code)
108 { return (struct _Locale_time*)_Locale_create(name, __err_code); }
109 
_Locale_collate_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)110 struct _Locale_collate* _Locale_collate_create(const char *name,
111                                                struct _Locale_name_hint* hint UNUSED,
112                                                int *__err_code)
113 { return (struct _Locale_collate*)_Locale_create(name, __err_code); }
114 
_Locale_monetary_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)115 struct _Locale_monetary* _Locale_monetary_create(const char *name,
116                                                  struct _Locale_name_hint* hint UNUSED,
117                                                  int *__err_code)
118 { return (struct _Locale_monetary*)_Locale_create(name, __err_code); }
119 
_Locale_messages_create(const char * name,struct _Locale_name_hint * hint UNUSED,int * __err_code)120 struct _Locale_messages* _Locale_messages_create(const char *name,
121                                                  struct _Locale_name_hint* hint UNUSED,
122                                                  int *__err_code)
123 { return (struct _Locale_messages*)_Locale_create(name, __err_code); }
124 
_Locale_ctype_default(char * buf UNUSED)125 const char *_Locale_ctype_default(char* buf UNUSED)    { return _C_name; }
_Locale_numeric_default(char * buf UNUSED)126 const char *_Locale_numeric_default(char * buf UNUSED) { return _C_name; }
_Locale_time_default(char * buf UNUSED)127 const char *_Locale_time_default(char* buf UNUSED)     { return _C_name; }
_Locale_collate_default(char * buf UNUSED)128 const char *_Locale_collate_default(char* buf UNUSED)  { return _C_name; }
_Locale_monetary_default(char * buf UNUSED)129 const char *_Locale_monetary_default(char* buf UNUSED) { return _C_name; }
_Locale_messages_default(char * buf UNUSED)130 const char *_Locale_messages_default(char* buf UNUSED) { return _C_name; }
131 
_Locale_ctype_name(const struct _Locale_ctype * lctype UNUSED,char * buf UNUSED)132 char const* _Locale_ctype_name(const struct _Locale_ctype *lctype UNUSED, char* buf UNUSED)
133 { return _C_name; }
134 
_Locale_codecvt_name(const struct _Locale_codecvt * lcodecvt UNUSED,char * buf UNUSED)135 char const* _Locale_codecvt_name(const struct _Locale_codecvt *lcodecvt UNUSED, char* buf UNUSED)
136 { return _C_name; }
137 
_Locale_numeric_name(const struct _Locale_numeric * lnum UNUSED,char * buf UNUSED)138 char const* _Locale_numeric_name(const struct _Locale_numeric *lnum UNUSED, char* buf UNUSED)
139 { return _C_name; }
140 
_Locale_time_name(const struct _Locale_time * ltime UNUSED,char * buf UNUSED)141 char const* _Locale_time_name(const struct _Locale_time *ltime UNUSED, char* buf UNUSED)
142 { return _C_name; }
143 
_Locale_collate_name(const struct _Locale_collate * lcol UNUSED,char * buf UNUSED)144 char const* _Locale_collate_name(const struct _Locale_collate *lcol UNUSED, char* buf UNUSED)
145 { return _C_name; }
146 
_Locale_monetary_name(const struct _Locale_monetary * lmon UNUSED,char * buf UNUSED)147 char const* _Locale_monetary_name(const struct _Locale_monetary *lmon UNUSED, char* buf UNUSED)
148 { return _C_name; }
149 
_Locale_messages_name(const struct _Locale_messages * lmes UNUSED,char * buf UNUSED)150 char const* _Locale_messages_name(const struct _Locale_messages *lmes UNUSED, char* buf UNUSED)
151 { return _C_name; }
152 
_Locale_ctype_destroy(struct _Locale_ctype * lctype UNUSED)153 void _Locale_ctype_destroy(struct _Locale_ctype *lctype UNUSED)     {}
_Locale_codecvt_destroy(struct _Locale_codecvt * lcodecvt UNUSED)154 void _Locale_codecvt_destroy(struct _Locale_codecvt *lcodecvt UNUSED)   {}
_Locale_numeric_destroy(struct _Locale_numeric * lnum UNUSED)155 void _Locale_numeric_destroy(struct _Locale_numeric *lnum UNUSED)   {}
_Locale_time_destroy(struct _Locale_time * ltime UNUSED)156 void _Locale_time_destroy(struct _Locale_time *ltime UNUSED)        {}
_Locale_collate_destroy(struct _Locale_collate * lcol UNUSED)157 void _Locale_collate_destroy(struct _Locale_collate *lcol UNUSED)   {}
_Locale_monetary_destroy(struct _Locale_monetary * lmon UNUSED)158 void _Locale_monetary_destroy(struct _Locale_monetary *lmon UNUSED) {}
_Locale_messages_destroy(struct _Locale_messages * lmes UNUSED)159 void _Locale_messages_destroy(struct _Locale_messages *lmes UNUSED) {}
160 
_Locale_extract_name(const char * name,int * __err_code)161 static char const* _Locale_extract_name(const char* name, int *__err_code) {
162   // When the request is the default locale or the "C" locale we answer "C".
163   if (name[0] == 0 ||
164       (name[0] == 'C' && name[1] == 0))
165   {  return _C_name; }
166   *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
167 }
168 
_Locale_extract_ctype_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)169 char const* _Locale_extract_ctype_name(const char *name,
170                                        char *buf UNUSED,
171                                        struct _Locale_name_hint* hint UNUSED,
172                                        int *__err_code)
173 { return _Locale_extract_name(name, __err_code); }
174 
_Locale_extract_numeric_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)175 char const* _Locale_extract_numeric_name(const char *name,
176                                          char *buf UNUSED,
177                                          struct _Locale_name_hint* hint UNUSED,
178                                          int *__err_code)
179 { return _Locale_extract_name(name, __err_code); }
180 
_Locale_extract_time_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)181 char const* _Locale_extract_time_name(const char *name,
182                                       char *buf UNUSED,
183                                       struct _Locale_name_hint* hint UNUSED,
184                                       int *__err_code)
185 { return _Locale_extract_name(name, __err_code); }
186 
_Locale_extract_collate_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)187 char const* _Locale_extract_collate_name(const char *name,
188                                          char *buf UNUSED,
189                                          struct _Locale_name_hint* hint UNUSED,
190                                          int *__err_code)
191 { return _Locale_extract_name(name, __err_code); }
192 
_Locale_extract_monetary_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)193 char const* _Locale_extract_monetary_name(const char *name,
194                                           char *buf UNUSED,
195                                           struct _Locale_name_hint* hint UNUSED,
196                                           int *__err_code)
197 { return _Locale_extract_name(name, __err_code); }
198 
_Locale_extract_messages_name(const char * name,char * buf UNUSED,struct _Locale_name_hint * hint UNUSED,int * __err_code)199 char const* _Locale_extract_messages_name(const char *name,
200                                           char *buf UNUSED,
201                                           struct _Locale_name_hint* hint UNUSED,
202                                           int *__err_code)
203 { return _Locale_extract_name(name, __err_code); }
204 
_Locale_get_ctype_hint(struct _Locale_ctype * ctype UNUSED)205 struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype UNUSED)
206 { return 0; }
_Locale_get_numeric_hint(struct _Locale_numeric * numeric UNUSED)207 struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric UNUSED)
208 { return 0; }
_Locale_get_time_hint(struct _Locale_time * time UNUSED)209 struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time UNUSED)
210 { return 0; }
_Locale_get_collate_hint(struct _Locale_collate * collate UNUSED)211 struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate UNUSED)
212 { return 0; }
_Locale_get_monetary_hint(struct _Locale_monetary * monetary UNUSED)213 struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary UNUSED)
214 { return 0; }
_Locale_get_messages_hint(struct _Locale_messages * messages UNUSED)215 struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages UNUSED)
216 { return 0; }
217 
218 /* ctype */
_Locale_ctype_table(struct _Locale_ctype * lctype)219 const _Locale_mask_t* _Locale_ctype_table(struct _Locale_ctype* lctype) {
220   _STLP_MARK_PARAMETER_AS_UNUSED(lctype)
221   return ctable;
222 }
223 
_Locale_toupper(struct _Locale_ctype * lctype UNUSED,int c)224 int _Locale_toupper(struct _Locale_ctype*lctype UNUSED, int c)
225 { return toupper(c); }
226 
_Locale_tolower(struct _Locale_ctype * lctype UNUSED,int c)227 int _Locale_tolower(struct _Locale_ctype*lctype UNUSED, int c)
228 { return tolower(c); }
229 
230 #ifndef _STLP_NO_WCHAR_T
_WLocale_ctype(struct _Locale_ctype * lctype UNUSED,wint_t wc,_Locale_mask_t mask)231 _Locale_mask_t _WLocale_ctype(struct _Locale_ctype *lctype UNUSED, wint_t wc, _Locale_mask_t mask) {
232   _Locale_mask_t ret = 0;
233   if ((mask & _Locale_ALPHA) != 0 && iswalpha(wc))
234     ret |= _Locale_ALPHA;
235 
236   if ((mask & _Locale_CNTRL) != 0 && iswcntrl(wc))
237     ret |= _Locale_CNTRL;
238 
239   if ((mask & _Locale_DIGIT) != 0 && iswdigit(wc))
240     ret |= _Locale_DIGIT;
241 
242   if ((mask & _Locale_PRINT) != 0 && iswprint(wc))
243     ret |= _Locale_PRINT;
244 
245   if ((mask & _Locale_PUNCT) != 0 && iswpunct(wc))
246     ret |= _Locale_PUNCT;
247 
248   if ((mask & _Locale_SPACE) != 0 && iswspace(wc))
249     ret |= _Locale_SPACE;
250 
251   if ((mask & _Locale_XDIGIT) != 0 && iswxdigit(wc))
252     ret |= _Locale_XDIGIT;
253 
254   if ((mask & _Locale_UPPER) != 0 && iswupper(wc))
255     ret |= _Locale_UPPER;
256 
257   if ((mask & _Locale_LOWER) != 0 && iswlower(wc))
258     ret |= _Locale_LOWER;
259 
260   return ret;
261 }
262 
_WLocale_tolower(struct _Locale_ctype * lctype UNUSED,wint_t wc)263 wint_t _WLocale_tolower(struct _Locale_ctype *lctype UNUSED, wint_t wc)
264 { return towlower(wc); }
265 
_WLocale_toupper(struct _Locale_ctype * lctype UNUSED,wint_t wc)266 wint_t _WLocale_toupper(struct _Locale_ctype *lctype UNUSED, wint_t wc)
267 { return towupper(wc); }
268 
_WLocale_mb_cur_max(struct _Locale_codecvt * lcodecvt UNUSED)269 int _WLocale_mb_cur_max (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
_WLocale_mb_cur_min(struct _Locale_codecvt * lcodecvt UNUSED)270 int _WLocale_mb_cur_min (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
_WLocale_is_stateless(struct _Locale_codecvt * lcodecvt UNUSED)271 int _WLocale_is_stateless (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
272 
_WLocale_mbtowc(struct _Locale_codecvt * lcodecvt UNUSED,wchar_t * to,const char * from,size_t n UNUSED,mbstate_t * st UNUSED)273 size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt UNUSED,
274                        wchar_t *to,
275                        const char *from, size_t n UNUSED,
276                        mbstate_t *st UNUSED)
277 { *to = *from; return 1; }
278 
_WLocale_wctomb(struct _Locale_codecvt * lcodecvt UNUSED,char * to,size_t n UNUSED,const wchar_t c,mbstate_t * st UNUSED)279 size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt UNUSED,
280                        char *to, size_t n UNUSED,
281                        const wchar_t c,
282                        mbstate_t *st UNUSED)
283 { *to = (char)c; return 1; }
284 
_WLocale_unshift(struct _Locale_codecvt * lcodecvt UNUSED,mbstate_t * st UNUSED,char * buf,size_t n UNUSED,char ** next)285 size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt UNUSED,
286                         mbstate_t *st UNUSED,
287                         char *buf, size_t n UNUSED, char ** next)
288 { *next = buf; return 0; }
289 #endif
290 
291 /* Collate */
_Locale_strcmp(struct _Locale_collate * lcol UNUSED,const char * s1,size_t n1,const char * s2,size_t n2)292  int _Locale_strcmp(struct _Locale_collate* lcol UNUSED,
293                     const char* s1, size_t n1, const char* s2, size_t n2) {
294   int ret = 0;
295   char buf1[64], buf2[64];
296   while (n1 > 0 || n2 > 0) {
297     size_t bufsize1 = n1 < 63 ? n1 : 63;
298     size_t bufsize2 = n2 < 63 ? n2 : 63;
299     _STLP_STRNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
300     _STLP_STRNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
301 
302     ret = strcmp(buf1, buf2);
303     if (ret != 0) return ret < 0 ? -1 : 1;
304     s1 += bufsize1; n1 -= bufsize1;
305     s2 += bufsize2; n2 -= bufsize2;
306   }
307   return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
308 }
309 
310 #ifndef _STLP_NO_WCHAR_T
311 
_WLocale_strcmp(struct _Locale_collate * lcol UNUSED,const wchar_t * s1,size_t n1,const wchar_t * s2,size_t n2)312 int _WLocale_strcmp(struct _Locale_collate* lcol UNUSED,
313                     const wchar_t* s1, size_t n1, const wchar_t* s2, size_t n2) {
314   int ret = 0;
315   wchar_t buf1[64], buf2[64];
316   while (n1 > 0 || n2 > 0) {
317     size_t bufsize1 = n1 < 63 ? n1 : 63;
318     size_t bufsize2 = n2 < 63 ? n2 : 63;
319     _STLP_WCSNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
320     _STLP_WCSNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
321 
322     ret = wcscmp(buf1, buf2);
323     if (ret != 0) return ret < 0 ? -1 : 1;
324     s1 += bufsize1; n1 -= bufsize1;
325     s2 += bufsize2; n2 -= bufsize2;
326   }
327   return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
328 }
329 
330 #endif
331 
_Locale_strxfrm(struct _Locale_collate * lcol UNUSED,char * dest,size_t dest_n,const char * src,size_t src_n)332 size_t _Locale_strxfrm(struct _Locale_collate* lcol UNUSED,
333                        char* dest, size_t dest_n,
334                        const char* src, size_t src_n) {
335   if (dest != 0) {
336     _STLP_STRNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
337   }
338   return src_n;
339 }
340 
341 #ifndef _STLP_NO_WCHAR_T
342 
_WLocale_strxfrm(struct _Locale_collate * lcol UNUSED,wchar_t * dest,size_t dest_n,const wchar_t * src,size_t src_n)343 size_t _WLocale_strxfrm(struct _Locale_collate* lcol UNUSED,
344                         wchar_t* dest, size_t dest_n,
345                         const wchar_t* src, size_t src_n) {
346   if (dest != 0) {
347     _STLP_WCSNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
348   }
349   return src_n;
350 }
351 
352 #endif
353 
354 /* Numeric */
355 
_Locale_decimal_point(struct _Locale_numeric * lnum UNUSED)356 char _Locale_decimal_point(struct _Locale_numeric* lnum UNUSED)
357 { return '.'; }
_Locale_thousands_sep(struct _Locale_numeric * lnum UNUSED)358 char _Locale_thousands_sep(struct _Locale_numeric* lnum UNUSED)
359 { return ','; }
_Locale_grouping(struct _Locale_numeric * lnum UNUSED)360 const char* _Locale_grouping(struct _Locale_numeric * lnum UNUSED)
361 { return _empty_str; }
_Locale_true(struct _Locale_numeric * lnum UNUSED)362 const char * _Locale_true(struct _Locale_numeric * lnum UNUSED)
363 { return "true"; }
_Locale_false(struct _Locale_numeric * lnum UNUSED)364 const char * _Locale_false(struct _Locale_numeric * lnum UNUSED)
365 { return "false"; }
366 
367 #ifndef _STLP_NO_WCHAR_T
_WLocale_decimal_point(struct _Locale_numeric * lnum UNUSED)368 wchar_t _WLocale_decimal_point(struct _Locale_numeric* lnum UNUSED)
369 { return L'.'; }
_WLocale_thousands_sep(struct _Locale_numeric * lnum UNUSED)370 wchar_t _WLocale_thousands_sep(struct _Locale_numeric* lnum UNUSED)
371 { return L','; }
372 #if defined(WCHAR_MAX) && WCHAR_MAX == 255
_WLocale_true(struct _Locale_numeric * lnum UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)373 const wchar_t * _WLocale_true(struct _Locale_numeric* lnum UNUSED,
374                               wchar_t* buf UNUSED,
375                               size_t bufSize UNUSED)
376 { return "true"; }
_WLocale_false(struct _Locale_numeric * lnum UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)377 const wchar_t * _WLocale_false(struct _Locale_numeric* lnum UNUSED,
378                                wchar_t* buf UNUSED,
379                                size_t bufSize UNUSED)
380 { return "false"; }
381 #else
_WLocale_true(struct _Locale_numeric * lnum UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)382 const wchar_t * _WLocale_true(struct _Locale_numeric* lnum UNUSED,
383                               wchar_t* buf UNUSED,
384                               size_t bufSize UNUSED)
385 { return L"true"; }
_WLocale_false(struct _Locale_numeric * lnum UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)386 const wchar_t * _WLocale_false(struct _Locale_numeric* lnum UNUSED,
387                                wchar_t* buf UNUSED,
388                                size_t bufSize UNUSED)
389 { return L"false"; }
390 #endif
391 #endif
392 
393 /* Monetary */
394 
_Locale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED)395 const char* _Locale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED)
396 { return _empty_str; }
_Locale_currency_symbol(struct _Locale_monetary * lmon UNUSED)397 const char* _Locale_currency_symbol(struct _Locale_monetary * lmon UNUSED)
398 { return _empty_str; }
_Locale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)399 char        _Locale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)
400 { return '.'; }
_Locale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)401 char        _Locale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)
402 { return ','; }
_Locale_mon_grouping(struct _Locale_monetary * lmon UNUSED)403 const char* _Locale_mon_grouping(struct _Locale_monetary * lmon UNUSED)
404 { return _empty_str; }
_Locale_positive_sign(struct _Locale_monetary * lmon UNUSED)405 const char* _Locale_positive_sign(struct _Locale_monetary * lmon UNUSED)
406 { return _empty_str; }
_Locale_negative_sign(struct _Locale_monetary * lmon UNUSED)407 const char* _Locale_negative_sign(struct _Locale_monetary * lmon UNUSED)
408 { return _empty_str; }
_Locale_int_frac_digits(struct _Locale_monetary * lmon UNUSED)409 char        _Locale_int_frac_digits(struct _Locale_monetary * lmon UNUSED)
410 { return 0; }
_Locale_frac_digits(struct _Locale_monetary * lmon UNUSED)411 char        _Locale_frac_digits(struct _Locale_monetary * lmon UNUSED)
412 { return 0; }
_Locale_p_cs_precedes(struct _Locale_monetary * lmon UNUSED)413 int         _Locale_p_cs_precedes(struct _Locale_monetary * lmon UNUSED)
414 { return CHAR_MAX; }
_Locale_p_sep_by_space(struct _Locale_monetary * lmon UNUSED)415 int         _Locale_p_sep_by_space(struct _Locale_monetary * lmon UNUSED)
416 { return CHAR_MAX; }
_Locale_p_sign_posn(struct _Locale_monetary * lmon UNUSED)417 int         _Locale_p_sign_posn(struct _Locale_monetary * lmon UNUSED)
418 { return CHAR_MAX; }
_Locale_n_cs_precedes(struct _Locale_monetary * lmon UNUSED)419 int         _Locale_n_cs_precedes(struct _Locale_monetary * lmon UNUSED)
420 { return CHAR_MAX; }
_Locale_n_sep_by_space(struct _Locale_monetary * lmon UNUSED)421 int          _Locale_n_sep_by_space(struct _Locale_monetary * lmon UNUSED)
422 { return CHAR_MAX; }
_Locale_n_sign_posn(struct _Locale_monetary * lmon UNUSED)423 int          _Locale_n_sign_posn(struct _Locale_monetary * lmon UNUSED)
424 { return CHAR_MAX; }
425 
426 #ifndef _STLP_NO_WCHAR_T
_WLocale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)427 const wchar_t* _WLocale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED,
428                                         wchar_t* buf UNUSED,
429                                         size_t bufSize UNUSED)
430 { return _empty_wstr; }
_WLocale_currency_symbol(struct _Locale_monetary * lmon UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)431 const wchar_t* _WLocale_currency_symbol(struct _Locale_monetary * lmon UNUSED,
432                                         wchar_t* buf UNUSED,
433                                         size_t bufSize UNUSED)
434 { return _empty_wstr; }
_WLocale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)435 wchar_t        _WLocale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)
436 { return L'.'; }
_WLocale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)437 wchar_t        _WLocale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)
438 { return L','; }
_WLocale_positive_sign(struct _Locale_monetary * lmon UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)439 const wchar_t* _WLocale_positive_sign(struct _Locale_monetary * lmon UNUSED,
440                                       wchar_t* buf UNUSED,
441                                       size_t bufSize UNUSED)
442 { return _empty_wstr; }
_WLocale_negative_sign(struct _Locale_monetary * lmon UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)443 const wchar_t* _WLocale_negative_sign(struct _Locale_monetary * lmon UNUSED,
444                                       wchar_t* buf UNUSED,
445                                       size_t bufSize UNUSED)
446 { return _empty_wstr; }
447 #endif
448 
449 /* Time */
450 static const char* full_monthname[] =
451 { "January", "February", "March", "April", "May", "June",
452   "July", "August", "September", "October", "November", "December" };
_Locale_full_monthname(struct _Locale_time * ltime UNUSED,int n)453 const char * _Locale_full_monthname(struct _Locale_time * ltime UNUSED, int n)
454 { return full_monthname[n]; }
455 
456 static const char* abbrev_monthname[] =
457 { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
458   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
_Locale_abbrev_monthname(struct _Locale_time * ltime UNUSED,int n)459 const char * _Locale_abbrev_monthname(struct _Locale_time * ltime UNUSED, int n)
460 { return abbrev_monthname[n]; }
461 
462 static const char* full_dayname[] =
463 { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
_Locale_full_dayofweek(struct _Locale_time * ltime UNUSED,int n)464 const char * _Locale_full_dayofweek(struct _Locale_time * ltime UNUSED, int n)
465 { return full_dayname[n]; }
466 
467 static const char* abbrev_dayname[] =
468 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
_Locale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED,int n)469 const char * _Locale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED, int n)
470 { return abbrev_dayname[n]; }
471 
_Locale_d_t_fmt(struct _Locale_time * ltime UNUSED)472 const char* _Locale_d_t_fmt(struct _Locale_time* ltime UNUSED)
473 { return "%m/%d/%y"; }
_Locale_d_fmt(struct _Locale_time * ltime UNUSED)474 const char* _Locale_d_fmt(struct _Locale_time* ltime UNUSED)
475 { return "%m/%d/%y"; }
_Locale_t_fmt(struct _Locale_time * ltime UNUSED)476 const char* _Locale_t_fmt(struct _Locale_time* ltime UNUSED)
477 { return "%H:%M:%S"; }
_Locale_long_d_t_fmt(struct _Locale_time * ltime UNUSED)478 const char* _Locale_long_d_t_fmt(struct _Locale_time* ltime UNUSED)
479 { return _empty_str; }
_Locale_long_d_fmt(struct _Locale_time * ltime UNUSED)480 const char* _Locale_long_d_fmt(struct _Locale_time* ltime UNUSED)
481 { return _empty_str; }
_Locale_am_str(struct _Locale_time * ltime UNUSED)482 const char* _Locale_am_str(struct _Locale_time* ltime UNUSED)
483 { return "AM"; }
_Locale_pm_str(struct _Locale_time * ltime UNUSED)484 const char* _Locale_pm_str(struct _Locale_time* ltime UNUSED)
485 { return "PM"; }
486 
487 #ifndef _STLP_NO_WCHAR_T
488 #if defined(WCHAR_MAX) && WCHAR_MAX == 255
489 static const wchar_t* full_wmonthname[] =
490 { "January", "February", "March", "April", "May", "June",
491   "July", "August", "September", "October", "November", "December" };
_WLocale_full_monthname(struct _Locale_time * ltime,int n,wchar_t * buf,size_t bufSize)492 const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n,
493                                         wchar_t* buf, size_t bufSize)
494 { return full_wmonthname[n]; }
495 
496 static const wchar_t* abbrev_wmonthname[] =
497 { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
498   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
_WLocale_abbrev_monthname(struct _Locale_time * ltime,int n,wchar_t * buf,size_t bufSize)499 const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n,
500                                           wchar_t* buf, size_t bufSize)
501 { return abbrev_wmonthname[n]; }
502 
503 static const wchar_t* full_wdayname[] =
504 { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
_WLocale_full_dayofweek(struct _Locale_time * ltime,int n,wchar_t * buf,size_t bufSize)505 const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n,
506                                         wchar_t* buf, size_t bufSize)
507 { return full_wdayname[n]; }
508 
509 static const wchar_t* abbrev_wdayname[] =
510 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
_WLocale_abbrev_dayofweek(struct _Locale_time * ltime,int n,wchar_t * buf,size_t bufSize)511 const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n,
512                                           wchar_t* buf, size_t bufSize)
513 { return abbrev_wdayname[n]; }
514 
_WLocale_am_str(struct _Locale_time * ltime,wchar_t * buf,size_t bufSize)515 const wchar_t* _WLocale_am_str(struct _Locale_time* ltime,
516                                wchar_t* buf, size_t bufSize)
517 { return "AM"; }
_WLocale_pm_str(struct _Locale_time * ltime,wchar_t * buf,size_t bufSize)518 const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
519                                wchar_t* buf, size_t bufSize)
520 { return "PM"; }
521 #else /* WCHAR_MAX != 255 */
522 static const wchar_t* full_wmonthname[] =
523 { L"January", L"February", L"March", L"April", L"May", L"June",
524   L"July", L"August", L"September", L"October", L"November", L"December" };
_WLocale_full_monthname(struct _Locale_time * ltime UNUSED,int n,wchar_t * buf UNUSED,size_t bufSize UNUSED)525 const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime UNUSED,
526                                         int n,
527                                         wchar_t* buf UNUSED,
528                                         size_t bufSize UNUSED)
529 { return full_wmonthname[n]; }
530 
531 static const wchar_t* abbrev_wmonthname[] =
532 { L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
533   L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" };
_WLocale_abbrev_monthname(struct _Locale_time * ltime UNUSED,int n,wchar_t * buf UNUSED,size_t bufSize UNUSED)534 const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime UNUSED,
535                                           int n,
536                                           wchar_t* buf UNUSED,
537                                           size_t bufSize UNUSED)
538 { return abbrev_wmonthname[n]; }
539 
540 static const wchar_t* full_wdayname[] =
541 { L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", L"Friday", L"Saturday" };
_WLocale_full_dayofweek(struct _Locale_time * ltime UNUSED,int n,wchar_t * buf UNUSED,size_t bufSize UNUSED)542 const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime UNUSED,
543                                         int n,
544                                         wchar_t* buf UNUSED,
545                                         size_t bufSize UNUSED)
546 { return full_wdayname[n]; }
547 
548 static const wchar_t* abbrev_wdayname[] =
549 { L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" };
_WLocale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED,int n,wchar_t * buf UNUSED,size_t bufSize UNUSED)550 const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED,
551                                           int n,
552                                           wchar_t* buf UNUSED,
553                                           size_t bufSize UNUSED)
554 { return abbrev_wdayname[n]; }
555 
_WLocale_am_str(struct _Locale_time * ltime UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)556 const wchar_t* _WLocale_am_str(struct _Locale_time* ltime UNUSED,
557                                wchar_t* buf UNUSED,
558                                size_t bufSize UNUSED)
559 { return L"AM"; }
_WLocale_pm_str(struct _Locale_time * ltime UNUSED,wchar_t * buf UNUSED,size_t bufSize UNUSED)560 const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime UNUSED,
561                                wchar_t* buf UNUSED,
562                                size_t bufSize UNUSED)
563 { return L"PM"; }
564 #endif /* WCHAR_MAX != 255 */
565 #endif
566 
567 /* Messages */
568 
_Locale_catopen(struct _Locale_messages * lmes UNUSED,const char * name UNUSED)569 nl_catd_type _Locale_catopen(struct _Locale_messages* lmes UNUSED,
570                              const char* name UNUSED)
571 { return -1; }
_Locale_catclose(struct _Locale_messages * lmes UNUSED,nl_catd_type cat UNUSED)572 void _Locale_catclose(struct _Locale_messages* lmes UNUSED, nl_catd_type cat UNUSED) {}
_Locale_catgets(struct _Locale_messages * lmes UNUSED,nl_catd_type cat UNUSED,int setid UNUSED,int msgid UNUSED,const char * dfault)573 const char* _Locale_catgets(struct _Locale_messages* lmes UNUSED,
574                             nl_catd_type cat UNUSED,
575                             int setid UNUSED,
576                             int msgid UNUSED,
577                             const char *dfault)
578 { return dfault; }
579