X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffflush.c;h=5a0bc3662b57d725e3411afd6b0a2dd1e52c0617;hb=d865c4403fc91d1f1ac95ba76febcee9f429bb97;hp=5118503c530e413232e79dc8ece526356597ccf0;hpb=f63c745c3dde325a2260f2f8b998e2b24bb6419e;p=pdclib diff --git a/functions/stdio/fflush.c b/functions/stdio/fflush.c index 5118503..5a0bc36 100644 --- a/functions/stdio/fflush.c +++ b/functions/stdio/fflush.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* fflush( FILE * ) This file is part of the Public Domain C Library (PDCLib). @@ -9,7 +7,8 @@ #include #ifndef REGTEST -#include <_PDCLIB_glue.h> + +#include "_PDCLIB_glue.h" extern struct _PDCLIB_file_t * _PDCLIB_filelist; @@ -22,9 +21,12 @@ int fflush( struct _PDCLIB_file_t * stream ) int rc = 0; while ( stream != NULL ) { - if ( stream->bufidx > stream->bufend ) + if ( stream->status & _PDCLIB_FWRITE ) { - rc |= _PDCLIB_fflush( stream ); + if ( _PDCLIB_flushbuffer( stream ) == EOF ) + { + rc = EOF; + } } stream = stream->next; } @@ -32,20 +34,20 @@ int fflush( struct _PDCLIB_file_t * stream ) } else { - return _PDCLIB_fflush( stream ); + return _PDCLIB_flushbuffer( stream ); } } - + #endif #ifdef TEST -#include <_PDCLIB_test.h> + +#include "_PDCLIB_test.h" int main( void ) { - TESTCASE( NO_TESTDRIVER ); + /* Testing covered by ftell.c */ return TEST_RESULTS; } #endif -