Skip to content

Commit a672b67

Browse files
committed
Update print.h
1 parent 7f75df4 commit a672b67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

include/xml/print.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ xml_print_ex(FILE * __restrict ostream,
2828
int opt) {
2929
const xml_t *parent;
3030
const xml_attr_t *a;
31-
int pad, i;
31+
int pad, i, snode;
3232

33-
pad = 0;
33+
pad = snode = 0;
3434
parent = NULL;
3535

3636
while (xml) {
37-
if (opt > 0 && xml->type == XML_ELEMENT) {
37+
if (!snode && opt > 0 && xml->type == XML_ELEMENT) {
3838
for (i = 0; i < pad; i++)
3939
fprintf(ostream, "\t");
4040
}
4141

42+
snode = 0;
4243
switch (xml->type) {
4344
case XML_ELEMENT: {
4445
if (!xml->prefix)
@@ -100,6 +101,7 @@ xml_print_ex(FILE * __restrict ostream,
100101
}
101102
case XML_STRING:
102103
fprintf(ostream, "%.*s", xml->valsize, xml->val);
104+
snode = 1;
103105
break;
104106
default:
105107
break;
@@ -108,6 +110,7 @@ xml_print_ex(FILE * __restrict ostream,
108110
if (xml->next) {
109111
xml = xml->next;
110112
} else if ((parent = xml->parent)) {
113+
snode = 0;
111114
do {
112115
if (opt > 0 && (!xml || (xml && xml->type == XML_ELEMENT))) {
113116
for (i = 0; i < pad; i++)

0 commit comments

Comments
 (0)