Signed-off-by: David Kahurani k.kahurani@gmail.com
-- v3: xmllite/writer: Implement WriteSurrogateCharEntity. xmllite/writer: Implement WriteRawChars. xmllite/writer: Implement WriteChars.
From: David Kahurani k.kahurani@gmail.com
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 111 ++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 56 +++++++++++------- 2 files changed, 145 insertions(+), 22 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index d15fe8b64df..b607acd9edb 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1497,6 +1497,15 @@ static void test_writer_state(void) check_writer_state(writer, WR_E_INVALIDACTION); IStream_Release(stream);
+ /* WriteChars */ + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteChars(writer, L"a", 1); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + check_writer_state(writer, WR_E_INVALIDACTION); + + IStream_Release(stream); IXmlWriter_Release(writer); }
@@ -2123,6 +2132,107 @@ static void test_WriteString(void) IStream_Release(stream); }
+static void test_WriteChars(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + static WCHAR raw[] = {'s', 'a', 'm', 0xd800, 0xdc00, 'p', 'l', 'e', 0}; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"chars", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, L"<chars>", 20); + ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, L"<chars>", 7); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<chars><chars><chars>"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"chars", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, raw, 8); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + raw[3] = 0xdc00; + raw[4] = 0xd800; + hr = IXmlWriter_WriteChars(writer, raw, 8); + ok(hr == WR_E_INVALIDSURROGATEPAIR, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<chars>sam\U00010000plesam"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"chars", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, NULL, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteFullEndElement(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<chars></chars>"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"chars", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, L"", 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<chars"); + + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"c", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteChars(writer, L"", 5); + ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<c>"); + + IXmlWriter_Release(writer); + IStream_Release(stream); +} + static void test_WriteDocType(void) { static const struct @@ -2650,6 +2760,7 @@ START_TEST(writer) test_WriteAttributeString(); test_WriteFullEndElement(); test_WriteCharEntity(); + test_WriteChars(); test_WriteString(); test_WriteDocType(); test_WriteWhitespace(); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index def165656ef..b7e53b5d3c1 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1104,28 +1104,6 @@ static HRESULT WINAPI xmlwriter_WriteCharEntity(IXmlWriter *iface, WCHAR ch) return S_OK; }
-static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch) -{ - xmlwriter *This = impl_from_IXmlWriter(iface); - - FIXME("%p %s %d\n", This, wine_dbgstr_w(pwch), cwch); - - switch (This->state) - { - case XmlWriterState_Initial: - return E_UNEXPECTED; - case XmlWriterState_InvalidEncoding: - return MX_E_ENCODING; - case XmlWriterState_DocClosed: - return WR_E_INVALIDACTION; - default: - ; - } - - return E_NOTIMPL; -} - - static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment) { xmlwriter *This = impl_from_IXmlWriter(iface); @@ -1944,6 +1922,40 @@ static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, const WCHAR *stri return write_escaped_string(This, string, ~0u); }
+static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch) +{ + xmlwriter *writer = impl_from_IXmlWriter(iface); + + TRACE("%p, %s, %d\n", writer, debugstr_wn(pwch, cwch), cwch); + + if ((pwch == NULL && cwch != 0)) + return WC_E_XMLCHARACTER; + else if ((pwch == NULL && cwch == 0)) + return S_OK; + else if ((is_empty_string(pwch) && cwch == 0)) + return S_OK; + + switch (writer->state) + { + case XmlWriterState_Initial: + return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); + break; + case XmlWriterState_Ready: + case XmlWriterState_DocClosed: + writer->state = XmlWriterState_DocClosed; + return WR_E_INVALIDACTION; + default: + ; + } + + writer->textnode = 1; + return write_escaped_string(writer, pwch, cwch); +} + static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHAR wchLow, WCHAR wchHigh) { xmlwriter *This = impl_from_IXmlWriter(iface);
From: David Kahurani k.kahurani@gmail.com
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 95 +++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 33 +++++++++++-- 2 files changed, 124 insertions(+), 4 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index b607acd9edb..1a83246982c 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1903,6 +1903,100 @@ static void test_WriteCharEntity(void) IStream_Release(stream); }
+static void test_WriteRawChars(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + static WCHAR surrogates[] = {0xd800, 0xdc00, 0}; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteRawChars(writer, NULL, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, L"", 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"sub", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, L"<rawChars>", 5); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<sub><rawC"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"sub", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, L"<;;>", 10); + ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<sub><;;>"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"sub", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, surrogates, 1); + ok(hr == WR_E_INVALIDSURROGATEPAIR, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, surrogates, 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<sub>\U00010000"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"sub", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, L"", 5); + ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<sub>"); + IStream_Release(stream); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"sub", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, L"", 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<sub"); + + IXmlWriter_Release(writer); + IStream_Release(stream); +} + static void test_WriteString(void) { static const WCHAR surrogates[] = {0xd800, 0xdc00, 'x', 'y', '\0'}; @@ -2761,6 +2855,7 @@ START_TEST(writer) test_WriteFullEndElement(); test_WriteCharEntity(); test_WriteChars(); + test_WriteRawChars(); test_WriteString(); test_WriteDocType(); test_WriteWhitespace(); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index b7e53b5d3c1..095fdccef63 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1725,11 +1725,20 @@ static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + HRESULT hr = S_OK; + unsigned int count;
- FIXME("%p %s %d\n", This, wine_dbgstr_w(pwch), cwch); + TRACE("%p, %s, %d\n", writer, debugstr_wn(pwch, cwch), cwch);
- switch (This->state) + if ((pwch == NULL && cwch != 0)) + return WC_E_XMLCHARACTER; + else if ((pwch == NULL && cwch == 0)) + return S_OK; + else if ((is_empty_string(pwch) && cwch == 0)) + return S_OK; + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; @@ -1737,11 +1746,27 @@ static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *p return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; + case XmlWriterState_Ready: + write_xmldecl(writer, XmlStandalone_Omit); + break; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); default: ; }
- return E_NOTIMPL; + while (*pwch && cwch) + { + if (FAILED(hr = writer_get_next_write_count(pwch, cwch, &count))) return hr; + if (FAILED(hr = write_output_buffer(writer->output, pwch, count))) return hr; + + pwch += count; + cwch -= count; + } + + if (cwch) return WC_E_XMLCHARACTER; + + return hr; }
static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandalone standalone)
From: David Kahurani k.kahurani@gmail.com
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 55 +++++++++++++++++++++++++++++++++++-- dlls/xmllite/writer.c | 33 ++++++++++++++++++++-- 2 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 1a83246982c..7cd698d7441 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -138,6 +138,8 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) { IXmlReader *reader; HRESULT hr; + WCHAR low = 0xdcef; + WCHAR high = 0xdaff;
hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -217,7 +219,8 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- /* FIXME: add WriteSurrogateCharEntity */ + hr = IXmlWriter_WriteSurrogateCharEntity(writer, low, high); + ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
hr = IXmlWriter_WriteWhitespace(writer, L" "); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr); @@ -372,6 +375,8 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) { IXmlReader *reader; HRESULT hr; + WCHAR low = 0xdcef; + WCHAR high = 0xdaff;
hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -448,7 +453,8 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- /* TODO: WriteSurrogateCharEntity */ + hr = IXmlWriter_WriteSurrogateCharEntity(writer, low, high); + ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteWhitespace(writer, L" "); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr); @@ -1997,6 +2003,50 @@ static void test_WriteRawChars(void) IStream_Release(stream); }
+static void test_WriteSurrogateCharEntity(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + WCHAR low = 0xdcef; + WCHAR high = 0xdaff; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"root", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteSurrogateCharEntity(writer, high, low); + ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<root"); + + hr = IXmlWriter_WriteSurrogateCharEntity(writer, low, high); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteFullEndElement(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, "<root>󏳯</root>"); + + IXmlWriter_Release(writer); + IStream_Release(stream); +} + static void test_WriteString(void) { static const WCHAR surrogates[] = {0xd800, 0xdc00, 'x', 'y', '\0'}; @@ -2856,6 +2906,7 @@ START_TEST(writer) test_WriteCharEntity(); test_WriteChars(); test_WriteRawChars(); + test_WriteSurrogateCharEntity(); test_WriteString(); test_WriteDocType(); test_WriteWhitespace(); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 095fdccef63..054da344e46 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1983,11 +1983,38 @@ static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch,
static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHAR wchLow, WCHAR wchHigh) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + int codepoint; + WCHAR bufW[16];
- FIXME("%p %d %d\n", This, wchLow, wchHigh); + TRACE("%p, %d, %d\n", writer, wchLow, wchHigh);
- return E_NOTIMPL; + if (!IS_LOW_SURROGATE(wchLow)) + return WC_E_XMLCHARACTER; + + if (!IS_HIGH_SURROGATE(wchHigh)) + return WC_E_XMLCHARACTER; + + switch(writer->state) + { + case XmlWriterState_Initial: + return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); + break; + case XmlWriterState_DocClosed: + return WR_E_INVALIDACTION; + default: + ; + } + + codepoint = ((wchHigh - 0xd800) * 0x400) + (wchLow - 0xdc00) + 0x10000; + swprintf(bufW, ARRAY_SIZE(bufW), L"&#x%X;", codepoint); + write_output_buffer(writer->output, bufW, -1); + + return S_OK; }
static HRESULT WINAPI xmlwriter_WriteWhitespace(IXmlWriter *iface, LPCWSTR text)
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126494
Your paranoid android.
=== debian11 (32 bit report) ===
d3d8: stateblock: Timeout visual: Timeout
d3d9: d3d9ex: Timeout device: Timeout stateblock: Timeout visual: Timeout
d3dcompiler_43: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_46: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_47: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3drm: d3drm: Timeout vector: Timeout
d3dx10_34: d3dx10: Timeout
d3dx10_35: d3dx10: Timeout
d3dx10_36: d3dx10: Timeout
d3dx10_37: d3dx10: Timeout
d3dx10_38: d3dx10: Timeout
d3dx10_39: d3dx10: Timeout
Report validation errors: d3dx10: Timeout
=== debian11 (build log) ===
WineRunWineTest.pl:error: The task timed out
Nikolay Sivov (@nsivov) commented about dlls/xmllite/writer.c:
- switch (This->state)
- {
- case XmlWriterState_Initial:
return E_UNEXPECTED;
- case XmlWriterState_InvalidEncoding:
return MX_E_ENCODING;
- case XmlWriterState_DocClosed:
return WR_E_INVALIDACTION;
- default:
;
- }
- return E_NOTIMPL;
-}
Please keep relative order of method functions the way they are in the vtable. If you need to move helpers on top, do that.
Nikolay Sivov (@nsivov) commented about dlls/xmllite/writer.c:
return write_escaped_string(This, string, ~0u);
}
+static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch) +{
- xmlwriter *writer = impl_from_IXmlWriter(iface);
- TRACE("%p, %s, %d\n", writer, debugstr_wn(pwch, cwch), cwch);
Let's use "iface" value instead of a writer structure pointer, with a closing comma in a trace message. I'll make a change to unify tracing format in the reader too.
Nikolay Sivov (@nsivov) commented about dlls/xmllite/writer.c:
return write_escaped_string(This, string, ~0u);
}
+static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch) +{
- xmlwriter *writer = impl_from_IXmlWriter(iface);
- TRACE("%p, %s, %d\n", writer, debugstr_wn(pwch, cwch), cwch);
- if ((pwch == NULL && cwch != 0))
return WC_E_XMLCHARACTER;
- else if ((pwch == NULL && cwch == 0))
return S_OK;
- else if ((is_empty_string(pwch) && cwch == 0))
return S_OK;
It's not clear if this should come before state checks.
Nikolay Sivov (@nsivov) commented about dlls/xmllite/writer.c:
- writer_close_starttag(writer); default: ; }
- return E_NOTIMPL;
- while (*pwch && cwch)
- {
if (FAILED(hr = writer_get_next_write_count(pwch, cwch, &count))) return hr;
if (FAILED(hr = write_output_buffer(writer->output, pwch, count))) return hr;
pwch += count;
cwch -= count;
- }
- if (cwch) return WC_E_XMLCHARACTER;
Why do we need it here, but not in WriteRaw() ?
Nikolay Sivov (@nsivov) commented about dlls/xmllite/writer.c:
static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHAR wchLow, WCHAR wchHigh) {
- xmlwriter *This = impl_from_IXmlWriter(iface);
- xmlwriter *writer = impl_from_IXmlWriter(iface);
- int codepoint;
- WCHAR bufW[16];
- FIXME("%p %d %d\n", This, wchLow, wchHigh);
- TRACE("%p, %d, %d\n", writer, wchLow, wchHigh);
- return E_NOTIMPL;
- if (!IS_LOW_SURROGATE(wchLow))
return WC_E_XMLCHARACTER;
- if (!IS_HIGH_SURROGATE(wchHigh))
return WC_E_XMLCHARACTER;
There is a IS_SURROGATE_PAIR() to combine those two checks.
On Sun Nov 20 09:22:06 2022 +0000, Nikolay Sivov wrote:
Why do we need it here, but not in WriteRaw() ?
With WriteRawChars() we have two constraints
i) The string itself ii) The number of characters the user requested to write.
When correctly used, the two constraints should both fail or, the length constraint should fail but the string constraint shouldn't fail before the length constraint because that would mean someone tried to write `'\0'` which is invalid and hence the check.
On the other hand, we only have one constraint with WriteRaw()
On Sun Nov 20 14:38:07 2022 +0000, David Kahurani wrote:
With WriteRawChars() we have two constraints i) The string itself ii) The number of characters the user requested to write. When correctly used, the two constraints should both fail or, the length constraint should fail but the string constraint shouldn't fail before the length constraint because that would mean someone tried to write `'\0'` which is invalid and hence the check. On the other hand, we only have one constraint with WriteRaw()
I don't follow, why is this not the same situation as with write_escaped_string() with explicit length? Why do you have to check for (*pwch && cwch) and not just (cwch)?
On Sun Nov 20 15:06:27 2022 +0000, Nikolay Sivov wrote:
I don't follow, why is this not the same situation as with write_escaped_string() with explicit length? Why do you have to check for (*pwch && cwch) and not just (cwch)?
Write_escaped_string with explicit length basically writes everything including the terminating `'\0'` which gets rejected by writer_get_next_count with WC_E_XMLCHARACTER basically achieving the same result. In the case of WriteRaw() and WriteRawChars() the terminating `'\0'` never actually gets written.
I check both *pwch and cwch because we are writing a particular number of characters which yes, might equal the characters in the string or may not be equal.
Edit : Checking for *pwch allows us to catch a possible error where user tried to write more characters than are in the provided string
On Sun Nov 20 15:22:06 2022 +0000, David Kahurani wrote:
Write_escaped_string with explicit length basically writes everything including the terminating `'\0'` which gets rejected by writer_get_next_count with WC_E_XMLCHARACTER basically achieving the same result. In the case of WriteRaw() and WriteRawChars() the terminating `'\0'` never actually gets written. I check both *pwch and cwch because we are writing a particular number of characters which yes, might equal the characters in the string or may not be equal. Edit : Checking for *pwch allows us to catch a possible error where user tried to write more characters than are in the provided string
Uhhmm... Okay, I see where you're coming from. Just checking for cwch will achieve the same result, yes. Will update the code to just check for cwch.
On Sun Nov 20 15:24:55 2022 +0000, David Kahurani wrote:
Uhhmm... Okay, I see where you're coming from. Just checking for cwch will achieve the same result, yes. Will update the code to just check for cwch.
Is this testable at all? I don't see any test failures if I simply do while (cwch), with error `WC_E_XMLCHARACTER` return after the loop removed.
On Sun Nov 20 15:25:02 2022 +0000, Nikolay Sivov wrote:
Is this testable at all? I don't see any test failures if I simply do while (cwch), with error `WC_E_XMLCHARACTER` return after the loop removed.
Yes, your approach will achieve the same thing. I just noticed that. I will update the code to just check for cwch