From: David Kahurani k.kahurani@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 8 +------- dlls/xmllite/writer.c | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 0fae2bbca88..c109fedb072 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -3140,11 +3140,9 @@ static void test_WriteEntityRef(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, L""); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, NULL); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, L"name"); @@ -3155,7 +3153,6 @@ static void test_WriteEntityRef(void) writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteEntityRef(writer, L"name"); - todo_wine ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream); @@ -3168,7 +3165,6 @@ static void test_WriteEntityRef(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, L"na:me"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -3187,11 +3183,9 @@ static void test_WriteEntityRef(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, L"name"); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEntityRef(writer, L".name"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -3203,7 +3197,7 @@ static void test_WriteEntityRef(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<a>&name;</a>");
IStream_Release(stream); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 6e343d0ade6..be9666d6fd3 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1567,25 +1567,42 @@ static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface) return hr; }
-static HRESULT WINAPI xmlwriter_WriteEntityRef(IXmlWriter *iface, LPCWSTR pwszName) +static HRESULT WINAPI xmlwriter_WriteEntityRef(IXmlWriter *iface, const WCHAR *name) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + int name_len; + HRESULT hr;
- FIXME("%p %s\n", This, wine_dbgstr_w(pwszName)); + TRACE("%p, %s.\n", iface, wine_dbgstr_w(name));
- switch (This->state) + if (is_empty_string(name)) + return E_INVALIDARG; + + if (FAILED(hr = is_valid_ncname(name, &name_len))) + return hr; + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; + case XmlWriterState_Ready: case XmlWriterState_DocClosed: + writer->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_ElemStarted: + hr = writer_close_starttag(writer); + break; default: ; }
- return E_NOTIMPL; + write_output(writer, L"&", 1, &hr); + write_output(writer, name, name_len, &hr); + write_output(writer, L";", 1, &hr); + + return hr; }
static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)