X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=output%2Fcsv.c;h=28eedd6eadc02b55da4cec2cbfa6af0a28bf54cc;hb=6392d5992b12cf2b51d7f6704c4d23f3a2d4a294;hp=5ca8c392d3afcb8300a5576294f2d08913548595;hpb=e96cf218c08d474fca0285113ad334823a60a3b9;p=libsigrok.git diff --git a/output/csv.c b/output/csv.c index 5ca8c392..28eedd6e 100644 --- a/output/csv.c +++ b/output/csv.c @@ -98,7 +98,7 @@ static int init(struct sr_output *o) ctx->samplerate); /* Columns / channels */ - g_string_append_printf(ctx->header, "; Channels (%d/%d): ", + g_string_append_printf(ctx->header, "; Channels (%d/%d):", ctx->num_enabled_probes, num_probes); for (l = o->sdi->probes; l; l = l->next) { probe = l->data; @@ -106,8 +106,11 @@ static int init(struct sr_output *o) continue; if (!probe->enabled) continue; - g_string_append_printf(ctx->header, "%s, ", probe->name); + g_string_append_printf(ctx->header, " %s,", probe->name); } + if (o->sdi->probes) + /* Drop last separator. */ + g_string_truncate(ctx->header, ctx->header->len - 1); g_string_append_printf(ctx->header, "\n"); return SR_OK; @@ -150,6 +153,10 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi, g_string_append_c(*out, c ? '1' : '0'); g_string_append_c(*out, ctx->separator); } + if (j) { + /* Drop last separator. */ + g_string_truncate(*out, (*out)->len - 1); + } g_string_append_printf(*out, "\n"); } break;