PATCH: Re: Problem with Access-mdb/DAO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Ok, I just tried and changed the code a bit. This now works with
> normal wide char strings as well as binary data (may as well be an
> ASCII string) with type BSTR. Though it works for me it may not
> be the right solution.

It is.

I have changed all similar constructs to your code.

I have also added a testcase for VariantCopy().

Ciao, Marcus

Changelog:
	Copy BSTRs byte wise.
	Added a testcase for byte wise copy of VT_BSTR variant with VariantCopy().

Index: safearray.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/safearray.c,v
retrieving revision 1.31
diff -u -r1.31 safearray.c
--- dlls/oleaut32/safearray.c	31 Dec 2003 18:58:25 -0000	1.31
+++ dlls/oleaut32/safearray.c	8 Jan 2004 22:45:31 -0000
@@ -383,7 +386,7 @@
       {
         if (*lpBstr)
         {
-          *lpDest = SysAllocStringLen(*lpBstr, SysStringLen(*lpBstr));
+          *lpDest = SysAllocStringByteLen((char*)*lpBstr, SysStringByteLen(*lpBstr));
           if (!*lpDest)
             return E_OUTOFMEMORY;
         }
@@ -887,7 +893,7 @@
 
         if (lpBstr)
         {
-          *lpDest = SysAllocStringLen(lpBstr, SysStringLen(lpBstr));
+          *lpDest = SysAllocStringByteLen((char*)lpBstr, SysStringByteLen(lpBstr));
           if (!*lpDest)
             hRet = E_OUTOFMEMORY;
         }
@@ -968,7 +974,7 @@
 
         if (*lpBstr)
         {
-          *lpDest = SysAllocStringLen(*lpBstr, SysStringLen(*lpBstr));
+          *lpDest = SysAllocStringByteLen((char*)*lpBstr, SysStringByteLen(*lpBstr));
           if (!*lpBstr)
             hRet = E_OUTOFMEMORY;
         }
Index: variant.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/variant.c,v
retrieving revision 1.83
diff -u -r1.83 variant.c
--- dlls/oleaut32/variant.c	6 Jan 2004 22:08:34 -0000	1.83
+++ dlls/oleaut32/variant.c	8 Jan 2004 22:45:36 -0000
@@ -727,7 +729,7 @@
       {
         if (V_BSTR(pvargSrc))
         {
-          V_BSTR(pvargDest) = SysAllocStringLen(V_BSTR(pvargSrc), SysStringLen(V_BSTR(pvargSrc)));
+          V_BSTR(pvargDest) = SysAllocStringByteLen((char*)V_BSTR(pvargSrc), SysStringByteLen(V_BSTR(pvargSrc)));
           if (!V_BSTR(pvargDest))
             hres = E_OUTOFMEMORY;
         }
@@ -852,7 +855,7 @@
   else if (V_VT(pSrc) == (VT_BSTR|VT_BYREF))
   {
     /* Native doesn't check that *V_BSTRREF(pSrc) is valid */
-    V_BSTR(pvargDest) = SysAllocStringLen(*V_BSTRREF(pSrc), SysStringLen(*V_BSTRREF(pSrc)));
+    V_BSTR(pvargDest) = SysAllocStringByteLen((char*)*V_BSTRREF(pSrc), SysStringByteLen(*V_BSTRREF(pSrc)));
   }
   else if (V_VT(pSrc) == (VT_RECORD|VT_BYREF))
   {
Index: tests/vartype.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/tests/vartype.c,v
retrieving revision 1.4
diff -u -r1.4 vartype.c
--- dlls/oleaut32/tests/vartype.c	6 Jan 2004 22:08:34 -0000	1.4
+++ dlls/oleaut32/tests/vartype.c	8 Jan 2004 22:45:39 -0000
@@ -4607,6 +4607,7 @@
   const OLECHAR szTest[10] = { 'T','e','s','t','\0' };
   const CHAR szTestA[6] = { 'T','e','s','t','\0','?' };
   BSTR str;
+  HRESULT hres;
 
   str = SysAllocStringByteLen(szTestA, 0x80000000);
   ok (str == NULL, "Expected NULL, got %p\n", str);
@@ -4640,9 +4641,20 @@
   {
     const CHAR szTestTruncA[4] = { 'T','e','s','\0' };
     LPINTERNAL_BSTR bstr = Get(str);
+    VARIANT vt1, vt2;
 
     ok (bstr->dwLen == 3, "Expected 3, got %ld\n", bstr->dwLen);
     ok (!lstrcmpA((LPCSTR)bstr->szString, szTestTruncA), "String different\n");
+
+    V_VT(&vt1) = VT_BSTR;
+    V_BSTR(&vt1) = str;
+    V_VT(&vt2) = VT_EMPTY;
+    hres = VariantCopy(&vt2, &vt1);
+    ok (hres == S_OK,"Failed to copy binary bstring with hres 0x%08lx\n", hres);
+    bstr = Get(V_BSTR(&vt2));
+    ok (bstr->dwLen == 3, "Expected 3, got %ld\n", bstr->dwLen);
+    ok (!lstrcmpA((LPCSTR)bstr->szString, szTestTruncA), "String different\n");
+
     SysFreeString(str);
   }
 


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux