Module: wine Branch: master Commit: 7a974814cda795801fb845887508e85edaa67df6 URL: https://source.winehq.org/git/wine.git/?a=commit;h=7a974814cda795801fb845887...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Mar 30 12:09:15 2020 +0200
ntdll: Avoid using tolowerW().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/directory.c | 31 +++++++++++++------------------ dlls/ntdll/loader.c | 13 +++++++------ dlls/ntdll/locale.c | 4 +++- 3 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index cb9ce3740e..80777da149 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -1316,8 +1316,8 @@ static ULONG hash_short_file_name( const UNICODE_STRING *name, LPWSTR buffer ) if (!is_case_sensitive) { 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) ^ tolowerW(*p); /* Last character */ + hash = (hash<<3) ^ (hash>>5) ^ RtlDowncaseUnicodeChar(*p) ^ (RtlDowncaseUnicodeChar(p[1]) << 8); + hash = (hash<<3) ^ (hash>>5) ^ RtlDowncaseUnicodeChar(*p); /* Last character */ } else { @@ -2245,29 +2245,24 @@ static int match_redirect( const WCHAR *path, int len, const WCHAR *redir, BOOLE { 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; - 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; + if (strncmpW( path + start, redir, i - start )) return 0; } else { - if (tolowerW(path[i]) != tolowerW(*redir)) return 0; + if (wcsnicmp( path + start, redir, i - start )) return 0; } - i++; - redir++; + redir += i - start; + while (i < len && IS_SEPARATOR(path[i])) i++; + if (!*redir) return i; + if (*redir++ != '\') return 0; } - if (*redir) return 0; - if (i < len && !IS_SEPARATOR(path[i])) return 0; - while (i < len && IS_SEPARATOR(path[i])) i++; - return i; + return 0; }
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 8f607409f5..0e2e3f7dd1 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -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 soW[] = {'.','s','o',0}; - WCHAR *p, *fullname; - size_t i, len = strlen(filename); + WCHAR *p, *fullname, filenameW[256]; + 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 */ if (path && (p = strrchrW( path->Buffer, '\' ))) { p++; - for (i = 0; i < len; i++) - if (tolowerW(p[i]) != tolowerW( (WCHAR)filename[i]) ) break; - if (i == len && (!p[len] || !wcsicmp( p + len, soW ))) + if (!wcsnicmp( p, filenameW, len ) && (!p[len] || !wcsicmp( p + len, soW ))) { /* the filename matches, use path as the full path */ len += p - path->Buffer; @@ -1775,7 +1776,7 @@ static BOOL get_builtin_fullname( UNICODE_STRING *nt_name, const UNICODE_STRING return FALSE; strcpyW( fullname, nt_prefixW ); strcatW( fullname, system_dir ); - ascii_to_unicode( fullname + strlenW(fullname), filename, len + 1 ); + strcatW( fullname, filenameW ); done: RtlInitUnicodeString( nt_name, fullname ); return TRUE; diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 915a644c9d..0969037078 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -1496,7 +1496,9 @@ NTSTATUS WINAPI RtlUnicodeToOemN( char *dst, DWORD dstlen, DWORD *reslen, */ 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; }