X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=9fe694825a632fbaedab7e7d11915ac8aa157654;hb=HEAD;hp=fc6ff87a4dc4c5ec15cd260e4270874a1057698a;hpb=cc5d73c2db0ed51fcdf0b3c80fd043a7e91d4602;p=pdclib.old diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index fc6ff87..9fe6948 100644 --- a/functions/stdio/perror.c +++ b/functions/stdio/perror.c @@ -9,8 +9,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 +19,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 +51,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; }