]> pd.if.org Git - pdclib/blobdiff - functions/stdio/perror.c
Comment cleanups.
[pdclib] / functions / stdio / perror.c
index bf3b3afee1c1bf0028218f657263853c0ffcc7a6..d38a641bb7e8a6ba3723b92aefc3269afe499faf 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /* perror( const char * )
 
    This file is part of the Public Domain C Library (PDCLib).
@@ -11,6 +9,7 @@
 #ifndef REGTEST
 
 #include <errno.h>
+#include <locale.h>
 
 /* TODO: Doing this via a static array is not the way to do it. */
 void perror( const char * s )
@@ -19,7 +18,14 @@ void perror( const char * s )
     {
         fprintf( stderr, "%s: ", s );
     }
-    fprintf( stderr, "%s\n", _PDCLIB_errno_texts[ errno ] );
+    if ( errno >= _PDCLIB_ERRNO_MAX )
+    {
+        fprintf( stderr, "Unknown error\n" );
+    }
+    else
+    {
+        fprintf( stderr, "%s\n", _PDCLIB_lconv._PDCLIB_errno_texts[errno] );
+    }
     return;
 }