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