X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffflush.c;h=df458804dc3099274f024286c3c55db2091418d8;hb=84d648157e22cecc65902ecfdd4e3a1b88d5e53f;hp=5118503c530e413232e79dc8ece526356597ccf0;hpb=37de3232dda3b05297f00b4edc12d04bf4bf6eb3;p=pdclib.old diff --git a/functions/stdio/fflush.c b/functions/stdio/fflush.c index 5118503..df45880 100644 --- a/functions/stdio/fflush.c +++ b/functions/stdio/fflush.c @@ -13,7 +13,7 @@ extern struct _PDCLIB_file_t * _PDCLIB_filelist; -int fflush( struct _PDCLIB_file_t * stream ) +int fflush_unlocked( struct _PDCLIB_file_t * stream ) { if ( stream == NULL ) { @@ -22,9 +22,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,9 +35,17 @@ int fflush( struct _PDCLIB_file_t * stream ) } else { - return _PDCLIB_fflush( stream ); + return _PDCLIB_flushbuffer( stream ); } } + +int fflush( struct _PDCLIB_file_t * stream ) +{ + flockfile( stream ); + int res = fflush_unlocked(stream); + funlockfile( stream ); + return res; +} #endif @@ -43,7 +54,7 @@ int fflush( struct _PDCLIB_file_t * stream ) int main( void ) { - TESTCASE( NO_TESTDRIVER ); + /* Testing covered by ftell.c */ return TEST_RESULTS; }