-
- /*
- * Assume all lines have equal length (column count). Bail out
- * early on suspicious or insufficient input data (check input
- * which became available here against previous user specs or
- * auto-determined properties, regardless of layout variant).
- */
- if (num_columns < inc->column_want_count) {
- sr_err("Insufficient input text width for desired data amount, got %zu but want %zu columns.",
- num_columns, inc->column_want_count);
- ret = SR_ERR;
- goto out;
- }
-
- /*
- * Determine channel names. Optionally use text from a header
- * line (when requested by the user, and only works in multi
- * column mode). In the absence of header text, or in single
- * column mode, channels are assigned rather generic names.
- *
- * Manipulation of the column's caption is acceptable here, the
- * header line will never get processed another time.
- */
- channel_name = g_string_sized_new(64);
- for (col_idx = 0; col_idx < inc->column_want_count; col_idx++) {
-
- col_nr = col_idx + 1;
- detail = lookup_column_details(inc, col_nr);
- if (detail->text_format == FORMAT_NONE)
- continue;
- column = columns[col_idx];
- col_caption = sr_scpi_unquote_string(column);
- got_caption = inc->use_header && *col_caption;
- sr_dbg("DIAG col %zu, ch count %zu, text %s.",
- col_nr, detail->channel_count, col_caption);
- for (ch_idx = 0; ch_idx < detail->channel_count; ch_idx++) {
- ch_name_idx = detail->channel_offset + ch_idx;
- if (got_caption && detail->channel_count == 1)
- g_string_assign(channel_name, col_caption);
- else if (got_caption)
- g_string_printf(channel_name, "%s[%zu]",
- col_caption, ch_idx);
- else
- g_string_printf(channel_name, "%zu", ch_name_idx);
- sr_dbg("DIAG ch idx %zu, name %s.", ch_name_idx, channel_name->str);
- sr_channel_new(in->sdi, ch_name_idx, SR_CHANNEL_LOGIC, TRUE,
- channel_name->str);
- }
- }
- g_string_free(channel_name, TRUE);