From b89ee4f3fa1a44f707082d7669f6b167610b53bf Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 5 Nov 2002 13:20:42 +0000 Subject: [PATCH] Fix command-line error handling in pterm. (Hint: wrapping a multi- statement macro in `do ... while (0)' and putting a `continue' within it don't go well together. Oops.) git-svn-id: svn://svn.tartarus.org/sgt/putty@2192 cda61777-01e9-0310-a592-d414129be87e --- unix/pterm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/unix/pterm.c b/unix/pterm.c index b1b98c1e..5bc18856 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -1779,18 +1779,22 @@ int do_cmdline(int argc, char **argv, int do_everything) extern char **pty_argv; /* declared in pty.c */ /* - * Macros to make argument handling easier. + * Macros to make argument handling easier. Note that because + * they need to call `continue', they cannot be contained in + * the usual do {...} while (0) wrapper to make them + * syntactically single statements; hence it is not legal to + * use one of these macros as an unbraced statement between + * `if' and `else'. */ -#define EXPECTS_ARG do { \ +#define EXPECTS_ARG { \ if (--argc <= 0) { \ err = 1; \ fprintf(stderr, "pterm: %s expects an argument\n", p); \ + continue; \ } else \ val = *++argv; \ -} while (0) -#define SECOND_PASS_ONLY do { \ - if (!do_everything) continue; \ -} while (0) +} +#define SECOND_PASS_ONLY { if (!do_everything) continue; } /* * TODO: -- 2.11.0