From 698afdca98dd6e1525edaec73b78a60aebc1556b Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 26 Oct 2011 14:10:22 +0200 Subject: [PATCH] msvcrt: Don't search for LCID in _setmbcp_l if it was already done. --- dlls/msvcrt/locale.c | 2 +- dlls/msvcrt/mbcs.c | 13 +++++++++---- dlls/msvcrt/msvcrt.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index b196cee9abb..017d358dada 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -842,7 +842,7 @@ MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale) } } - _setmbcp_l(loc->locinfo->lc_id[MSVCRT_LC_CTYPE].wCodePage, loc->mbcinfo); + _setmbcp_l(loc->locinfo->lc_id[MSVCRT_LC_CTYPE].wCodePage, lcid[MSVCRT_LC_CTYPE], loc->mbcinfo); if(lcid[MSVCRT_LC_MONETARY] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_MONETARY)) { if(update_threadlocinfo_category(lcid[MSVCRT_LC_MONETARY], loc, MSVCRT_LC_MONETARY)) { diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 737f690582a..e9adbd897a1 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -184,7 +184,7 @@ int* CDECL ___mb_cur_max_l_func(MSVCRT__locale_t locale) /********************************************************************* * INTERNAL: _setmbcp_l */ -int _setmbcp_l(int cp, MSVCRT_pthreadmbcinfo mbcinfo) +int _setmbcp_l(int cp, LCID lcid, MSVCRT_pthreadmbcinfo mbcinfo) { const char format[] = ".%d"; @@ -222,8 +222,13 @@ int _setmbcp_l(int cp, MSVCRT_pthreadmbcinfo mbcinfo) break; } - sprintf(bufA, format, newcp); - mbcinfo->mblcid = MSVCRT_locale_to_LCID(bufA); + if(lcid == -1) { + sprintf(bufA, format, newcp); + mbcinfo->mblcid = MSVCRT_locale_to_LCID(bufA); + } else { + mbcinfo->mblcid = lcid; + } + if(mbcinfo->mblcid == -1) { WARN("Can't assign LCID to codepage (%d)\n", mbcinfo->mblcid); @@ -347,7 +352,7 @@ int _setmbcp_l(int cp, MSVCRT_pthreadmbcinfo mbcinfo) */ int CDECL _setmbcp(int cp) { - return _setmbcp_l(cp, NULL); + return _setmbcp_l(cp, -1, NULL); } /********************************************************************* diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 14bf9720cbc..671eb5bfd86 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -888,7 +888,7 @@ MSVCRT_pthreadmbcinfo get_mbcinfo(void); void __cdecl MSVCRT__free_locale(MSVCRT__locale_t); void free_locinfo(MSVCRT_pthreadlocinfo); void free_mbcinfo(MSVCRT_pthreadmbcinfo); -int _setmbcp_l(int, MSVCRT_pthreadmbcinfo); +int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo); #ifndef __WINE_MSVCRT_TEST int __cdecl MSVCRT__write(int,const void*,unsigned int);