[PATCH 9/9] winex11: Don't use unicode.h.

Jacek Caban wine at gitlab.winehq.org
Fri May 6 07:11:23 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
 dlls/winex11.drv/clipboard.c   |  3 +--
 dlls/winex11.drv/graphics.c    |  5 ++---
 dlls/winex11.drv/keyboard.c    |  5 ++---
 dlls/winex11.drv/mouse.c       |  9 ++++-----
 dlls/winex11.drv/settings.c    |  5 ++---
 dlls/winex11.drv/window.c      |  1 -
 dlls/winex11.drv/wintab.c      | 23 +++++++++++------------
 dlls/winex11.drv/x11drv.h      |  3 +--
 dlls/winex11.drv/x11drv_main.c | 13 ++++++-------
 dlls/winex11.drv/xim.c         |  7 +++----
 dlls/winex11.drv/xrandr.c      |  3 +--
 dlls/winex11.drv/xrender.c     |  7 +++----
 12 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index feb9eb487e5..80c3e8520d3 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -93,7 +93,6 @@
 #include "shlwapi.h"
 #include "wine/list.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(clipboard);
 
@@ -1135,7 +1134,7 @@ void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size )
 
         if (path)
         {
-            int pathSize = strlenW(path) + 1;
+            int pathSize = wcslen( path ) + 1;
             if (pathSize > capacity - total)
             {
                 WCHAR *new_out;
diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index 18d7c6e9adc..b833fe0c629 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -48,7 +48,6 @@
 
 #include "x11drv.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(graphics);
 
@@ -1733,7 +1732,7 @@ BOOL CDECL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size,
     else lstrcpyW( p, srgb );
 
     NtClose( hkey );
-    required = strlenW( fullname ) + 1 - 4 /* skip NT prefix */;
+    required = wcslen( fullname ) + 1 - 4 /* skip NT prefix */;
     if (*size < required)
     {
         *size = required;
@@ -1743,7 +1742,7 @@ BOOL CDECL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size,
     if (filename)
     {
         FILE_BASIC_INFORMATION info;
-        strcpyW( filename, fullname + 4 );
+        wcscpy( filename, fullname + 4 );
         RtlInitUnicodeString( &name, fullname );
         InitializeObjectAttributes( &attr, &name, OBJ_CASE_INSENSITIVE, NULL, NULL );
         if (NtQueryAttributesFile( &attr, &info ))
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index efd8f03eae1..6157548474b 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -53,7 +53,6 @@
 #include "ime.h"
 #include "x11drv.h"
 #include "wine/server.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 
 /* log format (add 0-padding as appropriate):
@@ -2104,7 +2103,7 @@ UINT X11DRV_MapVirtualKeyEx( UINT wCode, UINT wMapType, HKL hkl )
             if (len)
             {
                 WCHAR wch;
-                if (ntdll_umbstowcs( s, len, &wch, 1 )) ret = toupperW(wch);
+                if (ntdll_umbstowcs( s, len, &wch, 1 )) ret = RtlUpcaseUnicodeChar( wch );
             }
             break;
         }
@@ -2171,7 +2170,7 @@ INT X11DRV_GetKeyNameText( LONG lParam, LPWSTR lpBuffer, INT nSize )
       {
         if (nSize >= 2)
 	{
-          *lpBuffer = toupperW((WCHAR)ansi);
+          *lpBuffer = RtlUpcaseUnicodeChar( ansi );
           *(lpBuffer+1) = 0;
           return 1;
         }
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 458bd469caa..d0cdd3d4984 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -56,7 +56,6 @@ MAKE_FUNCPTR(XcursorLibraryLoadCursor);
 
 #include "x11drv.h"
 #include "wine/server.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(cursor);
@@ -1066,11 +1065,11 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
 
     if (!info->szModName[0]) return 0;
 
-    p = strrchrW( info->szModName, '\\' );
-    strcpyW( name, p ? p + 1 : info->szModName );
-    p = name + strlenW( name );
+    p = wcsrchr( info->szModName, '\\' );
+    wcscpy( name, p ? p + 1 : info->szModName );
+    p = name + lstrlenW( name );
     *p++ = ',';
-    if (info->szResName[0]) strcpyW( p, info->szResName );
+    if (info->szResName[0]) wcscpy( p, info->szResName );
     else
     {
         char buf[16];
diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c
index 9fffc9c0b0a..e7e353b33ad 100644
--- a/dlls/winex11.drv/settings.c
+++ b/dlls/winex11.drv/settings.c
@@ -35,7 +35,6 @@
 #include "winreg.h"
 #include "wingdi.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(x11settings);
 
@@ -241,11 +240,11 @@ static HKEY get_display_device_reg_key( const WCHAR *device_name )
     HKEY hkey;
 
     /* Device name has to be \\.\DISPLAY%d */
-    if (strncmpiW(device_name, display, ARRAY_SIZE(display)))
+    if (wcsnicmp( device_name, display, ARRAY_SIZE(display) ))
         return FALSE;
 
     /* Parse \\.\DISPLAY* */
-    adapter_index = strtolW(device_name + ARRAY_SIZE(display), &end_ptr, 10) - 1;
+    adapter_index = wcstol( device_name + ARRAY_SIZE(display), &end_ptr, 10 ) - 1;
     if (*end_ptr)
         return FALSE;
 
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 4506ba9c036..50a848cae86 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -49,7 +49,6 @@
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "wine/unicode.h"
 
 #include "x11drv.h"
 #include "wine/debug.h"
diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index ceb5e7276d6..b906a589e08 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -32,7 +32,6 @@
 #include "windef.h"
 #include "winbase.h"
 #include "x11drv.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 #include "wintab.h"
 
@@ -516,8 +515,8 @@ NTSTATUS x11drv_tablet_load_info( void *hwnd )
     hwndTabletDefault = hwnd;
 
     /* Do base initialization */
-    strcpyW(gSysContext.lcName, SZ_CONTEXT_NAME);
-    strcpyW(gSysDevice.NAME, SZ_DEVICE_NAME);
+    wcscpy(gSysContext.lcName, SZ_CONTEXT_NAME);
+    wcscpy(gSysDevice.NAME, SZ_DEVICE_NAME);
 
     gSysContext.lcOptions = CXO_SYSTEM;
     gSysContext.lcLocks = CXL_INSIZE | CXL_INASPECT | CXL_MARGIN |
@@ -553,7 +552,7 @@ NTSTATUS x11drv_tablet_load_info( void *hwnd )
     gSysDevice.PKTDATA =
         PK_CONTEXT | PK_STATUS | PK_SERIAL_NUMBER| PK_TIME | PK_CURSOR |
         PK_BUTTONS |  PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_ORIENTATION;
-    strcpyW(gSysDevice.PNPID, SZ_NON_PLUG_N_PLAY);
+    wcscpy(gSysDevice.PNPID, SZ_NON_PLUG_N_PLAY);
 
     devices = pXListInputDevices(data->display, &num_devices);
     if (!devices)
@@ -744,14 +743,14 @@ NTSTATUS x11drv_tablet_load_info( void *hwnd )
                         for (i = 0; i < cursor.BUTTONS; i++)
                         {
                             /* FIXME - these names are probably incorrect */
-                            int cch = strlenW(cursor.NAME) + 1;
+                            int cch = wcslen(cursor.NAME) + 1;
                             while (cch > cchBuf - cchPos - 1) /* we want one extra byte for the last NUL */
                             {
                                 cchBuf *= 2;
                                 cursor.BTNNAMES = realloc( cursor.BTNNAMES, sizeof(WCHAR) * cchBuf );
                             }
 
-                            strcpyW(cursor.BTNNAMES + cchPos, cursor.NAME);
+                            wcscpy(cursor.BTNNAMES + cchPos, cursor.NAME);
                             cchPos += cch;
                         }
                         cursor.BTNNAMES[cchPos++] = 0;
@@ -1034,7 +1033,7 @@ NTSTATUS x11drv_tablet_attach_queue( void *owner )
         if (!gSysCursor[cur_loop].ACTIVE) continue;
 
         /* the cursor name fits in the buffer because too long names are skipped */
-        ntdll_wcstoumbs(gSysCursor[cur_loop].NAME, lstrlenW(gSysCursor[cur_loop].NAME) + 1,
+        ntdll_wcstoumbs(gSysCursor[cur_loop].NAME, wcslen(gSysCursor[cur_loop].NAME) + 1,
                         cursorNameA, WT_MAX_NAME_LEN, FALSE);
         for (loop=0; loop < num_devices; loop ++)
             if (strcmp(devices[loop].name, cursorNameA) == 0)
@@ -1160,7 +1159,7 @@ NTSTATUS x11drv_tablet_info( void *arg )
                 case IFC_WINTABID:
                 {
                     static const WCHAR driver[] = {'W','i','n','e',' ','W','i','n','t','a','b',' ','1','.','1',0};
-                    rc = CopyTabletData(lpOutput, driver, (strlenW(driver) + 1) * sizeof(WCHAR));
+                    rc = CopyTabletData(lpOutput, driver, (wcslen(driver) + 1) * sizeof(WCHAR));
                     break;
                 }
                 case IFC_SPECVERSION:
@@ -1199,7 +1198,7 @@ NTSTATUS x11drv_tablet_info( void *arg )
                     break;
                 case CTX_NAME:
                     rc = CopyTabletData(lpOutput, gSysContext.lcName,
-                         (strlenW(gSysContext.lcName)+1) * sizeof(WCHAR));
+                         (wcslen(gSysContext.lcName)+1) * sizeof(WCHAR));
                     break;
                 case CTX_OPTIONS:
                     rc = CopyTabletData(lpOutput, &gSysContext.lcOptions,
@@ -1363,7 +1362,7 @@ NTSTATUS x11drv_tablet_info( void *arg )
                 {
                     case CSR_NAME:
                         rc = CopyTabletData(lpOutput, tgtcursor->NAME,
-                                            (strlenW(tgtcursor->NAME)+1) * sizeof(WCHAR));
+                                            (wcslen(tgtcursor->NAME)+1) * sizeof(WCHAR));
                         break;
                     case CSR_ACTIVE:
                         rc = CopyTabletData(lpOutput,&tgtcursor->ACTIVE,
@@ -1455,7 +1454,7 @@ NTSTATUS x11drv_tablet_info( void *arg )
             {
                 case DVC_NAME:
                     rc = CopyTabletData(lpOutput,gSysDevice.NAME,
-                                        (strlenW(gSysDevice.NAME)+1) * sizeof(WCHAR));
+                                        (wcslen(gSysDevice.NAME)+1) * sizeof(WCHAR));
                     break;
                 case DVC_HARDWARE:
                     rc = CopyTabletData(lpOutput,&gSysDevice.HARDWARE,
@@ -1539,7 +1538,7 @@ NTSTATUS x11drv_tablet_info( void *arg )
                     break;
                 case DVC_PNPID:
                     rc = CopyTabletData(lpOutput,gSysDevice.PNPID,
-                                        (strlenW(gSysDevice.PNPID)+1)*sizeof(WCHAR));
+                                        (wcslen(gSysDevice.PNPID)+1)*sizeof(WCHAR));
                     break;
                 default:
                     FIXME("WTI_DEVICES unhandled index %i\n",nIndex);
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 257146fadcf..fd102ea951a 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -63,7 +63,6 @@ typedef int Status;
 #include "wine/gdi_driver.h"
 #include "unixlib.h"
 #include "wine/list.h"
-#include "wine/unicode.h"
 
 #define MAX_DASHLEN 16
 
@@ -970,6 +969,6 @@ static inline LONG x11drv_wcstol( LPCWSTR s, LPWSTR *end, INT base )
     return ret;
 }
 
-#define strtolW x11drv_wcstol
+#define wcstol x11drv_wcstol
 
 #endif  /* __WINE_X11DRV_H */
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index e358e92e5fe..2742bdbdeb1 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -52,7 +52,6 @@
 #include "x11drv.h"
 #include "xcomposite.h"
 #include "wine/server.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 #include "wine/list.h"
 
@@ -449,8 +448,8 @@ static void setup_options(void)
     /* open the app-specific key */
 
     appname = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
-    if ((p = strrchrW( appname, '/' ))) appname = p + 1;
-    if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
+    if ((p = wcsrchr( appname, '/' ))) appname = p + 1;
+    if ((p = wcsrchr( appname, '\\' ))) appname = p + 1;
     len = lstrlenW( appname );
 
     if (len && len < MAX_PATH)
@@ -502,7 +501,7 @@ static void setup_options(void)
         grab_fullscreen = IS_OPTION_TRUE( buffer[0] );
 
     if (!get_config_key( hkey, appkey, "ScreenDepth", buffer, sizeof(buffer) ))
-        default_visual.depth = strtolW( buffer, NULL, 0 );
+        default_visual.depth = wcstol( buffer, NULL, 0 );
 
     if (!get_config_key( hkey, appkey, "ClientSideGraphics", buffer, sizeof(buffer) ))
         client_side_graphics = IS_OPTION_TRUE( buffer[0] );
@@ -520,13 +519,13 @@ static void setup_options(void)
         private_color_map = IS_OPTION_TRUE( buffer[0] );
 
     if (!get_config_key( hkey, appkey, "PrimaryMonitor", buffer, sizeof(buffer) ))
-        primary_monitor = strtolW( buffer, NULL, 0 );
+        primary_monitor = wcstol( buffer, NULL, 0 );
 
     if (!get_config_key( hkey, appkey, "CopyDefaultColors", buffer, sizeof(buffer) ))
-        copy_default_colors = strtolW( buffer, NULL, 0 );
+        copy_default_colors = wcstol( buffer, NULL, 0 );
 
     if (!get_config_key( hkey, appkey, "AllocSystemColors", buffer, sizeof(buffer) ))
-        alloc_system_colors = strtolW( buffer, NULL, 0 );
+        alloc_system_colors = wcstol( buffer, NULL, 0 );
 
     get_config_key( hkey, appkey, "InputStyle", input_style, sizeof(input_style) );
 
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index d2166697386..00c15bb3bcf 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -34,7 +34,6 @@
 #include "x11drv.h"
 #include "imm.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(xim);
 
@@ -286,11 +285,11 @@ BOOL X11DRV_InitXIM( const WCHAR *input_style )
     static const WCHAR overthespotW[] = {'o','v','e','r','t','h','e','s','p','o','t',0};
     static const WCHAR rootW[] = {'r','o','o','t',0};
 
-    if (!strcmpiW(input_style, offthespotW))
+    if (!wcsicmp( input_style, offthespotW ))
         ximStyleRequest = STYLE_OFFTHESPOT;
-    else if (!strcmpiW(input_style, overthespotW))
+    else if (!wcsicmp( input_style, overthespotW ))
         ximStyleRequest = STYLE_OVERTHESPOT;
-    else if (!strcmpiW(input_style, rootW))
+    else if (!wcsicmp( input_style, rootW ))
         ximStyleRequest = STYLE_ROOT;
 
     if (!XSupportsLocale())
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c
index 152a9f35734..3fa6bad56c1 100644
--- a/dlls/winex11.drv/xrandr.c
+++ b/dlls/winex11.drv/xrandr.c
@@ -47,7 +47,6 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
 #define VK_NO_PROTOTYPES
 #define WINE_VK_HOST
 
-#include "wine/unicode.h"
 #include "wine/vulkan.h"
 #include "wine/vulkan_driver.h"
 
@@ -1223,7 +1222,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id )
     WCHAR *end;
 
     /* Parse \\.\DISPLAY%d */
-    display_idx = strtolW( device_name + 11, &end, 10 ) - 1;
+    display_idx = wcstol( device_name + 11, &end, 10 ) - 1;
     if (*end)
         return FALSE;
 
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 407e58d6eda..db9e454c317 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -39,7 +39,6 @@
 #include "winbase.h"
 #include "x11drv.h"
 #include "winternl.h"
-#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(xrender);
@@ -587,7 +586,7 @@ static BOOL fontcmp(LFANDSIZE *p1, LFANDSIZE *p2)
   if(memcmp(&p1->devsize, &p2->devsize, sizeof(p1->devsize))) return TRUE;
   if(memcmp(&p1->xform, &p2->xform, sizeof(p1->xform))) return TRUE;
   if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
-  return strcmpiW(p1->lf.lfFaceName, p2->lf.lfFaceName);
+  return wcsicmp( p1->lf.lfFaceName, p2->lf.lfFaceName );
 }
 
 static int LookupEntry(LFANDSIZE *plfsz)
@@ -744,9 +743,9 @@ static void lfsz_calc_hash(LFANDSIZE *plfsz)
     two_chars = *ptr;
     pwc = (WCHAR *)&two_chars;
     if(!*pwc) break;
-    *pwc = toupperW(*pwc);
+    *pwc = RtlUpcaseUnicodeChar( *pwc );
     pwc++;
-    *pwc = toupperW(*pwc);
+    *pwc = RtlUpcaseUnicodeChar( *pwc );
     hash ^= two_chars;
     if(!*pwc) break;
   }
-- 
GitLab

https://gitlab.winehq.org/wine/wine/-/merge_requests/44



More information about the wine-devel mailing list