From: Gerhard Sittig Date: Sun, 30 Jul 2023 08:10:12 +0000 (+0200) Subject: input/protocoldata: also accept comma separated data values X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=395ac73eadfdb7a8e03107172dcdbf5d9176a1fa;p=libsigrok.git input/protocoldata: also accept comma separated data values Frame format specs in the header section accepted space and comma separators already (though comma separated frame format details are considered unusual). Protocol values in non-comment (text mode) lines assumed strictly space separated fields. Accept comma and semicolon too as data value separators for maximum user convenience. Simplifies the import of post processed other text formats, only requires the addition of headers and decoration (select control, text to number conversion base), but allows re-use of all existing values. Reduces diffs before and after manipulating original text into protocoldata which sigrok can import. These separators silently get ignored. They don't have a meaning in the sense of interpreting "1, , 3" as three values. There is no concept of empty fields in the sequence of data values. This is pure convenience. --- diff --git a/src/input/protocoldata.c b/src/input/protocoldata.c index 1438f6f4..e8591b22 100644 --- a/src/input/protocoldata.c +++ b/src/input/protocoldata.c @@ -2878,8 +2878,7 @@ static int process_textline(struct sr_input *in, char *line) struct context *inc; const struct proto_handler_t *handler; gboolean is_comm, is_pseudo; - char *word; - char *endp; + char *p, *word, *endp; unsigned long value; int ret; @@ -2931,11 +2930,16 @@ static int process_textline(struct sr_input *in, char *line) /* * Non-empty non-comment lines carry protocol values. * (Empty lines are handled transparently when they get here.) + * Accept comma and semicolon separators for user convenience. * Convert text according to previously received instructions. * Pass the values to the protocol handler. Flush waveforms * when handlers state that their construction has completed. */ sr_spew("got values line: %s", line); + for (p = line; *p; p++) { + if (*p == ',' || *p == ';') + *p = ' '; + } while (line) { word = sr_text_next_word(line, &line); if (!word)