Alexandre Julliard : ntdll: Avoid using toupperW().
Alexandre Julliard
julliard at winehq.org
Mon Mar 30 16:24:25 CDT 2020
Module: wine
Branch: master
Commit: 1cde8696271e71364ba2df0aaa374c93953f6fb1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=1cde8696271e71364ba2df0aaa374c93953f6fb1
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Mar 30 12:05:16 2020 +0200
ntdll: Avoid using toupperW().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/directory.c | 4 ++--
dlls/ntdll/loadorder.c | 17 +++++++----------
dlls/ntdll/locale.c | 3 ++-
dlls/ntdll/ntdll_misc.h | 1 +
dlls/ntdll/path.c | 2 +-
5 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 993a661015..cb9ce3740e 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1394,7 +1394,7 @@ static BOOLEAN match_filename( const UNICODE_STRING *name_str, const UNICODE_STR
if (is_case_sensitive)
while (name < name_end && (*name != *mask)) name++;
else
- while (name < name_end && (toupperW(*name) != toupperW(*mask))) name++;
+ while (name < name_end && (towupper(*name) != towupper(*mask))) name++;
next_to_retry = name;
break;
case '?':
@@ -1403,7 +1403,7 @@ static BOOLEAN match_filename( const UNICODE_STRING *name_str, const UNICODE_STR
break;
default:
if (is_case_sensitive) mismatch = (*mask != *name);
- else mismatch = (toupperW(*mask) != toupperW(*name));
+ else mismatch = (towupper(*mask) != towupper(*name));
if (!mismatch)
{
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index 8469f487d3..8c540f9683 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -89,13 +89,12 @@ static const WCHAR *get_basename( const WCHAR *name )
*
* Remove extension if it is ".dll".
*/
-static inline void remove_dll_ext( WCHAR *ext )
+static inline void remove_dll_ext( WCHAR *name )
{
- if (ext[0] == '.' &&
- toupperW(ext[1]) == 'D' &&
- toupperW(ext[2]) == 'L' &&
- toupperW(ext[3]) == 'L' &&
- !ext[4]) ext[0] = 0;
+ static const WCHAR dllW[] = {'.','d','l','l',0};
+ WCHAR *p = strrchrW( name, '.' );
+
+ if (p && !wcsicmp( p, dllW )) *p = 0;
}
@@ -213,8 +212,7 @@ static void add_load_order_set( WCHAR *entry )
if (*end) *end++ = 0;
if (*entry)
{
- WCHAR *ext = strrchrW(entry, '.');
- if (ext) remove_dll_ext( ext );
+ remove_dll_ext( entry );
ldo.modulename = entry;
add_load_order( &ldo );
entry = end;
@@ -457,10 +455,9 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
if (!(len = strlenW(path))) return ret;
if (!(module = RtlAllocateHeap( GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR) ))) return ret;
strcpyW( module+1, path ); /* reserve module[0] for the wildcard char */
+ remove_dll_ext( module + 1 );
basename = (WCHAR *)get_basename( module+1 );
- if (len >= 4) remove_dll_ext( module + 1 + len - 4 );
-
/* first explicit module name */
if ((ret = get_load_order_value( std_key, app_key, module+1 )) != LO_INVALID)
goto done;
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index 123b8985b1..915a644c9d 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -1638,7 +1638,8 @@ WCHAR __cdecl NTDLL_towlower( WCHAR ch )
*/
WCHAR __cdecl NTDLL_towupper( WCHAR ch )
{
- return casemap( nls_info.UpperCaseTable, ch );
+ if (nls_info.UpperCaseTable) return casemap( nls_info.UpperCaseTable, ch );
+ return casemap_ascii( ch );
}
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 20feabf56b..fe0d1755d0 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -298,6 +298,7 @@ ULONG __cdecl NTDLL_wcstoul( LPCWSTR s, LPWSTR *end, INT base );
#define wcsicmp(s1,s2) NTDLL__wcsicmp(s1,s2)
#define wcsnicmp(s1,s2,n) NTDLL__wcsnicmp(s1,s2,n)
+#define towupper(c) NTDLL_towupper(c)
#define wcslwr(s) NTDLL__wcslwr(s)
#define wcsupr(s) NTDLL__wcsupr(s)
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index 65539fa018..2f7b031d81 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -670,7 +670,7 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
case RELATIVE_DRIVE_PATH: /* c:foo */
dep = 2;
- if (toupperW(name[0]) != toupperW(cd->Buffer[0]) || cd->Buffer[1] != ':')
+ if (wcsnicmp( name, cd->Buffer, 2 ))
{
UNICODE_STRING var, val;
More information about the wine-cvs
mailing list