From: Gerhard Sittig Date: Mon, 5 Jun 2017 11:34:05 +0000 (+0200) Subject: input/csv: Re-order processing steps (column mode vs text line split) X-Git-Tag: libsigrok-0.5.0~19 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=f9b748615488d0d0f5e07978717a53dcdf79f732;p=libsigrok.git input/csv: Re-order processing steps (column mode vs text line split) Move an independent test for single/multi column operation out of a code path that checked for and then processed text lines. This commit does not change behaviour, but prepares a subsequent commit. --- diff --git a/src/input/csv.c b/src/input/csv.c index fa1d51fd..5585b0ee 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -638,6 +638,12 @@ static int process_buffer(struct sr_input *in) inc->started = TRUE; } + /* Limit the number of columns to parse. */ + if (inc->multi_column_mode) + max_columns = inc->num_channels; + else + max_columns = 1; + p = g_strrstr_len(in->buf->str, in->buf->len, inc->termination); if (!p) /* Don't have a full line. */ @@ -646,12 +652,6 @@ static int process_buffer(struct sr_input *in) *p = '\0'; g_strstrip(in->buf->str); - /* Limit the number of columns to parse. */ - if (inc->multi_column_mode) - max_columns = inc->num_channels; - else - max_columns = 1; - ret = SR_OK; lines = g_strsplit_set(in->buf->str, delim_set, 0); for (l = 0; lines[l]; l++) {