]> sigrok.org Git - sigrok-cli.git/blobdiff - show.c
doc: update IRC reference to Libera.Chat
[sigrok-cli.git] / show.c
diff --git a/show.c b/show.c
index 41474b3decfcc7cdea7cdfd92a15129f68998e39..9ce35b4a61b4360e39dcc03cbc6c985371a580bb 100644 (file)
--- a/show.c
+++ b/show.c
 #include <string.h>
 #include "sigrok-cli.h"
 
+#define DECODERS_HAVE_TAGS \
+       ((SRD_PACKAGE_VERSION_MAJOR > 0) || \
+        (SRD_PACKAGE_VERSION_MAJOR == 0) && (SRD_PACKAGE_VERSION_MINOR > 5))
+
 static gint sort_inputs(gconstpointer a, gconstpointer b)
 {
        return strcmp(sr_input_id_get((struct sr_input_module *)a),
@@ -235,11 +239,13 @@ void show_supported_wiki(void)
        for (l = sl; l; l = l->next) {
                dec = l->data;
 
+#if DECODERS_HAVE_TAGS
                GString *tags = g_string_new(NULL);
                for (GSList *t = dec->tags; t; t = t->next)
                        g_string_append_printf(tags, "%s, ", (char *)t->data);
                if (tags->len != 0)
                        g_string_truncate(tags, tags->len - 2);
+#endif
 
                GString *in = g_string_new(NULL);
                for (GSList *t = dec->inputs; t; t = t->next)
@@ -257,11 +263,19 @@ void show_supported_wiki(void)
                else
                        g_string_truncate(out, out->len - 2);
 
+#if DECODERS_HAVE_TAGS
                printf("{{pd|%s|%s|%s|%s|%s|%s|%s|supported}}\n",
                        dec->id, dec->name, dec->longname, dec->desc,
                        tags->str, in->str, out->str);
+#else
+               printf("{{pd|%s|%s|%s|%s|%s|%s|supported}}\n",
+                       dec->id, dec->name, dec->longname, dec->desc,
+                       in->str, out->str);
+#endif
 
+#if DECODERS_HAVE_TAGS
                g_string_free(tags, TRUE);
+#endif
                g_string_free(in, TRUE);
                g_string_free(out, TRUE);
        }
@@ -404,6 +418,7 @@ void show_dev_detail(void)
        char *tmp_str, *s, c;
        const char **stropts;
        double tmp_flt;
+       gboolean have_tmp_flt;
        const double *fltopts;
 
        if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
@@ -440,7 +455,7 @@ void show_dev_detail(void)
         * returned, or which values for them.
         */
        select_channels(sdi);
-       channel_group = select_channel_group(sdi);
+       channel_group = lookup_channel_group(sdi, NULL);
 
        if (!(opts = sr_dev_options(driver, sdi, channel_group)))
                /* Driver supports no device instance options. */
@@ -725,14 +740,16 @@ void show_dev_detail(void)
                } else if (srci->datatype == SR_T_FLOAT) {
                        printf("    %s: ", srci->id);
                        tmp_flt = 0.0;
+                       have_tmp_flt = FALSE;
                        if (maybe_config_get(driver, sdi, channel_group, key,
                                        &gvar) == SR_OK) {
                                tmp_flt = g_variant_get_double(gvar);
+                               have_tmp_flt = TRUE;
                                g_variant_unref(gvar);
                        }
                        if (maybe_config_list(driver, sdi, channel_group, key,
                                        &gvar) != SR_OK) {
-                               if (tmp_flt) {
+                               if (have_tmp_flt) {
                                        /* Can't list, but got a value to show. */
                                        printf("%f (current)", tmp_flt);
                                }
@@ -745,7 +762,7 @@ void show_dev_detail(void)
                                if (i)
                                        printf(", ");
                                printf("%f", fltopts[i]);
-                               if (tmp_flt && fltopts[i] == tmp_flt)
+                               if (have_tmp_flt && fltopts[i] == tmp_flt)
                                        printf(" (current)");
                        }
                        printf("\n");
@@ -877,6 +894,7 @@ static void show_pd_detail_single(const char *pd)
                        printf("None.\n");
                }
                printf("Decoder tags:\n");
+#if DECODERS_HAVE_TAGS
                if (dec->tags) {
                        for (l = dec->tags; l; l = l->next) {
                                str = l->data;
@@ -885,6 +903,7 @@ static void show_pd_detail_single(const char *pd)
                } else {
                        printf("None.\n");
                }
+#endif
                printf("Annotation classes:\n");
                if (dec->annotations) {
                        for (l = dec->annotations; l; l = l->next) {