2 * msvcrt.dll locale functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
41 /* FIXME: Need to hold locale for each LC_* type and aggregate
42 * string to produce lc_all.
44 #define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
45 #define MAX_LOCALE_LENGTH 256
46 MSVCRT__locale_t MSVCRT_locale
= NULL
;
47 int MSVCRT___lc_codepage
= 0;
48 int MSVCRT___lc_collate_cp
= 0;
49 HANDLE MSVCRT___lc_handle
[MSVCRT_LC_MAX
- MSVCRT_LC_MIN
+ 1] = { 0 };
50 unsigned char charmax
= CHAR_MAX
;
53 #define LOCK_LOCALE _mlock(_SETLOCALE_LOCK);
54 #define UNLOCK_LOCALE _munlock(_SETLOCALE_LOCK);
56 #define MSVCRT_LEADBYTE 0x8000
57 #define MSVCRT_C1_DEFINED 0x200
59 /* Friendly country strings & iso codes for synonym support.
60 * Based on MS documentation for setlocale().
62 static const char * const _country_synonyms
[] =
70 "United Kingdom","GB",
71 "United-Kingdom","GB",
80 /* INTERNAL: Map a synonym to an ISO code */
81 static void remap_synonym(char *name
)
84 for (i
= 0; i
< sizeof(_country_synonyms
)/sizeof(char*); i
+= 2 )
86 if (!strcasecmp(_country_synonyms
[i
],name
))
88 TRACE(":Mapping synonym %s to %s\n",name
,_country_synonyms
[i
+1]);
89 name
[0] = _country_synonyms
[i
+1][0];
90 name
[1] = _country_synonyms
[i
+1][1];
97 /* Note: Flags are weighted in order of matching importance */
98 #define FOUND_LANGUAGE 0x4
99 #define FOUND_COUNTRY 0x2
100 #define FOUND_CODEPAGE 0x1
103 char search_language
[MAX_ELEM_LEN
];
104 char search_country
[MAX_ELEM_LEN
];
105 char search_codepage
[MAX_ELEM_LEN
];
106 char found_language
[MAX_ELEM_LEN
];
107 char found_country
[MAX_ELEM_LEN
];
108 char found_codepage
[MAX_ELEM_LEN
];
109 unsigned int match_flags
;
110 LANGID found_lang_id
;
113 #define CONTINUE_LOOKING TRUE
114 #define STOP_LOOKING FALSE
116 /* INTERNAL: Get and compare locale info with a given string */
117 static int compare_info(LCID lcid
, DWORD flags
, char* buff
, const char* cmp
)
120 GetLocaleInfoA(lcid
, flags
|LOCALE_NOUSEROVERRIDE
,buff
, MAX_ELEM_LEN
);
121 if (!buff
[0] || !cmp
[0])
123 /* Partial matches are allowed, e.g. "Germ" matches "Germany" */
124 return !strncasecmp(cmp
, buff
, strlen(cmp
));
128 find_best_locale_proc(HMODULE hModule
, LPCSTR type
, LPCSTR name
, WORD LangID
, LONG_PTR lParam
)
130 locale_search_t
*res
= (locale_search_t
*)lParam
;
131 const LCID lcid
= MAKELCID(LangID
, SORT_DEFAULT
);
132 char buff
[MAX_ELEM_LEN
];
133 unsigned int flags
= 0;
135 if(PRIMARYLANGID(LangID
) == LANG_NEUTRAL
)
136 return CONTINUE_LOOKING
;
139 if (compare_info(lcid
,LOCALE_SISO639LANGNAME
,buff
,res
->search_language
) ||
140 compare_info(lcid
,LOCALE_SABBREVLANGNAME
,buff
,res
->search_language
) ||
141 compare_info(lcid
,LOCALE_SENGLANGUAGE
,buff
,res
->search_language
))
143 TRACE(":Found language: %s->%s\n", res
->search_language
, buff
);
144 flags
|= FOUND_LANGUAGE
;
145 memcpy(res
->found_language
,res
->search_language
,MAX_ELEM_LEN
);
147 else if (res
->match_flags
& FOUND_LANGUAGE
)
149 return CONTINUE_LOOKING
;
153 if (compare_info(lcid
,LOCALE_SISO3166CTRYNAME
,buff
,res
->search_country
) ||
154 compare_info(lcid
,LOCALE_SABBREVCTRYNAME
,buff
,res
->search_country
) ||
155 compare_info(lcid
,LOCALE_SENGCOUNTRY
,buff
,res
->search_country
))
157 TRACE("Found country:%s->%s\n", res
->search_country
, buff
);
158 flags
|= FOUND_COUNTRY
;
159 memcpy(res
->found_country
,res
->search_country
,MAX_ELEM_LEN
);
161 else if (res
->match_flags
& FOUND_COUNTRY
)
163 return CONTINUE_LOOKING
;
167 if (compare_info(lcid
,LOCALE_IDEFAULTCODEPAGE
,buff
,res
->search_codepage
) ||
168 (compare_info(lcid
,LOCALE_IDEFAULTANSICODEPAGE
,buff
,res
->search_codepage
)))
170 TRACE("Found codepage:%s->%s\n", res
->search_codepage
, buff
);
171 flags
|= FOUND_CODEPAGE
;
172 memcpy(res
->found_codepage
,res
->search_codepage
,MAX_ELEM_LEN
);
174 else if (res
->match_flags
& FOUND_CODEPAGE
)
176 return CONTINUE_LOOKING
;
179 if (flags
> res
->match_flags
)
181 /* Found a better match than previously */
182 res
->match_flags
= flags
;
183 res
->found_lang_id
= LangID
;
185 if ((flags
& (FOUND_LANGUAGE
| FOUND_COUNTRY
| FOUND_CODEPAGE
)) ==
186 (FOUND_LANGUAGE
| FOUND_COUNTRY
| FOUND_CODEPAGE
))
188 TRACE(":found exact locale match\n");
191 return CONTINUE_LOOKING
;
194 extern int atoi(const char *);
196 /* Internal: Find the LCID for a locale specification */
197 static LCID
MSVCRT_locale_to_LCID(const char *locale
)
200 locale_search_t search
;
203 memset(&search
, 0, sizeof(locale_search_t
));
205 cp
= strchr(locale
, '.');
206 region
= strchr(locale
, '_');
208 lstrcpynA(search
.search_language
, locale
, MAX_ELEM_LEN
);
210 lstrcpynA(search
.search_country
, region
+1, MAX_ELEM_LEN
);
211 if(region
-locale
< MAX_ELEM_LEN
)
212 search
.search_language
[region
-locale
] = '\0';
214 search
.search_country
[0] = '\0';
217 lstrcpynA(search
.search_codepage
, cp
+1, MAX_ELEM_LEN
);
218 if(cp
-region
-1 < MAX_ELEM_LEN
)
219 search
.search_country
[cp
-region
-1] = '\0';
220 if(cp
-locale
< MAX_ELEM_LEN
)
221 search
.search_language
[cp
-locale
] = '\0';
223 search
.search_codepage
[0] = '\0';
225 /* FIXME: MSVCRT_locale_to_LCID is not finding remaped values */
226 remap_synonym(search
.search_country
);
228 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR
)RT_STRING
,
229 (LPCSTR
)LOCALE_ILANGUAGE
,find_best_locale_proc
,
232 if (!search
.match_flags
)
235 /* If we were given something that didn't match, fail */
236 if (search
.search_country
[0] && !(search
.match_flags
& FOUND_COUNTRY
))
239 lcid
= MAKELCID(search
.found_lang_id
, SORT_DEFAULT
);
241 /* Populate partial locale, translating LCID to locale string elements */
242 if (!search
.found_codepage
[0]) {
243 /* Even if a codepage is not enumerated for a locale
244 * it can be set if valid */
245 if (search
.search_codepage
[0]) {
246 if (IsValidCodePage(atoi(search
.search_codepage
)))
247 memcpy(search
.found_codepage
,search
.search_codepage
,MAX_ELEM_LEN
);
249 /* Special codepage values: OEM & ANSI */
250 if (strcasecmp(search
.search_codepage
,"OCP")) {
251 GetLocaleInfoA(lcid
, LOCALE_IDEFAULTCODEPAGE
,
252 search
.found_codepage
, MAX_ELEM_LEN
);
253 } else if (strcasecmp(search
.search_codepage
,"ACP")) {
254 GetLocaleInfoA(lcid
, LOCALE_IDEFAULTANSICODEPAGE
,
255 search
.found_codepage
, MAX_ELEM_LEN
);
259 if (!atoi(search
.found_codepage
))
263 /* Prefer ANSI codepages if present */
264 GetLocaleInfoA(lcid
, LOCALE_IDEFAULTANSICODEPAGE
,
265 search
.found_codepage
, MAX_ELEM_LEN
);
266 if (!search
.found_codepage
[0] || !atoi(search
.found_codepage
))
267 GetLocaleInfoA(lcid
, LOCALE_IDEFAULTCODEPAGE
,
268 search
.found_codepage
, MAX_ELEM_LEN
);
272 GetLocaleInfoA(lcid
, LOCALE_SENGLANGUAGE
|LOCALE_NOUSEROVERRIDE
,
273 search
.found_language
, MAX_ELEM_LEN
);
274 GetLocaleInfoA(lcid
, LOCALE_SENGCOUNTRY
|LOCALE_NOUSEROVERRIDE
,
275 search
.found_country
, MAX_ELEM_LEN
);
279 /* INTERNAL: Set lc_handle, lc_id and lc_category in threadlocinfo struct */
280 static BOOL
update_threadlocinfo_category(LCID lcid
, MSVCRT__locale_t loc
, int category
)
285 if(GetLocaleInfoA(lcid
, LOCALE_ILANGUAGE
, buf
, 256)) {
288 loc
->locinfo
->lc_id
[category
].wLanguage
= 0;
290 loc
->locinfo
->lc_id
[category
].wLanguage
*= 16;
293 loc
->locinfo
->lc_id
[category
].wLanguage
+= *p
-'0';
295 loc
->locinfo
->lc_id
[category
].wLanguage
+= *p
-'a'+10;
300 loc
->locinfo
->lc_id
[category
].wCountry
=
301 loc
->locinfo
->lc_id
[category
].wLanguage
;
304 if(GetLocaleInfoA(lcid
, LOCALE_IDEFAULTANSICODEPAGE
, buf
, 256))
305 loc
->locinfo
->lc_id
[category
].wCodePage
= atoi(buf
);
307 loc
->locinfo
->lc_handle
[category
] = lcid
;
310 len
+= GetLocaleInfoA(lcid
, LOCALE_SLANGUAGE
, buf
, 256);
312 len
+= GetLocaleInfoA(lcid
, LOCALE_SCOUNTRY
, &buf
[len
], 256-len
);
314 len
+= GetLocaleInfoA(lcid
, LOCALE_IDEFAULTANSICODEPAGE
, &buf
[len
], 256-len
);
316 loc
->locinfo
->lc_category
[category
].locale
= MSVCRT_malloc(sizeof(char[len
]));
317 loc
->locinfo
->lc_category
[category
].refcount
= MSVCRT_malloc(sizeof(int));
318 if(!loc
->locinfo
->lc_category
[category
].locale
319 || !loc
->locinfo
->lc_category
[category
].refcount
) {
320 MSVCRT_free(loc
->locinfo
->lc_category
[category
].locale
);
321 MSVCRT_free(loc
->locinfo
->lc_category
[category
].refcount
);
322 loc
->locinfo
->lc_category
[category
].locale
= NULL
;
323 loc
->locinfo
->lc_category
[category
].refcount
= NULL
;
326 memcpy(loc
->locinfo
->lc_category
[category
].locale
, buf
, sizeof(char[len
]));
327 *loc
->locinfo
->lc_category
[category
].refcount
= 1;
332 /* INTERNAL: swap pointers values */
333 static inline void swap_pointers(void **p1
, void **p2
) {
341 /* INTERNAL: returns _locale_t struct for current locale */
342 MSVCRT__locale_t
get_locale(void) {
343 thread_data_t
*data
= msvcrt_get_thread_data();
345 if(!data
|| !data
->locale
)
346 return MSVCRT_locale
;
351 /* INTERNAL: constructs string returned by setlocale */
352 static inline char* construct_lc_all(MSVCRT__locale_t cur
) {
353 static char current_lc_all
[MAX_LOCALE_LENGTH
];
357 for(i
=MSVCRT_LC_MIN
+1; i
<MSVCRT_LC_MAX
; i
++) {
358 if(strcmp(cur
->locinfo
->lc_category
[i
].locale
,
359 cur
->locinfo
->lc_category
[i
+1].locale
))
364 return cur
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].locale
;
366 sprintf(current_lc_all
,
367 "LC_COLLATE=%s;LC_CTYPE=%s;LC_MONETARY=%s;LC_NUMERIC=%s;LC_TIME=%s",
368 cur
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].locale
,
369 cur
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].locale
,
370 cur
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].locale
,
371 cur
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].locale
,
372 cur
->locinfo
->lc_category
[MSVCRT_LC_TIME
].locale
);
374 return current_lc_all
;
378 /*********************************************************************
379 * wsetlocale (MSVCRT.@)
381 MSVCRT_wchar_t
* CDECL
MSVCRT__wsetlocale(int category
, const MSVCRT_wchar_t
* locale
)
383 static MSVCRT_wchar_t fake
[] = {
384 'E','n','g','l','i','s','h','_','U','n','i','t','e','d',' ',
385 'S','t','a','t','e','s','.','1','2','5','2',0 };
387 FIXME("%d %s\n", category
, debugstr_w(locale
));
392 /*********************************************************************
393 * _Getdays (MSVCRT.@)
395 const char* CDECL
_Getdays(void)
397 static const char MSVCRT_days
[] = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:"
398 "Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
399 /* FIXME: Use locale */
400 TRACE("(void) semi-stub\n");
404 /*********************************************************************
405 * _Getmonths (MSVCRT.@)
407 const char* CDECL
_Getmonths(void)
409 static const char MSVCRT_months
[] = ":Jan:January:Feb:February:Mar:March:Apr:"
410 "April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:"
411 "October:Nov:November:Dec:December";
412 /* FIXME: Use locale */
413 TRACE("(void) semi-stub\n");
414 return MSVCRT_months
;
417 /*********************************************************************
418 * _Gettnames (MSVCRT.@)
420 const char* CDECL
_Gettnames(void)
423 TRACE("(void) stub\n");
427 /*********************************************************************
428 * _Strftime (MSVCRT.@)
430 const char* CDECL
_Strftime(char *out
, unsigned int len
, const char *fmt
,
431 const void *tm
, void *foo
)
434 TRACE("(%p %d %s %p %p) stub\n", out
, len
, fmt
, tm
, foo
);
438 /*********************************************************************
439 * __crtLCMapStringA (MSVCRT.@)
441 int CDECL
__crtLCMapStringA(
442 LCID lcid
, DWORD mapflags
, const char* src
, int srclen
, char* dst
,
443 int dstlen
, unsigned int codepage
, int xflag
445 FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
446 lcid
,mapflags
,src
,srclen
,dst
,dstlen
,codepage
,xflag
);
447 /* FIXME: A bit incorrect. But msvcrt itself just converts its
448 * arguments to wide strings and then calls LCMapStringW
450 return LCMapStringA(lcid
,mapflags
,src
,srclen
,dst
,dstlen
);
453 /*********************************************************************
454 * __crtCompareStringA (MSVCRT.@)
456 int CDECL
__crtCompareStringA( LCID lcid
, DWORD flags
, const char *src1
, int len1
,
457 const char *src2
, int len2
)
459 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
460 lcid
, flags
, debugstr_a(src1
), len1
, debugstr_a(src2
), len2
);
461 /* FIXME: probably not entirely right */
462 return CompareStringA( lcid
, flags
, src1
, len1
, src2
, len2
);
465 /*********************************************************************
466 * __crtCompareStringW (MSVCRT.@)
468 int CDECL
__crtCompareStringW( LCID lcid
, DWORD flags
, const MSVCRT_wchar_t
*src1
, int len1
,
469 const MSVCRT_wchar_t
*src2
, int len2
)
471 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
472 lcid
, flags
, debugstr_w(src1
), len1
, debugstr_w(src2
), len2
);
473 /* FIXME: probably not entirely right */
474 return CompareStringW( lcid
, flags
, src1
, len1
, src2
, len2
);
477 /*********************************************************************
478 * __crtGetLocaleInfoW (MSVCRT.@)
480 int CDECL
__crtGetLocaleInfoW( LCID lcid
, LCTYPE type
, MSVCRT_wchar_t
*buffer
, int len
)
482 FIXME("(lcid %x, type %x, %p(%d), partial stub\n", lcid
, type
, buffer
, len
);
483 /* FIXME: probably not entirely right */
484 return GetLocaleInfoW( lcid
, type
, buffer
, len
);
487 /*********************************************************************
490 MSVCRT_wint_t CDECL
MSVCRT_btowc(int c
)
492 MSVCRT__locale_t locale
= get_locale();
493 unsigned char letter
= c
;
496 if(!MultiByteToWideChar(locale
->locinfo
->lc_handle
[MSVCRT_LC_CTYPE
],
497 0, (LPCSTR
)&letter
, 1, &ret
, 1))
503 /*********************************************************************
504 * __crtGetStringTypeW(MSVCRT.@)
506 * This function was accepting different number of arguments in older
507 * versions of msvcrt.
509 BOOL CDECL
__crtGetStringTypeW(DWORD unk
, DWORD type
,
510 MSVCRT_wchar_t
*buffer
, int len
, WORD
*out
)
512 FIXME("(unk %x, type %x, wstr %p(%d), %p) partial stub\n",
513 unk
, type
, buffer
, len
, out
);
515 return GetStringTypeW(type
, buffer
, len
, out
);
518 /*********************************************************************
519 * localeconv (MSVCRT.@)
521 struct MSVCRT_lconv
* CDECL
MSVCRT_localeconv(void)
523 return get_locale()->locinfo
->lconv
;
526 /*********************************************************************
527 * __lconv_init (MSVCRT.@)
529 void CDECL
__lconv_init(void)
531 /* this is used to make chars unsigned */
535 /*********************************************************************
536 * ___lc_handle_func (MSVCRT.@)
538 HANDLE
* CDECL
___lc_handle_func(void)
540 return MSVCRT___lc_handle
;
543 /*********************************************************************
544 * ___lc_codepage_func (MSVCRT.@)
546 int CDECL
___lc_codepage_func(void)
548 return MSVCRT___lc_codepage
;
551 /*********************************************************************
552 * ___lc_collate_cp_func (MSVCRT.@)
554 int CDECL
___lc_collate_cp_func(void)
556 return get_locale()->locinfo
->lc_collate_cp
;
559 /* _free_locale - not exported in native msvcrt */
560 void CDECL
_free_locale(MSVCRT__locale_t locale
)
564 for(i
=MSVCRT_LC_MIN
+1; i
<=MSVCRT_LC_MAX
; i
++) {
565 MSVCRT_free(locale
->locinfo
->lc_category
[i
].locale
);
566 MSVCRT_free(locale
->locinfo
->lc_category
[i
].refcount
);
569 if(locale
->locinfo
->lconv
) {
570 MSVCRT_free(locale
->locinfo
->lconv
->decimal_point
);
571 MSVCRT_free(locale
->locinfo
->lconv
->thousands_sep
);
572 MSVCRT_free(locale
->locinfo
->lconv
->grouping
);
573 MSVCRT_free(locale
->locinfo
->lconv
->int_curr_symbol
);
574 MSVCRT_free(locale
->locinfo
->lconv
->currency_symbol
);
575 MSVCRT_free(locale
->locinfo
->lconv
->mon_decimal_point
);
576 MSVCRT_free(locale
->locinfo
->lconv
->mon_thousands_sep
);
577 MSVCRT_free(locale
->locinfo
->lconv
->mon_grouping
);
578 MSVCRT_free(locale
->locinfo
->lconv
->positive_sign
);
579 MSVCRT_free(locale
->locinfo
->lconv
->negative_sign
);
581 MSVCRT_free(locale
->locinfo
->lconv_intl_refcount
);
582 MSVCRT_free(locale
->locinfo
->lconv_num_refcount
);
583 MSVCRT_free(locale
->locinfo
->lconv_mon_refcount
);
584 MSVCRT_free(locale
->locinfo
->lconv
);
586 MSVCRT_free(locale
->locinfo
->ctype1_refcount
);
587 MSVCRT_free(locale
->locinfo
->ctype1
);
589 MSVCRT_free(locale
->locinfo
->pclmap
);
590 MSVCRT_free(locale
->locinfo
->pcumap
);
592 MSVCRT_free(locale
->locinfo
);
593 MSVCRT_free(locale
->mbcinfo
);
597 /* _create_locale - not exported in native msvcrt */
598 MSVCRT__locale_t
_create_locale(int category
, const char *locale
)
600 static const char collate
[] = "COLLATE=";
601 static const char ctype
[] = "CTYPE=";
602 static const char monetary
[] = "MONETARY=";
603 static const char numeric
[] = "NUMERIC=";
604 static const char time
[] = "TIME=";
606 MSVCRT__locale_t loc
;
607 LCID lcid
[6] = { 0 };
611 TRACE("(%d %s)\n", category
, locale
);
613 if(category
<MSVCRT_LC_MIN
|| category
>MSVCRT_LC_MAX
|| !locale
)
616 if(locale
[0]=='C' && !locale
[1])
619 lcid
[0] = GetSystemDefaultLCID();
620 else if (locale
[0] == 'L' && locale
[1] == 'C' && locale
[2] == '_') {
624 locale
+= 3; /* LC_ */
625 if(!memcmp(locale
, collate
, sizeof(collate
)-1)) {
626 i
= MSVCRT_LC_COLLATE
;
627 locale
+= sizeof(collate
)-1;
628 } else if(!memcmp(locale
, ctype
, sizeof(ctype
)-1)) {
630 locale
+= sizeof(ctype
)-1;
631 } else if(!memcmp(locale
, monetary
, sizeof(monetary
)-1)) {
632 i
= MSVCRT_LC_MONETARY
;
633 locale
+= sizeof(monetary
)-1;
634 } else if(!memcmp(locale
, numeric
, sizeof(numeric
)-1)) {
635 i
= MSVCRT_LC_NUMERIC
;
636 locale
+= sizeof(numeric
)-1;
637 } else if(!memcmp(locale
, time
, sizeof(time
)-1)) {
639 locale
+= sizeof(time
)-1;
643 p
= strchr(locale
, ';');
644 if(locale
[0]=='C' && (locale
[1]==';' || locale
[1]=='\0'))
647 memcpy(buf
, locale
, p
-locale
);
648 lcid
[i
] = MSVCRT_locale_to_LCID(buf
);
650 lcid
[i
] = MSVCRT_locale_to_LCID(locale
);
655 if(!p
|| *(p
+1)!='L' || *(p
+2)!='C' || *(p
+3)!='_')
661 lcid
[0] = MSVCRT_locale_to_LCID(locale
);
671 loc
= MSVCRT_malloc(sizeof(MSVCRT__locale_tstruct
));
675 loc
->locinfo
= MSVCRT_malloc(sizeof(MSVCRT_threadlocinfo
));
681 loc
->mbcinfo
= MSVCRT_malloc(sizeof(MSVCRT_threadmbcinfo
));
683 MSVCRT_free(loc
->locinfo
);
688 memset(loc
->locinfo
, 0, sizeof(MSVCRT_threadlocinfo
));
689 memset(loc
->mbcinfo
, 0, sizeof(MSVCRT_threadmbcinfo
));
691 loc
->locinfo
->lconv
= MSVCRT_malloc(sizeof(struct MSVCRT_lconv
));
692 if(!loc
->locinfo
->lconv
) {
696 memset(loc
->locinfo
->lconv
, 0, sizeof(struct MSVCRT_lconv
));
698 loc
->locinfo
->pclmap
= MSVCRT_malloc(sizeof(char[256]));
699 loc
->locinfo
->pcumap
= MSVCRT_malloc(sizeof(char[256]));
700 if(!loc
->locinfo
->pclmap
|| !loc
->locinfo
->pcumap
) {
705 loc
->locinfo
->refcount
= 1;
707 if(lcid
[MSVCRT_LC_COLLATE
] && (category
==MSVCRT_LC_ALL
|| category
==MSVCRT_LC_COLLATE
)) {
708 if(update_threadlocinfo_category(lcid
[MSVCRT_LC_COLLATE
], loc
, MSVCRT_LC_COLLATE
)) {
713 loc
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].locale
= strdup("C");
715 if(lcid
[MSVCRT_LC_CTYPE
] && (category
==MSVCRT_LC_ALL
|| category
==MSVCRT_LC_CTYPE
)) {
718 if(update_threadlocinfo_category(lcid
[MSVCRT_LC_CTYPE
], loc
, MSVCRT_LC_CTYPE
)) {
723 loc
->locinfo
->lc_codepage
= loc
->locinfo
->lc_id
[MSVCRT_LC_CTYPE
].wCodePage
;
724 loc
->locinfo
->lc_collate_cp
= loc
->locinfo
->lc_codepage
;
725 loc
->locinfo
->lc_clike
= 1;
726 if(!GetCPInfo(loc
->locinfo
->lc_codepage
, &cp
)) {
730 loc
->locinfo
->mb_cur_max
= cp
.MaxCharSize
;
732 loc
->locinfo
->ctype1_refcount
= MSVCRT_malloc(sizeof(int));
733 loc
->locinfo
->ctype1
= MSVCRT_malloc(sizeof(short[257]));
734 if(!loc
->locinfo
->ctype1_refcount
|| !loc
->locinfo
->ctype1
) {
739 *loc
->locinfo
->ctype1_refcount
= 1;
740 loc
->locinfo
->ctype1
[0] = 0;
741 loc
->locinfo
->pctype
= loc
->locinfo
->ctype1
+1;
743 buf
[1] = buf
[2] = '\0';
744 for(i
=1; i
<257; i
++) {
747 GetStringTypeA(lcid
[MSVCRT_LC_CTYPE
], CT_CTYPE1
, buf
,
748 1, loc
->locinfo
->ctype1
+i
);
749 loc
->locinfo
->ctype1
[i
] |= 0x200;
752 loc
->locinfo
->lc_clike
= 1;
753 loc
->locinfo
->mb_cur_max
= 1;
754 loc
->locinfo
->pctype
= MSVCRT__ctype
+1;
755 loc
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].locale
= strdup("C");
761 LCMapStringA(lcid
[MSVCRT_LC_CTYPE
], LCMAP_LOWERCASE
, buf
, 256,
762 (char*)loc
->locinfo
->pclmap
, 256);
763 LCMapStringA(lcid
[MSVCRT_LC_CTYPE
], LCMAP_UPPERCASE
, buf
, 256,
764 (char*)loc
->locinfo
->pcumap
, 256);
766 loc
->mbcinfo
->refcount
= 1;
767 loc
->mbcinfo
->mbcodepage
= loc
->locinfo
->lc_id
[MSVCRT_LC_CTYPE
].wCodePage
;
769 for(i
=0; i
<256; i
++) {
770 if(loc
->locinfo
->pclmap
[i
] != i
) {
771 loc
->mbcinfo
->mbctype
[i
+1] |= 0x10;
772 loc
->mbcinfo
->mbcasemap
[i
] = loc
->locinfo
->pclmap
[i
];
773 } else if(loc
->locinfo
->pcumap
[i
] != i
) {
774 loc
->mbcinfo
->mbctype
[i
+1] |= 0x20;
775 loc
->mbcinfo
->mbcasemap
[i
] = loc
->locinfo
->pcumap
[i
];
779 if(lcid
[MSVCRT_LC_MONETARY
] && (category
==MSVCRT_LC_ALL
|| category
==MSVCRT_LC_MONETARY
)) {
780 if(update_threadlocinfo_category(lcid
[MSVCRT_LC_MONETARY
], loc
, MSVCRT_LC_MONETARY
)) {
785 loc
->locinfo
->lconv_intl_refcount
= MSVCRT_malloc(sizeof(int));
786 loc
->locinfo
->lconv_mon_refcount
= MSVCRT_malloc(sizeof(int));
787 if(!loc
->locinfo
->lconv_intl_refcount
|| !loc
->locinfo
->lconv_mon_refcount
) {
792 *loc
->locinfo
->lconv_intl_refcount
= 1;
793 *loc
->locinfo
->lconv_mon_refcount
= 1;
795 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SINTLSYMBOL
, buf
, 256);
796 if(i
&& (loc
->locinfo
->lconv
->int_curr_symbol
= MSVCRT_malloc(sizeof(char[i
]))))
797 memcpy(loc
->locinfo
->lconv
->int_curr_symbol
, buf
, sizeof(char[i
]));
803 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SCURRENCY
, buf
, 256);
804 if(i
&& (loc
->locinfo
->lconv
->currency_symbol
= MSVCRT_malloc(sizeof(char[i
]))))
805 memcpy(loc
->locinfo
->lconv
->currency_symbol
, buf
, sizeof(char[i
]));
811 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SMONDECIMALSEP
, buf
, 256);
812 if(i
&& (loc
->locinfo
->lconv
->mon_decimal_point
= MSVCRT_malloc(sizeof(char[i
]))))
813 memcpy(loc
->locinfo
->lconv
->mon_decimal_point
, buf
, sizeof(char[i
]));
819 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SMONTHOUSANDSEP
, buf
, 256);
820 if(i
&& (loc
->locinfo
->lconv
->mon_thousands_sep
= MSVCRT_malloc(sizeof(char[i
]))))
821 memcpy(loc
->locinfo
->lconv
->mon_thousands_sep
, buf
, sizeof(char[i
]));
827 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SMONGROUPING
, buf
, 256);
829 i
= i
/2 + (buf
[i
-2]=='0'?0:1);
830 if(i
&& (loc
->locinfo
->lconv
->mon_grouping
= MSVCRT_malloc(sizeof(char[i
])))) {
831 for(i
=0; buf
[i
+1]==';'; i
+=2)
832 loc
->locinfo
->lconv
->mon_grouping
[i
/2] = buf
[i
]-'0';
833 loc
->locinfo
->lconv
->mon_grouping
[i
/2] = buf
[i
]-'0';
835 loc
->locinfo
->lconv
->mon_grouping
[i
/2+1] = 127;
841 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SPOSITIVESIGN
, buf
, 256);
842 if(i
&& (loc
->locinfo
->lconv
->positive_sign
= MSVCRT_malloc(sizeof(char[i
]))))
843 memcpy(loc
->locinfo
->lconv
->positive_sign
, buf
, sizeof(char[i
]));
849 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_SNEGATIVESIGN
, buf
, 256);
850 if(i
&& (loc
->locinfo
->lconv
->negative_sign
= MSVCRT_malloc(sizeof(char[i
]))))
851 memcpy(loc
->locinfo
->lconv
->negative_sign
, buf
, sizeof(char[i
]));
857 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_IINTLCURRDIGITS
, buf
, 256))
858 loc
->locinfo
->lconv
->int_frac_digits
= atoi(buf
);
864 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_ICURRDIGITS
, buf
, 256))
865 loc
->locinfo
->lconv
->frac_digits
= atoi(buf
);
871 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_IPOSSYMPRECEDES
, buf
, 256))
872 loc
->locinfo
->lconv
->p_cs_precedes
= atoi(buf
);
878 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_IPOSSEPBYSPACE
, buf
, 256))
879 loc
->locinfo
->lconv
->p_sep_by_space
= atoi(buf
);
885 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_INEGSYMPRECEDES
, buf
, 256))
886 loc
->locinfo
->lconv
->n_cs_precedes
= atoi(buf
);
892 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_INEGSEPBYSPACE
, buf
, 256))
893 loc
->locinfo
->lconv
->n_sep_by_space
= atoi(buf
);
899 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_IPOSSIGNPOSN
, buf
, 256))
900 loc
->locinfo
->lconv
->p_sign_posn
= atoi(buf
);
906 if(GetLocaleInfoA(lcid
[MSVCRT_LC_MONETARY
], LOCALE_INEGSIGNPOSN
, buf
, 256))
907 loc
->locinfo
->lconv
->n_sign_posn
= atoi(buf
);
913 loc
->locinfo
->lconv
->int_curr_symbol
= MSVCRT_malloc(sizeof(char));
914 loc
->locinfo
->lconv
->currency_symbol
= MSVCRT_malloc(sizeof(char));
915 loc
->locinfo
->lconv
->mon_decimal_point
= MSVCRT_malloc(sizeof(char));
916 loc
->locinfo
->lconv
->mon_thousands_sep
= MSVCRT_malloc(sizeof(char));
917 loc
->locinfo
->lconv
->mon_grouping
= MSVCRT_malloc(sizeof(char));
918 loc
->locinfo
->lconv
->positive_sign
= MSVCRT_malloc(sizeof(char));
919 loc
->locinfo
->lconv
->negative_sign
= MSVCRT_malloc(sizeof(char));
921 if(!loc
->locinfo
->lconv
->int_curr_symbol
|| !loc
->locinfo
->lconv
->currency_symbol
922 || !loc
->locinfo
->lconv
->mon_decimal_point
|| !loc
->locinfo
->lconv
->mon_thousands_sep
923 || !loc
->locinfo
->lconv
->mon_grouping
|| !loc
->locinfo
->lconv
->positive_sign
924 || !loc
->locinfo
->lconv
->negative_sign
) {
929 loc
->locinfo
->lconv
->int_curr_symbol
[0] = '\0';
930 loc
->locinfo
->lconv
->currency_symbol
[0] = '\0';
931 loc
->locinfo
->lconv
->mon_decimal_point
[0] = '\0';
932 loc
->locinfo
->lconv
->mon_thousands_sep
[0] = '\0';
933 loc
->locinfo
->lconv
->mon_grouping
[0] = '\0';
934 loc
->locinfo
->lconv
->positive_sign
[0] = '\0';
935 loc
->locinfo
->lconv
->negative_sign
[0] = '\0';
936 loc
->locinfo
->lconv
->int_frac_digits
= 127;
937 loc
->locinfo
->lconv
->frac_digits
= 127;
938 loc
->locinfo
->lconv
->p_cs_precedes
= 127;
939 loc
->locinfo
->lconv
->p_sep_by_space
= 127;
940 loc
->locinfo
->lconv
->n_cs_precedes
= 127;
941 loc
->locinfo
->lconv
->n_sep_by_space
= 127;
942 loc
->locinfo
->lconv
->p_sign_posn
= 127;
943 loc
->locinfo
->lconv
->n_sign_posn
= 127;
945 loc
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].locale
= strdup("C");
948 if(lcid
[MSVCRT_LC_NUMERIC
] && (category
==MSVCRT_LC_ALL
|| category
==MSVCRT_LC_NUMERIC
)) {
949 if(update_threadlocinfo_category(lcid
[MSVCRT_LC_NUMERIC
], loc
, MSVCRT_LC_NUMERIC
)) {
954 if(!loc
->locinfo
->lconv_intl_refcount
)
955 loc
->locinfo
->lconv_intl_refcount
= MSVCRT_malloc(sizeof(int));
956 loc
->locinfo
->lconv_num_refcount
= MSVCRT_malloc(sizeof(int));
957 if(!loc
->locinfo
->lconv_intl_refcount
|| !loc
->locinfo
->lconv_num_refcount
) {
962 *loc
->locinfo
->lconv_intl_refcount
= 1;
963 *loc
->locinfo
->lconv_num_refcount
= 1;
965 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_NUMERIC
], LOCALE_SDECIMAL
, buf
, 256);
966 if(i
&& (loc
->locinfo
->lconv
->decimal_point
= MSVCRT_malloc(sizeof(char[i
]))))
967 memcpy(loc
->locinfo
->lconv
->decimal_point
, buf
, sizeof(char[i
]));
973 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_NUMERIC
], LOCALE_STHOUSAND
, buf
, 256);
974 if(i
&& (loc
->locinfo
->lconv
->thousands_sep
= MSVCRT_malloc(sizeof(char[i
]))))
975 memcpy(loc
->locinfo
->lconv
->thousands_sep
, buf
, sizeof(char[i
]));
981 i
= GetLocaleInfoA(lcid
[MSVCRT_LC_NUMERIC
], LOCALE_SGROUPING
, buf
, 256);
983 i
= i
/2 + (buf
[i
-2]=='0'?0:1);
984 if(i
&& (loc
->locinfo
->lconv
->grouping
= MSVCRT_malloc(sizeof(char[i
])))) {
985 for(i
=0; buf
[i
+1]==';'; i
+=2)
986 loc
->locinfo
->lconv
->grouping
[i
/2] = buf
[i
]-'0';
987 loc
->locinfo
->lconv
->grouping
[i
/2] = buf
[i
]-'0';
989 loc
->locinfo
->lconv
->grouping
[i
/2+1] = 127;
995 loc
->locinfo
->lconv
->decimal_point
= MSVCRT_malloc(sizeof(char[2]));
996 loc
->locinfo
->lconv
->thousands_sep
= MSVCRT_malloc(sizeof(char));
997 loc
->locinfo
->lconv
->grouping
= MSVCRT_malloc(sizeof(char));
998 if(!loc
->locinfo
->lconv
->decimal_point
|| !loc
->locinfo
->lconv
->thousands_sep
999 || !loc
->locinfo
->lconv
->grouping
) {
1004 loc
->locinfo
->lconv
->decimal_point
[0] = '.';
1005 loc
->locinfo
->lconv
->decimal_point
[1] = '\0';
1006 loc
->locinfo
->lconv
->thousands_sep
[0] = '\0';
1007 loc
->locinfo
->lconv
->grouping
[0] = '\0';
1009 loc
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].locale
= strdup("C");
1012 if(lcid
[MSVCRT_LC_TIME
] && (category
==MSVCRT_LC_ALL
|| category
==MSVCRT_LC_TIME
)) {
1013 if(update_threadlocinfo_category(lcid
[MSVCRT_LC_TIME
], loc
, MSVCRT_LC_TIME
)) {
1018 loc
->locinfo
->lc_category
[MSVCRT_LC_TIME
].locale
= strdup("C");
1023 /* _configthreadlocale - not exported in native msvcrt */
1024 int CDECL
_configthreadlocale(int type
)
1026 thread_data_t
*data
= msvcrt_get_thread_data();
1032 ret
= (data
->locale
? MSVCRT__ENABLE_PER_THREAD_LOCALE
: MSVCRT__DISABLE_PER_THREAD_LOCALE
);
1034 if(type
== MSVCRT__ENABLE_PER_THREAD_LOCALE
) {
1036 /* Copy current global locale */
1037 data
->locale
= _create_locale(MSVCRT_LC_ALL
, MSVCRT_setlocale(MSVCRT_LC_ALL
, NULL
));
1045 if(type
== MSVCRT__DISABLE_PER_THREAD_LOCALE
) {
1047 _free_locale(data
->locale
);
1048 data
->locale
= NULL
;
1060 /*********************************************************************
1061 * setlocale (MSVCRT.@)
1063 char* CDECL
MSVCRT_setlocale(int category
, const char* locale
)
1065 MSVCRT__locale_t loc
, cur
;
1069 if(category
<MSVCRT_LC_MIN
|| category
>MSVCRT_LC_MAX
)
1073 if(category
== MSVCRT_LC_ALL
)
1074 return construct_lc_all(cur
);
1076 return cur
->locinfo
->lc_category
[category
].locale
;
1079 loc
= _create_locale(category
, locale
);
1081 WARN("%d %s failed\n", category
, locale
);
1091 case MSVCRT_LC_COLLATE
:
1092 cur
->locinfo
->lc_handle
[MSVCRT_LC_COLLATE
] =
1093 loc
->locinfo
->lc_handle
[MSVCRT_LC_COLLATE
];
1094 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].locale
,
1095 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].locale
);
1096 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].refcount
,
1097 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_COLLATE
].refcount
);
1099 if(category
!= MSVCRT_LC_ALL
)
1101 case MSVCRT_LC_CTYPE
:
1102 cur
->locinfo
->lc_handle
[MSVCRT_LC_CTYPE
] =
1103 loc
->locinfo
->lc_handle
[MSVCRT_LC_CTYPE
];
1104 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].locale
,
1105 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].locale
);
1106 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].refcount
,
1107 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_CTYPE
].refcount
);
1109 cur
->locinfo
->lc_codepage
= loc
->locinfo
->lc_codepage
;
1110 cur
->locinfo
->lc_collate_cp
= loc
->locinfo
->lc_collate_cp
;
1111 cur
->locinfo
->lc_clike
= loc
->locinfo
->lc_clike
;
1112 cur
->locinfo
->mb_cur_max
= loc
->locinfo
->mb_cur_max
;
1114 swap_pointers((void**)&cur
->locinfo
->ctype1_refcount
,
1115 (void**)&loc
->locinfo
->ctype1_refcount
);
1116 swap_pointers((void**)&cur
->locinfo
->ctype1
, (void**)&loc
->locinfo
->ctype1
);
1117 swap_pointers((void**)&cur
->locinfo
->pctype
, (void**)&loc
->locinfo
->pctype
);
1118 swap_pointers((void**)&cur
->locinfo
->pclmap
, (void**)&loc
->locinfo
->pclmap
);
1119 swap_pointers((void**)&cur
->locinfo
->pcumap
, (void**)&loc
->locinfo
->pcumap
);
1121 memcpy(cur
->mbcinfo
, loc
->mbcinfo
, sizeof(MSVCRT_threadmbcinfo
));
1123 if(category
!= MSVCRT_LC_ALL
)
1125 case MSVCRT_LC_MONETARY
:
1126 cur
->locinfo
->lc_handle
[MSVCRT_LC_MONETARY
] =
1127 loc
->locinfo
->lc_handle
[MSVCRT_LC_MONETARY
];
1128 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].locale
,
1129 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].locale
);
1130 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].refcount
,
1131 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_MONETARY
].refcount
);
1133 swap_pointers((void**)&cur
->locinfo
->lconv
->int_curr_symbol
,
1134 (void**)&loc
->locinfo
->lconv
->int_curr_symbol
);
1135 swap_pointers((void**)&cur
->locinfo
->lconv
->currency_symbol
,
1136 (void**)&loc
->locinfo
->lconv
->currency_symbol
);
1137 swap_pointers((void**)&cur
->locinfo
->lconv
->mon_decimal_point
,
1138 (void**)&loc
->locinfo
->lconv
->mon_decimal_point
);
1139 swap_pointers((void**)&cur
->locinfo
->lconv
->mon_thousands_sep
,
1140 (void**)&loc
->locinfo
->lconv
->mon_thousands_sep
);
1141 swap_pointers((void**)&cur
->locinfo
->lconv
->mon_grouping
,
1142 (void**)&loc
->locinfo
->lconv
->mon_grouping
);
1143 swap_pointers((void**)&cur
->locinfo
->lconv
->positive_sign
,
1144 (void**)&loc
->locinfo
->lconv
->positive_sign
);
1145 swap_pointers((void**)&cur
->locinfo
->lconv
->negative_sign
,
1146 (void**)&loc
->locinfo
->lconv
->negative_sign
);
1147 cur
->locinfo
->lconv
->int_frac_digits
= loc
->locinfo
->lconv
->int_frac_digits
;
1148 cur
->locinfo
->lconv
->frac_digits
= loc
->locinfo
->lconv
->frac_digits
;
1149 cur
->locinfo
->lconv
->p_cs_precedes
= loc
->locinfo
->lconv
->p_cs_precedes
;
1150 cur
->locinfo
->lconv
->p_sep_by_space
= loc
->locinfo
->lconv
->p_sep_by_space
;
1151 cur
->locinfo
->lconv
->n_cs_precedes
= loc
->locinfo
->lconv
->n_cs_precedes
;
1152 cur
->locinfo
->lconv
->n_sep_by_space
= loc
->locinfo
->lconv
->n_sep_by_space
;
1153 cur
->locinfo
->lconv
->p_sign_posn
= loc
->locinfo
->lconv
->p_sign_posn
;
1154 cur
->locinfo
->lconv
->n_sign_posn
= loc
->locinfo
->lconv
->n_sign_posn
;
1156 if(category
!= MSVCRT_LC_ALL
)
1158 case MSVCRT_LC_NUMERIC
:
1159 cur
->locinfo
->lc_handle
[MSVCRT_LC_NUMERIC
] =
1160 loc
->locinfo
->lc_handle
[MSVCRT_LC_NUMERIC
];
1161 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].locale
,
1162 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].locale
);
1163 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].refcount
,
1164 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_NUMERIC
].refcount
);
1166 swap_pointers((void**)&cur
->locinfo
->lconv
->decimal_point
,
1167 (void**)&loc
->locinfo
->lconv
->decimal_point
);
1168 swap_pointers((void**)&cur
->locinfo
->lconv
->thousands_sep
,
1169 (void**)&loc
->locinfo
->lconv
->thousands_sep
);
1170 swap_pointers((void**)&cur
->locinfo
->lconv
->grouping
,
1171 (void**)&loc
->locinfo
->lconv
->grouping
);
1173 if(category
!= MSVCRT_LC_ALL
)
1175 case MSVCRT_LC_TIME
:
1176 cur
->locinfo
->lc_handle
[MSVCRT_LC_TIME
] =
1177 loc
->locinfo
->lc_handle
[MSVCRT_LC_TIME
];
1178 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_TIME
].locale
,
1179 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_TIME
].locale
);
1180 swap_pointers((void**)&cur
->locinfo
->lc_category
[MSVCRT_LC_TIME
].refcount
,
1181 (void**)&loc
->locinfo
->lc_category
[MSVCRT_LC_TIME
].refcount
);
1183 if(category
!= MSVCRT_LC_ALL
)
1188 MSVCRT_locale
= cur
= loc
;
1194 if(cur
== MSVCRT_locale
) {
1195 MSVCRT___lc_codepage
= cur
->locinfo
->lc_codepage
;
1196 MSVCRT___lc_collate_cp
= cur
->locinfo
->lc_collate_cp
;
1197 MSVCRT___mb_cur_max
= cur
->locinfo
->mb_cur_max
;
1198 MSVCRT__pctype
= cur
->locinfo
->pctype
;
1201 if(category
== MSVCRT_LC_ALL
)
1202 return construct_lc_all(cur
);
1204 return cur
->locinfo
->lc_category
[category
].locale
;