[MSXML3] Sync with Wine Staging 4.18. CORE-16441
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 10 Nov 2019 13:07:55 +0000 (14:07 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 10 Nov 2019 13:07:55 +0000 (14:07 +0100)
dll/win32/msxml3/dispex.c
dll/win32/msxml3/httprequest.c
dll/win32/msxml3/main.c
dll/win32/msxml3/mxwriter.c
dll/win32/msxml3/node.c
dll/win32/msxml3/saxreader.c
dll/win32/msxml3/selection.c
media/doc/README.WINE

index bd29a21..b1fb728 100644 (file)
@@ -150,31 +150,43 @@ static inline unsigned get_libid_from_tid(tid_t tid)
     return tid_ids[tid].lib;
 }
 
     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]) {
     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(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;
 
     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 */
         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;
             if(FAILED(hres)) {
                 ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
                 return hres;
index 07eeb74..c6f9fdb 100644 (file)
@@ -759,7 +759,7 @@ static HRESULT BindStatusCallback_create(httprequest* This, BindStatusCallback *
         case VT_ARRAY|VT_UI1:
         {
             sa = V_ARRAY(body);
         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;
             {
                 heap_free(bsc);
                 return hr;
index debd84e..fb94bb2 100644 (file)
@@ -230,6 +230,168 @@ static void init_libxslt(void)
 #endif
 }
 
 #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 */
 
 
 #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");
 
                             wineXmlReadCallback, wineXmlFileCloseCallback) == -1)
             WARN("Failed to register callbacks\n");
 
+        init_char_encoders();
+
         schemasInit();
         init_libxslt();
 #endif
         schemasInit();
         init_libxslt();
 #endif
index 10be250..a5bfdf1 100644 (file)
@@ -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 */
     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));
 
     ptr = ret = heap_alloc(conv_len*sizeof(WCHAR));
 
-    while (*str && p)
+    while (p)
     {
         if (ptr - ret > conv_len - grow_thresh)
         {
     {
         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++;
         }
 
         str++;
-        if (*len != -1) p--;
+        p--;
     }
 
     }
 
-    if (*len != -1) *len = ptr-ret;
+    *len = ptr-ret;
     *++ptr = 0;
 
     return ret;
     *++ptr = 0;
 
     return ret;
@@ -2206,7 +2206,7 @@ static HRESULT WINAPI VBSAXContentHandler_characters(IVBSAXContentHandler *iface
     if (!chars)
         return E_POINTER;
 
     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)
 }
 
 static HRESULT WINAPI VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler *iface, BSTR *chars)
index fc18935..27abf94 100644 (file)
@@ -1217,7 +1217,7 @@ static HRESULT node_transform_write(xsltStylesheetPtr style, xmlDocPtr result, B
         htmlSetMetaEncoding(result, (const xmlChar *)encoding);
         if (indent == -1)
             indent = 1;
         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"))
     {
     }
     else if (method && xmlStrEqual(method, (const xmlChar *)"xhtml"))
     {
index 04fab81..fc27260 100644 (file)
@@ -149,6 +149,8 @@ static saxreader_feature get_saxreader_feature(const WCHAR *name)
     return FeatureUnknown;
 }
 
     return FeatureUnknown;
 }
 
+static const WCHAR empty_str;
+
 struct bstrpool
 {
     BSTR *pool;
 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, &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);
 
                     element->qname, SysStringLen(element->qname),
                     &This->ISAXAttributes_iface);
 
@@ -1739,8 +1741,8 @@ static void libxmlEndElementNS(
     else
         hr = ISAXContentHandler_endElement(
                 handler->handler,
     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);
                 element->qname, SysStringLen(element->qname));
 
     free_attribute_values(This);
index b7c560a..31be4d8 100644 (file)
@@ -831,7 +831,7 @@ HRESULT create_selection(xmlNodePtr node, xmlChar* query, IXMLDOMNodeList **out)
     TRACE("found %d matches\n", xmlXPathNodeSetGetLength(This->result->nodesetval));
 
 cleanup:
     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;
         IXMLDOMSelection_Release( &This->IXMLDOMSelection_iface );
     xmlXPathFreeContext(ctxt);
     return hr;
index 3e2c2f7..c4baef8 100644 (file)
@@ -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/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
 dll/win32/msxml4              # Synced to WineStaging-3.3
 dll/win32/msxml6              # Synced to WineStaging-3.3
 dll/win32/nddeapi             # Synced to WineStaging-3.3