]> sigrok.org Git - libsigrok.git/commitdiff
input/csv: trim surrounding whitespace from header line channel names
authorGerhard Sittig <redacted>
Mon, 6 Jan 2020 08:59:21 +0000 (09:59 +0100)
committerGerhard Sittig <redacted>
Sun, 25 Apr 2021 10:51:33 +0000 (12:51 +0200)
When CSV import grabs channel names from the first line in the file then
the text strictly between column separators (a comma) was used. Which
resulted in channel names like " channel 1". Trim leading and trailing
space before unquote, to better fulfill most users' expectation. Users
still can quote the input data for special cases if desired.

src/input/csv.c

index 66cf4bb3c2445af3ad9c8c3c1be36e2d658b03d4..4dcc77b8eaeb19e13999324e230786d8da19ef9f 100644 (file)
@@ -657,10 +657,12 @@ static int make_column_details_from_format(const struct sr_input *in,
                         * line won't get processed another time.
                         */
                        column = column_texts[detail->col_nr - 1];
-                       if (inc->use_header && column && *column)
+                       if (inc->use_header && column && *column) {
+                               column = g_strstrip(column);
                                caption = sr_scpi_unquote_string(column);
-                       else
+                       } else {
                                caption = NULL;
+                       }
                        if (!caption || !*caption)
                                caption = NULL;
                        /*