ntdll: Avoid using toupperW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-30 12:05:16 +02:00
parent 34f3e7793b
commit 1cde869627
5 changed files with 13 additions and 14 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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 );
}

View File

@ -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)

View File

@ -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;