From: Gerhard Sittig Date: Mon, 5 Jun 2017 14:41:42 +0000 (+0200) Subject: input/csv: Correctly skip over last processed end-of-line sequence X-Git-Tag: libsigrok-0.5.0~17 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=241c386a4f727faa7c8379ae9212661011aa50ae;hp=4555d3bda00ed6f12016d4aca28bbef3cb459988;p=libsigrok.git input/csv: Correctly skip over last processed end-of-line sequence The CSV input module supports variable length end-of-line encodings (either CRLF, or CR, or LF). When a bunch of accumulated text lines got processed, do skip the corresponding number of characters after the end of the last processed line. This fixes one of the issues discussed in bug #635. --- diff --git a/src/input/csv.c b/src/input/csv.c index 5399027b..d58e0031 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -657,6 +657,7 @@ static int process_buffer(struct sr_input *in) if (!p) return SR_ERR; *p = '\0'; + p += strlen(inc->termination); g_strstrip(in->buf->str); ret = SR_OK; @@ -725,7 +726,7 @@ static int process_buffer(struct sr_input *in) g_strfreev(columns); } g_strfreev(lines); - g_string_erase(in->buf, 0, p - in->buf->str + 1); + g_string_erase(in->buf, 0, p - in->buf->str); return ret; }