ntdll: Avoid using tolowerW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-30 12:09:15 +02:00
parent 1cde869627
commit 7a974814cd
3 changed files with 23 additions and 25 deletions

View File

@ -1316,8 +1316,8 @@ static ULONG hash_short_file_name( const UNICODE_STRING *name, LPWSTR buffer )
if (!is_case_sensitive) if (!is_case_sensitive)
{ {
for (p = name->Buffer, hash = 0xbeef; p < end - 1; p++) for (p = name->Buffer, hash = 0xbeef; p < end - 1; p++)
hash = (hash<<3) ^ (hash>>5) ^ tolowerW(*p) ^ (tolowerW(p[1]) << 8); hash = (hash<<3) ^ (hash>>5) ^ RtlDowncaseUnicodeChar(*p) ^ (RtlDowncaseUnicodeChar(p[1]) << 8);
hash = (hash<<3) ^ (hash>>5) ^ tolowerW(*p); /* Last character */ hash = (hash<<3) ^ (hash>>5) ^ RtlDowncaseUnicodeChar(*p); /* Last character */
} }
else else
{ {
@ -2245,29 +2245,24 @@ static int match_redirect( const WCHAR *path, int len, const WCHAR *redir, BOOLE
{ {
int i = 0; int i = 0;
while (i < len && *redir) while (i < len)
{ {
if (IS_SEPARATOR(path[i])) int start = i;
while (i < len && !IS_SEPARATOR(path[i])) i++;
if (check_case)
{ {
if (*redir++ != '\\') return 0; if (strncmpW( path + start, redir, i - start )) return 0;
while (i < len && IS_SEPARATOR(path[i])) i++;
continue; /* move on to next path component */
}
else if (check_case)
{
if (path[i] != *redir) return 0;
} }
else else
{ {
if (tolowerW(path[i]) != tolowerW(*redir)) return 0; if (wcsnicmp( path + start, redir, i - start )) return 0;
} }
i++; redir += i - start;
redir++;
}
if (*redir) return 0;
if (i < len && !IS_SEPARATOR(path[i])) return 0;
while (i < len && IS_SEPARATOR(path[i])) i++; while (i < len && IS_SEPARATOR(path[i])) i++;
return i; if (!*redir) return i;
if (*redir++ != '\\') return 0;
}
return 0;
} }

View File

@ -1749,16 +1749,17 @@ static BOOL get_builtin_fullname( UNICODE_STRING *nt_name, const UNICODE_STRING
{ {
static const WCHAR nt_prefixW[] = {'\\','?','?','\\',0}; static const WCHAR nt_prefixW[] = {'\\','?','?','\\',0};
static const WCHAR soW[] = {'.','s','o',0}; static const WCHAR soW[] = {'.','s','o',0};
WCHAR *p, *fullname; WCHAR *p, *fullname, filenameW[256];
size_t i, len = strlen(filename); size_t len = strlen(filename);
if (len >= ARRAY_SIZE(filenameW)) return FALSE;
ascii_to_unicode( filenameW, filename, len + 1 );
/* check if path can correspond to the dll we have */ /* check if path can correspond to the dll we have */
if (path && (p = strrchrW( path->Buffer, '\\' ))) if (path && (p = strrchrW( path->Buffer, '\\' )))
{ {
p++; p++;
for (i = 0; i < len; i++) if (!wcsnicmp( p, filenameW, len ) && (!p[len] || !wcsicmp( p + len, soW )))
if (tolowerW(p[i]) != tolowerW( (WCHAR)filename[i]) ) break;
if (i == len && (!p[len] || !wcsicmp( p + len, soW )))
{ {
/* the filename matches, use path as the full path */ /* the filename matches, use path as the full path */
len += p - path->Buffer; len += p - path->Buffer;
@ -1775,7 +1776,7 @@ static BOOL get_builtin_fullname( UNICODE_STRING *nt_name, const UNICODE_STRING
return FALSE; return FALSE;
strcpyW( fullname, nt_prefixW ); strcpyW( fullname, nt_prefixW );
strcatW( fullname, system_dir ); strcatW( fullname, system_dir );
ascii_to_unicode( fullname + strlenW(fullname), filename, len + 1 ); strcatW( fullname, filenameW );
done: done:
RtlInitUnicodeString( nt_name, fullname ); RtlInitUnicodeString( nt_name, fullname );
return TRUE; return TRUE;

View File

@ -1496,7 +1496,9 @@ NTSTATUS WINAPI RtlUnicodeToOemN( char *dst, DWORD dstlen, DWORD *reslen,
*/ */
WCHAR WINAPI RtlDowncaseUnicodeChar( WCHAR wch ) WCHAR WINAPI RtlDowncaseUnicodeChar( WCHAR wch )
{ {
return casemap( nls_info.LowerCaseTable, wch ); if (nls_info.LowerCaseTable) return casemap( nls_info.LowerCaseTable, wch );
if (wch >= 'A' && wch <= 'Z') wch += 'a' - 'A';
return wch;
} }