about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/err.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/misc/err.c b/misc/err.c
index 82719a8756..3ad7bf360f 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -20,6 +20,8 @@ Cambridge, MA 02139, USA.  */
 #include <stdarg.h>
 #include <err.h>
 #include <stdlib.h>
+#include <errno.h>
+#include <string.h>
 #include <stdio.h>
 
 extern char *__progname;
@@ -33,18 +35,28 @@ extern char *__progname;
 }
 
 void
-vwarn (const char *format, __gnuc_va_list ap)
+vwarnx (const char *format, __gnuc_va_list ap)
 {
-  fprintf (stderr, format, ap);
+  if (__progname)
+    fprintf (stderr, "%s: ", __progname);
+  if (format)
+    vfprintf (stderr, format, ap);
+  putc ('\n', stderr);
 }
 
 void
-vwarnx (const char *format, __gnuc_va_list ap)
+vwarn (const char *format, __gnuc_va_list ap)
 {
+  int error = errno;
+
   if (__progname)
     fprintf (stderr, "%s: ", __progname);
-  fprintf (stderr, format, ap);
-  putc ('\n', stderr);
+  if (format)
+    {
+      vfprintf (stderr, format, ap);
+      fputs (": ", stderr);
+    }
+  fprintf (stderr, "%s\n", strerror (error));
 }