X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=9fe694825a632fbaedab7e7d11915ac8aa157654;hb=HEAD;hp=bf3b3afee1c1bf0028218f657263853c0ffcc7a6;hpb=33515db12d3cc5e53a8bdea58d2cde299cba2267;p=pdclib.old diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index bf3b3af..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; }