From: Ralph Corderoy Date: Sun, 10 Sep 2017 13:53:32 +0000 (+0100) Subject: fmt_compile.c: Alter FINDCOMP(): the caller must supply the semicolon. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/edcbc70e11973f191f960a4102708b195dc378bf?ds=sidebyside fmt_compile.c: Alter FINDCOMP(): the caller must supply the semicolon. The macro expands to a for-loop, including the semicolon body. The caller typically supplies their own semicolon. This results in two on one line that looks odd. Alter the macro to have the for-loop inside a do-while loop that doesn't have a semicolon, ensuring the caller must supply it. --- diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 3930f8ca..ff0cf013 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -280,11 +280,12 @@ static struct colormap colortable[] = { /* * Find a component in the hash table. */ -#define FINDCOMP(comp,name) \ - for (comp = wantcomp[CHASH(name)]; \ - comp && strcmp(comp->c_name,name); \ - comp = comp->c_next) \ - ; +#define FINDCOMP(comp,name) do { \ + for (comp = wantcomp[CHASH(name)]; \ + comp && strcmp(comp->c_name,name); \ + comp = comp->c_next) \ + ; \ + } while (0) /* Add new component to the hash table */ #define NEWCOMP(cm,name) do { \