summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-12-14 00:59:02 +0100
committerGravatar Nikias Bassen2018-12-14 00:59:02 +0100
commit3007c970a6d61efe453b51b76cb7a79c94fc6a06 (patch)
treef3eda3cba7b45a6cf4fed01a73f0391d9a8541bd /src
parent58334812f923fcf659d4a59ff32e1fe14787571d (diff)
downloadlibplist-3007c970a6d61efe453b51b76cb7a79c94fc6a06.tar.gz
libplist-3007c970a6d61efe453b51b76cb7a79c94fc6a06.tar.bz2
xplist: Fix writing of empty dict and array nodes to XML
Diffstat (limited to 'src')
-rw-r--r--src/xplist.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/xplist.c b/src/xplist.c
index d905b92..bb27f53 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -199,12 +199,12 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
case PLIST_ARRAY:
tag = XPLIST_ARRAY;
tag_len = XPLIST_ARRAY_LEN;
- isStruct = TRUE;
+ isStruct = (node->children) ? TRUE : FALSE;
break;
case PLIST_DICT:
tag = XPLIST_DICT;
tag_len = XPLIST_DICT_LEN;
- isStruct = TRUE;
+ isStruct = (node->children) ? TRUE : FALSE;
break;
case PLIST_DATE:
tag = XPLIST_DATE;
@@ -350,11 +350,11 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
}
free(val);
- /* add return for structured types */
- if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT)
+ if (isStruct) {
+ /* add newline for structured types */
str_buf_append(*outbuf, "\n", 1);
- if (isStruct) {
+ /* add child nodes */
if (node_data->type == PLIST_DICT && node->children) {
assert((node->children->count % 2) == 0);
}
@@ -362,10 +362,8 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
node_to_xml(ch, outbuf, depth+1);
}
- }
- /* fix indent for structured types */
- if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT) {
+ /* fix indent for structured types */
for (i = 0; i < depth; i++) {
str_buf_append(*outbuf, "\t", 1);
}