From cf61fe14aebf2b5f753261afdb9e03167b31a843 Mon Sep 17 00:00:00 2001 From: Mark Whitley Date: Tue, 5 Dec 2000 19:27:13 +0000 Subject: [PATCH] Applied patch from Matt Kraai to add v*error functions for handling vararg lists in a safe 'n sane fashion. --- utility.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/utility.c b/utility.c index 7c41ab8fb..eb3338302 100644 --- a/utility.c +++ b/utility.c @@ -84,36 +84,35 @@ extern void usage(const char *usage) exit(EXIT_FAILURE); } -extern void errorMsg(const char *s, ...) +static void verrorMsg(const char *s, va_list p) { - va_list p; - - va_start(p, s); fflush(stdout); fprintf(stderr, "%s: ", applet_name); vfprintf(stderr, s, p); - va_end(p); fflush(stderr); } -extern void fatalError(const char *s, ...) +extern void errorMsg(const char *s, ...) { va_list p; va_start(p, s); - fflush(stdout); - fprintf(stderr, "%s: ", applet_name); - vfprintf(stderr, s, p); + verrorMsg(s, p); va_end(p); - fflush(stderr); - exit(EXIT_FAILURE); } -extern void perrorMsg(const char *s, ...) +extern void fatalError(const char *s, ...) { va_list p; va_start(p, s); + verrorMsg(s, p); + va_end(p); + exit(EXIT_FAILURE); +} + +static void vperrorMsg(const char *s, va_list p) +{ fflush(stdout); fprintf(stderr, "%s: ", applet_name); if (s && *s) { @@ -121,24 +120,25 @@ extern void perrorMsg(const char *s, ...) fputs(": ", stderr); } fprintf(stderr, "%s\n", strerror(errno)); - va_end(p); fflush(stderr); } +extern void perrorMsg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + vperrorMsg(s, p); + va_end(p); +} + extern void fatalPerror(const char *s, ...) { va_list p; va_start(p, s); - fflush(stdout); - fprintf(stderr, "%s: ", applet_name); - if (s && *s) { - vfprintf(stderr, s, p); - fputs(": ", stderr); - } - fprintf(stderr, "%s\n", strerror(errno)); + vperrorMsg(s, p); va_end(p); - fflush(stderr); exit(EXIT_FAILURE); } -- 2.25.1