[MSXML3] Sync with Wine Staging 4.18. CORE-16441

This commit is contained in:
Amine Khaldi 2019-11-10 14:07:55 +01:00
parent ac43fd2b92
commit eb44c20c47
8 changed files with 200 additions and 22 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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

View 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 */
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)

View 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;
htmldoc_dumpcontent(output, result, (const char*)encoding, indent);
htmldoc_dumpcontent(output, result, encoding, indent);
}
else if (method && xmlStrEqual(method, (const xmlChar *)"xhtml"))
{

View file

@ -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);

View file

@ -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;

View 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/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