Skip to content

Commit 22695d3

Browse files
authored
Merge pull request #528 from marek22k/fix-522-2
xml report: remove leading spaces
2 parents cfe22c9 + 5465d66 commit 22695d3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ui/report.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ void xml_close(
406406
int i, j, at, max;
407407
ip_t *addr;
408408
char name[MAX_FORMAT_STR];
409+
char buf[128];
409410

410411
printf("<?xml version=\"1.0\"?>\n");
411412
printf("<MTR SRC=\"%s\" DST=\"%s\"", ctl->LocalHostname,
@@ -438,9 +439,6 @@ void xml_close(
438439
if (j <= 0)
439440
continue; /* Field nr 0, " " shouldn't be printed in this method. */
440441

441-
snprintf(name, sizeof(name), "%s%s%s", " <%s>",
442-
data_fields[j].format, "</%s>\n");
443-
444442
/* XML doesn't allow "%" in tag names, rename Loss% to just Loss */
445443
title = data_fields[j].title;
446444
if (strcmp(data_fields[j].title, "Loss%") == 0) {
@@ -449,11 +447,12 @@ void xml_close(
449447

450448
/* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
451449
if (strchr(data_fields[j].format, 'f')) {
452-
printf(name,
453-
title, data_fields[j].net_xxx(at) / 1000.0, title);
450+
snprintf(buf, sizeof(buf), data_fields[j].format, data_fields[j].net_xxx(at) / 1000.0);
454451
} else {
455-
printf(name, title, data_fields[j].net_xxx(at), title);
452+
snprintf(buf, sizeof(buf), data_fields[j].format, data_fields[j].net_xxx(at));
456453
}
454+
trim(buf, 0);
455+
printf(" <%s>%s</%s>\n", title, buf, title);
457456
}
458457
printf(" </HUB>\n");
459458
}

0 commit comments

Comments
 (0)