diff options
author | jilles <jilles@FreeBSD.org> | 2010-12-20 23:06:57 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-12-20 23:06:57 +0000 |
commit | ccc4611f77bac2a7b430fdfcf18e1688f0dbfb00 (patch) | |
tree | e4c737ef986fabeba17f1f80244fe8dccc3ca5d9 /bin/sh | |
parent | 3830b0c9c78eedec2084a8ebcbcb06fb7a9b2a5c (diff) | |
download | FreeBSD-src-ccc4611f77bac2a7b430fdfcf18e1688f0dbfb00.zip FreeBSD-src-ccc4611f77bac2a7b430fdfcf18e1688f0dbfb00.tar.gz |
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.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/bltin/bltin.h | 21 |
1 files changed, 6 insertions, 15 deletions
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 |