L"YES" is a NO NO!!!

Francois Gouget fgouget at free.fr
Thu Nov 1 00:05:52 CST 2001


   Wine cannot use Unicode strings literals. When you write L"YES" this
is a 32bit Unicode string, not a 16bit unicode string. This means that
when you pass it to lstrcmpiW, which expects 16bit Unicode strings like
all the APIs in Wine, what it sees is this: "Y\0E\0S\0\0\0". And this is
obviously different from "YES".


   I guess it pays to check the warnings form time to time!



Changelog:

 * dlls/shlwapi/reg.c

   Fix incorrect use of a Unicode string literal   


--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
           Demander si un ordinateur peut penser revient à demander
                          si un sous-marin peut nager.
-------------- next part --------------
Index: dlls/shlwapi/reg.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/reg.c,v
retrieving revision 1.15
diff -u -r1.15 reg.c
--- dlls/shlwapi/reg.c	2001/10/28 21:13:16	1.15
+++ dlls/shlwapi/reg.c	2001/10/31 23:51:52
@@ -430,6 +430,10 @@
 	BOOL fIgnoreHKCU,
 	BOOL fDefault)
 {
+	static const WCHAR wYES[]=  {'Y','E','S','\0'};
+	static const WCHAR wTRUE[]= {'T','R','U','E','\0'};
+	static const WCHAR wNO[]=   {'N','O','\0'};
+	static const WCHAR wFALSE[]={'F','A','L','S','E','\0'};
 	LONG retvalue;
 	DWORD type, datalen, work;
 	BOOL ret = fDefault;
@@ -447,10 +451,10 @@
 	    switch (type) {
 	    case REG_SZ:
 		data[9] = L'\0';     /* set end of string */
-		if (lstrcmpiW(data, L"YES") == 0) ret = TRUE;
-		if (lstrcmpiW(data, L"TRUE") == 0) ret = TRUE;
-		if (lstrcmpiW(data, L"NO") == 0) ret = FALSE;
-		if (lstrcmpiW(data, L"FALSE") == 0) ret = FALSE;
+		if (lstrcmpiW(data, wYES)==0 || lstrcmpiW(data, wTRUE)==0)
+		    ret = TRUE;
+		else if (lstrcmpiW(data, wNO)==0 || lstrcmpiW(data, wFALSE)==0)
+		    ret = FALSE;
 		break;
 	    case REG_DWORD:
 		work = *(LPDWORD)data;


More information about the wine-patches mailing list