Skip to content

Commit

Permalink
show: Only use decoder tags if they're available.
Browse files Browse the repository at this point in the history
This allows us to reduce the libsigrokdecode requirement back to >= 0.5.0,
i.e. we don't strictly need libsigrokdecode >= 0.6.0.
  • Loading branch information
uwehermann committed Feb 24, 2021
1 parent a23df11 commit dded02f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Requirements
- pkg-config >= 0.22
- libglib >= 2.32.0
- libsigrok >= 0.5.0
- libsigrokdecode >= 0.6.0
- libsigrokdecode >= 0.5.0


Building and installing
Expand Down
16 changes: 16 additions & 0 deletions show.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#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),
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -880,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;
Expand All @@ -888,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) {
Expand Down

0 comments on commit dded02f

Please sign in to comment.