]> pd.if.org Git - pdclib/blobdiff - functions/stdio/perror.c
PDCLib includes with quotes, not <>.
[pdclib] / functions / stdio / perror.c
index fc6ff87a4dc4c5ec15cd260e4270874a1057698a..97b727f253632fa08ddbfc3dda68f0e2dfd2456c 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /* perror( const char * )
 
    This file is part of the Public Domain C Library (PDCLib).
@@ -9,8 +7,8 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
 #include <errno.h>
+#include "_PDCLIB_locale.h"
 
 /* TODO: Doing this via a static array is not the way to do it. */
 void perror( const char * s )
@@ -19,14 +17,21 @@ 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_threadlocale()->_ErrnoStr[errno] );
+    }
     return;
 }
 
 #endif
 
 #ifdef TEST
-#include <_PDCLIB_test.h>
+#include "_PDCLIB_test.h"
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
@@ -44,7 +49,7 @@ int main( void )
     TESTCASE( fread( buffer, 1, 7, fh ) == 7 );
     TESTCASE( memcmp( buffer, "Test: ", 6 ) == 0 );
     TESTCASE( fclose( fh ) == 0 );
-    remove( testfile );
+    TESTCASE( remove( testfile ) == 0 );
     return TEST_RESULTS;
 }