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 #define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
42 #define MAX_LOCALE_LENGTH 256
43 MSVCRT__locale_t MSVCRT_locale = NULL;
44 int MSVCRT___lc_codepage = 0;
45 int MSVCRT___lc_collate_cp = 0;
46 HANDLE MSVCRT___lc_handle[MSVCRT_LC_MAX - MSVCRT_LC_MIN + 1] = { 0 };
47 unsigned char charmax = CHAR_MAX;
50 #define LOCK_LOCALE _mlock(_SETLOCALE_LOCK);
51 #define UNLOCK_LOCALE _munlock(_SETLOCALE_LOCK);
53 #define MSVCRT_LEADBYTE 0x8000
54 #define MSVCRT_C1_DEFINED 0x200
56 /* Friendly country strings & language names abbreviations. */
57 static const char * const _country_synonyms[] =
60 "american english", "enu",
61 "american-english", "enu",
62 "english-american", "enu",
70 "french-belgian", "frb",
73 "french-canadian", "frc",
75 "chinese-simplified", "chs",
76 "chinese-traditional", "cht",
77 "dutch-belgian", "nlb",
81 "french-swiss", "frs",
83 "german-swiss", "des",
84 "italian-swiss", "its",
85 "german-austrian", "dea",
87 "portuguese-brazil", "ptb",
88 "spanish-mexican", "esm",
89 "norwegian-bokmal", "nor",
90 "norwegian-nynorsk", "non",
91 "spanish-modern", "esn"
94 /* INTERNAL: Map a synonym to an ISO code */
95 static void remap_synonym(char *name)
98 for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
100 if (!strcasecmp(_country_synonyms[i],name))
102 TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
103 memcpy(name, _country_synonyms[i+1], sizeof(_country_synonyms[i+1]));
109 /* Note: Flags are weighted in order of matching importance */
110 #define FOUND_LANGUAGE 0x4
111 #define FOUND_COUNTRY 0x2
112 #define FOUND_CODEPAGE 0x1
115 char search_language[MAX_ELEM_LEN];
116 char search_country[MAX_ELEM_LEN];
117 char search_codepage[MAX_ELEM_LEN];
118 char found_codepage[MAX_ELEM_LEN];
119 unsigned int match_flags;
120 LANGID found_lang_id;
123 #define CONTINUE_LOOKING TRUE
124 #define STOP_LOOKING FALSE
126 /* INTERNAL: Get and compare locale info with a given string */
127 static int compare_info(LCID lcid, DWORD flags, char* buff, const char* cmp, BOOL exact)
132 GetLocaleInfoA(lcid, flags|LOCALE_NOUSEROVERRIDE, buff, MAX_ELEM_LEN);
133 if (!buff[0] || !cmp[0])
136 /* Partial matches are only allowed on language/country names */
139 return !strcasecmp(cmp, buff);
141 return !strncasecmp(cmp, buff, len);
145 find_best_locale_proc(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
147 locale_search_t *res = (locale_search_t *)lParam;
148 const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
149 char buff[MAX_ELEM_LEN];
150 unsigned int flags = 0;
152 if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
153 return CONTINUE_LOOKING;
156 if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language, TRUE) ||
157 compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language, TRUE) ||
158 compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language, FALSE))
160 TRACE(":Found language: %s->%s\n", res->search_language, buff);
161 flags |= FOUND_LANGUAGE;
163 else if (res->match_flags & FOUND_LANGUAGE)
165 return CONTINUE_LOOKING;
169 if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country, TRUE) ||
170 compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country, TRUE) ||
171 compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country, FALSE))
173 TRACE("Found country:%s->%s\n", res->search_country, buff);
174 flags |= FOUND_COUNTRY;
176 else if (res->match_flags & FOUND_COUNTRY)
178 return CONTINUE_LOOKING;
182 if (compare_info(lcid,LOCALE_IDEFAULTCODEPAGE,buff,res->search_codepage, TRUE) ||
183 (compare_info(lcid,LOCALE_IDEFAULTANSICODEPAGE,buff,res->search_codepage, TRUE)))
185 TRACE("Found codepage:%s->%s\n", res->search_codepage, buff);
186 flags |= FOUND_CODEPAGE;
187 memcpy(res->found_codepage,res->search_codepage,MAX_ELEM_LEN);
189 else if (res->match_flags & FOUND_CODEPAGE)
191 return CONTINUE_LOOKING;
194 if (flags > res->match_flags)
196 /* Found a better match than previously */
197 res->match_flags = flags;
198 res->found_lang_id = LangID;
200 if ((flags & (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE)) ==
201 (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE))
203 TRACE(":found exact locale match\n");
206 return CONTINUE_LOOKING;
209 extern int atoi(const char *);
211 /* Internal: Find the LCID for a locale specification */
212 static LCID MSVCRT_locale_to_LCID(const char *locale)
215 locale_search_t search;
218 memset(&search, 0, sizeof(locale_search_t));
220 cp = strchr(locale, '.');
221 region = strchr(locale, '_');
223 lstrcpynA(search.search_language, locale, MAX_ELEM_LEN);
225 lstrcpynA(search.search_country, region+1, MAX_ELEM_LEN);
226 if(region-locale < MAX_ELEM_LEN)
227 search.search_language[region-locale] = '\0';
229 search.search_country[0] = '\0';
232 lstrcpynA(search.search_codepage, cp+1, MAX_ELEM_LEN);
233 if(cp-region-1 < MAX_ELEM_LEN)
234 search.search_country[cp-region-1] = '\0';
235 if(cp-locale < MAX_ELEM_LEN)
236 search.search_language[cp-locale] = '\0';
238 search.search_codepage[0] = '\0';
240 if(!search.search_country[0] && !search.search_codepage[0])
241 remap_synonym(search.search_language);
243 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR)RT_STRING,
244 (LPCSTR)LOCALE_ILANGUAGE,find_best_locale_proc,
247 if (!search.match_flags)
250 /* If we were given something that didn't match, fail */
251 if (search.search_country[0] && !(search.match_flags & FOUND_COUNTRY))
254 lcid = MAKELCID(search.found_lang_id, SORT_DEFAULT);
256 /* Populate partial locale, translating LCID to locale string elements */
257 if (!search.found_codepage[0]) {
258 /* Even if a codepage is not enumerated for a locale
259 * it can be set if valid */
260 if (search.search_codepage[0]) {
261 if (IsValidCodePage(atoi(search.search_codepage)))
262 memcpy(search.found_codepage,search.search_codepage,MAX_ELEM_LEN);
264 /* Special codepage values: OEM & ANSI */
265 if (strcasecmp(search.search_codepage,"OCP")) {
266 GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
267 search.found_codepage, MAX_ELEM_LEN);
268 } else if (strcasecmp(search.search_codepage,"ACP")) {
269 GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
270 search.found_codepage, MAX_ELEM_LEN);
274 if (!atoi(search.found_codepage))
278 /* Prefer ANSI codepages if present */
279 GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
280 search.found_codepage, MAX_ELEM_LEN);
281 if (!search.found_codepage[0] || !atoi(search.found_codepage))
282 GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
283 search.found_codepage, MAX_ELEM_LEN);
290 /* INTERNAL: Set lc_handle, lc_id and lc_category in threadlocinfo struct */
291 static BOOL update_threadlocinfo_category(LCID lcid, MSVCRT__locale_t loc, int category)
296 if(GetLocaleInfoA(lcid, LOCALE_ILANGUAGE|LOCALE_NOUSEROVERRIDE, buf, 256)) {
299 loc->locinfo->lc_id[category].wLanguage = 0;
301 loc->locinfo->lc_id[category].wLanguage *= 16;
304 loc->locinfo->lc_id[category].wLanguage += *p-'0';
306 loc->locinfo->lc_id[category].wLanguage += *p-'a'+10;
311 loc->locinfo->lc_id[category].wCountry =
312 loc->locinfo->lc_id[category].wLanguage;
315 if(GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE
316 |LOCALE_NOUSEROVERRIDE, buf, 256))
317 loc->locinfo->lc_id[category].wCodePage = atoi(buf);
319 loc->locinfo->lc_handle[category] = lcid;
322 len += GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE
323 |LOCALE_NOUSEROVERRIDE, buf, 256);
325 len += GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY
326 |LOCALE_NOUSEROVERRIDE, &buf[len], 256-len);
328 len += GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE
329 |LOCALE_NOUSEROVERRIDE, &buf[len], 256-len);
331 loc->locinfo->lc_category[category].locale = MSVCRT_malloc(sizeof(char[len]));
332 loc->locinfo->lc_category[category].refcount = MSVCRT_malloc(sizeof(int));
333 if(!loc->locinfo->lc_category[category].locale
334 || !loc->locinfo->lc_category[category].refcount) {
335 MSVCRT_free(loc->locinfo->lc_category[category].locale);
336 MSVCRT_free(loc->locinfo->lc_category[category].refcount);
337 loc->locinfo->lc_category[category].locale = NULL;
338 loc->locinfo->lc_category[category].refcount = NULL;
341 memcpy(loc->locinfo->lc_category[category].locale, buf, sizeof(char[len]));
342 *loc->locinfo->lc_category[category].refcount = 1;
347 /* INTERNAL: swap pointers values */
348 static inline void swap_pointers(void **p1, void **p2) {
356 /* INTERNAL: returns _locale_t struct for current locale */
357 MSVCRT__locale_t get_locale(void) {
358 thread_data_t *data = msvcrt_get_thread_data();
360 if(!data || !data->locale)
361 return MSVCRT_locale;
366 /* INTERNAL: constructs string returned by setlocale */
367 static inline char* construct_lc_all(MSVCRT__locale_t cur) {
368 static char current_lc_all[MAX_LOCALE_LENGTH];
372 for(i=MSVCRT_LC_MIN+1; i<MSVCRT_LC_MAX; i++) {
373 if(strcmp(cur->locinfo->lc_category[i].locale,
374 cur->locinfo->lc_category[i+1].locale))
379 return cur->locinfo->lc_category[MSVCRT_LC_COLLATE].locale;
381 sprintf(current_lc_all,
382 "LC_COLLATE=%s;LC_CTYPE=%s;LC_MONETARY=%s;LC_NUMERIC=%s;LC_TIME=%s",
383 cur->locinfo->lc_category[MSVCRT_LC_COLLATE].locale,
384 cur->locinfo->lc_category[MSVCRT_LC_CTYPE].locale,
385 cur->locinfo->lc_category[MSVCRT_LC_MONETARY].locale,
386 cur->locinfo->lc_category[MSVCRT_LC_NUMERIC].locale,
387 cur->locinfo->lc_category[MSVCRT_LC_TIME].locale);
389 return current_lc_all;
393 /*********************************************************************
394 * wsetlocale (MSVCRT.@)
396 MSVCRT_wchar_t* CDECL MSVCRT__wsetlocale(int category, const MSVCRT_wchar_t* locale)
398 static MSVCRT_wchar_t fake[] = {
399 'E','n','g','l','i','s','h','_','U','n','i','t','e','d',' ',
400 'S','t','a','t','e','s','.','1','2','5','2',0 };
402 FIXME("%d %s\n", category, debugstr_w(locale));
407 /*********************************************************************
408 * _Getdays (MSVCRT.@)
410 const char* CDECL _Getdays(void)
412 static const char MSVCRT_days[] = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:"
413 "Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
414 /* FIXME: Use locale */
415 TRACE("(void) semi-stub\n");
419 /*********************************************************************
420 * _Getmonths (MSVCRT.@)
422 const char* CDECL _Getmonths(void)
424 static const char MSVCRT_months[] = ":Jan:January:Feb:February:Mar:March:Apr:"
425 "April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:"
426 "October:Nov:November:Dec:December";
427 /* FIXME: Use locale */
428 TRACE("(void) semi-stub\n");
429 return MSVCRT_months;
432 /*********************************************************************
433 * _Gettnames (MSVCRT.@)
435 const char* CDECL _Gettnames(void)
438 TRACE("(void) stub\n");
442 /*********************************************************************
443 * _Strftime (MSVCRT.@)
445 const char* CDECL _Strftime(char *out, unsigned int len, const char *fmt,
446 const void *tm, void *foo)
449 TRACE("(%p %d %s %p %p) stub\n", out, len, fmt, tm, foo);
453 /*********************************************************************
454 * __crtLCMapStringA (MSVCRT.@)
456 int CDECL __crtLCMapStringA(
457 LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst,
458 int dstlen, unsigned int codepage, int xflag
460 FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
461 lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag);
462 /* FIXME: A bit incorrect. But msvcrt itself just converts its
463 * arguments to wide strings and then calls LCMapStringW
465 return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen);
468 /*********************************************************************
469 * __crtLCMapStringW (MSVCRT.@)
471 int CDECL __crtLCMapStringW(LCID lcid, DWORD mapflags, const MSVCRT_wchar_t *src,
472 int srclen, MSVCRT_wchar_t *dst, int dstlen, unsigned int codepage, int xflag)
474 FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
475 lcid, mapflags, debugstr_w(src), srclen, dst, dstlen, codepage, xflag);
477 return LCMapStringW(lcid, mapflags, src, srclen, dst, dstlen);
480 /*********************************************************************
481 * __crtCompareStringA (MSVCRT.@)
483 int CDECL __crtCompareStringA( LCID lcid, DWORD flags, const char *src1, int len1,
484 const char *src2, int len2 )
486 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
487 lcid, flags, debugstr_a(src1), len1, debugstr_a(src2), len2 );
488 /* FIXME: probably not entirely right */
489 return CompareStringA( lcid, flags, src1, len1, src2, len2 );
492 /*********************************************************************
493 * __crtCompareStringW (MSVCRT.@)
495 int CDECL __crtCompareStringW( LCID lcid, DWORD flags, const MSVCRT_wchar_t *src1, int len1,
496 const MSVCRT_wchar_t *src2, int len2 )
498 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
499 lcid, flags, debugstr_w(src1), len1, debugstr_w(src2), len2 );
500 /* FIXME: probably not entirely right */
501 return CompareStringW( lcid, flags, src1, len1, src2, len2 );
504 /*********************************************************************
505 * __crtGetLocaleInfoW (MSVCRT.@)
507 int CDECL __crtGetLocaleInfoW( LCID lcid, LCTYPE type, MSVCRT_wchar_t *buffer, int len )
509 FIXME("(lcid %x, type %x, %p(%d), partial stub\n", lcid, type, buffer, len );
510 /* FIXME: probably not entirely right */
511 return GetLocaleInfoW( lcid, type, buffer, len );
514 /*********************************************************************
517 MSVCRT_wint_t CDECL MSVCRT_btowc(int c)
519 MSVCRT__locale_t locale = get_locale();
520 unsigned char letter = c;
523 if(!MultiByteToWideChar(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE],
524 0, (LPCSTR)&letter, 1, &ret, 1))
530 /*********************************************************************
531 * __crtGetStringTypeW(MSVCRT.@)
533 * This function was accepting different number of arguments in older
534 * versions of msvcrt.
536 BOOL CDECL __crtGetStringTypeW(DWORD unk, DWORD type,
537 MSVCRT_wchar_t *buffer, int len, WORD *out)
539 FIXME("(unk %x, type %x, wstr %p(%d), %p) partial stub\n",
540 unk, type, buffer, len, out);
542 return GetStringTypeW(type, buffer, len, out);
545 /*********************************************************************
546 * localeconv (MSVCRT.@)
548 struct MSVCRT_lconv * CDECL MSVCRT_localeconv(void)
550 return get_locale()->locinfo->lconv;
553 /*********************************************************************
554 * __lconv_init (MSVCRT.@)
556 int CDECL __lconv_init(void)
558 /* this is used to make chars unsigned */
563 /*********************************************************************
564 * ___lc_handle_func (MSVCRT.@)
566 HANDLE * CDECL ___lc_handle_func(void)
568 return MSVCRT___lc_handle;
571 /*********************************************************************
572 * ___lc_codepage_func (MSVCRT.@)
574 int CDECL ___lc_codepage_func(void)
576 return MSVCRT___lc_codepage;
579 /*********************************************************************
580 * ___lc_collate_cp_func (MSVCRT.@)
582 int CDECL ___lc_collate_cp_func(void)
584 return get_locale()->locinfo->lc_collate_cp;
587 /* _free_locale - not exported in native msvcrt */
588 void CDECL MSVCRT__free_locale(MSVCRT__locale_t locale)
595 for(i=MSVCRT_LC_MIN+1; i<=MSVCRT_LC_MAX; i++) {
596 MSVCRT_free(locale->locinfo->lc_category[i].locale);
597 MSVCRT_free(locale->locinfo->lc_category[i].refcount);
600 if(locale->locinfo->lconv) {
601 MSVCRT_free(locale->locinfo->lconv->decimal_point);
602 MSVCRT_free(locale->locinfo->lconv->thousands_sep);
603 MSVCRT_free(locale->locinfo->lconv->grouping);
604 MSVCRT_free(locale->locinfo->lconv->int_curr_symbol);
605 MSVCRT_free(locale->locinfo->lconv->currency_symbol);
606 MSVCRT_free(locale->locinfo->lconv->mon_decimal_point);
607 MSVCRT_free(locale->locinfo->lconv->mon_thousands_sep);
608 MSVCRT_free(locale->locinfo->lconv->mon_grouping);
609 MSVCRT_free(locale->locinfo->lconv->positive_sign);
610 MSVCRT_free(locale->locinfo->lconv->negative_sign);
612 MSVCRT_free(locale->locinfo->lconv_intl_refcount);
613 MSVCRT_free(locale->locinfo->lconv_num_refcount);
614 MSVCRT_free(locale->locinfo->lconv_mon_refcount);
615 MSVCRT_free(locale->locinfo->lconv);
617 MSVCRT_free(locale->locinfo->ctype1_refcount);
618 MSVCRT_free(locale->locinfo->ctype1);
620 MSVCRT_free(locale->locinfo->pclmap);
621 MSVCRT_free(locale->locinfo->pcumap);
623 MSVCRT_free(locale->locinfo);
624 MSVCRT_free(locale->mbcinfo);
628 /* _create_locale - not exported in native msvcrt */
629 MSVCRT__locale_t MSVCRT__create_locale(int category, const char *locale)
631 static const char collate[] = "COLLATE=";
632 static const char ctype[] = "CTYPE=";
633 static const char monetary[] = "MONETARY=";
634 static const char numeric[] = "NUMERIC=";
635 static const char time[] = "TIME=";
637 MSVCRT__locale_t loc;
638 LCID lcid[6] = { 0 };
642 TRACE("(%d %s)\n", category, locale);
644 if(category<MSVCRT_LC_MIN || category>MSVCRT_LC_MAX || !locale)
647 if(locale[0]=='C' && !locale[1])
650 lcid[0] = GetSystemDefaultLCID();
651 else if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_') {
655 locale += 3; /* LC_ */
656 if(!memcmp(locale, collate, sizeof(collate)-1)) {
657 i = MSVCRT_LC_COLLATE;
658 locale += sizeof(collate)-1;
659 } else if(!memcmp(locale, ctype, sizeof(ctype)-1)) {
661 locale += sizeof(ctype)-1;
662 } else if(!memcmp(locale, monetary, sizeof(monetary)-1)) {
663 i = MSVCRT_LC_MONETARY;
664 locale += sizeof(monetary)-1;
665 } else if(!memcmp(locale, numeric, sizeof(numeric)-1)) {
666 i = MSVCRT_LC_NUMERIC;
667 locale += sizeof(numeric)-1;
668 } else if(!memcmp(locale, time, sizeof(time)-1)) {
670 locale += sizeof(time)-1;
674 p = strchr(locale, ';');
675 if(locale[0]=='C' && (locale[1]==';' || locale[1]=='\0'))
678 memcpy(buf, locale, p-locale);
679 buf[p-locale] = '\0';
680 lcid[i] = MSVCRT_locale_to_LCID(buf);
682 lcid[i] = MSVCRT_locale_to_LCID(locale);
687 if(!p || *(p+1)!='L' || *(p+2)!='C' || *(p+3)!='_')
693 lcid[0] = MSVCRT_locale_to_LCID(locale);
703 loc = MSVCRT_malloc(sizeof(MSVCRT__locale_tstruct));
707 loc->locinfo = MSVCRT_malloc(sizeof(MSVCRT_threadlocinfo));
713 loc->mbcinfo = MSVCRT_malloc(sizeof(MSVCRT_threadmbcinfo));
715 MSVCRT_free(loc->locinfo);
720 memset(loc->locinfo, 0, sizeof(MSVCRT_threadlocinfo));
721 memset(loc->mbcinfo, 0, sizeof(MSVCRT_threadmbcinfo));
723 loc->locinfo->lconv = MSVCRT_malloc(sizeof(struct MSVCRT_lconv));
724 if(!loc->locinfo->lconv) {
725 MSVCRT__free_locale(loc);
728 memset(loc->locinfo->lconv, 0, sizeof(struct MSVCRT_lconv));
730 loc->locinfo->pclmap = MSVCRT_malloc(sizeof(char[256]));
731 loc->locinfo->pcumap = MSVCRT_malloc(sizeof(char[256]));
732 if(!loc->locinfo->pclmap || !loc->locinfo->pcumap) {
733 MSVCRT__free_locale(loc);
737 loc->locinfo->refcount = 1;
739 if(lcid[MSVCRT_LC_COLLATE] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_COLLATE)) {
740 if(update_threadlocinfo_category(lcid[MSVCRT_LC_COLLATE], loc, MSVCRT_LC_COLLATE)) {
741 MSVCRT__free_locale(loc);
745 loc->locinfo->lc_category[MSVCRT_LC_COLLATE].locale = _strdup("C");
747 if(lcid[MSVCRT_LC_CTYPE] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_CTYPE)) {
751 if(update_threadlocinfo_category(lcid[MSVCRT_LC_CTYPE], loc, MSVCRT_LC_CTYPE)) {
752 MSVCRT__free_locale(loc);
756 loc->locinfo->lc_codepage = loc->locinfo->lc_id[MSVCRT_LC_CTYPE].wCodePage;
757 loc->locinfo->lc_collate_cp = loc->locinfo->lc_codepage;
758 loc->locinfo->lc_clike = 1;
759 if(!GetCPInfo(loc->locinfo->lc_codepage, &cp)) {
760 MSVCRT__free_locale(loc);
763 loc->locinfo->mb_cur_max = cp.MaxCharSize;
765 loc->locinfo->ctype1_refcount = MSVCRT_malloc(sizeof(int));
766 loc->locinfo->ctype1 = MSVCRT_malloc(sizeof(short[257]));
767 if(!loc->locinfo->ctype1_refcount || !loc->locinfo->ctype1) {
768 MSVCRT__free_locale(loc);
772 *loc->locinfo->ctype1_refcount = 1;
773 loc->locinfo->ctype1[0] = 0;
774 loc->locinfo->pctype = loc->locinfo->ctype1+1;
776 buf[1] = buf[2] = '\0';
777 for(i=1; i<257; i++) {
780 GetStringTypeA(lcid[MSVCRT_LC_CTYPE], CT_CTYPE1, buf,
781 1, loc->locinfo->ctype1+i);
784 for(i=0; cp.LeadByte[i+1]!=0; i+=2)
785 for(j=cp.LeadByte[i]; j<=cp.LeadByte[i+1]; j++)
786 loc->locinfo->ctype1[j+1] |= MSVCRT__LEADBYTE;
788 loc->locinfo->lc_clike = 1;
789 loc->locinfo->mb_cur_max = 1;
790 loc->locinfo->pctype = MSVCRT__ctype+1;
791 loc->locinfo->lc_category[MSVCRT_LC_CTYPE].locale = _strdup("C");
794 for(i=0; i<256; i++) {
795 if(loc->locinfo->pctype[i] & MSVCRT__LEADBYTE)
802 LCMapStringA(lcid[MSVCRT_LC_CTYPE], LCMAP_LOWERCASE, buf, 256,
803 (char*)loc->locinfo->pclmap, 256);
804 LCMapStringA(lcid[MSVCRT_LC_CTYPE], LCMAP_UPPERCASE, buf, 256,
805 (char*)loc->locinfo->pcumap, 256);
807 loc->mbcinfo->refcount = 1;
808 loc->mbcinfo->mbcodepage = loc->locinfo->lc_id[MSVCRT_LC_CTYPE].wCodePage;
810 for(i=0; i<256; i++) {
811 if(loc->locinfo->pclmap[i] != i) {
812 loc->mbcinfo->mbctype[i+1] |= 0x10;
813 loc->mbcinfo->mbcasemap[i] = loc->locinfo->pclmap[i];
814 } else if(loc->locinfo->pcumap[i] != i) {
815 loc->mbcinfo->mbctype[i+1] |= 0x20;
816 loc->mbcinfo->mbcasemap[i] = loc->locinfo->pcumap[i];
820 if(lcid[MSVCRT_LC_MONETARY] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_MONETARY)) {
821 if(update_threadlocinfo_category(lcid[MSVCRT_LC_MONETARY], loc, MSVCRT_LC_MONETARY)) {
822 MSVCRT__free_locale(loc);
826 loc->locinfo->lconv_intl_refcount = MSVCRT_malloc(sizeof(int));
827 loc->locinfo->lconv_mon_refcount = MSVCRT_malloc(sizeof(int));
828 if(!loc->locinfo->lconv_intl_refcount || !loc->locinfo->lconv_mon_refcount) {
829 MSVCRT__free_locale(loc);
833 *loc->locinfo->lconv_intl_refcount = 1;
834 *loc->locinfo->lconv_mon_refcount = 1;
836 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SINTLSYMBOL
837 |LOCALE_NOUSEROVERRIDE, buf, 256);
838 if(i && (loc->locinfo->lconv->int_curr_symbol = MSVCRT_malloc(sizeof(char[i]))))
839 memcpy(loc->locinfo->lconv->int_curr_symbol, buf, sizeof(char[i]));
841 MSVCRT__free_locale(loc);
845 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SCURRENCY
846 |LOCALE_NOUSEROVERRIDE, buf, 256);
847 if(i && (loc->locinfo->lconv->currency_symbol = MSVCRT_malloc(sizeof(char[i]))))
848 memcpy(loc->locinfo->lconv->currency_symbol, buf, sizeof(char[i]));
850 MSVCRT__free_locale(loc);
854 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SMONDECIMALSEP
855 |LOCALE_NOUSEROVERRIDE, buf, 256);
856 if(i && (loc->locinfo->lconv->mon_decimal_point = MSVCRT_malloc(sizeof(char[i]))))
857 memcpy(loc->locinfo->lconv->mon_decimal_point, buf, sizeof(char[i]));
859 MSVCRT__free_locale(loc);
863 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SMONTHOUSANDSEP
864 |LOCALE_NOUSEROVERRIDE, buf, 256);
865 if(i && (loc->locinfo->lconv->mon_thousands_sep = MSVCRT_malloc(sizeof(char[i]))))
866 memcpy(loc->locinfo->lconv->mon_thousands_sep, buf, sizeof(char[i]));
868 MSVCRT__free_locale(loc);
872 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SMONGROUPING
873 |LOCALE_NOUSEROVERRIDE, buf, 256);
875 i = i/2 + (buf[i-2]=='0'?0:1);
876 if(i && (loc->locinfo->lconv->mon_grouping = MSVCRT_malloc(sizeof(char[i])))) {
877 for(i=0; buf[i+1]==';'; i+=2)
878 loc->locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
879 loc->locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
881 loc->locinfo->lconv->mon_grouping[i/2+1] = 127;
883 MSVCRT__free_locale(loc);
887 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SPOSITIVESIGN
888 |LOCALE_NOUSEROVERRIDE, buf, 256);
889 if(i && (loc->locinfo->lconv->positive_sign = MSVCRT_malloc(sizeof(char[i]))))
890 memcpy(loc->locinfo->lconv->positive_sign, buf, sizeof(char[i]));
892 MSVCRT__free_locale(loc);
896 i = GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_SNEGATIVESIGN
897 |LOCALE_NOUSEROVERRIDE, buf, 256);
898 if(i && (loc->locinfo->lconv->negative_sign = MSVCRT_malloc(sizeof(char[i]))))
899 memcpy(loc->locinfo->lconv->negative_sign, buf, sizeof(char[i]));
901 MSVCRT__free_locale(loc);
905 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_IINTLCURRDIGITS
906 |LOCALE_NOUSEROVERRIDE, buf, 256))
907 loc->locinfo->lconv->int_frac_digits = atoi(buf);
909 MSVCRT__free_locale(loc);
913 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_ICURRDIGITS
914 |LOCALE_NOUSEROVERRIDE, buf, 256))
915 loc->locinfo->lconv->frac_digits = atoi(buf);
917 MSVCRT__free_locale(loc);
921 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_IPOSSYMPRECEDES
922 |LOCALE_NOUSEROVERRIDE, buf, 256))
923 loc->locinfo->lconv->p_cs_precedes = atoi(buf);
925 MSVCRT__free_locale(loc);
929 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_IPOSSEPBYSPACE
930 |LOCALE_NOUSEROVERRIDE, buf, 256))
931 loc->locinfo->lconv->p_sep_by_space = atoi(buf);
933 MSVCRT__free_locale(loc);
937 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_INEGSYMPRECEDES
938 |LOCALE_NOUSEROVERRIDE, buf, 256))
939 loc->locinfo->lconv->n_cs_precedes = atoi(buf);
941 MSVCRT__free_locale(loc);
945 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_INEGSEPBYSPACE
946 |LOCALE_NOUSEROVERRIDE, buf, 256))
947 loc->locinfo->lconv->n_sep_by_space = atoi(buf);
949 MSVCRT__free_locale(loc);
953 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_IPOSSIGNPOSN
954 |LOCALE_NOUSEROVERRIDE, buf, 256))
955 loc->locinfo->lconv->p_sign_posn = atoi(buf);
957 MSVCRT__free_locale(loc);
961 if(GetLocaleInfoA(lcid[MSVCRT_LC_MONETARY], LOCALE_INEGSIGNPOSN
962 |LOCALE_NOUSEROVERRIDE, buf, 256))
963 loc->locinfo->lconv->n_sign_posn = atoi(buf);
965 MSVCRT__free_locale(loc);
969 loc->locinfo->lconv->int_curr_symbol = MSVCRT_malloc(sizeof(char));
970 loc->locinfo->lconv->currency_symbol = MSVCRT_malloc(sizeof(char));
971 loc->locinfo->lconv->mon_decimal_point = MSVCRT_malloc(sizeof(char));
972 loc->locinfo->lconv->mon_thousands_sep = MSVCRT_malloc(sizeof(char));
973 loc->locinfo->lconv->mon_grouping = MSVCRT_malloc(sizeof(char));
974 loc->locinfo->lconv->positive_sign = MSVCRT_malloc(sizeof(char));
975 loc->locinfo->lconv->negative_sign = MSVCRT_malloc(sizeof(char));
977 if(!loc->locinfo->lconv->int_curr_symbol || !loc->locinfo->lconv->currency_symbol
978 || !loc->locinfo->lconv->mon_decimal_point || !loc->locinfo->lconv->mon_thousands_sep
979 || !loc->locinfo->lconv->mon_grouping || !loc->locinfo->lconv->positive_sign
980 || !loc->locinfo->lconv->negative_sign) {
981 MSVCRT__free_locale(loc);
985 loc->locinfo->lconv->int_curr_symbol[0] = '\0';
986 loc->locinfo->lconv->currency_symbol[0] = '\0';
987 loc->locinfo->lconv->mon_decimal_point[0] = '\0';
988 loc->locinfo->lconv->mon_thousands_sep[0] = '\0';
989 loc->locinfo->lconv->mon_grouping[0] = '\0';
990 loc->locinfo->lconv->positive_sign[0] = '\0';
991 loc->locinfo->lconv->negative_sign[0] = '\0';
992 loc->locinfo->lconv->int_frac_digits = 127;
993 loc->locinfo->lconv->frac_digits = 127;
994 loc->locinfo->lconv->p_cs_precedes = 127;
995 loc->locinfo->lconv->p_sep_by_space = 127;
996 loc->locinfo->lconv->n_cs_precedes = 127;
997 loc->locinfo->lconv->n_sep_by_space = 127;
998 loc->locinfo->lconv->p_sign_posn = 127;
999 loc->locinfo->lconv->n_sign_posn = 127;
1001 loc->locinfo->lc_category[MSVCRT_LC_MONETARY].locale = _strdup("C");
1004 if(lcid[MSVCRT_LC_NUMERIC] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_NUMERIC)) {
1005 if(update_threadlocinfo_category(lcid[MSVCRT_LC_NUMERIC], loc, MSVCRT_LC_NUMERIC)) {
1006 MSVCRT__free_locale(loc);
1010 if(!loc->locinfo->lconv_intl_refcount)
1011 loc->locinfo->lconv_intl_refcount = MSVCRT_malloc(sizeof(int));
1012 loc->locinfo->lconv_num_refcount = MSVCRT_malloc(sizeof(int));
1013 if(!loc->locinfo->lconv_intl_refcount || !loc->locinfo->lconv_num_refcount) {
1014 MSVCRT__free_locale(loc);
1018 *loc->locinfo->lconv_intl_refcount = 1;
1019 *loc->locinfo->lconv_num_refcount = 1;
1021 i = GetLocaleInfoA(lcid[MSVCRT_LC_NUMERIC], LOCALE_SDECIMAL
1022 |LOCALE_NOUSEROVERRIDE, buf, 256);
1023 if(i && (loc->locinfo->lconv->decimal_point = MSVCRT_malloc(sizeof(char[i]))))
1024 memcpy(loc->locinfo->lconv->decimal_point, buf, sizeof(char[i]));
1026 MSVCRT__free_locale(loc);
1030 i = GetLocaleInfoA(lcid[MSVCRT_LC_NUMERIC], LOCALE_STHOUSAND
1031 |LOCALE_NOUSEROVERRIDE, buf, 256);
1032 if(i && (loc->locinfo->lconv->thousands_sep = MSVCRT_malloc(sizeof(char[i]))))
1033 memcpy(loc->locinfo->lconv->thousands_sep, buf, sizeof(char[i]));
1035 MSVCRT__free_locale(loc);
1039 i = GetLocaleInfoA(lcid[MSVCRT_LC_NUMERIC], LOCALE_SGROUPING
1040 |LOCALE_NOUSEROVERRIDE, buf, 256);
1042 i = i/2 + (buf[i-2]=='0'?0:1);
1043 if(i && (loc->locinfo->lconv->grouping = MSVCRT_malloc(sizeof(char[i])))) {
1044 for(i=0; buf[i+1]==';'; i+=2)
1045 loc->locinfo->lconv->grouping[i/2] = buf[i]-'0';
1046 loc->locinfo->lconv->grouping[i/2] = buf[i]-'0';
1048 loc->locinfo->lconv->grouping[i/2+1] = 127;
1050 MSVCRT__free_locale(loc);
1054 loc->locinfo->lconv->decimal_point = MSVCRT_malloc(sizeof(char[2]));
1055 loc->locinfo->lconv->thousands_sep = MSVCRT_malloc(sizeof(char));
1056 loc->locinfo->lconv->grouping = MSVCRT_malloc(sizeof(char));
1057 if(!loc->locinfo->lconv->decimal_point || !loc->locinfo->lconv->thousands_sep
1058 || !loc->locinfo->lconv->grouping) {
1059 MSVCRT__free_locale(loc);
1063 loc->locinfo->lconv->decimal_point[0] = '.';
1064 loc->locinfo->lconv->decimal_point[1] = '\0';
1065 loc->locinfo->lconv->thousands_sep[0] = '\0';
1066 loc->locinfo->lconv->grouping[0] = '\0';
1068 loc->locinfo->lc_category[MSVCRT_LC_NUMERIC].locale = _strdup("C");
1071 if(lcid[MSVCRT_LC_TIME] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_TIME)) {
1072 if(update_threadlocinfo_category(lcid[MSVCRT_LC_TIME], loc, MSVCRT_LC_TIME)) {
1073 MSVCRT__free_locale(loc);
1077 loc->locinfo->lc_category[MSVCRT_LC_TIME].locale = _strdup("C");
1082 /* _configthreadlocale - not exported in native msvcrt */
1083 int CDECL _configthreadlocale(int type)
1085 thread_data_t *data = msvcrt_get_thread_data();
1091 ret = (data->locale ? MSVCRT__ENABLE_PER_THREAD_LOCALE : MSVCRT__DISABLE_PER_THREAD_LOCALE);
1093 if(type == MSVCRT__ENABLE_PER_THREAD_LOCALE) {
1095 /* Copy current global locale */
1096 data->locale = MSVCRT__create_locale(MSVCRT_LC_ALL, MSVCRT_setlocale(MSVCRT_LC_ALL, NULL));
1104 if(type == MSVCRT__DISABLE_PER_THREAD_LOCALE) {
1106 MSVCRT__free_locale(data->locale);
1107 data->locale = NULL;
1119 /*********************************************************************
1120 * setlocale (MSVCRT.@)
1122 char* CDECL MSVCRT_setlocale(int category, const char* locale)
1124 MSVCRT__locale_t loc, cur;
1128 if(category<MSVCRT_LC_MIN || category>MSVCRT_LC_MAX)
1132 if(category == MSVCRT_LC_ALL)
1133 return construct_lc_all(cur);
1135 return cur->locinfo->lc_category[category].locale;
1138 loc = MSVCRT__create_locale(category, locale);
1140 WARN("%d %s failed\n", category, locale);
1150 case MSVCRT_LC_COLLATE:
1151 cur->locinfo->lc_handle[MSVCRT_LC_COLLATE] =
1152 loc->locinfo->lc_handle[MSVCRT_LC_COLLATE];
1153 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_COLLATE].locale,
1154 (void**)&loc->locinfo->lc_category[MSVCRT_LC_COLLATE].locale);
1155 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_COLLATE].refcount,
1156 (void**)&loc->locinfo->lc_category[MSVCRT_LC_COLLATE].refcount);
1158 if(category != MSVCRT_LC_ALL)
1160 case MSVCRT_LC_CTYPE:
1161 cur->locinfo->lc_handle[MSVCRT_LC_CTYPE] =
1162 loc->locinfo->lc_handle[MSVCRT_LC_CTYPE];
1163 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_CTYPE].locale,
1164 (void**)&loc->locinfo->lc_category[MSVCRT_LC_CTYPE].locale);
1165 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_CTYPE].refcount,
1166 (void**)&loc->locinfo->lc_category[MSVCRT_LC_CTYPE].refcount);
1168 cur->locinfo->lc_codepage = loc->locinfo->lc_codepage;
1169 cur->locinfo->lc_collate_cp = loc->locinfo->lc_collate_cp;
1170 cur->locinfo->lc_clike = loc->locinfo->lc_clike;
1171 cur->locinfo->mb_cur_max = loc->locinfo->mb_cur_max;
1173 swap_pointers((void**)&cur->locinfo->ctype1_refcount,
1174 (void**)&loc->locinfo->ctype1_refcount);
1175 swap_pointers((void**)&cur->locinfo->ctype1, (void**)&loc->locinfo->ctype1);
1176 swap_pointers((void**)&cur->locinfo->pctype, (void**)&loc->locinfo->pctype);
1177 swap_pointers((void**)&cur->locinfo->pclmap, (void**)&loc->locinfo->pclmap);
1178 swap_pointers((void**)&cur->locinfo->pcumap, (void**)&loc->locinfo->pcumap);
1180 memcpy(cur->mbcinfo, loc->mbcinfo, sizeof(MSVCRT_threadmbcinfo));
1182 if(category != MSVCRT_LC_ALL)
1184 case MSVCRT_LC_MONETARY:
1185 cur->locinfo->lc_handle[MSVCRT_LC_MONETARY] =
1186 loc->locinfo->lc_handle[MSVCRT_LC_MONETARY];
1187 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_MONETARY].locale,
1188 (void**)&loc->locinfo->lc_category[MSVCRT_LC_MONETARY].locale);
1189 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_MONETARY].refcount,
1190 (void**)&loc->locinfo->lc_category[MSVCRT_LC_MONETARY].refcount);
1192 swap_pointers((void**)&cur->locinfo->lconv->int_curr_symbol,
1193 (void**)&loc->locinfo->lconv->int_curr_symbol);
1194 swap_pointers((void**)&cur->locinfo->lconv->currency_symbol,
1195 (void**)&loc->locinfo->lconv->currency_symbol);
1196 swap_pointers((void**)&cur->locinfo->lconv->mon_decimal_point,
1197 (void**)&loc->locinfo->lconv->mon_decimal_point);
1198 swap_pointers((void**)&cur->locinfo->lconv->mon_thousands_sep,
1199 (void**)&loc->locinfo->lconv->mon_thousands_sep);
1200 swap_pointers((void**)&cur->locinfo->lconv->mon_grouping,
1201 (void**)&loc->locinfo->lconv->mon_grouping);
1202 swap_pointers((void**)&cur->locinfo->lconv->positive_sign,
1203 (void**)&loc->locinfo->lconv->positive_sign);
1204 swap_pointers((void**)&cur->locinfo->lconv->negative_sign,
1205 (void**)&loc->locinfo->lconv->negative_sign);
1206 cur->locinfo->lconv->int_frac_digits = loc->locinfo->lconv->int_frac_digits;
1207 cur->locinfo->lconv->frac_digits = loc->locinfo->lconv->frac_digits;
1208 cur->locinfo->lconv->p_cs_precedes = loc->locinfo->lconv->p_cs_precedes;
1209 cur->locinfo->lconv->p_sep_by_space = loc->locinfo->lconv->p_sep_by_space;
1210 cur->locinfo->lconv->n_cs_precedes = loc->locinfo->lconv->n_cs_precedes;
1211 cur->locinfo->lconv->n_sep_by_space = loc->locinfo->lconv->n_sep_by_space;
1212 cur->locinfo->lconv->p_sign_posn = loc->locinfo->lconv->p_sign_posn;
1213 cur->locinfo->lconv->n_sign_posn = loc->locinfo->lconv->n_sign_posn;
1215 if(category != MSVCRT_LC_ALL)
1217 case MSVCRT_LC_NUMERIC:
1218 cur->locinfo->lc_handle[MSVCRT_LC_NUMERIC] =
1219 loc->locinfo->lc_handle[MSVCRT_LC_NUMERIC];
1220 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_NUMERIC].locale,
1221 (void**)&loc->locinfo->lc_category[MSVCRT_LC_NUMERIC].locale);
1222 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_NUMERIC].refcount,
1223 (void**)&loc->locinfo->lc_category[MSVCRT_LC_NUMERIC].refcount);
1225 swap_pointers((void**)&cur->locinfo->lconv->decimal_point,
1226 (void**)&loc->locinfo->lconv->decimal_point);
1227 swap_pointers((void**)&cur->locinfo->lconv->thousands_sep,
1228 (void**)&loc->locinfo->lconv->thousands_sep);
1229 swap_pointers((void**)&cur->locinfo->lconv->grouping,
1230 (void**)&loc->locinfo->lconv->grouping);
1232 if(category != MSVCRT_LC_ALL)
1234 case MSVCRT_LC_TIME:
1235 cur->locinfo->lc_handle[MSVCRT_LC_TIME] =
1236 loc->locinfo->lc_handle[MSVCRT_LC_TIME];
1237 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_TIME].locale,
1238 (void**)&loc->locinfo->lc_category[MSVCRT_LC_TIME].locale);
1239 swap_pointers((void**)&cur->locinfo->lc_category[MSVCRT_LC_TIME].refcount,
1240 (void**)&loc->locinfo->lc_category[MSVCRT_LC_TIME].refcount);
1242 if(category != MSVCRT_LC_ALL)
1247 MSVCRT_locale = cur = loc;
1249 MSVCRT__free_locale(loc);
1253 if(cur == MSVCRT_locale) {
1254 MSVCRT___lc_codepage = cur->locinfo->lc_codepage;
1255 MSVCRT___lc_collate_cp = cur->locinfo->lc_collate_cp;
1256 MSVCRT___mb_cur_max = cur->locinfo->mb_cur_max;
1257 MSVCRT__pctype = cur->locinfo->pctype;
1260 if(category == MSVCRT_LC_ALL)
1261 return construct_lc_all(cur);
1263 return cur->locinfo->lc_category[category].locale;