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