- Timestamp:
- 10/26/09 23:27:59 (9 months ago)
- Files:
-
- trunk/functions/stdio/fgets.c (modified) (1 diff)
- trunk/functions/stdio/fputs.c (modified) (1 diff)
- trunk/functions/stdio/freopen.c (modified) (2 diffs)
- trunk/functions/stdio/fscanf.c (modified) (1 diff)
- trunk/functions/stdio/fseek.c (modified) (1 diff)
- trunk/functions/stdio/ungetc.c (modified) (1 diff)
- trunk/functions/stdio/vsnprintf.c (modified) (1 diff)
- trunk/functions/stdio/vsprintf.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/functions/stdio/fgets.c
r366 r382 14 14 #include <_PDCLIB_glue.h> 15 15 16 char * fgets( char * s, int size, struct _PDCLIB_file_t *stream )16 char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 17 17 { 18 18 if ( size <= 1 ) trunk/functions/stdio/fputs.c
r366 r382 12 12 #include <_PDCLIB_glue.h> 13 13 14 int fputs( const char * s, struct _PDCLIB_file_t *stream )14 int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 15 15 { 16 16 if ( _PDCLIB_prepwrite( stream ) == EOF ) trunk/functions/stdio/freopen.c
r366 r382 1 1 /* $Id$ */ 2 2 3 /* freopen( const char *, const char * )3 /* freopen( const char *, const char *, FILE * ) 4 4 5 5 This file is part of the Public Domain C Library (PDCLib). … … 22 22 */ 23 23 24 struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * stream )24 struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 25 25 { 26 26 /* FIXME: This is ad-hoc (to make the vprintf() testdriver work), and must be checked. */ trunk/functions/stdio/fscanf.c
r375 r382 27 27 #include <_PDCLIB_test.h> 28 28 29 #include <limits.h>30 29 #include <string.h> 30 31 char scanstring[] = " 1 23\00045\000\00067 "; 32 33 void scantest( int testnr, FILE * fh, size_t position, char const * format, 34 int expected_fscan_rc, char const * expected_fscan_output, size_t expected_fscan_length, 35 int expected_sscan_rc, char const * expected_sscan_output, size_t expected_sscan_length ) 36 { 37 char buffer[15]; 38 printf( "Test %d\n", testnr ); 39 TESTCASE( memset( buffer, -1, 15 ) == buffer ); 40 TESTCASE( fseek( fh, position, SEEK_SET ) == 0 ); 41 TESTCASE( fscanf( fh, format, buffer ) == expected_fscan_rc ); 42 TESTCASE( memcmp( buffer, expected_fscan_output, expected_fscan_length ) == 0 ); 43 TESTCASE( memset( buffer, -1, 15 ) == buffer ); 44 TESTCASE( sscanf( scanstring + position, format, buffer ) == expected_sscan_rc ); 45 TESTCASE( memcmp( buffer, expected_sscan_output, expected_sscan_length ) == 0 ); 46 } 31 47 32 48 int main( void ) 33 49 { 34 char teststring1[] = " 1 23\045\0\067 ";35 char buffer[15];36 50 FILE * fh; 37 51 TESTCASE( ( fh = fopen( "testfile", "w+" ) ) != NULL ); 38 TESTCASE( fwrite( teststring1, 15, 1, fh ) == 1 );52 TESTCASE( fwrite( scanstring, 14, 1, fh ) == 1 ); 39 53 rewind( fh ); 40 /* */ 41 TESTCASE( memset( buffer, CHAR_MAX, 15 ) == buffer ); \ 42 TESTCASE( fseek( fh, 0, SEEK_SET ) == 0 ); \ 43 TESTCASE( fscanf( fh, "%14c", buffer ) == 1 ); \ 44 TESTCASE( memcmp( buffer, teststring1 + 0, 14 ) == 0 ); \ 45 TESTCASE( buffer[ 14 ] == CHAR_MAX ); \ 46 TESTCASE( memset( buffer, CHAR_MAX, 15 ) == buffer ); \ 47 TESTCASE( sscanf( teststring1 + 14, "%14c", buffer ) ); \ 48 TESTCASE( memcmp( buffer, teststring1 + 0, 14 ) == 0 ); \ 49 TESTCASE( buffer[ 14 ] == CHAR_MAX ); 54 55 /* %14c - full scan */ 56 scantest( 1, fh, 0, "%14c", 57 1, " 1 23\00045\000\00067 \377", 15, 58 1, " 1 23\377", 7 ); 59 60 /* %c - default to one, reading whitespace */ 61 scantest( 2, fh, 0, "%c", 62 1, " \377", 2, 63 1, " \377", 2 ); 64 65 /* %1c - reading zero byte */ 66 scantest( 3, fh, 9, "%1c", 67 1, "\000\377", 2, 68 -1, "\377", 1 ); 69 70 /* %0c - NOT reading EOF */ 71 scantest( 4, fh, 13, "%0c", 72 0, "\377", 1, 73 0, "\377", 1 ); 74 75 TESTCASE( fclose( fh ) == 0 ); 76 //TESTCASE( remove( "testfile" ) == 0 ); 77 50 78 return TEST_RESULTS; 51 79 } trunk/functions/stdio/fseek.c
r376 r382 13 13 #include <_PDCLIB_glue.h> 14 14 15 int fseek( struct _PDCLIB_file_t * _PDCLIB_restrictstream, long offset, int whence )15 int fseek( struct _PDCLIB_file_t * stream, long offset, int whence ) 16 16 { 17 17 if ( stream->status & _PDCLIB_FWRITE ) trunk/functions/stdio/ungetc.c
r366 r382 11 11 #ifndef REGTEST 12 12 13 int ungetc( int c, struct _PDCLIB_file_t * _PDCLIB_restrictstream )13 int ungetc( int c, struct _PDCLIB_file_t * stream ) 14 14 { 15 15 if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE ) trunk/functions/stdio/vsnprintf.c
r366 r382 12 12 #ifndef REGTEST 13 13 14 int vsnprintf( char * s, size_t n, const char *format, _PDCLIB_va_list arg )14 int vsnprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg ) 15 15 { 16 16 /* TODO: This function should interpret format as multibyte characters. */ trunk/functions/stdio/vsprintf.c
r366 r382 13 13 #ifndef REGTEST 14 14 15 int vsprintf( char * str, const char *format, va_list arg )15 int vsprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, va_list arg ) 16 16 { 17 return vsnprintf( s tr, SIZE_MAX, format, arg ); /* TODO: Replace with a non-checking call */17 return vsnprintf( s, SIZE_MAX, format, arg ); /* TODO: Replace with a non-checking call */ 18 18 } 19 19
