3 /* perror( const char * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
15 /* TODO: Doing this via a static array is not the way to do it. */
16 void perror( const char * s )
18 if ( ( s != NULL ) && ( s[0] != '\n' ) )
20 fprintf( stderr, "%s: ", s );
22 if ( errno >= _PDCLIB_ERRNO_MAX )
24 fprintf( stderr, "Unknown error\n" );
28 fprintf( stderr, "%s\n", _PDCLIB_lconv._PDCLIB_errno_texts[errno] );
36 #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 );