[PATCH 0/5] MR11066: msxml3/writer: Normalize newlines in CDATA content.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/mxwriter.c | 237 +++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 138 deletions(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index d8d60e863b6..c2dda9e89c9 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -35,15 +35,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml); -static const WCHAR emptyW[] = {0}; -static const WCHAR spaceW[] = {' '}; -static const WCHAR quotW[] = {'\"'}; -static const WCHAR closetagW[] = {'>','\r','\n'}; -static const WCHAR crlfW[] = {'\r','\n'}; -static const WCHAR entityW[] = {'<','!','E','N','T','I','T','Y',' '}; -static const WCHAR publicW[] = {'P','U','B','L','I','C',' '}; -static const WCHAR systemW[] = {'S','Y','S','T','E','M',' '}; - /* should be ordered as encoding names are sorted */ typedef enum { @@ -461,9 +452,9 @@ static HRESULT write_output_buffer(mxwriter *writer, const WCHAR *data, int len) static HRESULT write_output_buffer_quoted(mxwriter *writer, const WCHAR *data, int len) { - write_output_buffer(writer, quotW, 1); + write_output_buffer(writer, L"\"", 1); write_output_buffer(writer, data, len); - write_output_buffer(writer, quotW, 1); + write_output_buffer(writer, L"\"", 1); return S_OK; } @@ -578,33 +569,27 @@ static void write_string_with_crlf(mxwriter *writer, const WCHAR *str, int len) static void write_prolog_buffer(mxwriter *writer) { - static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='}; - static const WCHAR encodingW[] = {' ','e','n','c','o','d','i','n','g','=','\"'}; - static const WCHAR standaloneW[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'}; - static const WCHAR yesW[] = {'y','e','s','\"','?','>'}; - static const WCHAR noW[] = {'n','o','\"','?','>'}; - /* version */ - write_output_buffer(writer, versionW, ARRAY_SIZE(versionW)); + write_output_buffer(writer, L"<?xml version=", 14); write_output_buffer_quoted(writer, writer->version, -1); /* encoding */ - write_output_buffer(writer, encodingW, ARRAY_SIZE(encodingW)); + write_output_buffer(writer, L" encoding=", 10); if (writer->dest) - write_output_buffer(writer, writer->encoding, -1); + write_output_buffer_quoted(writer, writer->encoding, -1); else - write_output_buffer(writer, L"UTF-16", ARRAY_SIZE(L"UTF-16") - 1); - write_output_buffer(writer, quotW, 1); + write_output_buffer_quoted(writer, L"UTF-16", 6); /* standalone */ - write_output_buffer(writer, standaloneW, ARRAY_SIZE(standaloneW)); + write_output_buffer(writer, L" standalone=", 12); if (writer->props[MXWriter_Standalone] == VARIANT_TRUE) - write_output_buffer(writer, yesW, ARRAY_SIZE(yesW)); + write_output_buffer_quoted(writer, L"yes", 3); else - write_output_buffer(writer, noW, ARRAY_SIZE(noW)); + write_output_buffer_quoted(writer, L"no", 2); + write_output_buffer(writer, L"?>", 2); - write_output_buffer(writer, crlfW, ARRAY_SIZE(crlfW)); + write_output_buffer(writer, L"\r\n", 2); writer->newline = TRUE; } @@ -637,14 +622,12 @@ static HRESULT write_data_to_stream(mxwriter *writer) we have to close it differently. */ static void close_element_starttag(mxwriter *writer) { - static const WCHAR gtW[] = {'>'}; if (!writer->element) return; - write_output_buffer(writer, gtW, 1); + write_output_buffer(writer, L">", 1); } static void write_node_indent(mxwriter *writer) { - static const WCHAR tabW[] = {'\t'}; int indent = writer->indent; if (!writer->props[MXWriter_Indent] || writer->text) @@ -656,9 +639,9 @@ static void write_node_indent(mxwriter *writer) /* This is to workaround PI output logic that always puts newline chars, document prolog PI does that too. */ if (!writer->newline) - write_output_buffer(writer, crlfW, ARRAY_SIZE(crlfW)); + write_output_buffer(writer, L"\r\n", 2); while (indent--) - write_output_buffer(writer, tabW, 1); + write_output_buffer(writer, L"\t", 1); writer->newline = FALSE; writer->text = FALSE; @@ -1271,12 +1254,10 @@ static HRESULT WINAPI SAXContentHandler_endPrefixMapping( static void mxwriter_write_attribute(mxwriter *writer, const WCHAR *qname, int qname_len, const WCHAR *value, int value_len, BOOL escape) { - static const WCHAR eqW[] = {'='}; - /* space separator in front of every attribute */ - write_output_buffer(writer, spaceW, 1); + write_output_buffer(writer, L" ", 1); write_output_buffer(writer, qname, qname_len); - write_output_buffer(writer, eqW, 1); + write_output_buffer(writer, L"=", 1); write_output_buffer(writer, L"\"", 1); if (escape) @@ -1288,15 +1269,13 @@ static void mxwriter_write_attribute(mxwriter *writer, const WCHAR *qname, int q static void mxwriter_write_starttag(mxwriter *writer, const WCHAR *qname, int len) { - static const WCHAR ltW[] = {'<'}; - close_element_starttag(writer); - set_element_name(writer, qname ? qname : emptyW, qname ? len : 0); + set_element_name(writer, qname ? qname : L"", qname ? len : 0); write_node_indent(writer); - write_output_buffer(writer, ltW, 1); - write_output_buffer(writer, qname ? qname : emptyW, qname ? len : 0); + write_output_buffer(writer, L"<", 1); + write_output_buffer(writer, qname ? qname : L"", qname ? len : 0); writer_inc_indent(writer); } @@ -1372,18 +1351,14 @@ static HRESULT WINAPI SAXContentHandler_endElement( if (This->element) { - static const WCHAR closeW[] = {'/','>'}; - write_output_buffer(This, closeW, 2); + write_output_buffer(This, L"/>", 2); } else { - static const WCHAR closetagW[] = {'<','/'}; - static const WCHAR gtW[] = {'>'}; - write_node_indent(This); - write_output_buffer(This, closetagW, 2); + write_output_buffer(This, L"</", 2); write_output_buffer(This, QName, nQName); - write_output_buffer(This, gtW, 1); + write_output_buffer(This, L">", 1); } set_element_name(This, NULL, 0); @@ -1439,28 +1414,26 @@ static HRESULT WINAPI SAXContentHandler_processingInstruction( const WCHAR *data, int ndata) { - mxwriter *This = impl_from_ISAXContentHandler( iface ); - static const WCHAR openpiW[] = {'<','?'}; - static const WCHAR closepiW[] = {'?','>','\r','\n'}; + mxwriter *writer = impl_from_ISAXContentHandler(iface); - TRACE("(%p)->(%s %s)\n", This, debugstr_wn(target, ntarget), debugstr_wn(data, ndata)); + TRACE("%p, %s, %s.\n", iface, debugstr_wn(target, ntarget), debugstr_wn(data, ndata)); if (!target) return E_INVALIDARG; - write_node_indent(This); - write_output_buffer(This, openpiW, ARRAY_SIZE(openpiW)); + write_node_indent(writer); + write_output_buffer(writer, L"<?", 2); if (*target) - write_output_buffer(This, target, ntarget); + write_output_buffer(writer, target, ntarget); if (data && *data && ndata) { - write_output_buffer(This, spaceW, 1); - write_output_buffer(This, data, ndata); + write_output_buffer(writer, L" ", 1); + write_output_buffer(writer, data, ndata); } - write_output_buffer(This, closepiW, ARRAY_SIZE(closepiW)); - This->newline = TRUE; + write_output_buffer(writer, L"?>\r\n", 4); + writer->newline = TRUE; return S_OK; } @@ -1517,60 +1490,56 @@ static HRESULT WINAPI SAXLexicalHandler_startDTD(ISAXLexicalHandler *iface, const WCHAR *name, int name_len, const WCHAR *publicId, int publicId_len, const WCHAR *systemId, int systemId_len) { - static const WCHAR doctypeW[] = {'<','!','D','O','C','T','Y','P','E',' '}; - static const WCHAR openintW[] = {'[','\r','\n'}; + mxwriter *writer = impl_from_ISAXLexicalHandler(iface); - mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - - TRACE("(%p)->(%s %s %s)\n", This, debugstr_wn(name, name_len), debugstr_wn(publicId, publicId_len), + TRACE("%p, %s. %s. %s.\n", iface, debugstr_wn(name, name_len), debugstr_wn(publicId, publicId_len), debugstr_wn(systemId, systemId_len)); if (!name) return E_INVALIDARG; - write_output_buffer(This, doctypeW, ARRAY_SIZE(doctypeW)); + write_output_buffer(writer, L"<!DOCTYPE ", 10); if (*name) { - write_output_buffer(This, name, name_len); - write_output_buffer(This, spaceW, 1); + write_output_buffer(writer, name, name_len); + write_output_buffer(writer, L" ", 1); } if (publicId) { - write_output_buffer(This, publicW, ARRAY_SIZE(publicW)); - write_output_buffer_quoted(This, publicId, publicId_len); + write_output_buffer(writer, L"PUBLIC ", 7); + write_output_buffer_quoted(writer, publicId, publicId_len); if (!systemId) return E_INVALIDARG; if (*publicId) - write_output_buffer(This, spaceW, 1); + write_output_buffer(writer, L" ", 1); - write_output_buffer_quoted(This, systemId, systemId_len); + write_output_buffer_quoted(writer, systemId, systemId_len); if (*systemId) - write_output_buffer(This, spaceW, 1); + write_output_buffer(writer, L" ", 1); } else if (systemId) { - write_output_buffer(This, systemW, ARRAY_SIZE(systemW)); - write_output_buffer_quoted(This, systemId, systemId_len); + write_output_buffer(writer, L"SYSTEM ", 7); + write_output_buffer_quoted(writer, systemId, systemId_len); if (*systemId) - write_output_buffer(This, spaceW, 1); + write_output_buffer(writer, L" ", 1); } - write_output_buffer(This, openintW, ARRAY_SIZE(openintW)); + write_output_buffer(writer, L"[\r\n", 3); return S_OK; } static HRESULT WINAPI SAXLexicalHandler_endDTD(ISAXLexicalHandler *iface) { - mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - static const WCHAR closedtdW[] = {']','>','\r','\n'}; + mxwriter *writer = impl_from_ISAXLexicalHandler(iface); - TRACE("(%p)\n", This); + TRACE("%p.\n", iface); - write_output_buffer(This, closedtdW, ARRAY_SIZE(closedtdW)); + write_output_buffer(writer, L"]>\r\n", 4); return S_OK; } @@ -1591,48 +1560,44 @@ static HRESULT WINAPI SAXLexicalHandler_endEntity(ISAXLexicalHandler *iface, con static HRESULT WINAPI SAXLexicalHandler_startCDATA(ISAXLexicalHandler *iface) { - static const WCHAR scdataW[] = {'<','!','[','C','D','A','T','A','['}; - mxwriter *This = impl_from_ISAXLexicalHandler( iface ); + mxwriter *writer = impl_from_ISAXLexicalHandler(iface); - TRACE("(%p)\n", This); + TRACE("%p.\n", iface); - write_node_indent(This); - write_output_buffer(This, scdataW, ARRAY_SIZE(scdataW)); - This->cdata = TRUE; + write_node_indent(writer); + write_output_buffer(writer, L"<![CDATA[", 9); + writer->cdata = TRUE; return S_OK; } static HRESULT WINAPI SAXLexicalHandler_endCDATA(ISAXLexicalHandler *iface) { - mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - static const WCHAR ecdataW[] = {']',']','>'}; + mxwriter *writer = impl_from_ISAXLexicalHandler(iface); - TRACE("(%p)\n", This); + TRACE("%p.\n", iface); - write_output_buffer(This, ecdataW, ARRAY_SIZE(ecdataW)); - This->cdata = FALSE; + write_output_buffer(writer, L"]]>", 3); + writer->cdata = FALSE; return S_OK; } static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const WCHAR *chars, int nchars) { - mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - static const WCHAR copenW[] = {'<','!','-','-'}; - static const WCHAR ccloseW[] = {'-','-','>','\r','\n'}; + mxwriter *writer = impl_from_ISAXLexicalHandler(iface); - TRACE("(%p)->(%s:%d)\n", This, debugstr_wn(chars, nchars), nchars); + TRACE("%p, %s:%d.\n", iface, debugstr_wn(chars, nchars), nchars); if (!chars) return E_INVALIDARG; - close_element_starttag(This); - write_node_indent(This); + close_element_starttag(writer); + write_node_indent(writer); - write_output_buffer(This, copenW, ARRAY_SIZE(copenW)); + write_output_buffer(writer, L"<!--", 4); if (nchars) - write_output_buffer(This, chars, nchars); - write_output_buffer(This, ccloseW, ARRAY_SIZE(ccloseW)); + write_output_buffer(writer, chars, nchars); + write_output_buffer(writer, L"-->\r\n", 5); return S_OK; } @@ -1674,7 +1639,6 @@ static ULONG WINAPI SAXDeclHandler_Release(ISAXDeclHandler *iface) static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface, const WCHAR *name, int n_name, const WCHAR *model, int n_model) { - static const WCHAR elementW[] = {'<','!','E','L','E','M','E','N','T',' '}; mxwriter *This = impl_from_ISAXDeclHandler( iface ); TRACE("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name, @@ -1682,14 +1646,14 @@ static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface, if (!name || !model) return E_INVALIDARG; - write_output_buffer(This, elementW, ARRAY_SIZE(elementW)); + write_output_buffer(This, L"<!ELEMENT ", 10); if (n_name) { write_output_buffer(This, name, n_name); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); } if (n_model) write_output_buffer(This, model, n_model); - write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(This, L">\r\n", 3); return S_OK; } @@ -1700,38 +1664,36 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface, const WCHAR *value, int n_value) { mxwriter *This = impl_from_ISAXDeclHandler( iface ); - static const WCHAR attlistW[] = {'<','!','A','T','T','L','I','S','T',' '}; - static const WCHAR closetagW[] = {'>','\r','\n'}; TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This, debugstr_wn(element, n_element), n_element, debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default, debugstr_wn(value, n_value), n_value); - write_output_buffer(This, attlistW, ARRAY_SIZE(attlistW)); + write_output_buffer(This, L"<!ATTLIST ", 10); if (n_element) { write_output_buffer(This, element, n_element); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); } if (n_attr) { write_output_buffer(This, attr, n_attr); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); } if (n_type) { write_output_buffer(This, type, n_type); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); } if (n_default) { write_output_buffer(This, Default, n_default); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); } if (n_value) write_output_buffer_quoted(This, value, n_value); - write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(This, L">\r\n", 3); return S_OK; } @@ -1739,23 +1701,23 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface, static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface, const WCHAR *name, int n_name, const WCHAR *value, int n_value) { - mxwriter *This = impl_from_ISAXDeclHandler( iface ); + mxwriter *writer = impl_from_ISAXDeclHandler(iface); - TRACE("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name, + TRACE("%p, %s:%d, %s:%d.\n", iface, debugstr_wn(name, n_name), n_name, debugstr_wn(value, n_value), n_value); if (!name || !value) return E_INVALIDARG; - write_output_buffer(This, entityW, ARRAY_SIZE(entityW)); + write_output_buffer(writer, L"<!ENTITY ", 9); if (n_name) { - write_output_buffer(This, name, n_name); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(writer, name, n_name); + write_output_buffer(writer, L" ", 1); } if (n_value) - write_output_buffer_quoted(This, value, n_value); + write_output_buffer_quoted(writer, value, n_value); - write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(writer, L">\r\n", 3); return S_OK; } @@ -1764,33 +1726,33 @@ static HRESULT WINAPI SAXDeclHandler_externalEntityDecl(ISAXDeclHandler *iface, const WCHAR *name, int n_name, const WCHAR *publicId, int n_publicId, const WCHAR *systemId, int n_systemId) { - mxwriter *This = impl_from_ISAXDeclHandler( iface ); + mxwriter *writer = impl_from_ISAXDeclHandler(iface); - TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name, + TRACE("%p, %s:%d, %s:%d, %s:%d.\n", iface, debugstr_wn(name, n_name), n_name, debugstr_wn(publicId, n_publicId), n_publicId, debugstr_wn(systemId, n_systemId), n_systemId); if (!name || !systemId) return E_INVALIDARG; - write_output_buffer(This, entityW, ARRAY_SIZE(entityW)); + write_output_buffer(writer, L"<!ENTITY ", 9); if (n_name) { - write_output_buffer(This, name, n_name); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(writer, name, n_name); + write_output_buffer(writer, L" ", 1); } if (publicId) { - write_output_buffer(This, publicW, ARRAY_SIZE(publicW)); - write_output_buffer_quoted(This, publicId, n_publicId); - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); - write_output_buffer_quoted(This, systemId, n_systemId); + write_output_buffer(writer, L"PUBLIC ", 7); + write_output_buffer_quoted(writer, publicId, n_publicId); + write_output_buffer(writer, L" ", 1); + write_output_buffer_quoted(writer, systemId, n_systemId); } else { - write_output_buffer(This, systemW, ARRAY_SIZE(systemW)); - write_output_buffer_quoted(This, systemId, n_systemId); + write_output_buffer(writer, L"SYSTEM ", 7); + write_output_buffer_quoted(writer, systemId, n_systemId); } - write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(writer, L">\r\n", 3); return S_OK; } @@ -2293,7 +2255,6 @@ static HRESULT WINAPI SAXDTDHandler_notationDecl(ISAXDTDHandler *iface, const WCHAR *publicid, INT n_publicid, const WCHAR *systemid, INT n_systemid) { - static const WCHAR notationW[] = {'<','!','N','O','T','A','T','I','O','N',' '}; mxwriter *This = impl_from_ISAXDTDHandler( iface ); TRACE("(%p)->(%s:%d, %s:%d, %s:%d)\n", This, debugstr_wn(name, n_name), n_name, @@ -2302,30 +2263,30 @@ static HRESULT WINAPI SAXDTDHandler_notationDecl(ISAXDTDHandler *iface, if (!name || !n_name) return E_INVALIDARG; - write_output_buffer(This, notationW, ARRAY_SIZE(notationW)); + write_output_buffer(This, L"<!NOTATION ", 11); write_output_buffer(This, name, n_name); if (!publicid && !systemid) return E_INVALIDARG; - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); if (publicid) { - write_output_buffer(This, publicW, ARRAY_SIZE(publicW)); + write_output_buffer(This, L"PUBLIC ", 7); write_output_buffer_quoted(This, publicid, n_publicid); if (systemid) { - write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW)); + write_output_buffer(This, L" ", 1); write_output_buffer_quoted(This, systemid, n_systemid); } } else { - write_output_buffer(This, systemW, ARRAY_SIZE(systemW)); + write_output_buffer(This, L"SYSTEM ", 7); write_output_buffer_quoted(This, systemid, n_systemid); } - write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(This, L">\r\n", 3); return S_OK; } @@ -2771,7 +2732,7 @@ static HRESULT WINAPI MXAttributes_addAttribute(IMXAttributes *iface, attr->qname = SysAllocString(QName); attr->local = SysAllocString(localName); attr->uri = SysAllocString(uri); - attr->type = SysAllocString(type ? type : emptyW); + attr->type = SysAllocString(type ? type : L""); attr->value = SysAllocString(value); This->length++; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/tests/saxreader.c | 146 ++++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 35 deletions(-) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 9eb2ac1d8c2..51c427ec53d 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -35,6 +35,22 @@ #include "wine/test.h" +#define check_writer_output(writer, expected) check_writer_output_(writer, expected, false, __LINE__) +#define check_writer_output_todo(writer, expected) check_writer_output_(writer, expected, true, __LINE__) +static void check_writer_output_(IMXWriter *writer, const WCHAR *expected, bool todo, int line) +{ + VARIANT dest; + HRESULT hr; + + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_get_output(writer, &dest); + ok_(__FILE__, line)(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(V_VT(&dest) == VT_BSTR, "Unexpected type %d.\n", V_VT(&dest)); + todo_wine_if(todo) + ok_(__FILE__, line)(!wcscmp(expected, V_BSTR(&dest)), "Unexpected content %s.\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); +} + struct sink { IVBSAXContentHandler IVBSAXContentHandler_iface; @@ -5422,42 +5438,67 @@ static void test_mxwriter_comment(void) hr = ISAXLexicalHandler_comment(lexical, L"comment", 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!---->\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!---->\r\n"); hr = ISAXLexicalHandler_comment(lexical, L"comment", 7); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!---->\r\n<!--comment-->\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!---->\r\n<!--comment-->\r\n"); /* As an element child */ V_VT(&dest) = VT_EMPTY; hr = IMXWriter_put_output(writer, dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, _bstr_("a"), -1, NULL); + hr = ISAXLexicalHandler_comment(lexical, L"c1", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXLexicalHandler_comment(lexical, L"comment", 7); + check_writer_output(writer, L"<!--c1-->\r\n"); + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", -1, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, _bstr_("a"), -1); + check_writer_output(writer, L"<!--c1-->\r\n<a>"); + hr = ISAXLexicalHandler_comment(lexical, L"c2", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a><!--c2-->"); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", -1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a><!--c2--></a>"); + hr = ISAXLexicalHandler_comment(lexical, L"c3", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a><!--c2--></a><!--c3-->"); + + hr = IMXWriter_put_indent(writer, VARIANT_TRUE); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); + hr = IMXWriter_put_output(writer, dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "Unexpected type %d.\n", V_VT(&dest)); - todo_wine - ok(!lstrcmpW(L"<a><!--comment--></a>", V_BSTR(&dest)), "Unexpected content %s.\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + + hr = ISAXLexicalHandler_comment(lexical, L"c1", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->"); + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", -1, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a>"); + hr = ISAXLexicalHandler_comment(lexical, L"c2", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a>\r\n\t<!--c2-->"); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", -1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a>\r\n\t<!--c2-->\r\n</a>"); + hr = ISAXLexicalHandler_comment(lexical, L"c3", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a>\r\n\t<!--c2-->\r\n</a>\r\n<!--c3-->"); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"b", -1, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXLexicalHandler_comment(lexical, L"c4", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"b", -1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXLexicalHandler_comment(lexical, L"c5", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<!--c1-->\r\n<a>\r\n\t<!--c2-->\r\n</a>\r\n" + "<!--c3-->\r\n<b>\r\n\t<!--c4-->\r\n</b>\r\n<!--c5-->"); ISAXContentHandler_Release(content); ISAXLexicalHandler_Release(lexical); @@ -5555,37 +5596,72 @@ static void test_mxwriter_pi(void) hr = ISAXContentHandler_processingInstruction(content, L"target", 6, NULL, 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?\?>\r\n<?target?>\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?\?>\r\n<?target?>\r\n"); hr = ISAXContentHandler_processingInstruction(content, L"target", 4, L"data", 4); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output(writer, L"<?\?>\r\n<?target?>\r\n<?targ data?>\r\n"); + V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); + hr = IMXWriter_put_output(writer, dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?\?>\r\n<?target?>\r\n<?targ data?>\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + hr = ISAXContentHandler_processingInstruction(content, L"target", 6, L"data", 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + check_writer_output(writer, L"<?target?>\r\n"); + + /* As an element child */ V_VT(&dest) = VT_EMPTY; hr = IMXWriter_put_output(writer, dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXContentHandler_processingInstruction(content, L"target", 6, L"data", 0); + hr = ISAXContentHandler_processingInstruction(content, L"t1", 2, L"d1", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output(writer, L"<?t1 d1?>\r\n"); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, _bstr_("a"), -1, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output(writer, L"<?t1 d1?>\r\n<a>"); + + hr = ISAXContentHandler_processingInstruction(content, L"t2", 2, L"d2", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, _bstr_("a"), -1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXContentHandler_processingInstruction(content, L"t3", 2, L"d3", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXContentHandler_processingInstruction(content, L"t4", 2, L"d4", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + check_writer_output_todo(writer, L"<?t1 d1?>\r\n<a><?t2 d2?></a><?t3 d3?><?t4 d4?>"); + + /* With indentation */ + hr = IMXWriter_put_indent(writer, VARIANT_TRUE); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); + hr = IMXWriter_put_output(writer, dest); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = ISAXContentHandler_processingInstruction(content, L"t1", 2, L"d1", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<?t1 d1?>"); + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, _bstr_("a"), -1, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output(writer, L"<?t1 d1?>\r\n<a>"); + hr = ISAXContentHandler_processingInstruction(content, L"t2", 2, L"d2", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output_todo(writer, L"<?t1 d1?>\r\n<a>\r\n\t<?t2 d2?>"); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, _bstr_("a"), -1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_writer_output(writer, L"<?t1 d1?>\r\n<a>\r\n\t<?t2 d2?>\r\n</a>"); + hr = ISAXContentHandler_processingInstruction(content, L"t3", 2, L"d3", 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = ISAXContentHandler_processingInstruction(content, L"t4", 2, L"d4", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?target?>\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output_todo(writer, L"<?t1 d1?>\r\n<a>\r\n\t<?t2 d2?>\r\n</a>\r\n<?t3 d3?>\r\n<?t4 d4?>"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/tests/saxreader.c | 346 ++++++---------------------------- 1 file changed, 54 insertions(+), 292 deletions(-) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 51c427ec53d..62eea511504 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -3711,7 +3711,6 @@ static void test_mxwriter_properties(void) VARIANT_BOOL b; HRESULT hr; BSTR str, str2; - VARIANT dest; test_mxwriter_default_properties(mxwriter_default_props); @@ -3804,13 +3803,8 @@ static void test_mxwriter_properties(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?>\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?>\r\n"); + ISAXContentHandler_Release(content); hr = IMXWriter_get_version(writer, NULL); @@ -4057,7 +4051,6 @@ static void test_mxwriter_startenddocument(void) { ISAXContentHandler *content; IMXWriter *writer; - VARIANT dest; HRESULT hr; hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, @@ -4073,26 +4066,14 @@ static void test_mxwriter_startenddocument(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n", V_BSTR(&dest)), - "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"); /* now try another startDocument */ hr = ISAXContentHandler_startDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); /* and get duplicated prolog */ - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n" - "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n", V_BSTR(&dest)), - "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n" + "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4114,12 +4095,7 @@ static void test_mxwriter_startenddocument(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L""); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4144,13 +4120,7 @@ static void test_mxwriter_startenddocument(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n<a>", V_BSTR(&dest)), - "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n<a>"); free_bstrs(); } @@ -4276,6 +4246,8 @@ static void test_mxwriter_startendelement_batch(const struct writer_startendelem &IID_IMXWriter, (void**)&writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + winetest_push_context("Test %d", i); + hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -4296,7 +4268,7 @@ static void test_mxwriter_startendelement_batch(const struct writer_startendelem hr = ISAXContentHandler_startElement(content, table->uri, table->uri ? lstrlenW(table->uri) : 0, table->local_name, table->local_name ? lstrlenW(table->local_name) : 0, table->qname, table->qname ? lstrlenW(table->qname) : 0, table->attr); - ok(hr == table->hr, "test %d: got %#lx, expected %#lx\n", i, hr, table->hr); + ok(hr == table->hr, "Unexpected hr %#lx.\n", hr); } if (table->type & EndElement) @@ -4304,26 +4276,18 @@ static void test_mxwriter_startendelement_batch(const struct writer_startendelem hr = ISAXContentHandler_endElement(content, table->uri, table->uri ? lstrlenW(table->uri) : 0, table->local_name, table->local_name ? lstrlenW(table->local_name) : 0, table->qname, table->qname ? lstrlenW(table->qname) : 0); - ok(hr == table->hr, "test %d: got %#lx, expected %#lx\n", i, hr, table->hr); + ok(hr == table->hr, "Unexpected hr %#lx.\n", hr); } /* test output */ if (hr == S_OK) - { - VARIANT dest; - - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(table->output, V_BSTR(&dest)), - "test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), wine_dbgstr_w(table->output)); - VariantClear(&dest); - } + check_writer_output(writer, table->output); ISAXContentHandler_Release(content); IMXWriter_Release(writer); + winetest_pop_context(); + table++; i++; } @@ -4389,17 +4353,7 @@ static void test_mxwriter_startendelement_batch2(const struct writer_startendele /* test output */ if (hr == S_OK) - { - VARIANT dest; - - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(table->output, V_BSTR(&dest)), - "test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), wine_dbgstr_w(table->output)); - VariantClear(&dest); - } + check_writer_output(writer, table->output); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4448,22 +4402,12 @@ static void test_mxwriter_startendelement(void) hr = IVBSAXContentHandler_startElement(vb_content, &bstr_empty, &bstr_b, &bstr_empty, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<>"); hr = IVBSAXContentHandler_startElement(vb_content, &bstr_empty, &bstr_empty, &bstr_b, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<><b>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<><b>"); hr = IVBSAXContentHandler_endElement(vb_content, &bstr_null, &bstr_null, &bstr_b); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); @@ -4483,12 +4427,7 @@ static void test_mxwriter_startendelement(void) hr = IVBSAXContentHandler_endElement(vb_content, &bstr_empty, &bstr_empty, &bstr_b); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<><b></b>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<><b></b>"); SysFreeString(bstr_empty); SysFreeString(bstr_a); @@ -4518,22 +4457,12 @@ static void test_mxwriter_startendelement(void) hr = ISAXContentHandler_startElement(content, L"", 0, L"b", 1, L"", 0, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<>"); hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"b", 1, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<><b>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<><b>"); hr = ISAXContentHandler_endElement(content, NULL, 0, NULL, 0, L"a:b", 3); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); @@ -4547,13 +4476,7 @@ static void test_mxwriter_startendelement(void) hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"b", 1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<><b></b>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<><b></b>"); hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -4562,25 +4485,14 @@ static void test_mxwriter_startendelement(void) hr = IMXWriter_put_output(writer, dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L""); hr = ISAXContentHandler_startDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"abcdef", 3, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<abc>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<abc>"); hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -4588,12 +4500,7 @@ static void test_mxwriter_startendelement(void) hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"abdcdef", 3); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<abc></abd>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<abc></abd>"); V_VT(&dest) = VT_EMPTY; hr = IMXWriter_put_output(writer, dest); @@ -4602,12 +4509,7 @@ static void test_mxwriter_startendelement(void) /* length -1 */ hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", -1, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<a>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<a>"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4668,12 +4570,7 @@ static void test_mxwriter_characters(void) hr = ISAXContentHandler_characters(content, L"TESTCHARDATA .", 14); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"VbCharsTESTCHARDATA .", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"VbCharsTESTCHARDATA ."); hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -4705,12 +4602,7 @@ static void test_mxwriter_characters(void) hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", 1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<a></a>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<a></a>"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4790,12 +4682,7 @@ static void test_mxwriter_characters(void) hr = ISAXContentHandler_characters(content, L"\ncd", 3); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "Unexpected type %d.\n", V_VT(&dest)); - ok(!lstrcmpW(L"ab\r\n\r\ncd", V_BSTR(&dest)), "Unexpected content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"ab\r\n\r\ncd"); V_VT(&dest) = VT_EMPTY; hr = IMXWriter_put_output(writer, dest); @@ -4804,12 +4691,7 @@ static void test_mxwriter_characters(void) hr = ISAXContentHandler_characters(content, L"\nab\rc\r\n", 7); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "Unexpected type %d.\n", V_VT(&dest)); - ok(!lstrcmpW(L"\r\nab\r\nc\r\n", V_BSTR(&dest)), "Unexpected content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"\r\nab\r\nc\r\n"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4841,15 +4723,7 @@ static void test_mxwriter_characters(void) /* test output */ if (hr == S_OK) - { - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(table->output, V_BSTR(&dest)), - "test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), wine_dbgstr_w(table->output)); - VariantClear(&dest); - } + check_writer_output(writer, table->output); /* with disabled escaping */ V_VT(&dest) = VT_EMPTY; @@ -4864,15 +4738,7 @@ static void test_mxwriter_characters(void) /* test output */ if (hr == S_OK) - { - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(table->data, V_BSTR(&dest)), - "test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), wine_dbgstr_w(table->data)); - VariantClear(&dest); - } + check_writer_output(writer, table->data); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -4907,12 +4773,7 @@ static void test_mxwriter_characters(void) hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", 1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<a>test</a>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<a>test</a>"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -5062,13 +4923,7 @@ static void test_mxwriter_stream(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n", V_BSTR(&dest)), - "Got wrong content: %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"); /* test when BOM is written to output stream */ V_VT(&dest) = VT_EMPTY; @@ -5151,13 +5006,7 @@ static void test_mxwriter_encoding(void) /* The content is always re-encoded to UTF-16 when the output is * retrieved as a BSTR. */ - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n", V_BSTR(&dest)), - "got wrong content: %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"); /* switch encoding when something is written already */ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); @@ -5513,7 +5362,6 @@ static void test_mxwriter_cdata(void) ISAXContentHandler *content; ISAXLexicalHandler *lexical; IMXWriter *writer; - VARIANT dest; HRESULT hr; hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, @@ -5538,12 +5386,7 @@ static void test_mxwriter_cdata(void) hr = ISAXLexicalHandler_startCDATA(lexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<![CDATA[", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<![CDATA["); hr = IVBSAXLexicalHandler_startCDATA(vblexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -5558,13 +5401,7 @@ static void test_mxwriter_cdata(void) hr = ISAXLexicalHandler_endCDATA(lexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - todo_wine - ok(!lstrcmpW(L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output_todo(writer, L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>"); ISAXContentHandler_Release(content); ISAXLexicalHandler_Release(lexical); @@ -5671,7 +5508,6 @@ static void test_mxwriter_ignorablespaces(void) { ISAXContentHandler *content; IMXWriter *writer; - VARIANT dest; HRESULT hr; hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, @@ -5693,12 +5529,7 @@ static void test_mxwriter_ignorablespaces(void) hr = ISAXContentHandler_ignorableWhitespace(content, L"data", 1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"datad", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"datad"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -5759,12 +5590,7 @@ static void test_mxwriter_dtd(void) hr = ISAXLexicalHandler_startDTD(lexical, L"name", 4, NULL, 0, NULL, 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!DOCTYPE name [\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!DOCTYPE name [\r\n"); /* system id is required if public is present */ hr = ISAXLexicalHandler_startDTD(lexical, L"name", 4, L"pub", 3, NULL, 0); @@ -5773,13 +5599,8 @@ static void test_mxwriter_dtd(void) hr = ISAXLexicalHandler_startDTD(lexical, L"name", 4, L"pub", 3, L"sys", 3); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\"" - "<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\"" + "<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n"); hr = ISAXLexicalHandler_endDTD(lexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -5787,14 +5608,8 @@ static void test_mxwriter_dtd(void) hr = IVBSAXLexicalHandler_endDTD(vblexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\"" - "<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n]>\r\n]>\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\"" + "<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n]>\r\n]>\r\n"); /* element declaration */ V_VT(&dest) = VT_EMPTY; @@ -5813,13 +5628,7 @@ static void test_mxwriter_dtd(void) hr = ISAXDeclHandler_elementDecl(decl, L"name", 4, L"content", 7); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ELEMENT name content>\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!ELEMENT name content>\r\n"); V_VT(&dest) = VT_EMPTY; hr = IMXWriter_put_output(writer, dest); @@ -5828,13 +5637,7 @@ static void test_mxwriter_dtd(void) hr = ISAXDeclHandler_elementDecl(decl, L"name", 4, L"content", 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ELEMENT name >\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!ELEMENT name >\r\n"); /* attribute declaration */ V_VT(&dest) = VT_EMPTY; @@ -5845,13 +5648,7 @@ static void test_mxwriter_dtd(void) L"#REQUIRED", 9, L"value", 5); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"); hr = ISAXDeclHandler_attributeDecl(decl, L"element", 7, L"attribute2", 10, L"CDATA", 5, L"#REQUIRED", 9, L"value2", 6); @@ -5861,15 +5658,9 @@ static void test_mxwriter_dtd(void) L"#REQUIRED", 9, L"value3", 6); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n" + check_writer_output(writer, L"<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n" "<!ATTLIST element attribute2 CDATA #REQUIRED \"value2\">\r\n" - "<!ATTLIST element2 attribute3 CDATA #REQUIRED \"value3\">\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + "<!ATTLIST element2 attribute3 CDATA #REQUIRED \"value3\">\r\n"); /* internal entities */ V_VT(&dest) = VT_EMPTY; @@ -5888,12 +5679,7 @@ static void test_mxwriter_dtd(void) hr = ISAXDeclHandler_internalEntityDecl(decl, L"name", 4, L"value", 5); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ENTITY name \"value\">\r\n", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<!ENTITY name \"value\">\r\n"); /* external entities */ V_VT(&dest) = VT_EMPTY; @@ -5921,14 +5707,7 @@ static void test_mxwriter_dtd(void) hr = ISAXDeclHandler_externalEntityDecl(decl, L"name", 4, L"pubid", 5, NULL, 0); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<!ENTITY name PUBLIC \"pubid\" \"sysid\">\r\n<!ENTITY name SYSTEM \"sysid\">\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - - VariantClear(&dest); + check_writer_output(writer, L"<!ENTITY name PUBLIC \"pubid\" \"sysid\">\r\n<!ENTITY name SYSTEM \"sysid\">\r\n"); /* notation declaration */ hr = IMXWriter_QueryInterface(writer, &IID_ISAXDTDHandler, (void**)&dtd); @@ -5953,17 +5732,11 @@ static void test_mxwriter_dtd(void) hr = ISAXDTDHandler_notationDecl(dtd, L"name", 4, NULL, 0, L"sysid", 5); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW( + check_writer_output(writer, L"<!NOTATION name" "<!NOTATION name PUBLIC \"pubid\">\r\n" "<!NOTATION name PUBLIC \"pubid\" \"sysid\">\r\n" - "<!NOTATION name SYSTEM \"sysid\">\r\n", - V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - - VariantClear(&dest); + "<!NOTATION name SYSTEM \"sysid\">\r\n"); ISAXDTDHandler_Release(dtd); @@ -6414,7 +6187,6 @@ static void test_mxwriter_indent(void) { ISAXContentHandler *content; IMXWriter *writer; - VARIANT dest; HRESULT hr; hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, &IID_IMXWriter, (void**)&writer); @@ -6453,13 +6225,8 @@ static void test_mxwriter_indent(void) hr = ISAXContentHandler_endDocument(content); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - V_VT(&dest) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &dest); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - ok(!lstrcmpW(L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n<a><b>\r\n\t\t<c/>\r\n\t</b>\r\n</a>", V_BSTR(&dest)), - "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); - VariantClear(&dest); + check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n" + "<a><b>\r\n\t\t<c/>\r\n\t</b>\r\n</a>"); ISAXContentHandler_Release(content); IMXWriter_Release(writer); @@ -6521,12 +6288,7 @@ static void test_mxwriter_from_reader(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); VariantClear(&var); - V_VT(&var) = VT_EMPTY; - hr = IMXWriter_get_output(writer, &var); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(V_VT(&var) == VT_BSTR, "Unexpected output type %d.\n", V_VT(&var)); - ok(!lstrcmpW(L"<a>text</a>", V_BSTR(&var)), "Unexpected content %s.\n", wine_dbgstr_w(V_BSTR(&var))); - VariantClear(&var); + check_writer_output(writer, L"<a>text</a>"); IMXWriter_Release(writer); IVBSAXXMLReader_Release(reader); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/tests/saxreader.c | 39 ++++++++++------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 62eea511504..d35370f8a89 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -2529,8 +2529,6 @@ static void test_saxreader_cdata(void) ISAXXMLReader_Release(reader); table++; } - - free_bstrs(); } static void test_saxreader_pi(void) @@ -2578,8 +2576,6 @@ static void test_saxreader_pi(void) ISAXXMLReader_Release(reader); table++; } - - free_bstrs(); } static void test_saxreader_characters(void) @@ -2638,8 +2634,6 @@ static void test_saxreader_characters(void) ISAXXMLReader_Release(reader); table++; } - - free_bstrs(); } static void test_saxreader_properties(void) @@ -4121,8 +4115,6 @@ static void test_mxwriter_startenddocument(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output(writer, L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n<a>"); - - free_bstrs(); } enum startendtype @@ -4291,8 +4283,6 @@ static void test_mxwriter_startendelement_batch(const struct writer_startendelem table++; i++; } - - free_bstrs(); } /* point of these test is to start/end element with different names and name lengths */ @@ -4360,8 +4350,6 @@ static void test_mxwriter_startendelement_batch2(const struct writer_startendele table++; i++; - - free_bstrs(); } } @@ -5353,7 +5341,6 @@ static void test_mxwriter_comment(void) ISAXLexicalHandler_Release(lexical); IVBSAXLexicalHandler_Release(vblexical); IMXWriter_Release(writer); - free_bstrs(); } static void test_mxwriter_cdata(void) @@ -5407,7 +5394,6 @@ static void test_mxwriter_cdata(void) ISAXLexicalHandler_Release(lexical); IVBSAXLexicalHandler_Release(vblexical); IMXWriter_Release(writer); - free_bstrs(); } static void test_mxwriter_pi(void) @@ -5458,13 +5444,13 @@ static void test_mxwriter_pi(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output(writer, L"<?t1 d1?>\r\n"); - hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, _bstr_("a"), -1, NULL); + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", -1, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output(writer, L"<?t1 d1?>\r\n<a>"); hr = ISAXContentHandler_processingInstruction(content, L"t2", 2, L"d2", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, _bstr_("a"), -1); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", -1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = ISAXContentHandler_processingInstruction(content, L"t3", 2, L"d3", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -5484,13 +5470,13 @@ static void test_mxwriter_pi(void) hr = ISAXContentHandler_processingInstruction(content, L"t1", 2, L"d1", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output_todo(writer, L"<?t1 d1?>"); - hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, _bstr_("a"), -1, NULL); + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", -1, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output(writer, L"<?t1 d1?>\r\n<a>"); hr = ISAXContentHandler_processingInstruction(content, L"t2", 2, L"d2", 2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output_todo(writer, L"<?t1 d1?>\r\n<a>\r\n\t<?t2 d2?>"); - hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, _bstr_("a"), -1); + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", -1); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); check_writer_output(writer, L"<?t1 d1?>\r\n<a>\r\n\t<?t2 d2?>\r\n</a>"); hr = ISAXContentHandler_processingInstruction(content, L"t3", 2, L"d3", 2); @@ -5746,7 +5732,6 @@ static void test_mxwriter_dtd(void) IVBSAXDeclHandler_Release(vbdecl); ISAXDeclHandler_Release(decl); IMXWriter_Release(writer); - free_bstrs(); } typedef struct { @@ -6230,8 +6215,6 @@ static void test_mxwriter_indent(void) ISAXContentHandler_Release(content); IMXWriter_Release(writer); - - free_bstrs(); } static void test_saxreader_vb_content_handler(void) @@ -6418,34 +6401,34 @@ static void test_saxreader_max_element_depth(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); memset(&v, 0, sizeof(v)); - hr = ISAXXMLReader_getProperty(reader, _bstr_("max-element-depth"), &v); + hr = ISAXXMLReader_getProperty(reader, L"max-element-depth", &v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_VT(&v) == VT_I4, "Unexpected type %d.\n", V_VT(&v)); ok(V_I4(&v) == 5000, "Unexpected value %ld.\n", V_I4(&v)); V_UI4(&v) = 2147483648; - hr = ISAXXMLReader_putProperty(reader, _bstr_("max-element-depth"), v); + hr = ISAXXMLReader_putProperty(reader, L"max-element-depth", v); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); V_I4(&v) = 2147483647; - hr = ISAXXMLReader_putProperty(reader, _bstr_("max-element-depth"), v); + hr = ISAXXMLReader_putProperty(reader, L"max-element-depth", v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXXMLReader_getProperty(reader, _bstr_("max-element-depth"), &v); + hr = ISAXXMLReader_getProperty(reader, L"max-element-depth", &v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_VT(&v) == VT_I4, "Unexpected type %d.\n", V_VT(&v)); ok(V_I4(&v) == 2147483647, "Unexpected value %ld.\n", V_I4(&v)); V_I4(&v) = 0; - hr = ISAXXMLReader_putProperty(reader, _bstr_("max-element-depth"), v); + hr = ISAXXMLReader_putProperty(reader, L"max-element-depth", v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = ISAXXMLReader_getProperty(reader, _bstr_("max-element-depth"), &v); + hr = ISAXXMLReader_getProperty(reader, L"max-element-depth", &v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_I4(&v) == 0, "Unexpected value %ld.\n", V_I4(&v)); V_I4(&v) = 1; - hr = ISAXXMLReader_putProperty(reader, _bstr_("max-element-depth"), v); + hr = ISAXXMLReader_putProperty(reader, L"max-element-depth", v); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); V_VT(&v) = VT_BSTR; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/mxwriter.c | 4 +++- dlls/msxml3/tests/saxreader.c | 2 +- dlls/msxml4/tests/saxreader.c | 1 - dlls/msxml6/tests/saxreader.c | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index c2dda9e89c9..947777e6fb4 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -1382,7 +1382,9 @@ static HRESULT WINAPI SAXContentHandler_characters(ISAXContentHandler *iface, co if (nchars) { - if (writer->cdata || writer->props[MXWriter_DisableEscaping] == VARIANT_TRUE) + if (writer->cdata) + write_string_with_crlf(writer, chars, nchars); + else if (writer->props[MXWriter_DisableEscaping] == VARIANT_TRUE) write_output_buffer(writer, chars, nchars); else write_escaped_string(writer, chars, nchars, EscapeText); diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index d35370f8a89..c85cd538d55 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -5388,7 +5388,7 @@ static void test_mxwriter_cdata(void) hr = ISAXLexicalHandler_endCDATA(lexical); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - check_writer_output_todo(writer, L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>"); + check_writer_output(writer, L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>"); ISAXContentHandler_Release(content); ISAXLexicalHandler_Release(lexical); diff --git a/dlls/msxml4/tests/saxreader.c b/dlls/msxml4/tests/saxreader.c index 196208c8d75..3dc185d723b 100644 --- a/dlls/msxml4/tests/saxreader.c +++ b/dlls/msxml4/tests/saxreader.c @@ -4847,7 +4847,6 @@ static void test_mxwriter_cdata(void) hr = IMXWriter_get_output(writer, &dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - todo_wine ok(!lstrcmpW(L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); VariantClear(&dest); diff --git a/dlls/msxml6/tests/saxreader.c b/dlls/msxml6/tests/saxreader.c index ad11ea29945..27e6e8c688b 100644 --- a/dlls/msxml6/tests/saxreader.c +++ b/dlls/msxml6/tests/saxreader.c @@ -2855,7 +2855,6 @@ static void test_mxwriter_cdata(void) hr = IMXWriter_get_output(writer, &dest); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); - todo_wine ok(!lstrcmpW(L"<![CDATA[<![CDATA[< > & \"\r\na\r\nb\r\n]]>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); VariantClear(&dest); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11066
participants (2)
-
Nikolay Sivov -
Nikolay Sivov (@nsivov)