[hackers] [wmii] Make fatal() a bit nicer.

From: Kris Maglione <jg_AT_suckless.org>
Date: Tue Jul 17 04:19:45 2007

changeset: 2199:41450fc70ffc
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Jul 16 22:16:58 2007 -0400
summary: Make fatal() a bit nicer.

diff -r 2c12bfc17f89 -r 41450fc70ffc cmd/util.c
--- a/cmd/util.c Mon Jul 16 21:44:25 2007 -0400
+++ b/cmd/util.c Mon Jul 16 22:16:58 2007 -0400
@@ -9,30 +9,37 @@
 #include <util.h>
 #include <fmt.h>
 
+typedef struct VFmt VFmt;
+struct VFmt {
+ const char *fmt;
+ va_list args;
+};
+
+#ifdef VARARGCK
+# pragma varargck type "V" VFmt*
+#endif
+
 static int
 Vfmt(Fmt *f) {
- char *fmt;
- va_list ap;
+ VFmt *vf;
         int i;
 
- fmt = va_arg(f->args, char*);
- va_copy(ap, va_arg(f->args, va_list));
-
- i = fmtvprint(f, fmt, ap);
- va_end(ap);
+ vf = va_arg(f->args, VFmt*);
+ i = fmtvprint(f, vf->fmt, vf->args);
         return i;
 }
 
 void
 fatal(const char *fmt, ...) {
- va_list ap;
+ VFmt fp;
 
         fmtinstall('V', Vfmt);
         fmtinstall('\001', Vfmt);
 
- va_start(ap, fmt);
- fprint(2, "%s: fatal: %V\n", argv0, fmt, ap);
- va_end(ap);
+ fp.fmt = fmt;
+ va_start(fp.args, fmt);
+ fprint(2, "%s: fatal: %V\n", argv0, &fp);
+ va_end(fp.args);
 
         exit(1);
 }
Received on Tue Jul 17 2007 - 04:19:45 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:38 UTC