Alexandre Julliard : ntdll: Use wcsncmp() instead of strncmpW().

Alexandre Julliard julliard at winehq.org
Tue Mar 31 16:44:23 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar 31 11:55:51 2020 +0200

ntdll: Use wcsncmp() instead of strncmpW().

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

---

 dlls/ntdll/actctx.c     | 13 ++++++-------
 dlls/ntdll/directory.c  |  3 +--
 dlls/ntdll/loadorder.c  |  3 +--
 dlls/ntdll/locale.c     |  7 +++++--
 dlls/ntdll/ntdll_misc.h |  1 +
 dlls/ntdll/process.c    |  3 +--
 dlls/ntdll/resource.c   |  3 +--
 7 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index 6612e33cee..1ca14827a7 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -36,7 +36,6 @@
 #include "ntdll_misc.h"
 #include "wine/exception.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(actctx);
 
@@ -754,7 +753,7 @@ static WCHAR *xmlstrdupW(const xmlstr_t* str)
 
 static inline BOOL xmlstr_cmp(const xmlstr_t* xmlstr, const WCHAR *str)
 {
-    return !strncmpW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len];
+    return !wcsncmp(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len];
 }
 
 static inline BOOL xmlstr_cmpi(const xmlstr_t* xmlstr, const WCHAR *str)
@@ -771,8 +770,8 @@ static BOOL xml_name_cmp( const struct xml_elem *elem1, const struct xml_elem *e
 {
     return (elem1->name.len == elem2->name.len &&
             elem1->ns.len == elem2->ns.len &&
-            !strncmpW( elem1->name.ptr, elem2->name.ptr, elem1->name.len ) &&
-            !strncmpW( elem1->ns.ptr, elem2->ns.ptr, elem1->ns.len ));
+            !wcsncmp( elem1->name.ptr, elem2->name.ptr, elem1->name.len ) &&
+            !wcsncmp( elem1->ns.ptr, elem2->ns.ptr, elem1->ns.len ));
 }
 
 static inline BOOL xml_elem_cmp(const struct xml_elem *elem, const WCHAR *str, const WCHAR *namespace)
@@ -1230,7 +1229,7 @@ static BOOL is_xmlns_attr( const struct xml_attr *attr )
 {
     const int len = wcslen( xmlnsW );
     if (attr->name.len < len) return FALSE;
-    if (strncmpW( attr->name.ptr, xmlnsW, len )) return FALSE;
+    if (wcsncmp( attr->name.ptr, xmlnsW, len )) return FALSE;
     return (attr->name.len == len || attr->name.ptr[len] == ':');
 }
 
@@ -1262,7 +1261,7 @@ static xmlstr_t find_xmlns( xmlbuf_t *xmlbuf, const xmlstr_t *name )
     for (i = xmlbuf->ns_pos - 1; i >= 0; i--)
     {
         if (xmlbuf->namespaces[i].name.len == name->len &&
-            !strncmpW( xmlbuf->namespaces[i].name.ptr, name->ptr, name->len ))
+            !wcsncmp( xmlbuf->namespaces[i].name.ptr, name->ptr, name->len ))
             return xmlbuf->namespaces[i].value;
     }
     if (xmlbuf->ns_pos) WARN( "namespace %s not found\n", debugstr_xmlstr( name ));
@@ -1602,7 +1601,7 @@ static OLEMISC get_olemisc_value(const WCHAR *str, int len)
 
         n = (min+max)/2;
 
-        c = strncmpW(olemisc_values[n].name, str, len);
+        c = wcsncmp(olemisc_values[n].name, str, len);
         if (!c && !olemisc_values[n].name[len])
             return olemisc_values[n].value;
 
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 436ddf5366..be55a5a8c1 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -104,7 +104,6 @@
 #include "winternl.h"
 #include "ddk/wdm.h"
 #include "ntdll_misc.h"
-#include "wine/unicode.h"
 #include "wine/server.h"
 #include "wine/list.h"
 #include "wine/library.h"
