Commit a6d6bebe authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/writer: Do not indent after just BOM has been written.

parent 5773a5d3
...@@ -648,6 +648,8 @@ static void test_bom(void) ...@@ -648,6 +648,8 @@ static void test_bom(void)
hr = IXmlWriter_SetOutput(writer, output); hr = IXmlWriter_SetOutput(writer, output);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
writer_set_property(writer, XmlWriterProperty_Indent);
hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL); hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
...@@ -658,7 +660,8 @@ static void test_bom(void) ...@@ -658,7 +660,8 @@ static void test_bom(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal); ptr = GlobalLock(hglobal);
ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]); ok(ptr[0] == 0xff && ptr[1] == 0xfe && ptr[2] == '<', "Unexpected output: %#x,%#x,%#x\n",
ptr[0], ptr[1], ptr[2]);
GlobalUnlock(hglobal); GlobalUnlock(hglobal);
IUnknown_Release(output); IUnknown_Release(output);
......
...@@ -447,7 +447,9 @@ static void write_node_indent(xmlwriter *writer) ...@@ -447,7 +447,9 @@ static void write_node_indent(xmlwriter *writer)
if (!writer->indent) if (!writer->indent)
return; return;
if (writer->output->buffer.written) /* Do state check to prevent newline inserted after BOM. It is assumed that
state does not change between writing BOM and inserting indentation. */
if (writer->output->buffer.written && writer->state != XmlWriterState_Ready)
write_output_buffer(writer->output, crlfW, ARRAY_SIZE(crlfW)); write_output_buffer(writer->output, crlfW, ARRAY_SIZE(crlfW));
while (indent_level--) while (indent_level--)
write_output_buffer(writer->output, dblspaceW, ARRAY_SIZE(dblspaceW)); write_output_buffer(writer->output, dblspaceW, ARRAY_SIZE(dblspaceW));
...@@ -1208,12 +1210,13 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre ...@@ -1208,12 +1210,13 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
write_encoding_bom(This); write_encoding_bom(This);
write_node_indent(This);
This->state = XmlWriterState_ElemStarted; This->state = XmlWriterState_ElemStarted;
This->starttagopen = TRUE; This->starttagopen = TRUE;
push_element(This, element); push_element(This, element);
write_node_indent(This);
write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW)); write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW));
write_output_qname(This->output, prefix, local_name); write_output_qname(This->output, prefix, local_name);
writer_inc_indent(This); writer_inc_indent(This);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment