1 /* perror( const char * )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
13 /* TODO: Doing this via a static array is not the way to do it. */
14 void perror( const char * s )
16 if ( ( s != NULL ) && ( s[0] != '\n' ) )
18 fprintf( stderr, "%s: ", s );
20 if ( errno >= _PDCLIB_ERRNO_MAX )
22 fprintf( stderr, "Unknown error\n" );
26 fprintf( stderr, "%s\n", _PDCLIB_lconv._PDCLIB_errno_texts[errno] );
35 #include "_PDCLIB_test.h"
44 unsigned long long max = ULLONG_MAX;
46 sprintf( buffer, "%llu", max );
47 TESTCASE( ( fh = freopen( testfile, "wb+", stderr ) ) != NULL );
48 TESTCASE( strtol( buffer, NULL, 10 ) == LONG_MAX );
51 TESTCASE( fread( buffer, 1, 7, fh ) == 7 );
52 TESTCASE( memcmp( buffer, "Test: ", 6 ) == 0 );
53 TESTCASE( fclose( fh ) == 0 );
54 TESTCASE( remove( testfile ) == 0 );