X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fcsv.c;h=4dcc77b8eaeb19e13999324e230786d8da19ef9f;hb=838f01227382bfd8e5b9c817e7fefff93d2c7b28;hp=1c4a5d7f16c8f7e18e063554a23ebccdb564c8f6;hpb=ce3fe379693f7ef113e027a674946e07f340a377;p=libsigrok.git diff --git a/src/input/csv.c b/src/input/csv.c index 1c4a5d7f..4dcc77b8 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -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; /* @@ -756,7 +758,20 @@ static void strip_comment(char *buf, const GString *prefix) */ static char **split_line(char *buf, struct context *inc) { - return g_strsplit(buf, inc->delimiter->str, 0); + char **fields, *f; + size_t l; + + fields = g_strsplit(buf, inc->delimiter->str, 0); + if (!fields) + return NULL; + + l = g_strv_length(fields); + while (l--) { + f = fields[l]; + g_strchomp(f); + } + + return fields; } /**