3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
10 #include <_PDCLIB_io.h>
12 void _PDCLIB_clearerr_unlocked( FILE * stream )
14 stream->status &= ~( _PDCLIB_ERRORFLAG | _PDCLIB_EOFFLAG );
17 void clearerr( FILE * stream )
19 _PDCLIB_flockfile( stream );
20 _PDCLIB_clearerr_unlocked( stream );
21 _PDCLIB_funlockfile( stream );
27 #include <_PDCLIB_test.h>
32 TESTCASE( ( fh = tmpfile() ) != NULL );
33 /* Flags should be clear */
34 TESTCASE( ! ferror( fh ) );
35 TESTCASE( ! feof( fh ) );
36 /* Reading from input stream - should provoke error */
37 /* FIXME: Apparently glibc disagrees on this assumption. How to provoke error on glibc? */
38 TESTCASE( fgetc( fh ) == EOF );
39 TESTCASE( ferror( fh ) );
40 TESTCASE( ! feof( fh ) );
41 /* clearerr() should clear flags */
43 TESTCASE( ! ferror( fh ) );
44 TESTCASE( ! feof( fh ) );
45 /* Reading from empty stream - should provoke EOF */
47 TESTCASE( fgetc( fh ) == EOF );
48 TESTCASE( ! ferror( fh ) );
49 TESTCASE( feof( fh ) );
50 /* clearerr() should clear flags */
52 TESTCASE( ! ferror( fh ) );
53 TESTCASE( ! feof( fh ) );
54 TESTCASE( fclose( fh ) == 0 );