Commit d58b385b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Change implementation of setlocale.

parent 10023a15
......@@ -50,15 +50,12 @@ WORD MSVCRT__ctype [257] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Internal: Current ctype table for locale */
WORD MSVCRT_current_ctype[257];
/* pctype is used by macros in the Win32 headers. It must point
* To a table of flags exactly like ctype. To allow locale
* changes to affect ctypes (i.e. isleadbyte), we use a second table
* and update its flags whenever the current locale changes.
*/
WORD* MSVCRT__pctype = MSVCRT_current_ctype + 1;
WORD* MSVCRT__pctype;
/*********************************************************************
* __pctype_func (MSVCRT.@)
......@@ -87,8 +84,8 @@ int CDECL _isctype(int c, int type)
*pconv++ = c & 0xff;
*pconv = 0;
/* FIXME: Use ctype LCID, not lc_all */
if (GetStringTypeExA(MSVCRT_current_lc_all_lcid, CT_CTYPE1,
convert, convert[1] ? 2 : 1, &typeInfo))
if (GetStringTypeExA(MSVCRT_locale->locinfo->lc_handle[MSVCRT_LC_CTYPE],
CT_CTYPE1, convert, convert[1] ? 2 : 1, &typeInfo))
return typeInfo & type;
}
return 0;
......
......@@ -86,14 +86,20 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
if (!msvcrt_init_tls())
return FALSE;
msvcrt_init_mt_locks();
if(!MSVCRT_setlocale(0, "C")) {
msvcrt_free_mt_locks();
return FALSE;
}
if (!msvcrt_init_tls()) {
_free_locale(MSVCRT_locale);
msvcrt_free_mt_locks();
return FALSE;
}
msvcrt_init_io();
msvcrt_init_console();
msvcrt_init_args();
msvcrt_init_signals();
MSVCRT_setlocale(0, "C");
_setmbcp(_MB_CP_LOCALE);
TRACE("finished process init\n");
break;
......@@ -108,6 +114,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
msvcrt_free_tls_mem();
if (!msvcrt_free_tls())
return FALSE;
_free_locale(MSVCRT_locale);
TRACE("finished process free\n");
break;
case DLL_THREAD_DETACH:
......
......@@ -124,9 +124,7 @@ extern thread_data_t *msvcrt_get_thread_data(void);
extern int MSVCRT___lc_codepage;
extern int MSVCRT___lc_collate_cp;
extern int MSVCRT___mb_cur_max;
extern LCID MSVCRT_current_lc_all_lcid;
extern WORD MSVCRT__ctype [257];
extern WORD MSVCRT_current_ctype[257];
extern WORD* MSVCRT__pctype;
void msvcrt_set_errno(int);
......@@ -792,6 +790,9 @@ typedef struct MSVCRT_localeinfo_struct
MSVCRT_pthreadmbcinfo mbcinfo;
} MSVCRT__locale_tstruct, *MSVCRT__locale_t;
extern MSVCRT__locale_t MSVCRT_locale;
void __cdecl _free_locale(MSVCRT__locale_t);
#ifndef __WINE_MSVCRT_TEST
int __cdecl MSVCRT__write(int,const void*,unsigned int);
int __cdecl _getch(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment