From 1bae72d2b5bbbf7d71b1ff9a1f88fbe560d9b7ba Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 7 Jul 2025 13:53:04 -0400 Subject: Simplify some more macros with C23 syntax --- tests/ptyx.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/ptyx.c b/tests/ptyx.c index 59292df..bd47699 100644 --- a/tests/ptyx.c +++ b/tests/ptyx.c @@ -48,20 +48,16 @@ int main(int argc, char *argv[]) { const char *cmd = argc > 0 ? argv[0] : "ptyx"; /** Report an error message and exit. */ -#define die(...) die_(__VA_ARGS__, ) - -#define die_(format, ...) \ +#define die(format, ...) \ do { \ - fprintf(stderr, "%s: " format "%s", cmd, __VA_ARGS__ "\n"); \ + fprintf(stderr, "%s: " format "\n", cmd __VA_OPT__(,) __VA_ARGS__); \ exit(EXIT_FAILURE); \ } while (0) /** Report an error code and exit. */ -#define edie(...) edie_(__VA_ARGS__, ) - -#define edie_(format, ...) \ +#define edie(format, ...) \ do { \ - fprintf(stderr, "%s: " format ": %s\n", cmd, __VA_ARGS__ errstr()); \ + fprintf(stderr, "%s: " format ": %s\n", cmd __VA_OPT__(,) __VA_ARGS__, errstr()); \ exit(EXIT_FAILURE); \ } while (0) -- cgit v1.2.3