xmllite/writer: Fix initial state handling in WriteEndDocument().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-03-23 13:07:27 +03:00 committed by Alexandre Julliard
parent 8ad295ed70
commit 86a7dd99e0
2 changed files with 8 additions and 12 deletions

View File

@ -104,7 +104,7 @@ todo_wine {
hr = IXmlWriter_WriteNmToken(writer, aW); hr = IXmlWriter_WriteNmToken(writer, aW);
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
}
/* FIXME: add WriteNode */ /* FIXME: add WriteNode */
/* FIXME: add WriteNodeShallow */ /* FIXME: add WriteNodeShallow */
@ -112,12 +112,14 @@ todo_wine {
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL); hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL);
todo_wine
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
hr = IXmlWriter_WriteRaw(writer, aW); hr = IXmlWriter_WriteRaw(writer, aW);
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
hr = IXmlWriter_WriteRawChars(writer, aW, 1); hr = IXmlWriter_WriteRawChars(writer, aW, 1);
todo_wine
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
@ -127,8 +129,9 @@ todo_wine {
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
hr = IXmlWriter_WriteString(writer, aW); hr = IXmlWriter_WriteString(writer, aW);
todo_wine
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
}
/* FIXME: add WriteSurrogateCharEntity */ /* FIXME: add WriteSurrogateCharEntity */
/* FIXME: add WriteWhitespace */ /* FIXME: add WriteWhitespace */
} }

View File

@ -754,28 +754,21 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr
static HRESULT WINAPI xmlwriter_WriteEndDocument(IXmlWriter *iface) static HRESULT WINAPI xmlwriter_WriteEndDocument(IXmlWriter *iface)
{ {
xmlwriter *This = impl_from_IXmlWriter(iface); xmlwriter *This = impl_from_IXmlWriter(iface);
HRESULT hr = S_OK;
TRACE("%p\n", This); TRACE("%p\n", This);
switch (This->state) switch (This->state)
{ {
case XmlWriterState_Initial: case XmlWriterState_Initial:
hr = E_UNEXPECTED; return E_UNEXPECTED;
break;
case XmlWriterState_Ready: case XmlWriterState_Ready:
case XmlWriterState_DocClosed: case XmlWriterState_DocClosed:
hr = WR_E_INVALIDACTION; This->state = XmlWriterState_DocClosed;
break; return WR_E_INVALIDACTION;
default: default:
; ;
} }
if (FAILED(hr)) {
This->state = XmlWriterState_DocClosed;
return hr;
}
/* empty element stack */ /* empty element stack */
while (IXmlWriter_WriteEndElement(iface) == S_OK) while (IXmlWriter_WriteEndElement(iface) == S_OK)
; ;