Piotr Caban : msvcrt: Improve toupper_l implementation.
Alexandre Julliard
julliard at winehq.org
Thu Mar 13 14:40:35 CDT 2014
Module: wine
Branch: master
Commit: 28cc0b8bc15e78a66fe2ea6692cd08ba843aa8db
URL: http://source.winehq.org/git/wine.git/?a=commit;h=28cc0b8bc15e78a66fe2ea6692cd08ba843aa8db
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Mar 13 14:13:02 2014 +0100
msvcrt: Improve toupper_l implementation.
---
dlls/msvcrt/ctype.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/dlls/msvcrt/ctype.c b/dlls/msvcrt/ctype.c
index c486f8e..8b9d14c 100644
--- a/dlls/msvcrt/ctype.c
+++ b/dlls/msvcrt/ctype.c
@@ -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;
-
- if(!MultiByteToWideChar(locinfo->lc_codepage,
- MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
- return c;
+ else {
+ *MSVCRT__errno() = MSVCRT_EILSEQ;
+ str[1] = 0;
+ }
+ *p++ = c & 255;
- upper = toupperW(wide);
- if(upper == wide)
- return c;
+ if(!MultiByteToWideChar(locinfo->lc_codepage,
+ MB_ERR_INVALID_CHARS, (char*)str, p-str, &wide, 1))
+ 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;
}
/*********************************************************************
More information about the wine-cvs
mailing list