]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
csv: preserve blank output fields 622/head
authoryvs <VSYakovetsky@gmail.com>
Fri, 8 May 2026 12:55:25 +0000 (16:55 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 12:55:25 +0000 (16:55 +0400)
Port the CSV blank-field behavior from yvs2014/mtr085 so an output order spacer produces an empty CSV column instead of reusing the drop counter callback.

Ported-from: yvs2014/mtr085@1871c38c4735112adcecc7cef31091e6d0e7f261

Original-author: yvs <VSYakovetsky@gmail.com>

ui/report.c

index 506ac77bc2e43894f033c07c972bab550ae127e1..acc72c0035809b70c5feb9ac855286fb0371dcd2 100644 (file)
@@ -579,6 +579,10 @@ void csv_close(
                 j = ctl->fld_index[ctl->fld_active[i]];
                 if (j < 0)
                     continue;
+                if (data_fields[j].key == ' ') {
+                    printf(",");
+                    continue;
+                }
                 printf("%s,", data_fields[j].title);
             }
             printf("\n");
@@ -599,6 +603,10 @@ void csv_close(
             j = ctl->fld_index[ctl->fld_active[i]];
             if (j < 0)
                 continue;
+            if (data_fields[j].key == ' ') {
+                printf(",");
+                continue;
+            }
 
             /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
             if (strchr(data_fields[j].format, 'f')) {
@@ -652,6 +660,10 @@ void csv_close(
                         j = ctl->fld_index[ctl->fld_active[i]];
                         if (j < 0)
                             continue;
+                        if (data_fields[j].key == ' ') {
+                            printf(",");
+                            continue;
+                        }
 
                         /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
                         if (strchr(data_fields[j].format, 'f')) {