msvcrt: Use _create_locale instead of setlocale during initialization.

This commit is contained in:
Piotr Caban 2011-05-24 17:22:23 +02:00 committed by Alexandre Julliard
parent 093909cf88
commit 11bfced55d
3 changed files with 39 additions and 39 deletions

View File

@ -1079,43 +1079,6 @@ MSVCRT__locale_t MSVCRT__create_locale(int category, const char *locale)
return loc;
}
/* _configthreadlocale - not exported in native msvcrt */
int CDECL _configthreadlocale(int type)
{
thread_data_t *data = msvcrt_get_thread_data();
int ret;
if(!data)
return -1;
ret = (data->locale ? MSVCRT__ENABLE_PER_THREAD_LOCALE : MSVCRT__DISABLE_PER_THREAD_LOCALE);
if(type == MSVCRT__ENABLE_PER_THREAD_LOCALE) {
if(!data->locale) {
/* Copy current global locale */
data->locale = MSVCRT__create_locale(MSVCRT_LC_ALL, MSVCRT_setlocale(MSVCRT_LC_ALL, NULL));
if(!data->locale)
return -1;
}
return ret;
}
if(type == MSVCRT__DISABLE_PER_THREAD_LOCALE) {
if(data->locale) {
MSVCRT__free_locale(data->locale);
data->locale = NULL;
}
return ret;
}
if(!type)
return ret;
return -1;
}
/*********************************************************************
* setlocale (MSVCRT.@)
*/
@ -1262,3 +1225,40 @@ char* CDECL MSVCRT_setlocale(int category, const char* locale)
return cur->locinfo->lc_category[category].locale;
}
/* _configthreadlocale - not exported in native msvcrt */
int CDECL _configthreadlocale(int type)
{
thread_data_t *data = msvcrt_get_thread_data();
int ret;
if(!data)
return -1;
ret = (data->locale ? MSVCRT__ENABLE_PER_THREAD_LOCALE : MSVCRT__DISABLE_PER_THREAD_LOCALE);
if(type == MSVCRT__ENABLE_PER_THREAD_LOCALE) {
if(!data->locale) {
/* Copy current global locale */
data->locale = MSVCRT__create_locale(MSVCRT_LC_ALL, MSVCRT_setlocale(MSVCRT_LC_ALL, NULL));
if(!data->locale)
return -1;
}
return ret;
}
if(type == MSVCRT__DISABLE_PER_THREAD_LOCALE) {
if(data->locale) {
MSVCRT__free_locale(data->locale);
data->locale = NULL;
}
return ret;
}
if(!type)
return ret;
return -1;
}

View File

@ -93,7 +93,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
if (!msvcrt_init_tls())
return FALSE;
msvcrt_init_mt_locks();
if(!MSVCRT_setlocale(0, "C")) {
if(!(MSVCRT_locale = MSVCRT__create_locale(0, "C"))) {
msvcrt_free_mt_locks();
msvcrt_free_tls_mem();
return FALSE;

View File

@ -805,7 +805,6 @@ void __cdecl MSVCRT_abort(void);
MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);
int* __cdecl MSVCRT__errno(void);
char* __cdecl MSVCRT_getenv(const char*);
char* __cdecl MSVCRT_setlocale(int,const char*);
int __cdecl MSVCRT_fclose(MSVCRT_FILE*);
void __cdecl MSVCRT_terminate(void);
MSVCRT_FILE* __cdecl MSVCRT__iob_func(void);
@ -877,6 +876,7 @@ typedef struct MSVCRT_localeinfo_struct
#define MSVCRT__DISABLE_PER_THREAD_LOCALE 2
extern MSVCRT__locale_t MSVCRT_locale;
MSVCRT__locale_t MSVCRT__create_locale(int, const char*);
MSVCRT__locale_t get_locale(void);
void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);