- if ( stream->status & _PDCLIB_WROTELAST ) fflush( stream );
- if ( stream->status & _PDCLIB_LIBBUFFER ) free( stream->buffer );
+ /* Flush buffer */
+ if ( stream->status & _PDCLIB_FWRITE )
+ {
+ if ( _PDCLIB_flushbuffer( stream ) == EOF )
+ {
+ /* Flush failed, errno already set */
+ return EOF;
+ }
+ }
+ /* Close handle */
- TESTCASE( _PDCLIB_filelist == NULL );
- TESTCASE( ( file1 = fopen( "testfile1", "w" ) ) != NULL );
+ remove( testfile1 );
+ remove( testfile2 );
+ TESTCASE( _PDCLIB_filelist == stdin );
+ TESTCASE( ( file1 = fopen( testfile1, "w" ) ) != NULL );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file2 ) == 0 );
TESTCASE( _PDCLIB_filelist == file1 );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file2 ) == 0 );
TESTCASE( _PDCLIB_filelist == file1 );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file1 ) == 0 );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file2 ) == 0 );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file1 ) == 0 );
TESTCASE( _PDCLIB_filelist == file2 );
TESTCASE( fclose( file2 ) == 0 );
- TESTCASE( _PDCLIB_filelist == NULL );
- system( "rm testfile1 testfile2" );
+ TESTCASE( _PDCLIB_filelist == stdin );
+ TESTCASE( remove( testfile1 ) == 0 );
+ TESTCASE( remove( testfile2 ) == 0 );