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

Alexandre Julliard julliard at winehq.org
Fri Mar 27 16:14:38 CDT 2020


Module: wine
Branch: master
Commit: f831b3bd3d6b013893be7645df3a9cd05289c415
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f831b3bd3d6b013893be7645df3a9cd05289c415

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Mar 27 13:38:33 2020 +0100

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

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/actctx.c     | 12 ++++++------
 dlls/ntdll/directory.c  |  4 ++--
 dlls/ntdll/env.c        |  4 ++--
 dlls/ntdll/loadorder.c  |  2 +-
 dlls/ntdll/locale.c     |  2 +-
 dlls/ntdll/ntdll_misc.h |  1 +
 dlls/ntdll/path.c       | 12 ++++++------
 dlls/ntdll/process.c    |  4 ++--
 dlls/ntdll/relay.c      |  2 +-
 9 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index 236adf6c00..9f2d6ffeb0 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -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 */
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 7b0627cd3d..c3da7347d7 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -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;
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index 9005544f55..c8098e2d59 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -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;
 }
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index 2d82b12a7a..8469f487d3 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -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++;
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index ea629e8393..123b8985b1 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -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++;
             }
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index c22b32a5b7..45ca35442f 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -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
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index adbfb4f526..65539fa018 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -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;
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index 2290d5d186..0f24837884 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -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;
diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c
index b5db930e12..9ebb973e9a 100644
--- a/dlls/ntdll/relay.c
+++ b/dlls/ntdll/relay.c
@@ -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;




More information about the wine-cvs mailing list