diff options
| author | 2018-12-14 00:59:02 +0100 | |
|---|---|---|
| committer | 2018-12-14 00:59:02 +0100 | |
| commit | 3007c970a6d61efe453b51b76cb7a79c94fc6a06 (patch) | |
| tree | f3eda3cba7b45a6cf4fed01a73f0391d9a8541bd /src | |
| parent | 58334812f923fcf659d4a59ff32e1fe14787571d (diff) | |
| download | libplist-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.c | 14 |
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) | |||
| 199 | case PLIST_ARRAY: | 199 | case PLIST_ARRAY: |
| 200 | tag = XPLIST_ARRAY; | 200 | tag = XPLIST_ARRAY; |
| 201 | tag_len = XPLIST_ARRAY_LEN; | 201 | tag_len = XPLIST_ARRAY_LEN; |
| 202 | isStruct = TRUE; | 202 | isStruct = (node->children) ? TRUE : FALSE; |
| 203 | break; | 203 | break; |
| 204 | case PLIST_DICT: | 204 | case PLIST_DICT: |
| 205 | tag = XPLIST_DICT; | 205 | tag = XPLIST_DICT; |
| 206 | tag_len = XPLIST_DICT_LEN; | 206 | tag_len = XPLIST_DICT_LEN; |
| 207 | isStruct = TRUE; | 207 | isStruct = (node->children) ? TRUE : FALSE; |
| 208 | break; | 208 | break; |
| 209 | case PLIST_DATE: | 209 | case PLIST_DATE: |
| 210 | tag = XPLIST_DATE; | 210 | tag = XPLIST_DATE; |
| @@ -350,11 +350,11 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth) | |||
| 350 | } | 350 | } |
| 351 | free(val); | 351 | free(val); |
| 352 | 352 | ||
| 353 | /* add return for structured types */ | 353 | if (isStruct) { |
| 354 | if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT) | 354 | /* add newline for structured types */ |
| 355 | str_buf_append(*outbuf, "\n", 1); | 355 | str_buf_append(*outbuf, "\n", 1); |
| 356 | 356 | ||
| 357 | if (isStruct) { | 357 | /* add child nodes */ |
| 358 | if (node_data->type == PLIST_DICT && node->children) { | 358 | if (node_data->type == PLIST_DICT && node->children) { |
| 359 | assert((node->children->count % 2) == 0); | 359 | assert((node->children->count % 2) == 0); |
| 360 | } | 360 | } |
| @@ -362,10 +362,8 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth) | |||
| 362 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 362 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 363 | node_to_xml(ch, outbuf, depth+1); | 363 | node_to_xml(ch, outbuf, depth+1); |
| 364 | } | 364 | } |
| 365 | } | ||
| 366 | 365 | ||
| 367 | /* fix indent for structured types */ | 366 | /* fix indent for structured types */ |
| 368 | if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT) { | ||
| 369 | for (i = 0; i < depth; i++) { | 367 | for (i = 0; i < depth; i++) { |
| 370 | str_buf_append(*outbuf, "\t", 1); | 368 | str_buf_append(*outbuf, "\t", 1); |
| 371 | } | 369 | } |
