X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffreopen.c;h=906096f4a5cfbc57e6ab28770b9e2bc7dfd67f3c;hb=526e9954c39f30819e421cb74e82aa59d5a41013;hp=13992deb8214f5fe9f7e7d76584da4a5b1247dc3;hpb=f2dbc6a41d71a685ce2a69e83eaa5172fff5066a;p=pdclib diff --git a/functions/stdio/freopen.c b/functions/stdio/freopen.c index 13992de..906096f 100644 --- a/functions/stdio/freopen.c +++ b/functions/stdio/freopen.c @@ -1,6 +1,6 @@ /* $Id$ */ -/* freopen( const char *, const char * ) +/* freopen( const char *, const char *, FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. @@ -21,13 +21,13 @@ (Primary use of this function is to redirect stdin, stdout, and stderr.) */ -struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * stream ) +struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) { /* FIXME: This is ad-hoc (to make the vprintf() testdriver work), and must be checked. */ /* FIXME: If filename is NULL, change mode. */ /* TODO: This function can change wide orientation of a stream */ if ( filename == NULL ) return NULL; - if ( stream->status & _PDCLIB_WROTELAST ) fflush( stream ); + if ( stream->status & _PDCLIB_FWRITE ) fflush( stream ); if ( stream->status & _PDCLIB_LIBBUFFER ) free( stream->buffer ); _PDCLIB_close( stream->handle ); clearerr( stream ); @@ -37,7 +37,7 @@ struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const c if ( ( stream->buffer = malloc( BUFSIZ ) ) == NULL ) return NULL; stream->bufsize = BUFSIZ; stream->bufidx = 0; - stream->status |= ( _PDCLIB_LIBBUFFER | _PDCLIB_VIRGINSTR ); + stream->status |= _PDCLIB_LIBBUFFER; /* TODO: Setting mbstate */ return stream; }