msvcrt: Improve toupper_l implementation.
This commit is contained in:
parent
13f6194bb1
commit
28cc0b8bc1
|
@ -339,37 +339,42 @@ int CDECL MSVCRT___iscsymf(int c)
|
|||
int CDECL MSVCRT__toupper_l(int c, MSVCRT__locale_t locale)
|
||||
{
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
unsigned char str[2], *p = str;
|
||||
WCHAR wide, upper;
|
||||
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = locale->locinfo;
|
||||
|
||||
if(c < 256)
|
||||
return locinfo->pcumap[(unsigned char)c];
|
||||
if((unsigned)c < 256)
|
||||
return locinfo->pcumap[c];
|
||||
|
||||
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
|
||||
{
|
||||
WCHAR wide, upper;
|
||||
char str[2], *p = str;
|
||||
*p++ = (c>>8) & 255;
|
||||
*p++ = c & 255;
|
||||
else {
|
||||
*MSVCRT__errno() = MSVCRT_EILSEQ;
|
||||
str[1] = 0;
|
||||
}
|
||||
*p++ = c & 255;
|
||||
|
||||
if(!MultiByteToWideChar(locinfo->lc_codepage,
|
||||
MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
|
||||
return c;
|
||||
if(!MultiByteToWideChar(locinfo->lc_codepage,
|
||||
MB_ERR_INVALID_CHARS, (char*)str, p-str, &wide, 1))
|
||||
return c;
|
||||
|
||||
upper = toupperW(wide);
|
||||
if(upper == wide)
|
||||
return c;
|
||||
|
||||
WideCharToMultiByte(locinfo->lc_codepage, 0,
|
||||
&upper, 1, str, 2, NULL, NULL);
|
||||
upper = toupperW(wide);
|
||||
if(upper == wide)
|
||||
return str[0] + (str[1]<<8);
|
||||
|
||||
switch(WideCharToMultiByte(locinfo->lc_codepage, 0,
|
||||
&upper, 1, (char*)str, 2, NULL, NULL)) {
|
||||
case 0:
|
||||
return c;
|
||||
case 1:
|
||||
return str[0];
|
||||
default:
|
||||
return str[0] + (str[1]<<8);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
Loading…
Reference in New Issue