[PATCH v2 0/3] MR9083: xmllite/writer: Remove now unnecessary helper.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> -- v2: xmllite/writer: Output element stack on SetOutput(). https://gitlab.winehq.org/wine/wine/-/merge_requests/9083
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/xmllite/writer.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index e39255b99d7..2ac26019c5e 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -593,20 +593,6 @@ static HRESULT write_output_quoted(xmlwriter *writer, const WCHAR *data, int len return *hr; } -static HRESULT write_output_buffer_char(xmlwriteroutput *output, WCHAR ch) -{ - return write_output_buffer(output, &ch, 1); -} - -static HRESULT write_output_buffer_quoted(xmlwriteroutput *output, const WCHAR *data, int len) -{ - write_output_buffer_char(output, '"'); - if (!is_empty_string(data)) - write_output_buffer(output, data, len); - write_output_buffer_char(output, '"'); - return S_OK; -} - /* TODO: test if we need to validate char range */ static HRESULT write_output_qname(xmlwriter *writer, const WCHAR *prefix, int prefix_len, const WCHAR *local_name, int local_len, HRESULT *hr) @@ -1498,7 +1484,7 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr { write_output_qname(writer, L" xmlns", 6, prefix, prefix_len, &hr); write_output(writer, L"=", 1, &hr); - write_output_buffer_quoted(writer->output, uri, -1); + write_output_quoted(writer, uri, -1, &hr); } if (value) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9083
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/xmllite/tests/writer.c | 2 +- dlls/xmllite/writer.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 760029ee670..b0ea2a54901 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -708,7 +708,7 @@ static void test_flush(void) IXmlWriter_Release(writer); - CHECK_OUTPUT_TODO(stream, "<p:a xmlns:p=\"uri\" />"); + CHECK_OUTPUT(stream, "<p:a xmlns:p=\"uri\" />"); IStream_Release(stream); /* Resetting output flushes output */ diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 2ac26019c5e..764db383231 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -248,6 +248,22 @@ static struct element *pop_element(xmlwriter *writer) return element; } +static HRESULT write_end_element(xmlwriter *writer, const struct element *element); + +static HRESULT writer_end_elements(xmlwriter *writer) +{ + struct element *element; + HRESULT hr = S_OK; + + while (hr == S_OK && (element = pop_element(writer))) + { + hr = write_end_element(writer, element); + writer_free_element(writer, element); + } + + return hr; +} + static WCHAR *writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len) { WCHAR *ret; @@ -820,6 +836,7 @@ static ULONG WINAPI xmlwriter_Release(IXmlWriter *iface) { IMalloc *imalloc = writer->imalloc; + writer_end_elements(writer); writeroutput_flush_stream(writer->output); if (writer->output) IUnknown_Release(&writer->output->IXmlWriterOutput_iface); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9083
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/xmllite/tests/writer.c | 19 +++++++++++++++++-- dlls/xmllite/writer.c | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index b0ea2a54901..c441e026924 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -725,7 +725,7 @@ static void test_flush(void) hr = IXmlWriter_SetOutput(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - CHECK_OUTPUT_TODO(stream, "<a />"); + CHECK_OUTPUT(stream, "<a />"); IStream_Release(stream); /* Switching to different output. */ @@ -737,11 +737,26 @@ static void test_flush(void) CHECK_OUTPUT(stream, ""); stream2 = writer_set_output(writer); - CHECK_OUTPUT_TODO(stream, "<m:a xmlns:m=\"uri\" />"); + CHECK_OUTPUT(stream, "<m:a xmlns:m=\"uri\" />"); IStream_Release(stream2); IStream_Release(stream); + /* Setting same output again */ + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, L"m", L"a", L"uri"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, ""); + + hr = IXmlWriter_SetOutput(writer, (IUnknown *)stream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<m:a xmlns:m=\"uri\" />"); + + IStream_Release(stream); + /* Direct flush with open element */ stream = writer_set_output(writer); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 764db383231..c96b8ee374d 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -859,6 +859,9 @@ static HRESULT WINAPI xmlwriter_SetOutput(IXmlWriter *iface, IUnknown *output) TRACE("(%p)->(%p)\n", This, output); + writer_end_elements(This); + writeroutput_flush_stream(This->output); + if (This->output) { writeroutput_release_stream(This->output); IUnknown_Release(&This->output->IXmlWriterOutput_iface); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9083
participants (2)
-
Nikolay Sivov -
Nikolay Sivov (@nsivov)