ReactOS 0.4.15-dev-7788-g1ad9096
c_locale_win32.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * Written 2000
9 * Anton Lapach
10 *
11 * This material is provided "as is", with absolutely no warranty expressed
12 * or implied. Any use is at your own risk.
13 *
14 * Permission to use or copy this software for any purpose is hereby granted
15 * without fee, provided the above notices are retained on all copies.
16 * Permission to modify the code and to distribute modified code is granted,
17 * provided the above notices are retained, and a notice that the code was
18 * modified is included with the above copyright notice.
19 *
20 */
21
22#include <limits.h>
23#if defined (_STLP_MSVC) || defined (__ICL)
24# include <memory.h>
25#endif
26#include <string.h>
27#include <locale.h>
28#include <stdlib.h>
29#include <stdio.h>
30
31#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
32# define _STLP_STRCPY(D, DS, S) strcpy_s(D, DS, S)
33# define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C)
34# define _STLP_STRCAT(D, DS, S) strcat_s(D, DS, S)
35#else
36# define _STLP_STRCPY(D, DS, S) strcpy(D, S)
37# define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C)
38# define _STLP_STRCAT(D, DS, S) strcat(D, S)
39#endif
40
41#if defined (__cplusplus)
42extern "C" {
43#endif
44
45/* Framework functions */
46/*
47 locale :: "lang[_country[.code_page]]"
48 | ".code_page"
49 | ""
50 | NULL
51
52*/
53
54typedef struct _LOCALECONV {
55 const char* name;
56 const char* abbrev;
58
59#define MAX_LANG_LEN 64 /* max language name length */
60#define MAX_CTRY_LEN 64 /* max country name length */
61#define MAX_MODIFIER_LEN 0 /* max modifier name length - n/a */
62#define MAX_LC_LEN (MAX_LANG_LEN+MAX_CTRY_LEN+MAX_MODIFIER_LEN+3)
63 /* max entire locale string length */
64#define MAX_CP_LEN 5 /* max code page name length */
65
66#if !defined (LANG_INVARIANT)
67# define LANG_INVARIANT 0x7f
68# define _STLP_LANG_INVARIANT_DEFINED
69#endif
70
71#ifndef CP_UTF7
72# define CP_UTF7 65000
73#endif
74
75#ifndef CP_UTF8
76# define CP_UTF8 65001
77#endif
78
79#define INVARIANT_LCID MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT)
80
81static const char *_C_name = "C";
82
83/* non-NLS language string table */
85 {"american", "ENU"},
86 {"american english", "ENU"},
87 {"american-english", "ENU"},
88 {"australian", "ENA"},
89 {"belgian", "NLB"},
90 {"canadian", "ENC"},
91 {"chh", "ZHH"},
92 {"chi", "ZHI"},
93 {"chinese", "CHS"},
94 {"chinese-hongkong", "ZHH"},
95 {"chinese-simplified", "CHS"},
96 {"chinese-singapore", "ZHI"},
97 {"chinese-traditional", "CHT"},
98 {"dutch-belgian", "NLB"},
99 {"english-american", "ENU"},
100 {"english-aus", "ENA"},
101 {"english-belize", "ENL"},
102 {"english-can", "ENC"},
103 {"english-caribbean", "ENB"},
104 {"english-ire", "ENI"},
105 {"english-jamaica", "ENJ"},
106 {"english-nz", "ENZ"},
107 {"english-south africa", "ENS"},
108 {"english-trinidad y tobago", "ENT"},
109 {"english-uk", "ENG"},
110 {"english-us", "ENU"},
111 {"english-usa", "ENU"},
112 {"french-belgian", "FRB"},
113 {"french-canadian", "FRC"},
114 {"french-luxembourg", "FRL"},
115 {"french-swiss", "FRS"},
116 {"german-austrian", "DEA"},
117 {"german-lichtenstein", "DEC"},
118 {"german-luxembourg", "DEL"},
119 {"german-swiss", "DES"},
120 {"irish-english", "ENI"},
121 {"italian-swiss", "ITS"},
122 {"norwegian", "NOR"},
123 {"norwegian-bokmal", "NOR"},
124 {"norwegian-nynorsk", "NON"},
125 {"portuguese-brazilian", "PTB"},
126 {"spanish-argentina", "ESS"},
127 {"spanish-bolivia", "ESB"},
128 {"spanish-chile", "ESL"},
129 {"spanish-colombia", "ESO"},
130 {"spanish-costa rica", "ESC"},
131 {"spanish-dominican republic", "ESD"},
132 {"spanish-ecuador", "ESF"},
133 {"spanish-el salvador", "ESE"},
134 {"spanish-guatemala", "ESG"},
135 {"spanish-honduras", "ESH"},
136 {"spanish-mexican", "ESM"},
137 {"spanish-modern", "ESN"},
138 {"spanish-nicaragua", "ESI"},
139 {"spanish-panama", "ESA"},
140 {"spanish-paraguay", "ESZ"},
141 {"spanish-peru", "ESR"},
142 {"spanish-puerto rico", "ESU"},
143 {"spanish-uruguay", "ESY"},
144 {"spanish-venezuela", "ESV"},
145 {"swedish-finland", "SVF"},
146 {"swiss", "DES"},
147 {"uk", "ENG"},
148 {"us", "ENU"},
149 {"usa", "ENU"}
150};
151
152/* non-NLS country string table */
154 {"america", "USA"},
155 {"britain", "GBR"},
156 {"china", "CHN"},
157 {"czech", "CZE"},
158 {"england", "GBR"},
159 {"great britain", "GBR"},
160 {"holland", "NLD"},
161 {"hong-kong", "HKG"},
162 {"new-zealand", "NZL"},
163 {"nz", "NZL"},
164 {"pr china", "CHN"},
165 {"pr-china", "CHN"},
166 {"puerto-rico", "PRI"},
167 {"slovak", "SVK"},
168 {"south africa", "ZAF"},
169 {"south korea", "KOR"},
170 {"south-africa", "ZAF"},
171 {"south-korea", "KOR"},
172 {"trinidad & tobago", "TTO"},
173 {"uk", "GBR"},
174 {"united-kingdom", "GBR"},
175 {"united-states", "USA"},
176 {"us", "USA"},
177};
178
179typedef struct _Locale_name_hint {
182
183typedef struct _Locale_ctype {
186 unsigned short ctable[256];
188
189typedef struct _Locale_numeric {
191 char cp[MAX_CP_LEN + 1];
194 char *grouping;
196
197typedef struct _Locale_time {
199 char cp[MAX_CP_LEN + 1];
200 char *month[12];
201 char *abbrev_month[12];
202 char *dayofweek[7];
209 char am[9];
210 char pm[9];
212
213typedef struct _Locale_collate {
215 char cp[MAX_CP_LEN + 1];
217
218typedef struct _Locale_monetary {
220 char cp[MAX_CP_LEN + 1];
223 char *grouping;
224 char int_curr_symbol[5]; /* 3 + 1 + 1 */
225 char curr_symbol[6];
231
232/* Internal function */
233static void __FixGrouping(char *grouping);
234static const char* __ConvertName(const char* lname, LOCALECONV* ConvTable, int TableSize);
235static int __ParseLocaleString(const char* lname, char* lang, char* ctry, char* page);
236static int __GetLCID(const char* lang, const char* ctry, LCID* lcid);
237static int __GetLCIDFromName(const char* lname, LCID* lcid, char *cp, _Locale_lcid_t *hint);
238static char const* __GetLocaleName(LCID lcid, const char* cp, char* buf);
239static char const* __Extract_locale_name(const char* loc, const char* category, char* buf);
240static char const* __TranslateToSystem(const char* lname, char* buf, _Locale_lcid_t* hint, int *__err_code);
241static void __GetLocaleInfoUsingACP(LCID lcid, const char* cp, LCTYPE lctype, char* buf, int buf_size, wchar_t* wbuf, int wbuf_size);
242static int __intGetACP(LCID lcid);
243static int __intGetOCP(LCID lcid);
244static int __GetDefaultCP(LCID lcid);
245static char* __ConvertToCP(int from_cp, int to_cp, const char *from, size_t size, size_t *ret_buf_size);
246static void my_ltoa(long __x, char* buf);
247
248void my_ltoa(long __x, char* buf) {
249 char rbuf[64];
250 char* ptr = rbuf;
251
252 if (__x == 0)
253 *ptr++ = '0';
254 else {
255 for (; __x != 0; __x /= 10)
256 *ptr++ = (char)(__x % 10) + '0';
257 }
258 while(ptr > rbuf) *buf++ = *--ptr;
259 /* psw */
260 *buf = '\0';
261}
262
263#if defined (__cplusplus)
265extern "C" {
266#endif
267
269{ return (ltype != 0) ? &ltype->lc : 0; }
271{ return (lnumeric != 0) ? &lnumeric->lc : 0; }
273{ return (ltime != 0) ? &ltime->lc : 0; }
275{ return (lcollate != 0) ? &lcollate->lc : 0; }
277{ return (lmonetary != 0) ? &lmonetary->lc : 0; }
278_Locale_lcid_t* _Locale_get_messages_hint(struct _Locale_messages* lmessages) {
280 return 0;
281}
282
283#define MAP(x, y) if ((mask & x) != 0) ret |= (y)
284unsigned short MapCtypeMask(unsigned short mask) {
285 unsigned short ret = 0;
291 /* MAP(C1_BLANK, ?); */
294 if ((mask & C1_CNTRL) != 0) { ret |= _Locale_CNTRL; ret &= ~_Locale_PRINT; }
295 return ret;
296}
297
298static void MapCtypeMasks(unsigned short *cur, unsigned short *end) {
299 for (; cur != end; ++cur) {
300 *cur = MapCtypeMask(*cur);
301 }
302}
303
304_Locale_ctype_t* _Locale_ctype_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
305 char cp_name[MAX_CP_LEN + 1];
306 int NativeCP;
307 unsigned char Buffer[256];
308 unsigned char *ptr;
309 CPINFO CPInfo;
310 int i;
311 wchar_t *wbuffer;
312 int BufferSize;
313
315
316 if (!ltype) { *__err_code = _STLP_LOC_NO_MEMORY; return ltype; }
317 memset(ltype, 0, sizeof(_Locale_ctype_t));
318
319 if (__GetLCIDFromName(name, &ltype->lc.id, cp_name, lc_hint) == -1)
320 { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
321
322#if defined (__BORLANDC__)
323 if ( ltype->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
324 { ltype->lc.id = 0x409; }
325#endif
326
327 ltype->cp = atoi(cp_name);
328
329 NativeCP = __GetDefaultCP(ltype->lc.id);
330
331 /* Make table with all characters. */
332 for (i = 0; i < 256; ++i) Buffer[i] = (unsigned char)i;
333
334 if (!GetCPInfo(NativeCP, &CPInfo)) { free(ltype); return NULL; }
335
336 if (CPInfo.MaxCharSize > 1) {
337 for (ptr = (unsigned char*)CPInfo.LeadByte; *ptr && *(ptr + 1); ptr+=2)
338 for (i = *ptr; i <= *(ptr + 1); ++i) Buffer[i] = 0;
339 }
340
341 if ((UINT)NativeCP != ltype->cp) {
342 OSVERSIONINFO ver_info;
343 ver_info.dwOSVersionInfoSize = sizeof(ver_info);
344 GetVersionEx(&ver_info);
345 if (ver_info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
346 /* Convert character sequence to Unicode. */
347 BufferSize = MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, (const char*)Buffer, 256, NULL, 0);
348 if (!BufferSize) { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
349 wbuffer = (wchar_t*)malloc(BufferSize * sizeof(wchar_t));
350 if (!wbuffer) { free(ltype); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
351 MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, (const char*)Buffer, 256, wbuffer, BufferSize);
352
353 GetStringTypeW(CT_CTYPE1, wbuffer, 256, ltype->ctable);
354 MapCtypeMasks(ltype->ctable, ltype->ctable + 256);
355 free(wbuffer);
356 }
357 else {
358 unsigned short ctable[256];
359 unsigned char TargetBuffer[256];
360 GetStringTypeA(ltype->lc.id, CT_CTYPE1, (const char*)Buffer, 256, ctable);
361
362 /* Convert character sequence to target code page. */
363 BufferSize = MultiByteToWideChar(NativeCP, MB_PRECOMPOSED, (const char*)Buffer, 256, NULL, 0);
364 if (!BufferSize) { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
365 wbuffer = (wchar_t*)malloc(BufferSize * sizeof(wchar_t));
366 if (!wbuffer) { free(ltype); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
367 MultiByteToWideChar(NativeCP, MB_PRECOMPOSED, (const char*)Buffer, 256, wbuffer, BufferSize);
368 if (!WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuffer, BufferSize, (char*)TargetBuffer, 256, NULL, FALSE))
369 { free(wbuffer); free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
370
371 free(wbuffer);
372
373 /* Translate ctype table. */
374 for (i = 0; i < 256; ++i) {
375 if (!TargetBuffer[i]) continue;
376 ltype->ctable[TargetBuffer[i]] = MapCtypeMask(ctable[i]);
377 }
378 }
379 }
380 else {
381 GetStringTypeA(ltype->lc.id, CT_CTYPE1, (const char*)Buffer, 256, ltype->ctable);
382 MapCtypeMasks(ltype->ctable, ltype->ctable + 256);
383 }
384 return ltype;
385}
386
387_Locale_numeric_t* _Locale_numeric_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
388 wchar_t wbuf[4];
389 char *GroupingBuffer;
390 int BufferSize;
391
393 if (!lnum) { *__err_code = _STLP_LOC_NO_MEMORY; return lnum; }
394 memset(lnum, 0, sizeof(_Locale_numeric_t));
395
396 if (__GetLCIDFromName(name, &lnum->lc.id, lnum->cp, lc_hint) == -1)
397 { free(lnum); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
398
399#if defined (__BORLANDC__)
400 if (lnum->lc.id != INVARIANT_LCID) {
401#endif
402 __GetLocaleInfoUsingACP(lnum->lc.id, lnum->cp, LOCALE_SDECIMAL, lnum->decimal_point, 4, wbuf, 4);
403 __GetLocaleInfoUsingACP(lnum->lc.id, lnum->cp, LOCALE_STHOUSAND, lnum->thousands_sep, 4, wbuf, 4);
404#if defined (__BORLANDC__)
405 }
406 else
407 lnum->decimal_point[0] = '.';
408#endif
409
410 if (lnum->lc.id != INVARIANT_LCID) {
412 GroupingBuffer = (char*)malloc(BufferSize);
413 if (!GroupingBuffer) { free(lnum); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
414 GetLocaleInfoA(lnum->lc.id, LOCALE_SGROUPING, GroupingBuffer, BufferSize);
415 __FixGrouping(GroupingBuffer);
416 lnum->grouping = GroupingBuffer;
417 }
418 else {
419 lnum->grouping = (char*)malloc(1);
420 if (!lnum->grouping) { free(lnum); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
421 lnum->grouping[0] = 0;
422 }
423
424 return lnum;
425}
426
427static int __ConvertDate(const char *NTDate, char *buffer, int buf_size) {
428 /* This function will return an incomplete buffer if buffer is not long enough */
429 const char *cur_char;
430 char *cur_output, *end_output;
431
432 /* Correct time format. */
433 cur_char = NTDate;
434 cur_output = buffer;
435 end_output = cur_output + buf_size;
436 buf_size = 0;
437 while (*cur_char) {
438 if (cur_output && (cur_output == end_output)) break;
439 switch (*cur_char) {
440 case 'd':
441 {
442 if (*(cur_char + 1) == 'd') {
443 if (cur_output && (cur_output + 2 > end_output)) {
444 *cur_output = 0;
445 return ++buf_size;
446 }
447 if (*(cur_char + 2) == 'd') {
448 if (*(cur_char + 3) == 'd') {
449 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'A'; }
450 buf_size += 2;
451 cur_char += 3;
452 }
453 else {
454 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'a'; }
455 buf_size += 2;
456 cur_char += 2;
457 }
458 }
459 else {
460 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'd'; }
461 buf_size += 2;
462 cur_char++;
463 }
464 }
465 else {
466 if (cur_output && (cur_output + 3 > end_output)) {
467 *cur_output = 0;
468 return ++buf_size;
469 }
470 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'd'; }
471 buf_size += 3;
472 }
473 }
474 break;
475 case 'M':
476 {
477 if (*(cur_char + 1) == 'M') {
478 if (cur_output && (cur_output + 2 > end_output)) {
479 *cur_output = 0;
480 return ++buf_size;
481 }
482 if (*(cur_char + 2) == 'M') {
483 if (*(cur_char + 3) == 'M') {
484 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'B'; }
485 buf_size += 2;
486 cur_char += 3;
487 }
488 else {
489 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'b'; }
490 buf_size += 2;
491 cur_char += 2;
492 }
493 }
494 else {
495 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'm'; }
496 buf_size += 2;
497 cur_char++;
498 }
499 }
500 else {
501 if (cur_output && (cur_output + 3 > end_output)) {
502 *cur_output = 0;
503 return ++buf_size;
504 }
505 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'm'; }
506 buf_size += 3;
507 }
508 }
509 break;
510 case 'y':
511 {
512 if (*(cur_char + 1) == 'y') {
513 if (cur_output && (cur_output + 2 > end_output)) {
514 *cur_output = 0;
515 return ++buf_size;
516 }
517 if (*(cur_char + 2) == 'y' && *(cur_char + 3) == 'y') {
518 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'Y'; }
519 buf_size += 2;
520 cur_char += 3;
521 }
522 else {
523 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'y'; }
524 buf_size += 2;
525 cur_char++;
526 }
527 }
528 else {
529 if (cur_output && (cur_output + 3 > end_output)) {
530 *cur_output = 0;
531 return ++buf_size;
532 }
533 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'y'; }
534 buf_size += 3;
535 }
536 }
537 break;
538 case '%':
539 {
540 if (cur_output && (cur_output + 2 > end_output)) {
541 *cur_output = 0;
542 return ++buf_size;
543 }
544 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '%'; }
545 buf_size += 2;
546 }
547 break;
548 case '\'':
549 {
550 ++cur_char;
551 while (*cur_char != '\'' && *cur_char != 0 && (cur_output == NULL || cur_output != end_output)) {
552 if (cur_output) { *cur_output++ = *cur_char; }
553 ++cur_char;
554 buf_size += 1;
555 }
556 }
557 break;
558 default:
559 {
560 if (cur_output) { *(cur_output++) = *cur_char; }
561 buf_size += 1;
562 }
563 break;
564 }
565 if (*cur_char == 0) break;
566 ++cur_char;
567 }
568
569 if (!cur_output || cur_output != end_output) {
570 if (cur_output) *cur_output = 0;
571 buf_size += 1;
572 }
573 else {
574 /* We trunc result */
575 *(--cur_output) = 0;
576 }
577
578 return buf_size;
579}
580
581static int __ConvertTime(const char *NTTime, char *buffer, int buf_size) {
582 const char *cur_char;
583 char *cur_output, *end_output;
584 cur_char = NTTime;
585 cur_output = buffer;
586 end_output = cur_output + buf_size;
587 buf_size = 0;
588 while (*cur_char) {
589 switch(*cur_char) {
590 case 'h':
591 if (*(cur_char + 1) == 'h') {
592 if (cur_output && (cur_output + 2 > end_output)) {
593 *cur_output = 0;
594 return ++buf_size;
595 }
596 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'I'; }
597 buf_size += 2;
598 ++cur_char;
599 }
600 else {
601 if (cur_output && (cur_output + 3 > end_output)) {
602 *cur_output = 0;
603 return ++buf_size;
604 }
605 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'I'; }
606 buf_size += 3;
607 }
608 break;
609 case 'H':
610 if (*(cur_char + 1) == 'H') {
611 if (cur_output && (cur_output + 2 > end_output)) {
612 *cur_output = 0;
613 return ++buf_size;
614 }
615 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'H'; }
616 buf_size += 2;
617 ++cur_char;
618 }
619 else {
620 if (cur_output && (cur_output + 3 > end_output)) {
621 *cur_output = 0;
622 return ++buf_size;
623 }
624 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'H'; }
625 buf_size += 3;
626 }
627 break;
628 case 'm':
629 if (*(cur_char + 1) == 'm') {
630 if (cur_output && (cur_output + 2 > end_output)) {
631 *cur_output = 0;
632 return ++buf_size;
633 }
634 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'M'; }
635 buf_size += 2;
636 cur_char++;
637 }
638 else {
639 if (cur_output && (cur_output + 3 > end_output)) {
640 *cur_output = 0;
641 return ++buf_size;
642 }
643 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'M'; }
644 buf_size += 3;
645 }
646 break;
647 case 's':
648 if (*(cur_char + 1) == 's') {
649 if (cur_output && (cur_output + 2 > end_output)) {
650 *cur_output = 0;
651 return ++buf_size;
652 }
653 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'S'; }
654 buf_size += 2;
655 ++cur_char;
656 }
657 else {
658 if (cur_output && (cur_output + 3 > end_output)) {
659 *cur_output = 0;
660 return ++buf_size;
661 }
662 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'S'; }
663 buf_size += 3;
664 }
665 break;
666 case 't':
667 if (*(cur_char + 1) == 't')
668 ++cur_char;
669 if (cur_output && (cur_output + 2 > end_output)) {
670 *cur_output = 0;
671 return ++buf_size;
672 }
673 if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'p'; }
674 buf_size += 2;
675 break;
676 case '%':
677 if (cur_output && (cur_output + 2 > end_output)) {
678 *cur_output = 0;
679 return ++buf_size;
680 }
681 if (cur_output) { *(cur_output++)='%'; *(cur_output++)='%'; }
682 buf_size += 2;
683 break;
684 case '\'':
685 ++cur_char;
686 while (*cur_char != '\'' && *cur_char != 0 && (!cur_output || (cur_output != end_output))) {
687 if (cur_output) *cur_output++ = *cur_char;
688 ++cur_char;
689 buf_size += 1;
690 }
691 break;
692 default:
693 if (cur_output) { *(cur_output++) = *cur_char; }
694 buf_size += 1;
695 break;
696 }
697 if (*cur_char == 0) break;
698 ++cur_char;
699 }
700
701 if (!cur_output || cur_output != end_output) {
702 if (cur_output) *cur_output = 0;
703 buf_size += 1;
704 }
705 else {
706 /* We trunc result */
707 *(--cur_output) = 0;
708 }
709
710 return buf_size;
711}
712
713_Locale_time_t* _Locale_time_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
714 int size, month, dayofweek;
715 size_t length;
716 char fmt80[80];
717 wchar_t wbuf80[80];
718
720
721 if (!ltime) { *__err_code = _STLP_LOC_NO_MEMORY; return ltime; }
722 memset(ltime, 0, sizeof(_Locale_time_t));
723
724 if (__GetLCIDFromName(name, &ltime->lc.id, ltime->cp, lc_hint) == -1)
725 { free(ltime); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
726
727#if defined (__BORLANDC__)
728 if ( ltime->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
729 { ltime->lc.id = 0x409; }
730#endif
731
732 for (month = LOCALE_SMONTHNAME1; month <= LOCALE_SMONTHNAME12; ++month) { /* Small hack :-) */
733 size = GetLocaleInfoA(ltime->lc.id, month, NULL, 0);
734 ltime->month[month - LOCALE_SMONTHNAME1] = (char*)malloc(size);
735 if (!ltime->month[month - LOCALE_SMONTHNAME1])
736 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
737 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, month, ltime->month[month - LOCALE_SMONTHNAME1], size, wbuf80, 80);
738 }
739
741 size = GetLocaleInfoA(ltime->lc.id, month, NULL, 0);
744 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
745 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, month, ltime->abbrev_month[month - LOCALE_SABBREVMONTHNAME1], size, wbuf80, 80);
746 }
747
748 for (dayofweek = LOCALE_SDAYNAME1; dayofweek <= LOCALE_SDAYNAME7; ++dayofweek) {
749 int dayindex = ( dayofweek != LOCALE_SDAYNAME7 ) ? dayofweek - LOCALE_SDAYNAME1 + 1 : 0;
750 size = GetLocaleInfoA(ltime->lc.id, dayofweek, NULL, 0);
751 ltime->dayofweek[dayindex] = (char*)malloc(size);
752 if (!ltime->dayofweek[dayindex])
753 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
754 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, dayofweek, ltime->dayofweek[dayindex], size, wbuf80, 80);
755 }
756
757 for (dayofweek = LOCALE_SABBREVDAYNAME1; dayofweek <= LOCALE_SABBREVDAYNAME7; ++dayofweek) {
758 int dayindex = ( dayofweek != LOCALE_SABBREVDAYNAME7 ) ? dayofweek - LOCALE_SABBREVDAYNAME1 + 1 : 0;
759 size = GetLocaleInfoA(ltime->lc.id, dayofweek, NULL, 0);
760 ltime->abbrev_dayofweek[dayindex] = (char*)malloc(size);
761 if (!ltime->abbrev_dayofweek[dayindex])
762 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
763 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, dayofweek, ltime->abbrev_dayofweek[dayindex], size, wbuf80, 80);
764 }
765
766 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_SSHORTDATE, fmt80, 80, wbuf80, 80);
767 size = __ConvertDate(fmt80, NULL, 0);
768 ltime->date_format = (char*)malloc(size);
769 if (!ltime->date_format)
770 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
771 __ConvertDate(fmt80, ltime->date_format, size);
772
773 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_SLONGDATE, fmt80, 80, wbuf80, 80);
774 size = __ConvertDate(fmt80, NULL, 0);
775 ltime->long_date_format = (char*)malloc(size);
776 if (!ltime->long_date_format)
777 { _Locale_time_destroy(ltime);*__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
778 __ConvertDate(fmt80, ltime->long_date_format, size);
779
780 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_STIMEFORMAT, fmt80, 80, wbuf80, 80);
781 size = __ConvertTime(fmt80, NULL, 0);
782 ltime->time_format = (char*)malloc(size);
783 if (!ltime->time_format)
784 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
785 __ConvertTime(fmt80, ltime->time_format, size);
786
787 /* NT doesn't provide this information, we must simulate. */
788 length = strlen(ltime->date_format) + strlen(ltime->time_format) + 1 /* space */ + 1 /* trailing 0 */;
789 ltime->date_time_format = (char*)malloc(length);
790 if (!ltime->date_time_format)
791 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
795
796 /* NT doesn't provide this information, we must simulate. */
797 length = strlen(ltime->long_date_format) + strlen(ltime->time_format) + 1 /* space */ + 1 /* trailing 0 */;
798 ltime->long_date_time_format = (char*)malloc(length);
799 if (!ltime->long_date_time_format)
800 { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
804
805 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_S1159, ltime->am, 9, wbuf80, 80);
806 __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_S2359, ltime->pm, 9, wbuf80, 80);
807
808 return ltime;
809}
810
811_Locale_collate_t* _Locale_collate_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
813 if (!lcol) { *__err_code = _STLP_LOC_NO_MEMORY; return lcol; }
814 memset(lcol, 0, sizeof(_Locale_collate_t));
815
816 if (__GetLCIDFromName(name, &lcol->lc.id, lcol->cp, lc_hint) == -1)
817 { free(lcol); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
818
819#if defined (__BORLANDC__)
820 if ( lcol->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
821 { lcol->lc.id = 0x409; }
822#endif
823
824 return lcol;
825}
826
827_Locale_monetary_t* _Locale_monetary_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
828 char *GroupingBuffer;
829 int BufferSize;
830 char FracDigits[3];
831 wchar_t wbuf[6];
832
834 if (!lmon) { *__err_code = _STLP_LOC_NO_MEMORY; return lmon; }
835 memset(lmon, 0, sizeof(_Locale_monetary_t));
836
837 if (__GetLCIDFromName(name, &lmon->lc.id, lmon->cp, lc_hint) == -1)
838 { free(lmon); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
839
840 if (lmon->lc.id != INVARIANT_LCID) {
841 /* Extract information about monetary system */
842 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SDECIMAL, lmon->decimal_point, 4, wbuf, 6);
843 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_STHOUSAND, lmon->thousands_sep, 4, wbuf, 6);
844
846 GroupingBuffer = (char*)malloc(BufferSize);
847 if (!GroupingBuffer)
848 { lmon->grouping = NULL; *__err_code = _STLP_LOC_NO_MEMORY; return lmon; }
849 GetLocaleInfoA(lmon->lc.id, LOCALE_SGROUPING, GroupingBuffer, BufferSize);
850 __FixGrouping(GroupingBuffer);
851 lmon->grouping = GroupingBuffer;
852
853 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SCURRENCY, lmon->curr_symbol, 6, wbuf, 6);
854 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SNEGATIVESIGN, lmon->negative_sign, 5, wbuf, 6);
855 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SPOSITIVESIGN, lmon->positive_sign, 5, wbuf, 6);
856
857 GetLocaleInfoA(lmon->lc.id, LOCALE_ICURRDIGITS, FracDigits, 3);
858 lmon->frac_digits = atoi(FracDigits);
859
860 GetLocaleInfoA(lmon->lc.id, LOCALE_IINTLCURRDIGITS, FracDigits, 3);
861 lmon->int_frac_digits = atoi(FracDigits);
862
863 __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SINTLSYMBOL, lmon->int_curr_symbol, 5, wbuf, 6);
864 /* Even if Platform SDK documentation says that the returned symbol should
865 * be a 3 letters symbol followed by a seperation character, experimentation
866 * has shown that no seperation character is ever appended. We are adding it
867 * ourself to conform to the POSIX specification.
868 */
869 if (lmon->int_curr_symbol[3] == 0) {
870 lmon->int_curr_symbol[3] = ' ';
871 lmon->int_curr_symbol[4] = 0;
872 }
873 }
874 /* else it is already ok */
875
876 return lmon;
877}
878
879struct _Locale_messages* _Locale_messages_create(const char *name, _Locale_lcid_t* lc_hint, int *__err_code) {
880 /* The Win32 API has no support for messages facet */
884 return NULL;
885}
886
887static const char* _Locale_common_default(char* buf) {
888 char cp[MAX_CP_LEN + 1];
889 int CodePage = __GetDefaultCP(LOCALE_USER_DEFAULT);
890 my_ltoa(CodePage, cp);
892}
893
894const char* _Locale_ctype_default(char* buf)
895{ return _Locale_common_default(buf); }
896
897const char* _Locale_numeric_default(char * buf)
898{ return _Locale_common_default(buf); }
899
900const char* _Locale_time_default(char* buf)
901{ return _Locale_common_default(buf); }
902
903const char* _Locale_collate_default(char* buf)
904{ return _Locale_common_default(buf); }
905
907{ return _Locale_common_default(buf); }
908
910{ return _Locale_common_default(buf); }
911
912char const* _Locale_ctype_name(const _Locale_ctype_t* ltype, char* buf) {
913 char cp_buf[MAX_CP_LEN + 1];
914 my_ltoa(ltype->cp, cp_buf);
915 return __GetLocaleName(ltype->lc.id, cp_buf, buf);
916}
917
918char const* _Locale_numeric_name(const _Locale_numeric_t* lnum, char* buf)
919{ return __GetLocaleName(lnum->lc.id, lnum->cp, buf); }
920
921char const* _Locale_time_name(const _Locale_time_t* ltime, char* buf)
922{ return __GetLocaleName(ltime->lc.id, ltime->cp, buf); }
923
924char const* _Locale_collate_name(const _Locale_collate_t* lcol, char* buf)
925{ return __GetLocaleName(lcol->lc.id, lcol->cp, buf); }
926
927char const* _Locale_monetary_name(const _Locale_monetary_t* lmon, char* buf)
928{ return __GetLocaleName(lmon->lc.id, lmon->cp, buf); }
929
930char const* _Locale_messages_name(const struct _Locale_messages* lmes, char* buf) {
933 return NULL;
934}
935
937 if (!ltype) return;
938
939 free(ltype);
940}
941
943 if (!lnum) return;
944
945 if (lnum->grouping) free(lnum->grouping);
946 free(lnum);
947}
948
950 int i;
951 if (!ltime) return;
952
953 for (i = 0; i < 12; ++i) {
954 if (ltime->month[i]) free(ltime->month[i]);
955 if (ltime->abbrev_month[i]) free(ltime->abbrev_month[i]);
956 }
957
958 for (i = 0; i < 7; ++i) {
959 if (ltime->dayofweek[i]) free(ltime->dayofweek[i]);
960 if (ltime->abbrev_dayofweek[i]) free(ltime->abbrev_dayofweek[i]);
961 }
962
963 if (ltime->date_format) free(ltime->date_format);
964 if (ltime->long_date_format) free(ltime->long_date_format);
965 if (ltime->time_format) free(ltime->time_format);
966 if (ltime->date_time_format) free(ltime->date_time_format);
968
969 free(ltime);
970}
971
973 if (!lcol) return;
974
975 free(lcol);
976}
977
979 if (!lmon) return;
980
981 if (lmon->grouping) free(lmon->grouping);
982 free(lmon);
983}
984
985void _Locale_messages_destroy(struct _Locale_messages* lmes)
987
988static char const* _Locale_extract_category_name(const char* name, const char* category, char* buf,
989 _Locale_lcid_t* hint, int *__err_code) {
990 const char* cname = __Extract_locale_name(name, category, buf);
991 if (cname == 0 || (cname[0] == 'C' && cname[1] == 0)) {
992 return cname;
993 }
994 return __TranslateToSystem(cname, buf, hint, __err_code);
995}
996
997char const* _Locale_extract_ctype_name(const char* cname, char* buf,
998 _Locale_lcid_t* hint, int *__err_code)
999{ return _Locale_extract_category_name(cname, "LC_CTYPE", buf, hint, __err_code); }
1000
1001char const* _Locale_extract_numeric_name(const char* cname, char* buf,
1002 _Locale_lcid_t* hint, int *__err_code)
1003{ return _Locale_extract_category_name(cname, "LC_NUMERIC", buf, hint, __err_code); }
1004
1005char const* _Locale_extract_time_name(const char* cname, char* buf,
1006 _Locale_lcid_t* hint, int *__err_code)
1007{ return _Locale_extract_category_name(cname, "LC_TIME", buf, hint, __err_code); }
1008
1009char const* _Locale_extract_collate_name(const char* cname, char* buf,
1010 _Locale_lcid_t* hint, int *__err_code)
1011{ return _Locale_extract_category_name(cname, "LC_COLLATE", buf, hint, __err_code); }
1012
1013char const* _Locale_extract_monetary_name(const char* cname, char* buf,
1014 _Locale_lcid_t* hint, int *__err_code)
1015{ return _Locale_extract_category_name(cname, "LC_MONETARY", buf, hint, __err_code); }
1016
1017char const* _Locale_extract_messages_name(const char* cname, char* buf,
1018 _Locale_lcid_t* hint, int *__err_code) {
1019 if (cname[0] == 'L' && cname[1] == 'C' && cname[2] == '_') {
1020 return _C_name;
1021 }
1022 if (cname[0] == 'C' && cname[1] == 0) {
1023 return _C_name;
1024 }
1025 return __TranslateToSystem(cname, buf, hint, __err_code);
1026}
1027
1028/* ctype */
1029
1031 _STLP_STATIC_ASSERT(sizeof(_Locale_mask_t) == sizeof(ltype->ctable[0]))
1032 return (const _Locale_mask_t*)ltype->ctable;
1033}
1034
1036 char buf[2], out_buf[2];
1037 buf[0] = (char)c; buf[1] = 0;
1038 if ((UINT)__GetDefaultCP(ltype->lc.id) == ltype->cp) {
1039 LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_UPPERCASE, buf, 2, out_buf, 2);
1040 return out_buf[0];
1041 }
1042 else {
1043 wchar_t wbuf[2];
1044 MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, buf, 2, wbuf, 2);
1046
1047 LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_UPPERCASE, buf, 2, out_buf, 2);
1048
1049 MultiByteToWideChar(__GetDefaultCP(ltype->lc.id), MB_PRECOMPOSED, out_buf, 2, wbuf, 2);
1050 WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, out_buf, 2, NULL, FALSE);
1051 return out_buf[0];
1052 }
1053}
1054
1056 char buf[2], out_buf[2];
1057 buf[0] = (char)c; buf[1] = 0;
1058 if ((UINT)__GetDefaultCP(ltype->lc.id) == ltype->cp) {
1059 LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE, buf, 2, out_buf, 2);
1060 return out_buf[0];
1061 }
1062 else {
1063 wchar_t wbuf[2];
1064 MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, buf, 2, wbuf, 2);
1066
1067 LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE, buf, 2, out_buf, 2);
1068
1069 MultiByteToWideChar(__GetDefaultCP(ltype->lc.id), MB_PRECOMPOSED, out_buf, 2, wbuf, 2);
1070 WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, out_buf, 2, NULL, FALSE);
1071 return out_buf[0];
1072 }
1073}
1074
1075#ifndef CSTR_EQUAL /* VC5SP3*/
1076# define CSTR_EQUAL 2
1077#endif
1078#ifndef CSTR_LESS_THAN /* VC5SP3 */
1079# define CSTR_LESS_THAN 1
1080#endif
1081
1082static DWORD max_DWORD = 0xffffffff;
1083static DWORD trim_size_t_to_DWORD(size_t n) { return n < (size_t)max_DWORD ? (DWORD)n : max_DWORD; }
1084
1085/* Collate */
1086/* This function takes care of the potential size_t DWORD different size. */
1088 const char* s1, size_t n1,
1089 const char* s2, size_t n2) {
1090 int result = CSTR_EQUAL;
1091 while (n1 > 0 || n2 > 0) {
1092 DWORD size1 = trim_size_t_to_DWORD(n1);
1093 DWORD size2 = trim_size_t_to_DWORD(n2);
1094 result = CompareStringA(lcol->lc.id, 0, s1, size1, s2, size2);
1095 if (result != CSTR_EQUAL)
1096 break;
1097 n1 -= size1;
1098 n2 -= size2;
1099 }
1100 return result;
1101}
1102
1104 const char* s1, size_t n1,
1105 const char* s2, size_t n2) {
1106 int result;
1107 if (__GetDefaultCP(lcol->lc.id) == atoi(lcol->cp)) {
1108 result = _Locale_strcmp_auxA(lcol, s1, n1, s2, n2);
1109 }
1110 else {
1111 char *buf1, *buf2;
1112 size_t size1, size2;
1113 buf1 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), s1, n1, &size1);
1114 buf2 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), s2, n2, &size2);
1115
1116 result = _Locale_strcmp_auxA(lcol, buf1, size1, buf2, size2);
1117 free(buf1); free(buf2);
1118 }
1119 return (result == CSTR_EQUAL) ? 0 : (result == CSTR_LESS_THAN) ? -1 : 1;
1120}
1121
1123 char* dst, size_t dst_size,
1124 const char* src, size_t src_size) {
1125 int result;
1126
1127 /* The Windows API do not support transformation of very long strings (src_size > INT_MAX)
1128 * In this case the result will just be the input string:
1129 */
1130 if (src_size > INT_MAX) {
1131 if (dst != 0) {
1132 _STLP_STRNCPY(dst, dst_size, src, src_size);
1133 }
1134 return src_size;
1135 }
1136 if (dst_size > INT_MAX) {
1137 /* now that we know that src_size <= INT_MAX we can safely decrease dst_size to INT_MAX. */
1138 dst_size = INT_MAX;
1139 }
1140
1141 if (__GetDefaultCP(lcol->lc.id) == atoi(lcol->cp))
1142 result = LCMapStringA(lcol->lc.id, LCMAP_SORTKEY, src, (int)src_size, dst, (int)dst_size);
1143 else {
1144 char *buf;
1145 size_t size;
1146 buf = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), src, src_size, &size);
1147
1148 result = LCMapStringA(lcol->lc.id, LCMAP_SORTKEY, buf, (int)size, dst, (int)dst_size);
1149 free(buf);
1150 }
1151 return result != 0 ? result - 1 : 0;
1152}
1153
1154/* Numeric */
1155static const char* __true_name = "true";
1156static const char* __false_name = "false";
1157
1159{ return lnum->decimal_point[0]; }
1160
1162{ return lnum->thousands_sep[0]; }
1163
1165 if (!lnum->grouping) return "";
1166 else return lnum->grouping;
1167}
1168
1169const char * _Locale_true(_Locale_numeric_t * lnum) {
1171 return __true_name; /* NT does't provide information about this */
1172}
1173
1174const char * _Locale_false(_Locale_numeric_t * lnum) {
1176 return __false_name; /* NT does't provide information about this */
1177}
1178
1179/* Monetary */
1181{ return lmon->int_curr_symbol; }
1182
1184{ return lmon->curr_symbol; }
1185
1187{ return lmon->decimal_point[0]; }
1188
1190{ return lmon->thousands_sep[0]; }
1191
1193 if (!lmon->grouping) return "";
1194 else return lmon->grouping;
1195}
1196
1198{ return lmon->positive_sign; }
1199
1201{ return lmon->negative_sign; }
1202
1204{ return (char)lmon->int_frac_digits; }
1205
1207{ return (char)lmon->frac_digits; }
1208
1210 char loc_data[2];
1211 GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSYMPRECEDES, loc_data, 2);
1212 if (loc_data[0] == '0') return 0;
1213 else if (loc_data[0] == '1') return 1;
1214 else return -1;
1215}
1216
1218 char loc_data[2];
1219 GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSEPBYSPACE, loc_data, 2);
1220 if (loc_data[0] == '0') return 0;
1221 else if (loc_data[0] == '1') return 1;
1222 else return -1;
1223}
1224
1226 char loc_data[2];
1227 if (lmon->lc.id != INVARIANT_LCID) {
1228 GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSIGNPOSN, loc_data, 2);
1229 return atoi(loc_data);
1230 }
1231 else {
1232 return CHAR_MAX;
1233 }
1234}
1235
1237 char loc_data[2];
1238 GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSYMPRECEDES, loc_data, 2);
1239 if (loc_data[0] == '0') return 0;
1240 else if (loc_data[0] == '1') return 1;
1241 else return -1;
1242}
1243
1245 char loc_data[2];
1246 GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSEPBYSPACE, loc_data, 2);
1247 if (loc_data[0] == '0') return 0;
1248 else if (loc_data[0] == '1') return 1;
1249 else return -1;
1250}
1251
1253 char loc_data[2];
1254 if (lmon->lc.id != INVARIANT_LCID) {
1255 GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSIGNPOSN, loc_data, 2);
1256 return atoi(loc_data);
1257 }
1258 else {
1259 return CHAR_MAX;
1260 }
1261}
1262
1263/* Time */
1264const char * _Locale_full_monthname(_Locale_time_t * ltime, int month) {
1265 const char **names = (const char**)ltime->month;
1266 return names[month];
1267}
1268
1270 const char **names = (const char**)ltime->abbrev_month;
1271 return names[month];
1272}
1273
1274const char * _Locale_full_dayofweek(_Locale_time_t * ltime, int day) {
1275 const char **names = (const char**)ltime->dayofweek;
1276 return names[day];
1277}
1278
1279const char * _Locale_abbrev_dayofweek(_Locale_time_t * ltime, int day) {
1280 const char **names = (const char**)ltime->abbrev_dayofweek;
1281 return names[day];
1282}
1283
1285{ return ltime->date_time_format; }
1286
1288{ return ltime->long_date_time_format; }
1289
1291{ return ltime->date_format; }
1292
1294{ return ltime->long_date_format; }
1295
1297{ return ltime->time_format; }
1298
1300{ return ltime->am; }
1301
1303{ return ltime->pm; }
1304
1305/* Messages */
1306nl_catd_type _Locale_catopen(struct _Locale_messages* lmes, const char* cat_name) {
1309 return -1;
1310}
1311void _Locale_catclose(struct _Locale_messages* lmes, nl_catd_type cat) {
1314}
1315const char* _Locale_catgets(struct _Locale_messages* lmes, nl_catd_type cat,
1316 int setid, int msgid, const char *dfault) {
1321 return dfault;
1322}
1323
1324#ifdef __cplusplus
1325} /* extern C */
1327#endif
1328
1329void __FixGrouping(char *grouping) {
1330 /* This converts NT version which uses '0' instead of 0, etc ; to ANSI */
1331 char *g = grouping;
1332 char building_group = 0;
1333 char repeat_last = 0;
1334 /* Check there is a grouping info otherwise we would add a useless CHAR_MAX */
1335 if (*g) {
1336 for (; *g; ++g) {
1337 if (*g > '0' && *g <= '9') {
1338 if (!building_group) {
1339 *grouping = *g - '0';
1340 building_group = 1;
1341 }
1342 else {
1343 /* Known issue: grouping might roll. */
1344 *grouping = *grouping * 10 + *g - '0';
1345 }
1346 }
1347 else if (*g == '0') {
1348 if (!building_group) {
1349 repeat_last = 1;
1350 }
1351 else
1352 /* Known issue: grouping might roll. */
1353 *grouping *= 10;
1354 }
1355 else if (*g == ';') {
1356 /* Stop adding to the current group */
1357 building_group = 0;
1358 ++grouping;
1359 }
1360 /* else we ignore the character */
1361 }
1362
1363 if (!repeat_last)
1364 *grouping++ = CHAR_MAX;
1365 *grouping = 0;
1366 }
1367}
1368
1369const char* __ConvertName(const char* lname, LOCALECONV* ConvTable, int TableSize) {
1370 int i;
1371 int cmp;
1372 int low = 0;
1373 int high = TableSize - 1;
1374
1375 /* typical binary search - do until no more to search or match */
1376 while (low <= high) {
1377 i = (low + high) / 2;
1378
1379 if ((cmp = lstrcmpiA(lname, (*(ConvTable + i)).name)) == 0)
1380 return (*(ConvTable + i)).abbrev;
1381 else if (cmp < 0)
1382 high = i - 1;
1383 else
1384 low = i + 1;
1385 }
1386 return lname;
1387}
1388
1389int __ParseLocaleString(const char* lname,
1390 char* lang, char* ctry, char* page) {
1391 int param = 0;
1392 size_t len;
1393 size_t tmpLen;
1394
1395 if (lname[0] == 0)
1396 return 0;
1397
1398 /* We look for the first country separator '_' */
1399 len = strcspn(lname, "_");
1400 if (lname[len] == '_') {
1401 if (len == 0 || len > MAX_LANG_LEN) return -1; /* empty lang is invalid*/
1402 _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len);
1403 lname += len + 1;
1404 ++param;
1405 }
1406
1407 /* We look for the last code page separator '.' */
1408 len = -1;
1409 tmpLen = strcspn(lname, ".");
1410 while (lname[tmpLen] == '.') {
1411 len = tmpLen; ++tmpLen;
1412 tmpLen += strcspn(lname + tmpLen, ".");
1413 }
1414 if (len != -1) { /* Means that we found a '.' */
1415 if (param == 0) {
1416 /* We have no lang yet so we have to fill it first, no country */
1417 if (len > MAX_LANG_LEN) return -1;
1418 if (len == 0) {
1419 /* No language nor country, only code page */
1420 ++param;
1421 }
1422 else
1423 { _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len); }
1424 ++param;
1425 }
1426 else {
1427 /* We already have a lang so we are now looking for the country: */
1428 if (len == 0) return -1; /* We forbid locale name with the "_." motif in it */
1429 if (len > MAX_CTRY_LEN) return -1;
1430 _STLP_STRNCPY(ctry, MAX_CTRY_LEN + 1, lname, len);
1431 }
1432 ++param;
1433 lname += len + 1;
1434 }
1435
1436 /* We look for ',' for compatibility with POSIX */
1437 len = strcspn(lname, ",");
1438 switch (param) {
1439 case 0:
1440 if (len > MAX_LANG_LEN) return -1;
1441 _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len);
1442 break;
1443 case 1:
1444 if (len > MAX_CTRY_LEN) return -1;
1445 _STLP_STRNCPY(ctry, MAX_CTRY_LEN + 1, lname, len);
1446 break;
1447 default:
1448 if (len > MAX_CP_LEN) return -1;
1449 _STLP_STRNCPY(page, MAX_CP_LEN + 1, lname, len);
1450 break;
1451 }
1452
1453 /* ',' POSIX modifier is not used in NT */
1454 return 0;
1455}
1456
1457/* Data necessary for find LCID*/
1459static int __FindFlag;
1461static const char* __FndLang;
1462static const char* __FndCtry;
1463
1466
1469
1470static LCID LocaleFromHex(const char* locale) {
1471 unsigned long result = 0;
1472 int digit;
1473 while (*locale) {
1474 result <<= 4;
1475 digit = (*locale >= '0' && *locale <= '9') ? *locale - '0':
1476 (*locale >= 'A' && *locale <= 'F') ? (*locale - 'A') + 10
1477 : (*locale - 'a') + 10;
1478 result += digit;
1479 ++locale;
1480 }
1481 return (LCID)result;
1482}
1483
1485 LCID lcid = LocaleFromHex(locale);
1486 int LangFlag = 0, CtryFlag = !__FndCtry;
1487 static char Lang[MAX_LANG_LEN], Ctry[MAX_CTRY_LEN];
1488
1490 if (lstrcmpiA(Lang, __FndLang) != 0) {
1492 if (lstrcmpiA(Lang, __FndLang) != 0) {
1494 if (lstrcmpiA(Lang, __FndLang) == 0) LangFlag = 1;
1495 }
1496 else LangFlag = 1;
1497 }
1498 else LangFlag = 1;
1499
1500 if (__FndCtry) {
1502 if (lstrcmpiA(Ctry, __FndCtry) != 0) {
1504 if (lstrcmpiA(Ctry, __FndCtry) != 0) {
1506 if (lstrcmpiA(Ctry, __FndCtry) == 0) CtryFlag = 1;
1507 }
1508 else CtryFlag = 1;
1509 }
1510 else
1511 CtryFlag = 1;
1512 }
1513
1514 if (LangFlag && CtryFlag) {
1515 __FindFlag = 1;
1516 __FndLCID = lcid;
1517 return FALSE;
1518 }
1519
1520 return TRUE;
1521}
1522
1523int __GetLCID(const char* lang, const char* ctry, LCID* lcid) {
1524 int ret;
1526
1527 __FindFlag = 0;
1528 __FndLang = lang;
1529 __FndCtry = ctry;
1531
1532 if (__FindFlag != 0) *lcid = __FndLCID;
1533 ret = __FindFlag != 0 ? 0 : -1;
1534
1536 return ret;
1537}
1538
1539int __GetLCIDFromName(const char* lname, LCID* lcid, char* cp, _Locale_lcid_t *hint) {
1540 char lang[MAX_LANG_LEN + 1], ctry[MAX_CTRY_LEN + 1], page[MAX_CP_LEN + 1];
1541 int result = 0;
1542 if (lname == NULL || lname[0] == 0) {
1543 *lcid = LOCALE_USER_DEFAULT;
1544 return 0;
1545 }
1546
1547 memset(lang, 0, MAX_LANG_LEN + 1);
1548 memset(ctry, 0, MAX_CTRY_LEN + 1);
1549 memset(page, 0, MAX_CP_LEN + 1);
1550 if (__ParseLocaleString(lname, lang, ctry, page) == -1) return -1;
1551
1552 if (hint != 0) {
1553 *lcid = hint->id;
1554 }
1555 else {
1556 if (lang[0] == 0 && ctry[0] == 0)
1557 *lcid = LOCALE_USER_DEFAULT; /* Only code page given. */
1558 else {
1559 if (ctry[0] == 0) {
1561 if (result != 0) {
1562 /* Check 'C' special case. Check is done after call to __GetLCID because normal programs do not
1563 * generate facet from 'C' name, they use the locale::classic() facets. */
1564 if (lang[0] == 'C' && lang[1] == 0) {
1565 *lcid = INVARIANT_LCID;
1566 result = 0;
1567 }
1568 }
1569 }
1570 else {
1572 __ConvertName(ctry, __rg_country, sizeof(__rg_country) / sizeof(LOCALECONV)),
1573 lcid);
1574 if (result != 0) {
1575 /* Non NLS mapping might introduce problem with some locales when only one entry is mapped,
1576 * the lang or the country (example: chinese locales like 'chinese_taiwan' gives 'CHS_taiwan'
1577 * that do not exists in system). This is why we are giving this locale an other chance by
1578 * calling __GetLCID without the mapping. */
1579 result = __GetLCID(lang, ctry, lcid);
1580 }
1581 }
1582 }
1583 }
1584
1585 if (result == 0) {
1586 /* Handling code page */
1587 if (lstrcmpiA(page, "ACP") == 0 || page[0] == 0)
1588 my_ltoa(__intGetACP(*lcid), cp);
1589 else if (lstrcmpiA(page, "OCP") == 0)
1590 my_ltoa(__intGetOCP(*lcid), cp);
1591 else if (lstrcmpiA(page, "UTF7") == 0)
1592 my_ltoa(CP_UTF7, cp);
1593 else if (lstrcmpiA(page, "UTF8") == 0)
1594 my_ltoa(CP_UTF8, cp);
1595 else
1596 _STLP_STRNCPY(cp, MAX_CP_LEN + 1, page, 5);
1597
1598 /* Code page must be an integer value,
1599 * 0 returned by __intGetACP and 1 returned by __intGetOCP are invalid
1600 * values.
1601 */
1602 if (cp[1] == 0 && (cp[0] == '0' || cp[1] == '1'))
1603 return -1;
1604 else if (atoi(cp) == 0)
1605 return -1;
1606 }
1607
1608 return result;
1609}
1610
1611char const* __GetLocaleName(LCID lcid, const char* cp, char* buf) {
1612 if (lcid == INVARIANT_LCID) {
1613 return _C_name;
1614 }
1615 else {
1616 char lang[MAX_LANG_LEN + 1], ctry[MAX_CTRY_LEN + 1];
1624 return buf;
1625 }
1626}
1627
1628char const* __Extract_locale_name(const char* loc, const char* category, char* buf) {
1629 char *expr;
1630 size_t len_name;
1631
1632 if (loc[0] == 'L' && loc[1] == 'C' && loc[2] == '_') {
1633 expr = strstr((char*)loc, category);
1634 if (expr == NULL) return NULL; /* Category not found. */
1635 expr = strchr(expr, '=');
1636 if (expr == NULL) return NULL;
1637 ++expr;
1638 len_name = strcspn(expr, ";");
1639 len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1
1640 : len_name;
1641 _STLP_STRNCPY(buf, _Locale_MAX_SIMPLE_NAME, expr, len_name); buf[len_name] = 0;
1642 return buf;
1643 }
1644 else {
1645 return loc;
1646 }
1647}
1648
1649char const* __TranslateToSystem(const char* lname, char* buf, _Locale_lcid_t* hint,
1650 int *__err_code) {
1651 LCID lcid;
1652 char cp[MAX_CP_LEN + 1];
1653 if (__GetLCIDFromName(lname, &lcid, cp, hint) != 0)
1654 { *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
1655
1656 return __GetLocaleName(lcid, cp, buf);
1657}
1658
1659void __GetLocaleInfoUsingACP(LCID lcid, const char* cp, LCTYPE lctype, char* buf, int buf_size, wchar_t* wbuf, int wbuf_size) {
1660 wchar_t *Buffer;
1661 int BufferSize;
1662 int icp;
1663
1664 GetLocaleInfoA(lcid, lctype, buf, buf_size);
1665
1666 icp = atoi(cp);
1667 if (icp != CP_ACP && buf[0] != 0) {
1669 if (BufferSize > wbuf_size)
1670 {
1671 Buffer = (wchar_t*)malloc(sizeof(wchar_t) * BufferSize);
1672 }
1673 else
1674 {
1675 Buffer = wbuf;
1676 }
1678 WideCharToMultiByte(icp, 0, Buffer, -1, buf, buf_size, NULL, NULL);
1679 if (Buffer != wbuf)
1680 {
1681 free(Buffer);
1682 }
1683 }
1684}
1685
1686/* Return 0 if ANSI code page not used */
1688 char cp[6];
1690#if defined (_STLP_LANG_INVARIANT_DEFINED)
1691 if (lcid == INVARIANT_LCID) {
1692 /* We are using a limited PSDK, we rely on the most common code page */
1693 return 1252;
1694 }
1695#endif
1696 return 0;
1697 }
1698 return atoi(cp);
1699}
1700
1701/* Return 1 if OEM code page not used */
1703 char cp[6];
1705 return 0;
1706 return atoi(cp);
1707}
1708
1710 int cp = __intGetACP(lcid);
1711 if (cp == 0) return __intGetOCP(lcid);
1712 else return cp;
1713}
1714
1715static int trim_size_t_to_int(size_t n) { return n < (size_t)INT_MAX ? (int)n : INT_MAX; }
1716
1717char* __ConvertToCP(int from_cp, int to_cp, const char *from, size_t size, size_t *ret_buf_size) {
1718 size_t wbuffer_size, buffer_size, from_offset, wbuf_offset;
1719 int from_size, to_size, wbuf_size;
1720 wchar_t *wbuffer;
1721 char* buffer;
1722
1723 size_t orig_size = size;
1724
1725 wbuffer_size = 0;
1726 from_offset = 0;
1727 while (size > 0) {
1728 from_size = trim_size_t_to_int(size);
1729 wbuffer_size += MultiByteToWideChar(from_cp, MB_PRECOMPOSED,
1730 from + from_offset, from_size, NULL, 0);
1731 from_offset += from_size;
1732 size -= from_size;
1733 }
1734
1735 wbuffer = (wchar_t*)malloc(sizeof(wchar_t)*wbuffer_size);
1736
1737 size = orig_size;
1738 wbuf_offset = 0;
1739 from_offset = 0;
1740 while (size > 0) {
1741 from_size = trim_size_t_to_int(size);
1742 wbuf_size = trim_size_t_to_int(wbuffer_size - wbuf_offset);
1743 wbuf_offset += MultiByteToWideChar(from_cp, MB_PRECOMPOSED,
1744 from + from_offset, from_size, wbuffer + wbuf_offset, wbuf_size);
1745 from_offset += from_size;
1746 size -= from_size;
1747 }
1748
1749 buffer_size = 0;
1750 wbuf_offset = 0;
1751 size = wbuffer_size;
1752 while (size > 0) {
1753 wbuf_size = trim_size_t_to_int(size);
1755 wbuffer + wbuf_offset, wbuf_size,
1756 NULL, 0, NULL, FALSE);
1757 wbuf_offset += wbuf_size;
1758 size -= wbuf_size;
1759 }
1760
1761 buffer = (char*)malloc(buffer_size);
1762 *ret_buf_size = buffer_size;
1763
1764 size = wbuffer_size;
1765 wbuf_offset = 0;
1766 while (size > 0) {
1767 wbuf_size = trim_size_t_to_int(size);
1770 wbuffer + wbuf_offset, wbuf_size,
1771 buffer, to_size, NULL, FALSE);
1772 wbuf_offset += wbuf_size;
1773 size -= wbuf_size;
1774 }
1775
1776 free(wbuffer);
1777 return buffer;
1778}
1779
1780#ifdef __cplusplus
1781}
1782#endif
1783
1784#ifndef _STLP_NO_WCHAR_T
1785# include "c_wlocale_win32.c"
1786#endif
#define _STLP_MARK_PARAMETER_AS_UNUSED(X)
Definition: _dm.h:68
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static _Locale_mask_t ctable[256]
static int __GetLCID(const char *lang, const char *ctry, LCID *lcid)
const char * _Locale_negative_sign(_Locale_monetary_t *lmon)
char const * _Locale_extract_collate_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
char _Locale_decimal_point(_Locale_numeric_t *lnum)
char const * _Locale_extract_time_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
char const * _Locale_time_name(const _Locale_time_t *ltime, char *buf)
const char * _Locale_full_monthname(_Locale_time_t *ltime, int month)
void _Locale_time_destroy(_Locale_time_t *ltime)
static void my_ltoa(long __x, char *buf)
void _Locale_numeric_destroy(_Locale_numeric_t *lnum)
static int __intGetOCP(LCID lcid)
char const * _Locale_numeric_name(const _Locale_numeric_t *lnum, char *buf)
unsigned short MapCtypeMask(unsigned short mask)
void _Locale_catclose(struct _Locale_messages *lmes, nl_catd_type cat)
int _Locale_n_cs_precedes(_Locale_monetary_t *lmon)
#define MAX_LANG_LEN
_Locale_lcid_t * _Locale_get_numeric_hint(_Locale_numeric_t *lnumeric)
static const char * __ConvertName(const char *lname, LOCALECONV *ConvTable, int TableSize)
static int trim_size_t_to_int(size_t n)
const char * _Locale_currency_symbol(_Locale_monetary_t *lmon)
const char * _Locale_t_fmt(_Locale_time_t *ltime)
static void __FixGrouping(char *grouping)
static void MapCtypeMasks(unsigned short *cur, unsigned short *end)
static const char * __false_name
#define _STLP_STRCPY(D, DS, S)
int _Locale_n_sign_posn(_Locale_monetary_t *lmon)
const _Locale_mask_t * _Locale_ctype_table(_Locale_ctype_t *ltype)
static int __intGetACP(LCID lcid)
const char * _Locale_false(_Locale_numeric_t *lnum)
static const char * __FndCtry
static DWORD max_DWORD
_Locale_ctype_t * _Locale_ctype_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
const char * _Locale_pm_str(_Locale_time_t *ltime)
#define MAP(x, y)
_Locale_lcid_t * _Locale_get_messages_hint(struct _Locale_messages *lmessages)
#define _STLP_STRNCPY(D, DS, S, C)
char const * _Locale_extract_ctype_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
static const char * __FndLang
char const * _Locale_extract_monetary_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
int _Locale_tolower(_Locale_ctype_t *ltype, int c)
static LCID __FndLCID
#define _STLP_STRCAT(D, DS, S)
_Locale_lcid_t * _Locale_get_ctype_hint(_Locale_ctype_t *ltype)
const char * _Locale_positive_sign(_Locale_monetary_t *lmon)
const char * _Locale_int_curr_symbol(_Locale_monetary_t *lmon)
struct _Locale_numeric _Locale_numeric_t
const char * _Locale_time_default(char *buf)
char const * _Locale_extract_numeric_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
void _Locale_collate_destroy(_Locale_collate_t *lcol)
static DWORD trim_size_t_to_DWORD(size_t n)
const char * _Locale_d_fmt(_Locale_time_t *ltime)
#define CSTR_EQUAL
struct _Locale_ctype _Locale_ctype_t
void _Locale_monetary_destroy(_Locale_monetary_t *lmon)
struct _Locale_time _Locale_time_t
static char const * __Extract_locale_name(const char *loc, const char *category, char *buf)
#define INVARIANT_LCID
static LOCALECONV __rg_language[]
char _Locale_int_frac_digits(_Locale_monetary_t *lmon)
#define CP_UTF7
static int __ParseLocaleString(const char *lname, char *lang, char *ctry, char *page)
const char * _Locale_catgets(struct _Locale_messages *lmes, nl_catd_type cat, int setid, int msgid, const char *dfault)
char const * _Locale_ctype_name(const _Locale_ctype_t *ltype, char *buf)
_Locale_lcid_t * _Locale_get_collate_hint(_Locale_collate_t *lcollate)
struct _LOCALECONV LOCALECONV
const char * _Locale_ctype_default(char *buf)
const char * _Locale_abbrev_dayofweek(_Locale_time_t *ltime, int day)
void _Locale_ctype_destroy(_Locale_ctype_t *ltype)
const char * _Locale_numeric_default(char *buf)
const char * _Locale_mon_grouping(_Locale_monetary_t *lmon)
char const * _Locale_extract_messages_name(const char *cname, char *buf, _Locale_lcid_t *hint, int *__err_code)
static void __GetLocaleInfoUsingACP(LCID lcid, const char *cp, LCTYPE lctype, char *buf, int buf_size, wchar_t *wbuf, int wbuf_size)
struct _Locale_monetary _Locale_monetary_t
static const char * __true_name
static char const * _Locale_extract_category_name(const char *name, const char *category, char *buf, _Locale_lcid_t *hint, int *__err_code)
#define MAX_CP_LEN
static int __GetLCIDFromName(const char *lname, LCID *lcid, char *cp, _Locale_lcid_t *hint)
const char * _Locale_monetary_default(char *buf)
int _Locale_n_sep_by_space(_Locale_monetary_t *lmon)
char _Locale_frac_digits(_Locale_monetary_t *lmon)
char _Locale_mon_thousands_sep(_Locale_monetary_t *lmon)
const char * _Locale_true(_Locale_numeric_t *lnum)
struct _Locale_messages * _Locale_messages_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
const char * _Locale_long_d_t_fmt(_Locale_time_t *ltime)
static BOOL CALLBACK EnumLocalesProcA(LPSTR locale)
const char * _Locale_long_d_fmt(_Locale_time_t *ltime)
static char const * __GetLocaleName(LCID lcid, const char *cp, char *buf)
static int __GetDefaultCP(LCID lcid)
char const * _Locale_monetary_name(const _Locale_monetary_t *lmon, char *buf)
void _Locale_init()
#define CP_UTF8
void _Locale_messages_destroy(struct _Locale_messages *lmes)
struct _Locale_name_hint _Locale_lcid_t
int _Locale_toupper(_Locale_ctype_t *ltype, int c)
_Locale_collate_t * _Locale_collate_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
static CRITICAL_SECTION __criticalSection
_Locale_monetary_t * _Locale_monetary_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
char _Locale_mon_decimal_point(_Locale_monetary_t *lmon)
char _Locale_thousands_sep(_Locale_numeric_t *lnum)
int _Locale_p_sep_by_space(_Locale_monetary_t *lmon)
static int _Locale_strcmp_auxA(_Locale_collate_t *lcol, const char *s1, size_t n1, const char *s2, size_t n2)
char const * _Locale_collate_name(const _Locale_collate_t *lcol, char *buf)
const char * _Locale_messages_default(char *buf)
struct _Locale_collate _Locale_collate_t
nl_catd_type _Locale_catopen(struct _Locale_messages *lmes, const char *cat_name)
const char * _Locale_abbrev_monthname(_Locale_time_t *ltime, int month)
static int __FindFlag
static LCID LocaleFromHex(const char *locale)
size_t _Locale_strxfrm(_Locale_collate_t *lcol, char *dst, size_t dst_size, const char *src, size_t src_size)
static int __ConvertDate(const char *NTDate, char *buffer, int buf_size)
const char * _Locale_am_str(_Locale_time_t *ltime)
int _Locale_p_cs_precedes(_Locale_monetary_t *lmon)
static char const * __TranslateToSystem(const char *lname, char *buf, _Locale_lcid_t *hint, int *__err_code)
#define CSTR_LESS_THAN
const char * _Locale_grouping(_Locale_numeric_t *lnum)
const char * _Locale_full_dayofweek(_Locale_time_t *ltime, int day)
_Locale_time_t * _Locale_time_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
int _Locale_p_sign_posn(_Locale_monetary_t *lmon)
void _Locale_final()
#define MAX_CTRY_LEN
static const char * _C_name
static LOCALECONV __rg_country[]
_Locale_numeric_t * _Locale_numeric_create(const char *name, _Locale_lcid_t *lc_hint, int *__err_code)
static int __ConvertTime(const char *NTTime, char *buffer, int buf_size)
const char * _Locale_d_t_fmt(_Locale_time_t *ltime)
char const * _Locale_messages_name(const struct _Locale_messages *lmes, char *buf)
_Locale_lcid_t * _Locale_get_monetary_hint(_Locale_monetary_t *lmonetary)
int _Locale_strcmp(_Locale_collate_t *lcol, const char *s1, size_t n1, const char *s2, size_t n2)
static const char * _Locale_common_default(char *buf)
const char * _Locale_collate_default(char *buf)
static char * __ConvertToCP(int from_cp, int to_cp, const char *from, size_t size, size_t *ret_buf_size)
_Locale_lcid_t * _Locale_get_time_hint(_Locale_time_t *ltime)
Definition: bufpool.h:45
Definition: _locale.h:75
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
static DOUBLE day(DOUBLE time)
Definition: date.c:117
BOOL WINAPI GetCPInfo(UINT CodePage, LPCPINFO CodePageInfo)
Definition: nls.c:2039
unsigned char
Definition: typeof.h:29
static const WCHAR month[12][4]
Definition: session.c:2150
__kernel_size_t size_t
Definition: linux.h:237
#define _STLP_STATIC_ASSERT(expr)
Definition: features.h:313
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxCollectionEntry * cur
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
GLuint GLuint * names
Definition: glext.h:11545
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define C1_CNTRL
Definition: unicode.h:36
#define C1_DIGIT
Definition: unicode.h:33
#define C1_PUNCT
Definition: unicode.h:35
#define C1_SPACE
Definition: unicode.h:34
#define C1_ALPHA
Definition: unicode.h:39
#define WC_COMPOSITECHECK
Definition: unicode.h:43
#define C1_LOWER
Definition: unicode.h:32
#define C1_UPPER
Definition: unicode.h:31
#define C1_XDIGIT
Definition: unicode.h:38
#define _Locale_CNTRL
Definition: c_locale.h:122
#define _Locale_LOWER
Definition: c_locale.h:124
#define _Locale_XDIGIT
Definition: c_locale.h:128
#define _Locale_SPACE
Definition: c_locale.h:120
#define _Locale_PUNCT
Definition: c_locale.h:127
#define _Locale_ALPHA
Definition: c_locale.h:125
#define _Locale_UPPER
Definition: c_locale.h:123
#define _Locale_DIGIT
Definition: c_locale.h:126
#define _Locale_PRINT
Definition: c_locale.h:121
#define CHAR_MAX
Definition: limits.h:32
#define INT_MAX
Definition: limits.h:40
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
Definition: lang.c:2443
BOOL WINAPI GetStringTypeA(LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype)
Definition: lang.c:1823
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: lang.c:2695
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: lang.c:1028
BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum, DWORD dwFlags)
Definition: lang.c:1599
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: lang.c:1709
#define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY
Definition: c_locale.h:100
#define _Locale_MAX_SIMPLE_NAME
Definition: c_locale.h:54
unsigned short int _Locale_mask_t
Definition: c_locale.h:63
int nl_catd_type
Definition: c_locale.h:47
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_LOC_UNKNOWN_NAME
Definition: c_locale.h:101
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
POINT cp
Definition: magnifier.c:59
struct S1 s1
struct S2 s2
static PVOID ptr
Definition: dispmode.c:27
#define cmp(status, error)
Definition: error.c:114
unsigned int UINT
Definition: ndis.h:50
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
#define LOCALE_USER_DEFAULT
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
DWORD LCID
Definition: nls.h:13
#define memset(x, y, z)
Definition: compat.h:39
CardRegion * from
Definition: spigame.cpp:19
const char * name
const char * abbrev
char cp[MAX_CP_LEN+1]
_Locale_lcid_t lc
unsigned short ctable[256]
_Locale_lcid_t lc
char cp[MAX_CP_LEN+1]
_Locale_lcid_t lc
_Locale_lcid_t lc
char cp[MAX_CP_LEN+1]
char * dayofweek[7]
char * date_format
char * time_format
char * month[12]
char * abbrev_month[12]
char * abbrev_dayofweek[7]
char * long_date_format
char * long_date_time_format
char * date_time_format
_Locale_lcid_t lc
char cp[MAX_CP_LEN+1]
ULONG dwPlatformId
Definition: rtltypes.h:241
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
BYTE LeadByte[MAX_LEADBYTES]
Definition: winnls.h:583
UINT MaxCharSize
Definition: winnls.h:581
Definition: query.h:87
Definition: name.c:39
Definition: module.h:576
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
DWORD hint
Definition: vfdcmd.c:88
static const WCHAR lang[]
Definition: wbemdisp.c:287
int ret
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define GetVersionEx
Definition: winbase.h:3787
#define LCMAP_LINGUISTIC_CASING
Definition: winnls.h:192
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_ICURRDIGITS
Definition: winnls.h:54
#define LOCALE_IDEFAULTCODEPAGE
Definition: winnls.h:37
#define LOCALE_INEGSEPBYSPACE
Definition: winnls.h:124
#define LOCALE_INEGSIGNPOSN
Definition: winnls.h:120
#define LCID_INSTALLED
Definition: winnls.h:201
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define CT_CTYPE1
Definition: winnls.h:237
#define LOCALE_SENGLANGUAGE
Definition: winnls.h:27
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LCMAP_UPPERCASE
Definition: winnls.h:185
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define LOCALE_IINTLCURRDIGITS
Definition: winnls.h:55
#define LOCALE_S1159
Definition: winnls.h:71
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define WC_SEPCHARS
Definition: winnls.h:219
#define LOCALE_IPOSSYMPRECEDES
Definition: winnls.h:121
#define LOCALE_SPOSITIVESIGN
Definition: winnls.h:117
#define LOCALE_SISO639LANGNAME
Definition: winnls.h:126
#define LCMAP_SORTKEY
Definition: winnls.h:186
#define LCMAP_LOWERCASE
Definition: winnls.h:184
#define MB_PRECOMPOSED
Definition: winnls.h:281
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_INEGSYMPRECEDES
Definition: winnls.h:123
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LOCALE_IPOSSIGNPOSN
Definition: winnls.h:119
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
#define LOCALE_SISO3166CTRYNAME
Definition: winnls.h:127
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
#define LOCALE_SENGCOUNTRY
Definition: winnls.h:32
#define LOCALE_SABBREVCTRYNAME
Definition: winnls.h:33
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
DWORD LCTYPE
Definition: winnls.h:517
#define LOCALE_S2359
Definition: winnls.h:72
#define LOCALE_SINTLSYMBOL
Definition: winnls.h:50
#define LOCALE_SCURRENCY
Definition: winnls.h:49
#define LOCALE_IPOSSEPBYSPACE
Definition: winnls.h:122
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327
char * LPSTR
Definition: xmlstorage.h:182