X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fsetvbuf.c;h=e3f9278aed159a316ab9e3da1883ff52ee12767e;hb=dd71cbbfbd68cd8c653277a0c1f70ab2b179421c;hp=b9d97a01d0cead30eb2abbc4e0f4a90b3f4af1a6;hpb=8f67eac83402119dfdd2627da82c65d5a349cb02;p=pdclib diff --git a/functions/stdio/setvbuf.c b/functions/stdio/setvbuf.c index b9d97a0..e3f9278 100644 --- a/functions/stdio/setvbuf.c +++ b/functions/stdio/setvbuf.c @@ -21,7 +21,6 @@ int setvbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_res we don't want to e.g. flush the stream for every character of a stream being printed. */ - /* TODO: Check this */ break; case _IOFBF: case _IOLBF: @@ -80,32 +79,27 @@ int setvbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_res int main( void ) { #ifndef REGTEST - char const * const filename = "testfile"; char buffer[ BUFFERSIZE ]; FILE * fh; - remove( filename ); /* full buffered, user-supplied buffer */ - TESTCASE( ( fh = fopen( filename, "w" ) ) != NULL ); + TESTCASE( ( fh = tmpfile() ) != NULL ); TESTCASE( setvbuf( fh, buffer, _IOFBF, BUFFERSIZE ) == 0 ); TESTCASE( fh->buffer == buffer ); TESTCASE( fh->bufsize == BUFFERSIZE ); TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF ); TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( filename ) == 0 ); /* line buffered, lib-supplied buffer */ - TESTCASE( ( fh = fopen( filename, "w" ) ) != NULL ); + TESTCASE( ( fh = tmpfile() ) != NULL ); TESTCASE( setvbuf( fh, NULL, _IOLBF, BUFFERSIZE ) == 0 ); TESTCASE( fh->buffer != NULL ); TESTCASE( fh->bufsize == BUFFERSIZE ); TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOLBF ); TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( filename ) == 0 ); /* not buffered, user-supplied buffer */ - TESTCASE( ( fh = fopen( filename, "w" ) ) != NULL ); + TESTCASE( ( fh = tmpfile() ) != NULL ); TESTCASE( setvbuf( fh, buffer, _IONBF, BUFFERSIZE ) == 0 ); TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF ); TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( filename ) == 0 ); #else puts( " NOTEST setvbuf() test driver is PDCLib-specific." ); #endif