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