From 12138e498721892320e703702dcd3a4b191fb7fc Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 27 Jan 2008 15:26:08 -0600 Subject: Teach perror_exit() to take a NULL argument when we just want "command: error". --- lib/lib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/lib.c b/lib/lib.c index 1fadfb7b..71abc3ae 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -20,9 +20,12 @@ void xstrcpy(char *dest, char *src, size_t size) void verror_msg(char *msg, int err, va_list va) { + char *s = ": %s"; + fprintf(stderr, "%s: ", toys.which->name); - vfprintf(stderr, msg, va); - if (err) fprintf(stderr, ": %s", strerror(err)); + if (msg) vfprintf(stderr, msg, va); + else s+=2; + if (err) fprintf(stderr, s, strerror(err)); putc('\n', stderr); } -- cgit v1.2.3