https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb44c20c477e01a7a4edca...
commit eb44c20c477e01a7a4edca06bb805d9d3755d59c Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Sun Nov 10 14:07:55 2019 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Sun Nov 10 14:07:55 2019 +0100
[MSXML3] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/msxml3/dispex.c | 30 +++++--- dll/win32/msxml3/httprequest.c | 2 +- dll/win32/msxml3/main.c | 164 +++++++++++++++++++++++++++++++++++++++++ dll/win32/msxml3/mxwriter.c | 10 +-- dll/win32/msxml3/node.c | 2 +- dll/win32/msxml3/saxreader.c | 10 ++- dll/win32/msxml3/selection.c | 2 +- media/doc/README.WINE | 2 +- 8 files changed, 200 insertions(+), 22 deletions(-)
diff --git a/dll/win32/msxml3/dispex.c b/dll/win32/msxml3/dispex.c index bd29a212c8a..b1fb72847e7 100644 --- a/dll/win32/msxml3/dispex.c +++ b/dll/win32/msxml3/dispex.c @@ -150,31 +150,43 @@ static inline unsigned get_libid_from_tid(tid_t tid) return tid_ids[tid].lib; }
-HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) +static HRESULT get_typelib(unsigned lib, ITypeLib **tl) { - unsigned lib = get_libid_from_tid(tid); HRESULT hres;
if(!typelib[lib]) { - ITypeLib *tl; - - hres = LoadRegTypeLib(lib_ids[lib].iid, lib_ids[lib].major, 0, LOCALE_SYSTEM_DEFAULT, &tl); + hres = LoadRegTypeLib(lib_ids[lib].iid, lib_ids[lib].major, 0, LOCALE_SYSTEM_DEFAULT, tl); if(FAILED(hres)) { ERR("LoadRegTypeLib failed: %08x\n", hres); return hres; }
- if(InterlockedCompareExchangePointer((void**)&typelib[lib], tl, NULL)) - ITypeLib_Release(tl); + if (InterlockedCompareExchangePointer((void**)&typelib[lib], *tl, NULL)) + ITypeLib_Release(*tl); }
+ *tl = typelib[lib]; + return S_OK; +} + +HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) +{ + unsigned lib = get_libid_from_tid(tid); + ITypeLib *typelib; + HRESULT hres; + + if (FAILED(hres = get_typelib(lib, &typelib))) + return hres; + if(!typeinfos[tid]) { ITypeInfo *ti;
- hres = ITypeLib_GetTypeInfoOfGuid(typelib[lib], get_riid_from_tid(tid), &ti); + hres = ITypeLib_GetTypeInfoOfGuid(typelib, get_riid_from_tid(tid), &ti); if(FAILED(hres)) { /* try harder with typelib from msxml.dll */ - hres = ITypeLib_GetTypeInfoOfGuid(typelib[LibXml], get_riid_from_tid(tid), &ti); + if (FAILED(hres = get_typelib(LibXml, &typelib))) + return hres; + hres = ITypeLib_GetTypeInfoOfGuid(typelib, get_riid_from_tid(tid), &ti); if(FAILED(hres)) { ERR("GetTypeInfoOfGuid failed: %08x\n", hres); return hres; diff --git a/dll/win32/msxml3/httprequest.c b/dll/win32/msxml3/httprequest.c index 07eeb743702..c6f9fdb33eb 100644 --- a/dll/win32/msxml3/httprequest.c +++ b/dll/win32/msxml3/httprequest.c @@ -759,7 +759,7 @@ static HRESULT BindStatusCallback_create(httprequest* This, BindStatusCallback * case VT_ARRAY|VT_UI1: { sa = V_ARRAY(body); - if ((hr = SafeArrayAccessData(sa, (void **)&ptr)) != S_OK) + if ((hr = SafeArrayAccessData(sa, &ptr)) != S_OK) { heap_free(bsc); return hr; diff --git a/dll/win32/msxml3/main.c b/dll/win32/msxml3/main.c index debd84e0903..fb94bb2de06 100644 --- a/dll/win32/msxml3/main.c +++ b/dll/win32/msxml3/main.c @@ -230,6 +230,168 @@ static void init_libxslt(void) #endif }
+static int to_utf8(int cp, unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + WCHAR *tmp; + int len; + + if (!in || !inlen) return 0; + + len = MultiByteToWideChar(cp, 0, (const char *)in, *inlen, NULL, 0); + tmp = heap_alloc(len * sizeof(WCHAR)); + if (!tmp) return -1; + MultiByteToWideChar(cp, 0, (const char *)in, *inlen, tmp, len); + + len = WideCharToMultiByte(CP_UTF8, 0, tmp, len, (char *)out, *outlen, NULL, NULL); + heap_free(tmp); + if (!len) return -1; + + *outlen = len; + return len; +} + +static int from_utf8(int cp, unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + WCHAR *tmp; + int len; + + if (!in || !inlen) return 0; + + len = MultiByteToWideChar(CP_UTF8, 0, (const char *)in, *inlen, NULL, 0); + tmp = heap_alloc(len * sizeof(WCHAR)); + if (!tmp) return -1; + MultiByteToWideChar(CP_UTF8, 0, (const char *)in, *inlen, tmp, len); + + len = WideCharToMultiByte(cp, 0, tmp, len, (char *)out, *outlen, NULL, NULL); + heap_free(tmp); + if (!len) return -1; + + *outlen = len; + return len; +} + +static int win1250_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1250, out, outlen, in, inlen); +} + +static int utf8_to_win1250(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1250, out, outlen, in, inlen); +} + +static int win1251_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1251, out, outlen, in, inlen); +} + +static int utf8_to_win1251(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1251, out, outlen, in, inlen); +} + +static int win1252_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1252, out, outlen, in, inlen); +} + +static int utf8_to_win1252(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1252, out, outlen, in, inlen); +} + +static int win1253_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1253, out, outlen, in, inlen); +} + +static int utf8_to_win1253(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1253, out, outlen, in, inlen); +} +static int win1254_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1254, out, outlen, in, inlen); +} + +static int utf8_to_win1254(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1254, out, outlen, in, inlen); +} + +static int win1255_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1255, out, outlen, in, inlen); +} + +static int utf8_to_win1255(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1255, out, outlen, in, inlen); +} + +static int win1256_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1256, out, outlen, in, inlen); +} + +static int utf8_to_win1256(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1256, out, outlen, in, inlen); +} + +static int win1257_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1257, out, outlen, in, inlen); +} + +static int utf8_to_win1257(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1257, out, outlen, in, inlen); +} + +static int win1258_to_utf8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return to_utf8(1258, out, outlen, in, inlen); +} + +static int utf8_to_win1258(unsigned char *out, int *outlen, const unsigned char *in, int *inlen) +{ + return from_utf8(1258, out, outlen, in, inlen); +} + +static void init_char_encoders(void) +{ + static const struct + { + const char *encoding; + xmlCharEncodingInputFunc input; + xmlCharEncodingOutputFunc output; + } encoder[] = + { + { "windows-1250", win1250_to_utf8, utf8_to_win1250 }, + { "windows-1251", win1251_to_utf8, utf8_to_win1251 }, + { "windows-1252", win1252_to_utf8, utf8_to_win1252 }, + { "windows-1253", win1253_to_utf8, utf8_to_win1253 }, + { "windows-1254", win1254_to_utf8, utf8_to_win1254 }, + { "windows-1255", win1255_to_utf8, utf8_to_win1255 }, + { "windows-1256", win1256_to_utf8, utf8_to_win1256 }, + { "windows-1257", win1257_to_utf8, utf8_to_win1257 }, + { "windows-1258", win1258_to_utf8, utf8_to_win1258 } + }; + int i; + + xmlInitCharEncodingHandlers(); + + for (i = 0; i < ARRAY_SIZE(encoder); i++) + { + if (!xmlFindCharEncodingHandler(encoder[i].encoding)) + { + TRACE("Adding %s encoding handler\n", encoder[i].encoding); + xmlNewCharEncodingHandler(encoder[i].encoding, encoder[i].input, encoder[i].output); + } + } +} + #endif /* HAVE_LIBXML2 */
@@ -259,6 +421,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved) wineXmlReadCallback, wineXmlFileCloseCallback) == -1) WARN("Failed to register callbacks\n");
+ init_char_encoders(); + schemasInit(); init_libxslt(); #endif diff --git a/dll/win32/msxml3/mxwriter.c b/dll/win32/msxml3/mxwriter.c index 10be2508b21..a5bfdf1e991 100644 --- a/dll/win32/msxml3/mxwriter.c +++ b/dll/win32/msxml3/mxwriter.c @@ -498,10 +498,10 @@ static WCHAR *get_escaped_string(const WCHAR *str, escape_mode mode, int *len) WCHAR *ptr, *ret;
/* default buffer size to something if length is unknown */ - conv_len = *len == -1 ? default_alloc : max(2**len, default_alloc); + conv_len = max(2**len, default_alloc); ptr = ret = heap_alloc(conv_len*sizeof(WCHAR));
- while (*str && p) + while (p) { if (ptr - ret > conv_len - grow_thresh) { @@ -539,10 +539,10 @@ static WCHAR *get_escaped_string(const WCHAR *str, escape_mode mode, int *len) }
str++; - if (*len != -1) p--; + p--; }
- if (*len != -1) *len = ptr-ret; + *len = ptr-ret; *++ptr = 0;
return ret; @@ -2206,7 +2206,7 @@ static HRESULT WINAPI VBSAXContentHandler_characters(IVBSAXContentHandler *iface if (!chars) return E_POINTER;
- return ISAXContentHandler_characters(&This->ISAXContentHandler_iface, *chars, -1); + return ISAXContentHandler_characters(&This->ISAXContentHandler_iface, *chars, SysStringLen(*chars)); }
static HRESULT WINAPI VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler *iface, BSTR *chars) diff --git a/dll/win32/msxml3/node.c b/dll/win32/msxml3/node.c index fc18935b69b..27abf945301 100644 --- a/dll/win32/msxml3/node.c +++ b/dll/win32/msxml3/node.c @@ -1217,7 +1217,7 @@ static HRESULT node_transform_write(xsltStylesheetPtr style, xmlDocPtr result, B htmlSetMetaEncoding(result, (const xmlChar *)encoding); if (indent == -1) indent = 1; - htmldoc_dumpcontent(output, result, (const char*)encoding, indent); + htmldoc_dumpcontent(output, result, encoding, indent); } else if (method && xmlStrEqual(method, (const xmlChar *)"xhtml")) { diff --git a/dll/win32/msxml3/saxreader.c b/dll/win32/msxml3/saxreader.c index 04fab81708c..fc27260cc2c 100644 --- a/dll/win32/msxml3/saxreader.c +++ b/dll/win32/msxml3/saxreader.c @@ -149,6 +149,8 @@ static saxreader_feature get_saxreader_feature(const WCHAR *name) return FeatureUnknown; }
+static const WCHAR empty_str; + struct bstrpool { BSTR *pool; @@ -1665,8 +1667,8 @@ static void libxmlStartElementNS( &uri, &local, &element->qname, &This->IVBSAXAttributes_iface); else hr = ISAXContentHandler_startElement(handler->handler, - uri, SysStringLen(uri), - local, SysStringLen(local), + uri ? uri : &empty_str, SysStringLen(uri), + local ? local : &empty_str, SysStringLen(local), element->qname, SysStringLen(element->qname), &This->ISAXAttributes_iface);
@@ -1739,8 +1741,8 @@ static void libxmlEndElementNS( else hr = ISAXContentHandler_endElement( handler->handler, - uri, SysStringLen(uri), - local, SysStringLen(local), + uri ? uri : &empty_str, SysStringLen(uri), + local ? local : &empty_str, SysStringLen(local), element->qname, SysStringLen(element->qname));
free_attribute_values(This); diff --git a/dll/win32/msxml3/selection.c b/dll/win32/msxml3/selection.c index b7c560a9a5b..31be4d8f101 100644 --- a/dll/win32/msxml3/selection.c +++ b/dll/win32/msxml3/selection.c @@ -831,7 +831,7 @@ HRESULT create_selection(xmlNodePtr node, xmlChar* query, IXMLDOMNodeList **out) TRACE("found %d matches\n", xmlXPathNodeSetGetLength(This->result->nodesetval));
cleanup: - if (This && FAILED(hr)) + if (FAILED(hr)) IXMLDOMSelection_Release( &This->IXMLDOMSelection_iface ); xmlXPathFreeContext(ctxt); return hr; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 3e2c2f7a2e7..c4baef83eb3 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -130,7 +130,7 @@ dll/win32/msvfw32 # Synced to WineStaging-4.18 dll/win32/msvidc32 # Synced to WineStaging-4.0 dll/win32/msxml # Synced to WineStaging-3.3 dll/win32/msxml2 # Synced to WineStaging-3.3 -dll/win32/msxml3 # Synced to WineStaging-4.0 +dll/win32/msxml3 # Synced to WineStaging-4.18 dll/win32/msxml4 # Synced to WineStaging-3.3 dll/win32/msxml6 # Synced to WineStaging-3.3 dll/win32/nddeapi # Synced to WineStaging-3.3