Commit 6991ac03 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Use get_locinfo instead of get_locale.

parent 11bfced5
......@@ -63,7 +63,7 @@ unsigned short *MSVCRT__pctype = NULL;
*/
const unsigned short* CDECL MSVCRT___pctype_func(void)
{
return get_locale()->locinfo->pctype;
return get_locinfo()->pctype;
}
/*********************************************************************
......@@ -71,24 +71,28 @@ const unsigned short* CDECL MSVCRT___pctype_func(void)
*/
int CDECL _isctype_l(int c, int type, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if (c >= -1 && c <= 255)
return locale->locinfo->pctype[c] & type;
return locinfo->pctype[c] & type;
if (locale->locinfo->mb_cur_max != 1 && c > 0)
if (locinfo->mb_cur_max != 1 && c > 0)
{
/* FIXME: Is there a faster way to do this? */
WORD typeInfo;
char convert[3], *pconv = convert;
if (locale->locinfo->pctype[(UINT)c >> 8] & MSVCRT__LEADBYTE)
if (locinfo->pctype[(UINT)c >> 8] & MSVCRT__LEADBYTE)
*pconv++ = (UINT)c >> 8;
*pconv++ = c & 0xff;
*pconv = 0;
if (GetStringTypeExA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE],
if (GetStringTypeExA(locinfo->lc_handle[MSVCRT_LC_CTYPE],
CT_CTYPE1, convert, convert[1] ? 2 : 1, &typeInfo))
return typeInfo & type;
}
......@@ -333,20 +337,24 @@ int CDECL MSVCRT___iscsymf(int c)
*/
int CDECL MSVCRT__toupper_l(int c, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if(c < 256)
return locale->locinfo->pcumap[c];
return locinfo->pcumap[c];
if(locale->locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
{
WCHAR wide, upper;
char str[2], *p = str;
*p++ = (c>>8) & 255;
*p++ = c & 255;
if(!MultiByteToWideChar(locale->locinfo->lc_codepage,
if(!MultiByteToWideChar(locinfo->lc_codepage,
MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
return c;
......@@ -354,7 +362,7 @@ int CDECL MSVCRT__toupper_l(int c, MSVCRT__locale_t locale)
if(upper == wide)
return c;
WideCharToMultiByte(locale->locinfo->lc_codepage, 0,
WideCharToMultiByte(locinfo->lc_codepage, 0,
&upper, 1, str, 2, NULL, NULL);
return str[0] + (str[1]<<8);
......@@ -384,20 +392,24 @@ int CDECL MSVCRT__toupper(int c)
*/
int CDECL MSVCRT__tolower_l(int c, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if(c < 256)
return locale->locinfo->pclmap[c];
return locinfo->pclmap[c];
if(locale->locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
{
WCHAR wide, upper;
char str[2], *p = str;
*p++ = (c>>8) & 255;
*p++ = c & 255;
if(!MultiByteToWideChar(locale->locinfo->lc_codepage,
if(!MultiByteToWideChar(locinfo->lc_codepage,
MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
return c;
......@@ -405,7 +417,7 @@ int CDECL MSVCRT__tolower_l(int c, MSVCRT__locale_t locale)
if(upper == wide)
return c;
WideCharToMultiByte(locale->locinfo->lc_codepage, 0,
WideCharToMultiByte(locinfo->lc_codepage, 0,
&upper, 1, str, 2, NULL, NULL);
return str[0] + (str[1]<<8);
......
......@@ -2792,7 +2792,7 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file)
}
c = MSVCRT_fgetc(file);
if ((get_locale()->locinfo->mb_cur_max > 1) && MSVCRT_isleadbyte(c))
if ((get_locinfo()->mb_cur_max > 1) && MSVCRT_isleadbyte(c))
{
FIXME("Treat Multibyte characters\n");
}
......
......@@ -354,7 +354,7 @@ static inline void swap_pointers(void **p1, void **p2) {
}
/* INTERNAL: returns _locale_t struct for current locale */
MSVCRT__locale_t get_locale(void) {
static MSVCRT__locale_t get_locale(void) {
thread_data_t *data = msvcrt_get_thread_data();
if(!data || !data->locale)
......@@ -363,6 +363,16 @@ MSVCRT__locale_t get_locale(void) {
return data->locale;
}
/* INTERNAL: returns pthreadlocinfo struct */
MSVCRT_pthreadlocinfo get_locinfo(void) {
thread_data_t *data = msvcrt_get_thread_data();
if(!data || !data->locale)
return MSVCRT_locale->locinfo;
return data->locale->locinfo;
}
/* INTERNAL: constructs string returned by setlocale */
static inline char* construct_lc_all(MSVCRT__locale_t cur) {
static char current_lc_all[MAX_LOCALE_LENGTH];
......
......@@ -877,7 +877,7 @@ typedef struct MSVCRT_localeinfo_struct
extern MSVCRT__locale_t MSVCRT_locale;
MSVCRT__locale_t MSVCRT__create_locale(int, const char*);
MSVCRT__locale_t get_locale(void);
MSVCRT_pthreadlocinfo get_locinfo(void);
void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
#ifndef __WINE_MSVCRT_TEST
......
......@@ -111,19 +111,19 @@ static inline int FUNC_NAME(pf_fill)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ct
}
static inline int FUNC_NAME(pf_output_wstr)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx,
const MSVCRT_wchar_t *str, int len, MSVCRT__locale_t locale)
const MSVCRT_wchar_t *str, int len, MSVCRT_pthreadlocinfo locinfo)
{
#ifdef PRINTF_WIDE
return pf_puts(puts_ctx, len, str);
#else
LPSTR out;
int len_a = WideCharToMultiByte(locale->locinfo->lc_codepage, 0, str, len, NULL, 0, NULL, NULL);
int len_a = WideCharToMultiByte(locinfo->lc_codepage, 0, str, len, NULL, 0, NULL, NULL);
out = HeapAlloc(GetProcessHeap(), 0, len_a);
if(!out)
return -1;
WideCharToMultiByte(locale->locinfo->lc_codepage, 0, str, len, out, len_a, NULL, NULL);
WideCharToMultiByte(locinfo->lc_codepage, 0, str, len, out, len_a, NULL, NULL);
len = pf_puts(puts_ctx, len_a, out);
HeapFree(GetProcessHeap(), 0, out);
return len;
......@@ -131,17 +131,17 @@ static inline int FUNC_NAME(pf_output_wstr)(FUNC_NAME(puts_clbk) pf_puts, void *
}
static inline int FUNC_NAME(pf_output_str)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx,
const char *str, int len, MSVCRT__locale_t locale)
const char *str, int len, MSVCRT_pthreadlocinfo locinfo)
{
#ifdef PRINTF_WIDE
LPWSTR out;
int len_w = MultiByteToWideChar(locale->locinfo->lc_codepage, 0, str, len, NULL, 0);
int len_w = MultiByteToWideChar(locinfo->lc_codepage, 0, str, len, NULL, 0);
out = HeapAlloc(GetProcessHeap(), 0, len_w*sizeof(WCHAR));
if(!out)
return -1;
MultiByteToWideChar(locale->locinfo->lc_codepage, 0, str, len, out, len_w);
MultiByteToWideChar(locinfo->lc_codepage, 0, str, len, out, len_w);
len = pf_puts(puts_ctx, len_w, out);
HeapFree(GetProcessHeap(), 0, out);
return len;
......@@ -151,7 +151,7 @@ static inline int FUNC_NAME(pf_output_str)(FUNC_NAME(puts_clbk) pf_puts, void *p
}
static inline int FUNC_NAME(pf_output_format_wstr)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx,
const MSVCRT_wchar_t *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT__locale_t locale)
const MSVCRT_wchar_t *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT_pthreadlocinfo locinfo)
{
int r, ret;
......@@ -164,7 +164,7 @@ static inline int FUNC_NAME(pf_output_format_wstr)(FUNC_NAME(puts_clbk) pf_puts,
r = FUNC_NAME(pf_fill)(pf_puts, puts_ctx, len, flags, TRUE);
ret = r;
if(r >= 0) {
r = FUNC_NAME(pf_output_wstr)(pf_puts, puts_ctx, str, len, locale);
r = FUNC_NAME(pf_output_wstr)(pf_puts, puts_ctx, str, len, locinfo);
ret += r;
}
if(r >= 0) {
......@@ -176,7 +176,7 @@ static inline int FUNC_NAME(pf_output_format_wstr)(FUNC_NAME(puts_clbk) pf_puts,
}
static inline int FUNC_NAME(pf_output_format_str)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx,
const char *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT__locale_t locale)
const char *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT_pthreadlocinfo locinfo)
{
int r, ret;
......@@ -189,7 +189,7 @@ static inline int FUNC_NAME(pf_output_format_str)(FUNC_NAME(puts_clbk) pf_puts,
r = FUNC_NAME(pf_fill)(pf_puts, puts_ctx, len, flags, TRUE);
ret = r;
if(r >= 0) {
r = FUNC_NAME(pf_output_str)(pf_puts, puts_ctx, str, len, locale);
r = FUNC_NAME(pf_output_str)(pf_puts, puts_ctx, str, len, locinfo);
ret += r;
}
if(r >= 0) {
......@@ -201,27 +201,27 @@ static inline int FUNC_NAME(pf_output_format_str)(FUNC_NAME(puts_clbk) pf_puts,
}
static inline int FUNC_NAME(pf_handle_string)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx,
const void *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT__locale_t locale)
const void *str, int len, FUNC_NAME(pf_flags) *flags, MSVCRT_pthreadlocinfo locinfo)
{
#ifdef PRINTF_WIDE
static const MSVCRT_wchar_t nullW[] = {'(','n','u','l','l',')',0};
if(!str)
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, nullW, 6, flags, locale);
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, nullW, 6, flags, locinfo);
#else
if(!str)
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, "(null)", 6, flags, locale);
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, "(null)", 6, flags, locinfo);
#endif
if(flags->WideString || flags->IntegerLength=='l')
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, str, len, flags, locale);
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, str, len, flags, locinfo);
if(flags->IntegerLength == 'h')
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, str, len, flags, locale);
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, str, len, flags, locinfo);
if((flags->Format=='S' || flags->Format=='C') == (sizeof(APICHAR)==sizeof(MSVCRT_wchar_t)))
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, str, len, flags, locale);
return FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, str, len, flags, locinfo);
else
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, str, len, flags, locale);
return FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, str, len, flags, locinfo);
}
static inline void FUNC_NAME(pf_rebuild_format_string)(char *p, FUNC_NAME(pf_flags) *flags)
......@@ -339,6 +339,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
MSVCRT__locale_t locale, BOOL positional_params, BOOL invoke_invalid_param_handler,
args_clbk pf_args, void *args_ctx, __ms_va_list *valist)
{
MSVCRT_pthreadlocinfo locinfo;
const APICHAR *q, *p = fmt;
APICHAR buf[32];
int written = 0, pos, i;
......@@ -347,7 +348,9 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
TRACE("Format is: %s\n", FUNC_NAME(debugstr)(fmt));
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
while(*p) {
/* output characters before '%' */
......@@ -467,14 +470,14 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
if(flags.Format == 's' || flags.Format == 'S') {
i = FUNC_NAME(pf_handle_string)(pf_puts, puts_ctx,
pf_args(args_ctx, pos, VT_PTR, valist).get_ptr,
-1, &flags, locale);
-1, &flags, locinfo);
} else if(flags.Format == 'c' || flags.Format == 'C') {
int ch = pf_args(args_ctx, pos, VT_INT, valist).get_int;
if((ch&0xff) != ch)
FIXME("multibyte characters printing not supported\n");
i = FUNC_NAME(pf_handle_string)(pf_puts, puts_ctx, &ch, 1, &flags, locale);
i = FUNC_NAME(pf_handle_string)(pf_puts, puts_ctx, &ch, 1, &flags, locinfo);
} else if(flags.Format == 'p') {
flags.Format = 'X';
flags.PadZero = '0';
......@@ -486,9 +489,9 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
flags.Precision = i;
#ifdef PRINTF_WIDE
i = FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, buf, -1, &flags, locale);
i = FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, buf, -1, &flags, locinfo);
#else
i = FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, buf, -1, &flags, locale);
i = FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, buf, -1, &flags, locinfo);
#endif
} else if(flags.Format == 'n') {
int *used;
......@@ -522,9 +525,9 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
args_ctx, pos, VT_INT, valist).get_int);
#ifdef PRINTF_WIDE
i = FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, tmp, -1, &flags, locale);
i = FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, tmp, -1, &flags, locinfo);
#else
i = FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, tmp, -1, &flags, locale);
i = FUNC_NAME(pf_output_format_str)(pf_puts, puts_ctx, tmp, -1, &flags, locinfo);
#endif
if(tmp != buf)
HeapFree(GetProcessHeap(), 0, tmp);
......@@ -545,9 +548,9 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
decimal_point = strchr(tmp, '.');
if(decimal_point)
*decimal_point = *locale->locinfo->lconv->decimal_point;
*decimal_point = *locinfo->lconv->decimal_point;
i = FUNC_NAME(pf_output_str)(pf_puts, puts_ctx, tmp, strlen(tmp), locale);
i = FUNC_NAME(pf_output_str)(pf_puts, puts_ctx, tmp, strlen(tmp), locinfo);
if(tmp != buf_a)
HeapFree(GetProcessHeap(), 0, tmp);
} else {
......
......@@ -130,6 +130,7 @@
#endif /* CONSOLE */
_FUNCTION_ {
MSVCRT_pthreadlocinfo locinfo;
int rd = 0, consumed = 0;
int nch;
if (!*format) return 0;
......@@ -153,7 +154,9 @@ _FUNCTION_ {
}
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
while (*format) {
/* a whitespace character in the format string causes scanf to read,
......@@ -314,7 +317,7 @@ _FUNCTION_ {
nch = _GETC_(file);
}
/* get first digit. */
if (*locale->locinfo->lconv->decimal_point != nch) {
if (*locinfo->lconv->decimal_point != nch) {
if (!_ISDIGIT_(nch)) break;
cur = (nch - '0');
nch = _GETC_(file);
......@@ -329,7 +332,7 @@ _FUNCTION_ {
cur = 0; /* Fix: .8 -> 0.8 */
}
/* handle decimals */
if (width!=0 && nch == *locale->locinfo->lconv->decimal_point) {
if (width!=0 && nch == *locinfo->lconv->decimal_point) {
long double dec = 1;
nch = _GETC_(file);
if (width>0) width--;
......
......@@ -58,9 +58,6 @@ int CDECL _strlwr_s_l(char *str, MSVCRT_size_t len, MSVCRT__locale_t locale)
{
char *ptr = str;
if(!locale)
locale = get_locale();
if (!str || !len)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
......@@ -122,9 +119,6 @@ int CDECL _strupr_s_l(char *str, MSVCRT_size_t len, MSVCRT__locale_t locale)
{
char *ptr = str;
if(!locale)
locale = get_locale();
if (!str || !len)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
......@@ -293,6 +287,7 @@ void CDECL MSVCRT__swab(char* src, char* dst, int len)
*/
double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
unsigned __int64 d=0, hlp;
unsigned fpcontrol;
int exp=0, sign=1;
......@@ -306,7 +301,9 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
}
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
/* FIXME: use *_l functions */
p = str;
......@@ -333,7 +330,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
p++;
}
if(*p == *locale->locinfo->lconv->decimal_point)
if(*p == *locinfo->lconv->decimal_point)
p++;
while(isdigit(*p)) {
......@@ -431,6 +428,7 @@ double CDECL MSVCRT__atof_l( const char *str, MSVCRT__locale_t locale)
*/
int CDECL MSVCRT__atoflt_l( MSVCRT__CRT_FLOAT *value, char *str, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
unsigned __int64 d=0, hlp;
unsigned fpcontrol;
int exp=0, sign=1;
......@@ -439,7 +437,9 @@ int CDECL MSVCRT__atoflt_l( MSVCRT__CRT_FLOAT *value, char *str, MSVCRT__locale_
BOOL found_digit = FALSE;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
/* FIXME: use *_l functions */
p = str;
......@@ -466,7 +466,7 @@ int CDECL MSVCRT__atoflt_l( MSVCRT__CRT_FLOAT *value, char *str, MSVCRT__locale_
p++;
}
if(*p == *locale->locinfo->lconv->decimal_point)
if(*p == *locinfo->lconv->decimal_point)
p++;
while(isdigit(*p)) {
......@@ -536,10 +536,14 @@ int CDECL MSVCRT__atoflt_l( MSVCRT__CRT_FLOAT *value, char *str, MSVCRT__locale_
*/
int CDECL MSVCRT_strcoll_l( const char* str1, const char* str2, MSVCRT__locale_t locale )
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, -1, str2, -1)-2;
return CompareStringA(locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, -1, str2, -1)-2;
}
/*********************************************************************
......@@ -555,10 +559,14 @@ int CDECL MSVCRT_strcoll( const char* str1, const char* str2 )
*/
int CDECL MSVCRT__stricoll_l( const char* str1, const char* str2, MSVCRT__locale_t locale )
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
return CompareStringA(locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
str1, -1, str2, -1)-2;
}
......@@ -575,10 +583,14 @@ int CDECL MSVCRT__stricoll( const char* str1, const char* str2 )
*/
int CDECL MSVCRT_strncoll_l( const char* str1, const char* str2, MSVCRT_size_t count, MSVCRT__locale_t locale )
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, count, str2, count)-2;
return CompareStringA(locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, count, str2, count)-2;
}
/*********************************************************************
......@@ -594,10 +606,14 @@ int CDECL MSVCRT_strncoll( const char* str1, const char* str2, MSVCRT_size_t cou
*/
int CDECL MSVCRT__strnicoll_l( const char* str1, const char* str2, MSVCRT_size_t count, MSVCRT__locale_t locale )
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
return CompareStringA(locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
str1, count, str2, count)-2;
}
......
......@@ -196,6 +196,7 @@ int CDECL MSVCRT__wcslwr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n )
double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
unsigned __int64 d=0, hlp;
unsigned fpcontrol;
int exp=0, sign=1;
......@@ -209,7 +210,9 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
}
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
p = str;
while(isspaceW(*p))
......@@ -234,7 +237,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
exp++;
p++;
}
if(*p == *locale->locinfo->lconv->decimal_point)
if(*p == *locinfo->lconv->decimal_point)
p++;
while(isdigitW(*p)) {
......@@ -309,22 +312,25 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
static MSVCRT_size_t CDECL MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t **wcstr,
MSVCRT_size_t count, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
char default_char = '\0';
MSVCRT_size_t tmp = 0;
BOOL used_default;
if(!locale)
locale = get_locale();
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if(!mbstr)
return WideCharToMultiByte(locale->locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
return WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
*wcstr, -1, NULL, 0, &default_char, &used_default)-1;
while(**wcstr) {
char buf[3];
MSVCRT_size_t i, size;
size = WideCharToMultiByte(locale->locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
*wcstr, 1, buf, 3, &default_char, &used_default);
if(used_default)
return -1;
......@@ -1020,11 +1026,10 @@ MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t
*/
INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
{
MSVCRT__locale_t locale = get_locale();
char out;
BOOL error;
if(WideCharToMultiByte( locale->locinfo->lc_codepage, 0, &wchar, 1, &out, 1, NULL, &error ) && !error)
if(WideCharToMultiByte( get_locinfo()->lc_codepage, 0, &wchar, 1, &out, 1, NULL, &error ) && !error)
return (INT)out;
return MSVCRT_EOF;
}
......@@ -1034,8 +1039,7 @@ INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
*/
INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
{
MSVCRT__locale_t locale = get_locale();
return WideCharToMultiByte( locale->locinfo->lc_codepage, 0, &ch, 1, dst, 6, NULL, NULL );
return WideCharToMultiByte( get_locinfo()->lc_codepage, 0, &ch, 1, dst, 6, NULL, NULL );
}
/*********************************************************************
......
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