X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=609562a8e46a783a89420808117163d6d8ce5c5e;hb=4116251e9bb6c386580d71d8c4afd2d0d08c6096;hp=f93a53b522fa18ba3c8a00e9fa2a19973146cf8d;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index f93a53b..609562a 100644 --- a/functions/stdio/perror.c +++ b/functions/stdio/perror.c @@ -1,8 +1,37 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- - -void perror( const char * s ) { /* TODO */ }; +/* $Id$ */ + +/* perror( const char * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +#include + +/* TODO: Doing this via a static array is not the way to do it. */ +void perror( const char * s ) +{ + if ( ( s != NULL ) && ( s[0] != '\n' ) ) + { + fprintf( stderr, "%s: ", s ); + } + fprintf( stderr, "%s\n", _PDCLIB_errno_texts[ errno ] ); + return; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE( NO_TESTDRIVER ); + return TEST_RESULTS; +} + +#endif