From: Alex Henrie alexhenrie24@gmail.com
--- dlls/msxml3/tests/domdoc.c | 13 +++---------- dlls/msxml3/tests/httpreq.c | 11 ++--------- dlls/msxml3/tests/saxreader.c | 11 ++--------- dlls/msxml3/tests/schema.c | 13 +++---------- 4 files changed, 10 insertions(+), 38 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index cf9fb62a65e..7bcafd228a1 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -42,6 +42,7 @@ #include "initguid.h" #include "asptlb.h" #include "shlwapi.h" +#include "atlconv.h"
#include "wine/test.h"
@@ -1178,7 +1179,7 @@ static const WCHAR nonexistent_fileW[] = L"c:\Nonexistent.xml"; static const WCHAR szStrangeChars[] = L"&x \x2103";
#define expect_bstr_eq_and_free(bstr, expect) { \ - BSTR bstrExp = alloc_str_from_narrow(expect); \ + BSTR bstrExp = A2BSTR(expect); \ ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \ SysFreeString(bstr); \ SysFreeString(bstrExp); \ @@ -1211,21 +1212,13 @@ static void* _create_object(const GUID *clsid, const char *name, const IID *iid, #define create_cache(iid) _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__) #define create_xsltemplate(iid) _create_object(&_create(CLSID_XSLTemplate), iid, __LINE__)
-static BSTR alloc_str_from_narrow(const char *str) -{ - int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - return ret; -} - static BSTR alloced_bstrs[256]; static int alloced_bstrs_count;
static BSTR _bstr_(const char *str) { assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); - alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + alloced_bstrs[alloced_bstrs_count] = A2BSTR(str); return alloced_bstrs[alloced_bstrs_count++]; }
diff --git a/dlls/msxml3/tests/httpreq.c b/dlls/msxml3/tests/httpreq.c index bccfbaf582a..25a88f92bb1 100644 --- a/dlls/msxml3/tests/httpreq.c +++ b/dlls/msxml3/tests/httpreq.c @@ -30,6 +30,7 @@ #include "msxml2.h" #include "msxml2did.h" #include "dispex.h" +#include "atlconv.h"
#include "initguid.h" #include "objsafe.h" @@ -112,14 +113,6 @@ static int strcmp_wa(const WCHAR *strw, const char *stra) return lstrcmpW(strw, buf); }
-static BSTR alloc_str_from_narrow(const char *str) -{ - int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len-1); - return ret; -} - static BSTR alloced_bstrs[256]; static int alloced_bstrs_count;
@@ -129,7 +122,7 @@ static BSTR _bstr_(const char *str) return NULL;
assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); - alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + alloced_bstrs[alloced_bstrs_count] = A2BSTR(str); return alloced_bstrs[alloced_bstrs_count++]; }
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index e123d4eba5a..af07379dc3f 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -32,6 +32,7 @@ #include "msxml2did.h" #include "ocidl.h" #include "dispex.h" +#include "atlconv.h"
#include "wine/test.h"
@@ -86,21 +87,13 @@ static BOOL is_clsid_supported(const GUID *clsid, const struct msxmlsupported_da return FALSE; }
-static BSTR alloc_str_from_narrow(const char *str) -{ - int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - return ret; -} - static BSTR alloced_bstrs[512]; static int alloced_bstrs_count;
static BSTR _bstr_(const char *str) { assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); - alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + alloced_bstrs[alloced_bstrs_count] = A2BSTR(str); return alloced_bstrs[alloced_bstrs_count++]; }
diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c index 3d209c0e4a0..37b69576c00 100644 --- a/dlls/msxml3/tests/schema.c +++ b/dlls/msxml3/tests/schema.c @@ -31,6 +31,7 @@ #include "msxml2did.h" #include "dispex.h" #include "cguid.h" +#include "atlconv.h"
#include "wine/test.h"
@@ -431,18 +432,10 @@ static ULONG get_refcount(void *iface) static BSTR alloced_bstrs[256]; static int alloced_bstrs_count;
-static BSTR alloc_str_from_narrow(const char *str) -{ - int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - return ret; -} - static BSTR _bstr_(const char *str) { assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); - alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + alloced_bstrs[alloced_bstrs_count] = A2BSTR(str); return alloced_bstrs[alloced_bstrs_count++]; }
@@ -1217,7 +1210,7 @@ L"<?xml version='1.0'?>" hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v)); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); - namespace = alloc_str_from_narrow("urn:test"); + namespace = A2BSTR("urn:test"); hr = IXMLDOMSchemaCollection_add(cache, namespace, v); SysFreeString(namespace); VariantClear(&v);