Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ef7b911a
Commit
ef7b911a
authored
Sep 14, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Fix formatted output with interleaving text nodes.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9784ef16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
8 deletions
+103
-8
writer.c
dlls/xmllite/tests/writer.c
+87
-0
writer.c
dlls/xmllite/writer.c
+16
-8
No files found.
dlls/xmllite/tests/writer.c
View file @
ef7b911a
...
...
@@ -1981,6 +1981,93 @@ static void test_WriteString(void)
" <b>text</b>
\r\n
"
"</a>"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
write_start_element
(
writer
,
NULL
,
"a"
,
NULL
);
ok
(
hr
==
S_OK
,
"Failed to start element, hr %#x.
\n
"
,
hr
);
hr
=
write_start_element
(
writer
,
NULL
,
"b"
,
NULL
);
ok
(
hr
==
S_OK
,
"Failed to start element, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to end element, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />"
);
hr
=
write_start_element
(
writer
,
NULL
,
"c"
,
NULL
);
ok
(
hr
==
S_OK
,
"Failed to start element, hr %#x.
\n
"
,
hr
);
hr
=
write_attribute_string
(
writer
,
NULL
,
"attr"
,
NULL
,
"value"
);
ok
(
hr
==
S_OK
,
"Failed to write attribute string, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />
\r\n
"
" <c attr=
\"
value
\"
"
);
hr
=
write_string
(
writer
,
"text"
);
ok
(
hr
==
S_OK
,
"Failed to write a string, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />
\r\n
"
" <c attr=
\"
value
\"
>text"
);
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to end element, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />
\r\n
"
" <c attr=
\"
value
\"
>text</c>"
);
hr
=
write_start_element
(
writer
,
NULL
,
"d"
,
NULL
);
ok
(
hr
==
S_OK
,
"Failed to start element, hr %#x.
\n
"
,
hr
);
hr
=
write_string
(
writer
,
""
);
ok
(
hr
==
S_OK
,
"Failed to write a string, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to end element, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />
\r\n
"
" <c attr=
\"
value
\"
>text</c>
\r\n
"
" <d></d>"
);
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to end element, hr %#x.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#x.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a>
\r\n
"
" <b />
\r\n
"
" <c attr=
\"
value
\"
>text</c>
\r\n
"
" <d></d>
\r\n
"
"</a>"
);
IXmlWriter_Release
(
writer
);
IStream_Release
(
stream
);
}
...
...
dlls/xmllite/writer.c
View file @
ef7b911a
...
...
@@ -118,6 +118,7 @@ typedef struct _xmlwriter
struct
list
elements
;
DWORD
bomwritten
:
1
;
DWORD
starttagopen
:
1
;
DWORD
textnode
:
1
;
}
xmlwriter
;
static
inline
xmlwriter
*
impl_from_IXmlWriter
(
IXmlWriter
*
iface
)
...
...
@@ -626,8 +627,11 @@ static void write_node_indent(xmlwriter *writer)
static
const
WCHAR
crlfW
[]
=
{
'\r'
,
'\n'
};
unsigned
int
indent_level
=
writer
->
indent_level
;
if
(
!
writer
->
indent
)
if
(
!
writer
->
indent
||
writer
->
textnode
)
{
writer
->
textnode
=
0
;
return
;
}
/* Do state check to prevent newline inserted after BOM. It is assumed that
state does not change between writing BOM and inserting indentation. */
...
...
@@ -635,6 +639,8 @@ static void write_node_indent(xmlwriter *writer)
write_output_buffer
(
writer
->
output
,
crlfW
,
ARRAY_SIZE
(
crlfW
));
while
(
indent_level
--
)
write_output_buffer
(
writer
->
output
,
dblspaceW
,
ARRAY_SIZE
(
dblspaceW
));
writer
->
textnode
=
0
;
}
static
HRESULT
WINAPI
xmlwriter_QueryInterface
(
IXmlWriter
*
iface
,
REFIID
riid
,
void
**
ppvObject
)
...
...
@@ -704,6 +710,7 @@ static HRESULT WINAPI xmlwriter_SetOutput(IXmlWriter *iface, IUnknown *output)
IUnknown_Release
(
&
This
->
output
->
IXmlWriterOutput_iface
);
This
->
output
=
NULL
;
This
->
bomwritten
=
0
;
This
->
textnode
=
0
;
This
->
indent_level
=
0
;
writer_free_element_stack
(
This
);
}
...
...
@@ -1281,7 +1288,10 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)
/* don't force full end tag to the next line */
if
(
This
->
state
==
XmlWriterState_ElemStarted
)
{
This
->
state
=
XmlWriterState_Content
;
This
->
textnode
=
0
;
}
else
write_node_indent
(
This
);
...
...
@@ -1623,6 +1633,7 @@ static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, const WCHAR *stri
;
}
This
->
textnode
=
1
;
write_escaped_string
(
This
,
string
);
return
S_OK
;
}
...
...
@@ -1761,21 +1772,18 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
writer
=
IMalloc_Alloc
(
imalloc
,
sizeof
(
*
writer
));
else
writer
=
heap_alloc
(
sizeof
(
*
writer
));
if
(
!
writer
)
return
E_OUTOFMEMORY
;
if
(
!
writer
)
return
E_OUTOFMEMORY
;
memset
(
writer
,
0
,
sizeof
(
*
writer
));
writer
->
IXmlWriter_iface
.
lpVtbl
=
&
xmlwriter_vtbl
;
writer
->
ref
=
1
;
writer
->
imalloc
=
imalloc
;
if
(
imalloc
)
IMalloc_AddRef
(
imalloc
);
writer
->
output
=
NULL
;
writer
->
indent_level
=
0
;
writer
->
indent
=
FALSE
;
writer
->
bom
=
TRUE
;
writer
->
omitxmldecl
=
FALSE
;
writer
->
conformance
=
XmlConformanceLevel_Document
;
writer
->
state
=
XmlWriterState_Initial
;
writer
->
bomwritten
=
0
;
writer
->
starttagopen
=
0
;
list_init
(
&
writer
->
elements
);
hr
=
IXmlWriter_QueryInterface
(
&
writer
->
IXmlWriter_iface
,
riid
,
obj
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment