From ccc4611f77bac2a7b430fdfcf18e1688f0dbfb00 Mon Sep 17 00:00:00 2001 From: jilles Date: Mon, 20 Dec 2010 23:06:57 +0000 Subject: sh: Make warnings in the printf builtin non-fatal, like in the program. The #define for warnx now behaves much like the libc function (except that it uses sh command name and output). Also, it now uses C99 __VA_ARGS__ so there is no need for three different macros for 0, 1 or 2 parameters. --- bin/sh/bltin/bltin.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h index 0fc8a28..6618108 100644 --- a/bin/sh/bltin/bltin.h +++ b/bin/sh/bltin/bltin.h @@ -57,21 +57,12 @@ #define fwrite(ptr, size, nmemb, file) outbin(ptr, (size) * (nmemb), file) #define fflush flushout #define INITARGS(argv) -#define warnx1(a, b, c) { \ - char buf[64]; \ - (void)snprintf(buf, sizeof(buf), a); \ - error("%s", buf); \ -} -#define warnx2(a, b, c) { \ - char buf[64]; \ - (void)snprintf(buf, sizeof(buf), a, b); \ - error("%s", buf); \ -} -#define warnx3(a, b, c) { \ - char buf[64]; \ - (void)snprintf(buf, sizeof(buf), a, b, c); \ - error("%s", buf); \ -} +#define warnx(...) do { \ + out2fmt_flush("%s: ", commandname); \ + out2fmt_flush(__VA_ARGS__); \ + out2fmt_flush("\n"); \ + } while (0) +#define errx(exitstatus, ...) error(__VA_ARGS__) #else #undef NULL -- cgit v1.1