Also wrap vf?printf.
authorEric Blake <ebb9@byu.net>
Mon, 22 Oct 2007 20:09:16 +0000 (14:09 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 22 Oct 2007 21:54:17 +0000 (15:54 -0600)
* lib/xprintf.h (xvprintf, xvfprintf): New declarations.
* lib/xprintf.c (xprintf, xfprintf): Work for C89.
(xvprintf, xvfprintf): New functions.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/xprintf.c
lib/xprintf.h

index b14bd159dbae4c9946cab1c7d7ae022a059d0e47..1f17dbd091f365cae17c18bab8a5e507ff3fcbe5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-22  Eric Blake  <ebb9@byu.net>
+
+       Also wrap vf?printf.
+       * lib/xprintf.h (xvprintf, xvfprintf): New declarations.
+       * lib/xprintf.c (xprintf, xfprintf): Work for C89.
+       (xvprintf, xvfprintf): New functions.
+
 2007-10-22  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * modules/fstrcmp-tests (test_fstrcmp_LDADD): New, add
index b3940ad49d2b788427de94d89399cebbd93ddebb..7738cc4ee38a70ce36806bc92a9707cf8efd03a6 100644 (file)
@@ -19,7 +19,6 @@
 #include "xprintf.h"
 
 #include <errno.h>
-#include <stdarg.h>
 
 #include "error.h"
 #include "exitfail.h"
@@ -33,11 +32,22 @@ int
 xprintf (char const *restrict format, ...)
 {
   va_list args;
+  int err;
   va_start (args, format);
+  err = xvprintf (format, args);
+  va_end (args);
+
+  return err;
+}
+
+/* Just like vprintf, but call error if it fails without setting
+   the error indicator.  */
+int
+xvprintf (char const *restrict format, va_list args)
+{
   int err = vprintf (format, args);
   if (err < 0 && ! ferror (stdout))
     error (exit_failure, errno, gettext ("cannot perform formatted output"));
-  va_end (args);
 
   return err;
 }
@@ -48,11 +58,22 @@ int
 xfprintf (FILE *restrict stream, char const *restrict format, ...)
 {
   va_list args;
+  int err;
   va_start (args, format);
+  err = xvfprintf (stream, format, args);
+  va_end (args);
+
+  return err;
+}
+
+/* Just like vfprintf, but call error if it fails without setting
+   the error indicator.  */
+int
+xvfprintf (FILE *restrict stream, char const *restrict format, va_list args)
+{
   int err = vfprintf (stream, format, args);
   if (err < 0 && ! ferror (stream))
     error (exit_failure, errno, gettext ("cannot perform formatted output"));
-  va_end (args);
 
   return err;
 }
index 4c0870cfe87fe71ab9c77c29e34b13e16a18619f..5340aa3b2baa1568e05b7880c6bb940c07a4ce19 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef _XPRINTF_H
 #define _XPRINTF_H
 
+#include <stdarg.h>
 #include <stdio.h>
 
 #ifndef __attribute__
 
 extern int xprintf (char const *restrict format, ...)
   __attribute__ ((__format__ (__printf__, 1, 2)));
+extern int xvprintf (char const *restrict format, va_list args)
+  __attribute__ ((__format__ (__printf__, 1, 0)));
 extern int xfprintf (FILE *restrict stream, char const *restrict format, ...)
   __attribute__ ((__format__ (__printf__, 2, 3)));
+extern int xvfprintf (FILE *restrict stream, char const *restrict format,
+                     va_list args)
+  __attribute__ ((__format__ (__printf__, 2, 0)));
 
 #endif