5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
12 #include <_PDCLIB_io.h>
14 void clearerr_unlocked( FILE * stream )
16 stream->status &= ~( _PDCLIB_ERRORFLAG | _PDCLIB_EOFFLAG );
19 void clearerr( FILE * stream )
22 clearerr_unlocked( stream );
23 funlockfile( stream );
29 #include <_PDCLIB_test.h>
34 TESTCASE( ( fh = tmpfile() ) != NULL );
35 /* Flags should be clear */
36 TESTCASE( ! ferror( fh ) );
37 TESTCASE( ! feof( fh ) );
38 /* Reading from input stream - should provoke error */
39 /* FIXME: Apparently glibc disagrees on this assumption. How to provoke error on glibc? */
40 TESTCASE( fgetc( fh ) == EOF );
41 TESTCASE( ferror( fh ) );
42 TESTCASE( ! feof( fh ) );
43 /* clearerr() should clear flags */
45 TESTCASE( ! ferror( fh ) );
46 TESTCASE( ! feof( fh ) );
47 /* Reading from empty stream - should provoke EOF */
49 TESTCASE( fgetc( fh ) == EOF );
50 TESTCASE( ! ferror( fh ) );
51 TESTCASE( feof( fh ) );
52 /* clearerr() should clear flags */
54 TESTCASE( ! ferror( fh ) );
55 TESTCASE( ! feof( fh ) );
56 TESTCASE( fclose( fh ) == 0 );