From b47dac6540ed952b95dbdce78d2a5f48ff0db86b Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 3 Aug 2008 15:19:53 +0000 Subject: [PATCH] Add protective 'do { ... } while (0)' wrappers to multistatement macros --- ChangeLog | 12 ++++++++++++ sbr/fmt_compile.c | 25 ++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbd4ef2..1e9e31e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2008-08-03 Peter Maydell + * sbr/fmt_compile.c: add 'do { ... } while (0)' wrappers + to various multi-statement macros to avoid nasty surprises + if the macros are used in if() clauses. + + * bug #23436: man/scan.man, man/forw.man, man/inc.man, + man/mh-chart.man, man/mhmail.man, man/mhshow.man, + man/mhstore.man, man/msgchk.man, man/packf.man, man/scan.man: + fix minor syntax errors groff warns about. + * test/runtest, test/README: allow test cases to report + that they have been SKIPped as well as PASS/FAIL + * test/tests/manpages/test-manpages - new test which runs groff + on the manpages and checks that there are no warnings. * test/runalltests: ignore editor backup files 2008-08-03 Eric Gillespie diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index c42f1e3..89c25de 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -158,32 +158,35 @@ static struct ftable functable[] = { }; /* Add new component to the hash table */ -#define NEWCOMP(cm,name)\ +#define NEWCOMP(cm,name) do { \ cm = ((struct comp *) calloc(1, sizeof (struct comp)));\ cm->c_name = name;\ ncomp++;\ i = CHASH(name);\ cm->c_next = wantcomp[i];\ - wantcomp[i] = cm; + wantcomp[i] = cm; \ + } while (0) #define NEWFMT (next_fp++) -#define NEW(type,fill,wid)\ - fp=NEWFMT; fp->f_type=(type); fp->f_fill=(fill); fp->f_width=(wid); +#define NEW(type,fill,wid) do {\ + fp=NEWFMT; fp->f_type=(type); fp->f_fill=(fill); fp->f_width=(wid); \ + } while (0) /* Add (possibly new) component to the hash table */ -#define ADDC(name)\ +#define ADDC(name) do { \ FINDCOMP(cm, name);\ if (!cm) {\ NEWCOMP(cm,name);\ }\ - fp->f_comp = cm; + fp->f_comp = cm; \ + } while (0) -#define LV(type, value) NEW(type,0,0); fp->f_value = (value); -#define LS(type, str) NEW(type,0,0); fp->f_text = (str); +#define LV(type, value) do { NEW(type,0,0); fp->f_value = (value); } while (0) +#define LS(type, str) do { NEW(type,0,0); fp->f_text = (str); } while (0) -#define PUTCOMP(comp) NEW(FT_COMP,0,0); ADDC(comp); -#define PUTLIT(str) NEW(FT_LIT,0,0); fp->f_text = (str); -#define PUTC(c) NEW(FT_CHAR,0,0); fp->f_char = (c); +#define PUTCOMP(comp) do { NEW(FT_COMP,0,0); ADDC(comp); } while (0) +#define PUTLIT(str) do { NEW(FT_LIT,0,0); fp->f_text = (str); } while (0) +#define PUTC(c) do { NEW(FT_CHAR,0,0); fp->f_char = (c); } while (0) static char *format_string; static unsigned char *usr_fstring; /* for CERROR */ -- 1.7.10.4