]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
xml report: remove leading spaces 528/head
authorMarek Küthe <m.k@mk16.de>
Fri, 14 Feb 2025 23:14:24 +0000 (23:14 +0000)
committerMarek Küthe <m.k@mk16.de>
Sun, 16 Feb 2025 11:26:12 +0000 (11:26 +0000)
ui/report.c

index 61f2c74b3073f33f2615f2159326a98f00817c0b..364a9befd43ed3ab184e76fc0f64671436b06b54 100644 (file)
@@ -406,6 +406,7 @@ void xml_close(
     int i, j, at, max;
     ip_t *addr;
     char name[MAX_FORMAT_STR];
+    char buf[128];
 
     printf("<?xml version=\"1.0\"?>\n");
     printf("<MTR SRC=\"%s\" DST=\"%s\"", ctl->LocalHostname,
@@ -438,9 +439,6 @@ void xml_close(
             if (j <= 0)
                 continue;       /* Field nr 0, " " shouldn't be printed in this method. */
 
-            snprintf(name, sizeof(name), "%s%s%s", "        <%s>",
-                     data_fields[j].format, "</%s>\n");
-
             /* XML doesn't allow "%" in tag names, rename Loss% to just Loss */
             title = data_fields[j].title;
             if (strcmp(data_fields[j].title, "Loss%") == 0) {
@@ -449,11 +447,12 @@ void xml_close(
 
             /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
             if (strchr(data_fields[j].format, 'f')) {
-                printf(name,
-                       title, data_fields[j].net_xxx(at) / 1000.0, title);
+                snprintf(buf, sizeof(buf), data_fields[j].format, data_fields[j].net_xxx(at) / 1000.0);
             } else {
-                printf(name, title, data_fields[j].net_xxx(at), title);
+                snprintf(buf, sizeof(buf), data_fields[j].format, data_fields[j].net_xxx(at));
             }
+            trim(buf, 0);
+            printf("        <%s>%s</%s>\n", title, buf, title);
         }
         printf("    </HUB>\n");
     }