X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=23ce68bd356cc11e997dcdabf4873b32156b2204;hp=fc6ff87a4dc4c5ec15cd260e4270874a1057698a;hb=ce0e5d8cd76b50f239fb8e95170502b146247b35;hpb=afde3daa4992d49e190a6e8677e7317e0d367c59 diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index fc6ff87..23ce68b 100644 --- a/functions/stdio/perror.c +++ b/functions/stdio/perror.c @@ -11,6 +11,7 @@ #ifndef REGTEST #include +#include /* TODO: Doing this via a static array is not the way to do it. */ void perror( const char * s ) @@ -19,7 +20,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; } @@ -44,7 +52,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; }