ntdll: Use wcsnicmp() instead of strncmpiW() where possible.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-27 13:38:33 +01:00
parent 3e049b6b96
commit f831b3bd3d
9 changed files with 22 additions and 21 deletions

View file

@ -759,7 +759,7 @@ static inline BOOL xmlstr_cmp(const xmlstr_t* xmlstr, const WCHAR *str)
static inline BOOL xmlstr_cmpi(const xmlstr_t* xmlstr, const WCHAR *str)
{
return !strncmpiW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len];
return !wcsnicmp(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len];
}
static BOOL xml_attr_cmp( const struct xml_attr *attr, const WCHAR *str )
@ -1843,13 +1843,13 @@ static BOOL parse_typelib_flags(const xmlstr_t *value, struct entity *entity)
start = str;
while (*str != ',' && (i++ < value->len)) str++;
if (!strncmpiW(start, restrictedW, str-start))
if (!wcsnicmp(start, restrictedW, str-start))
*flags |= LIBFLAG_FRESTRICTED;
else if (!strncmpiW(start, controlW, str-start))
else if (!wcsnicmp(start, controlW, str-start))
*flags |= LIBFLAG_FCONTROL;
else if (!strncmpiW(start, hiddenW, str-start))
else if (!wcsnicmp(start, hiddenW, str-start))
*flags |= LIBFLAG_FHIDDEN;
else if (!strncmpiW(start, hasdiskimageW, str-start))
else if (!wcsnicmp(start, hasdiskimageW, str-start))
*flags |= LIBFLAG_FHASDISKIMAGE;
else
{
@ -3146,7 +3146,7 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
tmp = strchrW(tmp, '_') + 1;
tmp = strchrW(tmp, '_') + 1;
if (dir_info->FileNameLength - (tmp - dir_info->FileName) * sizeof(WCHAR) == sizeof(wine_trailerW) &&
!strncmpiW( tmp, wine_trailerW, ARRAY_SIZE( wine_trailerW )))
!wcsnicmp( tmp, wine_trailerW, ARRAY_SIZE( wine_trailerW )))
{
/* prefer a non-Wine manifest if we already have one */
/* we'll still load the builtin dll if specified through DllOverrides */

View file

@ -2160,7 +2160,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
{
WCHAR short_nameW[12];
ret = hash_short_file_name( &str, short_nameW );
if (ret == length && !strncmpiW( short_nameW, name, length ))
if (ret == length && !wcsnicmp( short_nameW, name, length ))
{
strcpy( unix_name + pos, de->d_name );
closedir( dir );
@ -2409,7 +2409,7 @@ static inline int get_dos_prefix_len( const UNICODE_STRING *name )
return ARRAY_SIZE( nt_prefixW );
if (name->Length >= sizeof(dosdev_prefixW) &&
!strncmpiW( name->Buffer, dosdev_prefixW, ARRAY_SIZE( dosdev_prefixW )))
!wcsnicmp( name->Buffer, dosdev_prefixW, ARRAY_SIZE( dosdev_prefixW )))
return ARRAY_SIZE( dosdev_prefixW );
return 0;

View file

@ -144,7 +144,7 @@ static void set_registry_variables( WCHAR **env, HANDLE hkey, ULONG type )
}
/* PATH is magic */
if (env_name.Length == sizeof(pathW) &&
!strncmpiW( env_name.Buffer, pathW, ARRAY_SIZE( pathW )) &&
!wcsnicmp( env_name.Buffer, pathW, ARRAY_SIZE( pathW )) &&
!RtlQueryEnvironmentVariable_U( *env, &env_name, &tmp ))
{
RtlAppendUnicodeToString( &tmp, sep );
@ -662,7 +662,7 @@ static inline BOOL is_path_prefix( const WCHAR *prefix, const WCHAR *path, const
{
DWORD len = strlenW( prefix );
if (strncmpiW( path, prefix, len )) return FALSE;
if (wcsnicmp( path, prefix, len )) return FALSE;
while (path[len] == '\\') len++;
return path + len == file;
}

View file

@ -447,7 +447,7 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
/* Strip path information if the module resides in the system directory
*/
if (!strncmpiW( system_dir, path, strlenW( system_dir )))
if (!wcsnicmp( system_dir, path, strlenW( system_dir )))
{
const WCHAR *p = path + strlenW( system_dir );
while (*p == '\\' || *p == '/') p++;

View file

@ -1719,7 +1719,7 @@ NTSTATUS WINAPI RtlLocaleNameToLcid( const WCHAR *name, LCID *lcid, ULONG flags
p = buf;
while (*p)
{
if (!strncmpiW( p, script, len ) && (!p[len] || p[len] == ';')) break;
if (!wcsnicmp( p, script, len ) && (!p[len] || p[len] == ';')) break;
if (!(p = strchrW( p, ';'))) break;
p++;
}

View file

@ -297,5 +297,6 @@ LONG __cdecl NTDLL_wcstol( LPCWSTR s, LPWSTR *end, INT base );
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)
#endif

View file

@ -306,13 +306,13 @@ ULONG WINAPI RtlIsDosDeviceName_U( PCWSTR dos_name )
switch(end - start + 1)
{
case 3:
if (strncmpiW( start, auxW, 3 ) &&
strncmpiW( start, conW, 3 ) &&
strncmpiW( start, nulW, 3 ) &&
strncmpiW( start, prnW, 3 )) break;
if (wcsnicmp( start, auxW, 3 ) &&
wcsnicmp( start, conW, 3 ) &&
wcsnicmp( start, nulW, 3 ) &&
wcsnicmp( start, prnW, 3 )) break;
return MAKELONG( 3 * sizeof(WCHAR), (start - dos_name) * sizeof(WCHAR) );
case 4:
if (strncmpiW( start, comW, 3 ) && strncmpiW( start, lptW, 3 )) break;
if (wcsnicmp( start, comW, 3 ) && wcsnicmp( start, lptW, 3 )) break;
if (*end <= '0' || *end > '9') break;
return MAKELONG( 4 * sizeof(WCHAR), (start - dos_name) * sizeof(WCHAR) );
default: /* can't match anything */
@ -1045,7 +1045,7 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir)
if (size && ptr[size - 1] != '\\') ptr[size++] = '\\';
/* convert \??\UNC\ path to \\ prefix */
if (size >= 4 && !strncmpiW(ptr, UncPfxW, 4))
if (size >= 4 && !wcsnicmp(ptr, UncPfxW, 4))
{
ptr += 2;
size -= 2;

View file

@ -1244,13 +1244,13 @@ static BOOL is_builtin_path( UNICODE_STRING *path, BOOL *is_64bit )
's','y','s','w','o','w','6','4'};
*is_64bit = is_win64;
if (path->Length > sizeof(systemW) && !strncmpiW( path->Buffer, systemW, ARRAY_SIZE(systemW) ))
if (path->Length > sizeof(systemW) && !wcsnicmp( path->Buffer, systemW, ARRAY_SIZE(systemW) ))
{
if (is_wow64 && !ntdll_get_thread_data()->wow64_redir) *is_64bit = TRUE;
return TRUE;
}
if ((is_win64 || is_wow64) && path->Length > sizeof(wow64W) &&
!strncmpiW( path->Buffer, wow64W, ARRAY_SIZE(wow64W) ))
!wcsnicmp( path->Buffer, wow64W, ARRAY_SIZE(wow64W) ))
{
*is_64bit = FALSE;
return TRUE;

View file

@ -294,7 +294,7 @@ static BOOL check_from_module( const WCHAR **includelist, const WCHAR **excludel
if (!wcsicmp( *listitem, module )) return !show;
len = strlenW( *listitem );
if (!strncmpiW( *listitem, module, len ) && !wcsicmp( module + len, dllW ))
if (!wcsnicmp( *listitem, module, len ) && !wcsicmp( module + len, dllW ))
return !show;
}
return show;