mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +00:00
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.) [originally from svn r2192]
This commit is contained in:
parent
64e9693c4d
commit
3a084e9333
16
unix/pterm.c
16
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 */
|
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) { \
|
if (--argc <= 0) { \
|
||||||
err = 1; \
|
err = 1; \
|
||||||
fprintf(stderr, "pterm: %s expects an argument\n", p); \
|
fprintf(stderr, "pterm: %s expects an argument\n", p); \
|
||||||
|
continue; \
|
||||||
} else \
|
} else \
|
||||||
val = *++argv; \
|
val = *++argv; \
|
||||||
} while (0)
|
}
|
||||||
#define SECOND_PASS_ONLY do { \
|
#define SECOND_PASS_ONLY { if (!do_everything) continue; }
|
||||||
if (!do_everything) continue; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
|
Loading…
Reference in New Issue
Block a user