X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=5df86c019b41c275ccdf61ce0fa60d8686c902d9;hb=e1c526e9bad3f6e69391e94059096145390508d3;hp=fc6ff87a4dc4c5ec15cd260e4270874a1057698a;hpb=afde3daa4992d49e190a6e8677e7317e0d367c59;p=pdclib diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index fc6ff87..5df86c0 100644 --- a/functions/stdio/perror.c +++ b/functions/stdio/perror.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* perror( const char * ) This file is part of the Public Domain C Library (PDCLib). @@ -9,8 +7,8 @@ #include #ifndef REGTEST - #include +#include <_PDCLIB_locale.h> /* TODO: Doing this via a static array is not the way to do it. */ void perror( const char * s ) @@ -19,7 +17,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_threadlocale()->_ErrnoStr[errno] ); + } return; } @@ -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; }