Alexandre Julliard : kernelbase: Don't use towlower() on the full Unicode character range.
Alexandre Julliard
julliard at winehq.org
Wed Mar 11 17:38:30 CDT 2020
Module: wine
Branch: master
Commit: 1a9ddc37590664b8710c19d487f92f86ded34dfe
URL: https://source.winehq.org/git/wine.git/?a=commit;h=1a9ddc37590664b8710c19d487f92f86ded34dfe
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Mar 9 15:14:44 2020 +0100
kernelbase: Don't use towlower() on the full Unicode character range.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/path.c | 17 +++++++----------
dlls/kernelbase/string.c | 8 +++++---
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index 93446815f2..0e0c3f3dbd 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -1652,7 +1652,7 @@ int WINAPI PathCommonPrefixW(const WCHAR *file1, const WCHAR *file2, WCHAR *path
if ((!*iter1 || *iter1 == '\\') && (!*iter2 || *iter2 == '\\'))
len = iter1 - file1; /* Common to this point */
- if (!*iter1 || (towlower(*iter1) != towlower(*iter2)))
+ if (!*iter1 || (towupper(*iter1) != towupper(*iter2)))
break; /* Strings differ at this point */
iter1++;
@@ -1813,8 +1813,6 @@ int WINAPI PathGetDriveNumberA(const char *path)
int WINAPI PathGetDriveNumberW(const WCHAR *path)
{
- WCHAR drive;
-
TRACE("%s\n", wine_dbgstr_w(path));
if (!path)
@@ -1822,11 +1820,10 @@ int WINAPI PathGetDriveNumberW(const WCHAR *path)
if (!wcsncmp(path, L"\\\\?\\", 4)) path += 4;
- drive = towlower(path[0]);
- if (drive < 'a' || drive > 'z' || path[1] != ':')
- return -1;
-
- return drive - 'a';
+ if (!path[0] || path[1] != ':') return -1;
+ if (path[0] >= 'A' && path[0] <= 'Z') return path[0] - 'A';
+ if (path[0] >= 'a' && path[0] <= 'z') return path[0] - 'a';
+ return -1;
}
BOOL WINAPI PathIsFileSpecA(const char *path)
@@ -4733,7 +4730,7 @@ HRESULT WINAPI UrlCombineW(const WCHAR *baseW, const WCHAR *relativeW, WCHAR *co
work = (LPWSTR)base.pszProtocol;
for (i = 0; i < base.cchProtocol; ++i)
- work[i] = towlower(work[i]);
+ work[i] = RtlDowncaseUnicodeChar(work[i]);
/* mk is a special case */
if (base.nScheme == URL_SCHEME_MK)
@@ -4871,7 +4868,7 @@ HRESULT WINAPI UrlCombineW(const WCHAR *baseW, const WCHAR *relativeW, WCHAR *co
{
work = (LPWSTR)relative.pszProtocol;
for (i = 0; i < relative.cchProtocol; ++i)
- work[i] = towlower(work[i]);
+ work[i] = RtlDowncaseUnicodeChar(work[i]);
}
/* Handle cases where relative has scheme. */
diff --git a/dlls/kernelbase/string.c b/dlls/kernelbase/string.c
index 7c484e2858..75ee5b0512 100644
--- a/dlls/kernelbase/string.c
+++ b/dlls/kernelbase/string.c
@@ -924,7 +924,7 @@ BOOL WINAPI StrToInt64ExW(const WCHAR *str, DWORD flags, LONGLONG *ret)
else if (*str == '+')
str++;
- if (flags & STIF_SUPPORT_HEX && *str == '0' && towlower(str[1]) == 'x')
+ if (flags & STIF_SUPPORT_HEX && *str == '0' && (str[1] == 'x' || str[1] == 'X'))
{
/* Read hex number */
str += 2;
@@ -935,10 +935,12 @@ BOOL WINAPI StrToInt64ExW(const WCHAR *str, DWORD flags, LONGLONG *ret)
while (iswxdigit(*str))
{
value *= 16;
- if (iswdigit(*str))
+ if (*str >= '0' && *str <= '9')
value += (*str - '0');
+ else if (*str >= 'A' && *str <= 'Z')
+ value += 10 + (*str - 'A');
else
- value += 10 + (towlower(*str) - 'a');
+ value += 10 + (*str - 'a');
str++;
}
More information about the wine-cvs
mailing list