@@ -2254,7 +2253,7 @@ static int match_redirect( const WCHAR *path, int len, const WCHAR *redir, BOOLE
         while (i < len && !IS_SEPARATOR(path[i])) i++;
         if (check_case)
         {
-            if (strncmpW( path + start, redir, i - start )) return 0;
+            if (wcsncmp( path + start, redir, i - start )) return 0;
         }
         else
         {
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index 291cc76031..dad5d915da 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -32,7 +32,6 @@
 #include "ntdll_misc.h"
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(module);
 
@@ -439,7 +438,7 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
     if (!init_done) init_load_order();
     std_key = get_standard_key();
     if (app_name) app_key = get_app_key( app_name );
-    if (!strncmpW( path, nt_prefixW, 4 )) path += 4;
+    if (!wcsncmp( path, nt_prefixW, 4 )) path += 4;
 
     TRACE("looking for %s\n", debugstr_w(path));
 
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index 9773284f63..ff9d713624 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -24,6 +24,7 @@
 
 #include <locale.h>
 #include <langinfo.h>
+#include <stdarg.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -34,9 +35,11 @@
 
 #include "ntstatus.h"
 #define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
 #include "ntdll_misc.h"
 #include "wine/library.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(nls);
@@ -2032,7 +2035,7 @@ NTSTATUS WINAPI RtlIsNormalizedString( ULONG form, const WCHAR *str, INT len, BO
         WCHAR *buffer = RtlAllocateHeap( GetProcessHeap(), 0, dstlen * sizeof(WCHAR) );
         if (!buffer) return STATUS_NO_MEMORY;
         status = RtlNormalizeString( form, str, len, buffer, &dstlen );
-        result = !status && (dstlen == len) && !strncmpW( buffer, str, len );
+        result = !status && (dstlen == len) && !wcsncmp( buffer, str, len );
         RtlFreeHeap( GetProcessHeap(), 0, buffer );
     }
     *res = result;
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index a81e13659e..2a91511f0d 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -312,6 +312,7 @@ int    WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... );
 #define wcscspn(s,r) NTDLL_wcscspn(s,r)
 #define wcsspn(s,a) NTDLL_wcsspn(s,a)
 #define wcscmp(s1,s2) NTDLL_wcscmp(s1,s2)
+#define wcsncmp(s1,s2,n) NTDLL_wcsncmp(s1,s2,n)
 
 /* convert from straight ASCII to Unicode without depending on the current codepage */
 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index fce5a8cdf8..6d506c8530 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -53,7 +53,6 @@
 #include "wine/exception.h"
 #include "wine/library.h"
 #include "wine/server.h"
-#include "wine/unicode.h"
 
 #ifdef HAVE_MACH_MACH_H
 #include <mach/mach.h>
@@ -1434,7 +1433,7 @@ static ULONG get_env_size( const RTL_USER_PROCESS_PARAMETERS *params, char **win
     while (*ptr)
     {
         static const WCHAR WINEDEBUG[] = {'W','I','N','E','D','E','B','U','G','=',0};
-        if (!*winedebug && !strncmpW( ptr, WINEDEBUG, ARRAY_SIZE( WINEDEBUG ) - 1 ))
+        if (!*winedebug && !wcsncmp( ptr, WINEDEBUG, ARRAY_SIZE( WINEDEBUG ) - 1 ))
         {
             DWORD len = wcslen(ptr) * 3 + 1;
             if ((*winedebug = RtlAllocateHeap( GetProcessHeap(), 0, len )))
diff --git a/dlls/ntdll/resource.c b/dlls/ntdll/resource.c
index dec0411ce2..9ebf374b44 100644
--- a/dlls/ntdll/resource.c
+++ b/dlls/ntdll/resource.c
@@ -43,7 +43,6 @@
 #include "ntdll_misc.h"
 #include "wine/asm.h"
 #include "wine/exception.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(resource);
@@ -152,7 +151,7 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_
     {
         pos = (min + max) / 2;
         str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].u.s.NameOffset);
-        res = strncmpW( name, str->NameString, str->Length );
+        res = wcsncmp( name, str->NameString, str->Length );
         if (!res && namelen == str->Length)
         {
             if (!entry[pos].u2.s2.DataIsDirectory == !want_dir)




More information about the wine-cvs mailing list