msvcrt: Use get_locinfo instead of get_locale.
This commit is contained in:
parent
11bfced55d
commit
6991ac0331
|
@ -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];
|
||||
|
|
|
@ -85,7 +85,7 @@ static MSVCRT_wchar_t msvcrt_mbc_to_wc(unsigned int ch)
|
|||
mbch[1] = ch & 0xff;
|
||||
n_chars = 2;
|
||||
}
|
||||
if (!MultiByteToWideChar(get_locale()->locinfo->lc_codepage, 0, mbch, n_chars, &chW, 1))
|
||||
if (!MultiByteToWideChar(get_locinfo()->lc_codepage, 0, mbch, n_chars, &chW, 1))
|
||||
{
|
||||
WARN("MultiByteToWideChar failed on %x\n", ch);
|
||||
return 0;
|
||||
|
@ -166,16 +166,20 @@ unsigned char* CDECL __p__mbctype(void)
|
|||
*/
|
||||
int* CDECL MSVCRT____mb_cur_max_func(void)
|
||||
{
|
||||
return &get_locale()->locinfo->mb_cur_max;
|
||||
return &get_locinfo()->mb_cur_max;
|
||||
}
|
||||
|
||||
/* ___mb_cur_max_l_func - not exported in native msvcrt */
|
||||
int* CDECL ___mb_cur_max_l_func(MSVCRT__locale_t locale)
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
return &locale->locinfo->mb_cur_max;
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
return &locinfo->mb_cur_max;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -183,7 +187,7 @@ int* CDECL ___mb_cur_max_l_func(MSVCRT__locale_t locale)
|
|||
*/
|
||||
int CDECL _setmbcp(int cp)
|
||||
{
|
||||
MSVCRT__locale_t locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo = get_locinfo();
|
||||
int newcp;
|
||||
CPINFO cpi;
|
||||
BYTE *bytes;
|
||||
|
@ -204,7 +208,7 @@ int CDECL _setmbcp(int cp)
|
|||
newcp = GetOEMCP();
|
||||
break;
|
||||
case _MB_CP_LOCALE:
|
||||
newcp = locale->locinfo->lc_codepage;
|
||||
newcp = locinfo->lc_codepage;
|
||||
break;
|
||||
case _MB_CP_SBCS:
|
||||
newcp = 20127; /* ASCII */
|
||||
|
@ -297,9 +301,9 @@ int CDECL _setmbcp(int cp)
|
|||
MSVCRT_mbctype[i + 1] |= _MS;
|
||||
}
|
||||
|
||||
locale->locinfo->lc_collate_cp = newcp;
|
||||
locale->locinfo->lc_codepage = newcp;
|
||||
TRACE("(%d) -> %d\n", cp, locale->locinfo->lc_codepage);
|
||||
locinfo->lc_collate_cp = newcp;
|
||||
locinfo->lc_codepage = newcp;
|
||||
TRACE("(%d) -> %d\n", cp, locinfo->lc_codepage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -308,8 +312,8 @@ int CDECL _setmbcp(int cp)
|
|||
*/
|
||||
int CDECL _getmbcp(void)
|
||||
{
|
||||
/* FIXME: get_locale()->mbcinfo->mbcodepage should be used here */
|
||||
return get_locale()->locinfo->lc_codepage;
|
||||
/* FIXME: get_mbcinfo()->mbcodepage should be used here */
|
||||
return get_locinfo()->lc_codepage;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -355,7 +359,7 @@ unsigned int CDECL _mbctombb(unsigned int c)
|
|||
{
|
||||
unsigned int value;
|
||||
|
||||
if(get_locale()->locinfo->lc_codepage == 932)
|
||||
if(get_locinfo()->lc_codepage == 932)
|
||||
{
|
||||
if(c >= 0x829f && c <= 0x82f1) /* Hiragana */
|
||||
return mbctombb_932_kana[c - 0x829f];
|
||||
|
@ -387,7 +391,7 @@ unsigned int CDECL _mbcjistojms(unsigned int c)
|
|||
{
|
||||
/* Conversion takes place only when codepage is 932.
|
||||
In all other cases, c is returned unchanged */
|
||||
if(get_locale()->locinfo->lc_codepage == 932)
|
||||
if(get_locinfo()->lc_codepage == 932)
|
||||
{
|
||||
if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
|
||||
LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
|
||||
|
@ -417,7 +421,7 @@ unsigned int CDECL _mbcjistojms(unsigned int c)
|
|||
*/
|
||||
unsigned char* CDECL _mbsdec(const unsigned char* start, const unsigned char* cur)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
return (unsigned char *)(_ismbstrail(start,cur-1) ? cur - 2 : cur -1);
|
||||
|
||||
return (unsigned char *)cur - 1; /* ASCII CP or SB char */
|
||||
|
@ -641,7 +645,7 @@ unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSV
|
|||
*/
|
||||
int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
do {
|
||||
|
@ -666,7 +670,7 @@ int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp)
|
|||
*/
|
||||
int CDECL _mbsicoll(const unsigned char* str, const unsigned char* cmp)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
do {
|
||||
|
@ -694,7 +698,7 @@ int CDECL _mbsicoll(const unsigned char* str, const unsigned char* cmp)
|
|||
*/
|
||||
int CDECL _mbscoll(const unsigned char* str, const unsigned char* cmp)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
do {
|
||||
|
@ -719,7 +723,7 @@ int CDECL _mbscoll(const unsigned char* str, const unsigned char* cmp)
|
|||
*/
|
||||
int CDECL _mbsicmp(const unsigned char* str, const unsigned char* cmp)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
do {
|
||||
|
@ -746,7 +750,7 @@ int CDECL _mbsncmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_si
|
|||
if(!len)
|
||||
return 0;
|
||||
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
while(len--)
|
||||
|
@ -776,7 +780,7 @@ int CDECL _mbsnbcmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_s
|
|||
{
|
||||
if (!len)
|
||||
return 0;
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
while (len)
|
||||
|
@ -819,7 +823,7 @@ int CDECL _mbsnbcmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_s
|
|||
int CDECL _mbsnicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
|
||||
{
|
||||
/* FIXME: No tolower() for mb strings yet */
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
while(len--)
|
||||
|
@ -847,7 +851,7 @@ int CDECL _mbsnbicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_
|
|||
{
|
||||
if (!len)
|
||||
return 0;
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int strc, cmpc;
|
||||
while (len)
|
||||
|
@ -917,7 +921,7 @@ unsigned char * CDECL _mbsstr(const unsigned char *haystack, const unsigned char
|
|||
*/
|
||||
unsigned char* CDECL _mbschr(const unsigned char* s, unsigned int x)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
while (1)
|
||||
|
@ -938,7 +942,7 @@ unsigned char* CDECL _mbschr(const unsigned char* s, unsigned int x)
|
|||
*/
|
||||
unsigned char* CDECL _mbsrchr(const unsigned char* s, unsigned int x)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
unsigned char* match=NULL;
|
||||
|
@ -966,7 +970,7 @@ unsigned char* CDECL _mbstok(unsigned char *str, const unsigned char *delim)
|
|||
thread_data_t *data = msvcrt_get_thread_data();
|
||||
unsigned char *ret;
|
||||
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
|
||||
|
@ -1018,7 +1022,7 @@ int CDECL MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
|
|||
*/
|
||||
unsigned int CDECL _mbbtombc(unsigned int c)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1 &&
|
||||
if(get_locinfo()->mb_cur_max > 1 &&
|
||||
((c >= 0x20 && c <=0x7e) ||(c >= 0xa1 && c <= 0xdf)))
|
||||
{
|
||||
/* FIXME: I can't get this function to return anything
|
||||
|
@ -1059,7 +1063,7 @@ int CDECL _mbbtype(unsigned char c, int type)
|
|||
int CDECL _ismbbkana(unsigned int c)
|
||||
{
|
||||
/* FIXME: use lc_ctype when supported, not lc_all */
|
||||
if(get_locale()->locinfo->lc_codepage == 932)
|
||||
if(get_locinfo()->lc_codepage == 932)
|
||||
{
|
||||
/* Japanese/Katakana, CP 932 */
|
||||
return (c >= 0xa1 && c <= 0xdf);
|
||||
|
@ -1169,7 +1173,7 @@ int CDECL _ismbcpunct(unsigned int ch)
|
|||
int CDECL _ismbchira(unsigned int c)
|
||||
{
|
||||
/* FIXME: use lc_ctype when supported, not lc_all */
|
||||
if(get_locale()->locinfo->lc_codepage == 932)
|
||||
if(get_locinfo()->lc_codepage == 932)
|
||||
{
|
||||
/* Japanese/Hiragana, CP 932 */
|
||||
return (c >= 0x829f && c <= 0x82f1);
|
||||
|
@ -1183,7 +1187,7 @@ int CDECL _ismbchira(unsigned int c)
|
|||
int CDECL _ismbckata(unsigned int c)
|
||||
{
|
||||
/* FIXME: use lc_ctype when supported, not lc_all */
|
||||
if(get_locale()->locinfo->lc_codepage == 932)
|
||||
if(get_locinfo()->lc_codepage == 932)
|
||||
{
|
||||
if(c < 256)
|
||||
return _ismbbkana(c);
|
||||
|
@ -1292,7 +1296,7 @@ unsigned char* CDECL _mbsset(unsigned char* str, unsigned int c)
|
|||
{
|
||||
unsigned char* ret = str;
|
||||
|
||||
if(get_locale()->locinfo->mb_cur_max == 1 || c < 256)
|
||||
if(get_locinfo()->mb_cur_max == 1 || c < 256)
|
||||
return u__strset(str, c); /* ASCII CP or SB char */
|
||||
|
||||
c &= 0xffff; /* Strip high bits */
|
||||
|
@ -1318,7 +1322,7 @@ unsigned char* CDECL _mbsnbset(unsigned char *str, unsigned int c, MSVCRT_size_t
|
|||
if(!len)
|
||||
return ret;
|
||||
|
||||
if(get_locale()->locinfo->mb_cur_max == 1 || c < 256)
|
||||
if(get_locinfo()->mb_cur_max == 1 || c < 256)
|
||||
return u__strnset(str, c, len); /* ASCII CP or SB char */
|
||||
|
||||
c &= 0xffff; /* Strip high bits */
|
||||
|
@ -1348,7 +1352,7 @@ unsigned char* CDECL _mbsnset(unsigned char* str, unsigned int c, MSVCRT_size_t
|
|||
if(!len)
|
||||
return ret;
|
||||
|
||||
if(get_locale()->locinfo->mb_cur_max == 1 || c < 256)
|
||||
if(get_locinfo()->mb_cur_max == 1 || c < 256)
|
||||
return u__strnset(str, c, len); /* ASCII CP or SB char */
|
||||
|
||||
c &= 0xffff; /* Strip high bits */
|
||||
|
@ -1371,7 +1375,7 @@ unsigned char* CDECL _mbsnset(unsigned char* str, unsigned int c, MSVCRT_size_t
|
|||
MSVCRT_size_t CDECL _mbsnccnt(const unsigned char* str, MSVCRT_size_t len)
|
||||
{
|
||||
MSVCRT_size_t ret;
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
ret=0;
|
||||
while(*str && len-- > 0)
|
||||
|
@ -1399,7 +1403,7 @@ MSVCRT_size_t CDECL _mbsnccnt(const unsigned char* str, MSVCRT_size_t len)
|
|||
MSVCRT_size_t CDECL _mbsnbcnt(const unsigned char* str, MSVCRT_size_t len)
|
||||
{
|
||||
MSVCRT_size_t ret;
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
const unsigned char* xstr = str;
|
||||
while(*xstr && len-- > 0)
|
||||
|
@ -1418,7 +1422,7 @@ MSVCRT_size_t CDECL _mbsnbcnt(const unsigned char* str, MSVCRT_size_t len)
|
|||
*/
|
||||
unsigned char* CDECL _mbsnbcat(unsigned char* dst, const unsigned char* src, MSVCRT_size_t len)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned char *res = dst;
|
||||
while (*dst) {
|
||||
|
@ -1469,7 +1473,7 @@ int CDECL _mbsnbcat_s(unsigned char *dst, MSVCRT_size_t size, const unsigned cha
|
|||
|
||||
/* If necessary, check that the character preceding the null terminator is
|
||||
* a lead byte and move the pointer back by one for later overwrite. */
|
||||
if (ptr != dst && get_locale()->locinfo->mb_cur_max > 1 && MSVCRT_isleadbyte(*(ptr - 1)))
|
||||
if (ptr != dst && get_locinfo()->mb_cur_max > 1 && MSVCRT_isleadbyte(*(ptr - 1)))
|
||||
size++, ptr--;
|
||||
|
||||
for (i = 0; *src && i < len; i++)
|
||||
|
@ -1494,7 +1498,7 @@ int CDECL _mbsnbcat_s(unsigned char *dst, MSVCRT_size_t size, const unsigned cha
|
|||
*/
|
||||
unsigned char* CDECL _mbsncat(unsigned char* dst, const unsigned char* src, MSVCRT_size_t len)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
||||
if(get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned char *res = dst;
|
||||
while (*dst)
|
||||
|
@ -1523,7 +1527,7 @@ unsigned char* CDECL _mbslwr(unsigned char* s)
|
|||
unsigned char *ret = s;
|
||||
if (!s)
|
||||
return NULL;
|
||||
if (get_locale()->locinfo->mb_cur_max > 1)
|
||||
if (get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
while (*s)
|
||||
|
@ -1557,7 +1561,7 @@ int CDECL _mbslwr_s(unsigned char* s, MSVCRT_size_t len)
|
|||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (get_locale()->locinfo->mb_cur_max > 1)
|
||||
if (get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
for ( ; *s && len > 0; len--)
|
||||
|
@ -1591,7 +1595,7 @@ unsigned char* CDECL _mbsupr(unsigned char* s)
|
|||
unsigned char *ret = s;
|
||||
if (!s)
|
||||
return NULL;
|
||||
if (get_locale()->locinfo->mb_cur_max > 1)
|
||||
if (get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
while (*s)
|
||||
|
@ -1625,7 +1629,7 @@ int CDECL _mbsupr_s(unsigned char* s, MSVCRT_size_t len)
|
|||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (get_locale()->locinfo->mb_cur_max > 1)
|
||||
if (get_locinfo()->mb_cur_max > 1)
|
||||
{
|
||||
unsigned int c;
|
||||
for ( ; *s && len > 0; len--)
|
||||
|
@ -1722,7 +1726,7 @@ unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned char*
|
|||
*/
|
||||
MSVCRT_size_t CDECL _mbscspn(const unsigned char* str, const unsigned char* cmp)
|
||||
{
|
||||
if (get_locale()->locinfo->mb_cur_max > 1)
|
||||
if (get_locinfo()->mb_cur_max > 1)
|
||||
FIXME("don't handle double character case\n");
|
||||
return u_strcspn(str, cmp);
|
||||
}
|
||||
|
@ -1809,7 +1813,7 @@ int CDECL MSVCRT_mblen(const char* str, MSVCRT_size_t size)
|
|||
{
|
||||
if (str && *str && size)
|
||||
{
|
||||
if(get_locale()->locinfo->mb_cur_max == 1)
|
||||
if(get_locinfo()->mb_cur_max == 1)
|
||||
return 1; /* ASCII CP */
|
||||
|
||||
return !MSVCRT_isleadbyte(*str) ? 1 : (size>1 ? 2 : -1);
|
||||
|
@ -1822,10 +1826,14 @@ int CDECL MSVCRT_mblen(const char* str, MSVCRT_size_t size)
|
|||
*/
|
||||
MSVCRT_size_t CDECL _mbstrlen_l(const char* str, MSVCRT__locale_t locale)
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
if(locale->locinfo->mb_cur_max > 1) {
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
if(locinfo->mb_cur_max > 1) {
|
||||
MSVCRT_size_t len = 0;
|
||||
while(*str) {
|
||||
/* FIXME: According to the documentation we are supposed to test for
|
||||
|
@ -1854,14 +1862,17 @@ MSVCRT_size_t CDECL _mbstrlen(const char* str)
|
|||
MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
|
||||
MSVCRT_size_t count, MSVCRT__locale_t locale)
|
||||
{
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
MSVCRT_size_t i, size;
|
||||
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
/* Ignore count parameter */
|
||||
if(!wcstr)
|
||||
return MultiByteToWideChar(locale->locinfo->lc_codepage, 0, mbstr, -1, NULL, 0)-1;
|
||||
return MultiByteToWideChar(locinfo->lc_codepage, 0, mbstr, -1, NULL, 0)-1;
|
||||
|
||||
for(i=0, size=0; i<count; i++) {
|
||||
if(mbstr[size] == '\0')
|
||||
|
@ -1870,7 +1881,7 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
|
|||
size += (MSVCRT_isleadbyte(mbstr[size]) ? 2 : 1);
|
||||
}
|
||||
|
||||
size = MultiByteToWideChar(locale->locinfo->lc_codepage, 0,
|
||||
size = MultiByteToWideChar(locinfo->lc_codepage, 0,
|
||||
mbstr, size, wcstr, count);
|
||||
|
||||
if(size<count && wcstr)
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, -1, str2, -1)-2;
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
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 )
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
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 )
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], 0, str1, count, str2, count)-2;
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
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 )
|
||||
{
|
||||
if(!locale)
|
||||
locale = get_locale();
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
||||
return CompareStringA(locale->locinfo->lc_handle[MSVCRT_LC_CTYPE], NORM_IGNORECASE,
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
Loading…
Reference in New Issue