about summary refs log tree commit diff
path: root/stdio-common/perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/perror.c')
-rw-r--r--stdio-common/perror.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/stdio-common/perror.c b/stdio-common/perror.c
index 4c29cb09e1..239d43edc6 100644
--- a/stdio-common/perror.c
+++ b/stdio-common/perror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1993,1997,1998,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,9 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
+#include <wchar.h>
 
 /* Print a line on stderr consisting of the text in S, a colon, a space,
    a message describing the meaning of the contents of `errno' and a newline.
@@ -29,12 +30,17 @@ perror (const char *s)
   char buf[1024];
   int errnum = errno;
   const char *colon;
+  const char *errstring;
 
   if (s == NULL || *s == '\0')
     s = colon = "";
   else
     colon = ": ";
 
-  (void) fprintf (stderr, "%s%s%s\n",
-		  s, colon, __strerror_r (errnum, buf, sizeof buf));
+  errstring = __strerror_r (errnum, buf, sizeof buf);
+
+  if (fwide (stderr, 0) > 0)
+    (void) fwprintf (stderr, L"%s%s%s\n", s, colon, errstring);
+  else
+    (void) fprintf (stderr, "%s%s%s\n", s, colon, errstring);
 }