Changeset 382 for trunk

Show
Ignore:
Timestamp:
10/26/09 23:27:59 (9 months ago)
Author:
solar
Message:

restrict keyword cleanup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/functions/stdio/fgets.c

    r366 r382  
    1414#include <_PDCLIB_glue.h> 
    1515 
    16 char * fgets( char * s, int size, struct _PDCLIB_file_t * stream ) 
     16char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 
    1717{ 
    1818    if ( size <= 1 ) 
  • trunk/functions/stdio/fputs.c

    r366 r382  
    1212#include <_PDCLIB_glue.h> 
    1313 
    14 int fputs( const char * s, struct _PDCLIB_file_t * stream ) 
     14int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 
    1515{ 
    1616    if ( _PDCLIB_prepwrite( stream ) == EOF ) 
  • trunk/functions/stdio/freopen.c

    r366 r382  
    11/* $Id$ */ 
    22 
    3 /* freopen( const char *, const char *
     3/* freopen( const char *, const char *, FILE *
    44 
    55   This file is part of the Public Domain C Library (PDCLib). 
     
    2222*/ 
    2323 
    24 struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * stream ) 
     24struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 
    2525{ 
    2626    /* FIXME: This is ad-hoc (to make the vprintf() testdriver work), and must be checked. */ 
  • trunk/functions/stdio/fscanf.c

    r375 r382  
    2727#include <_PDCLIB_test.h> 
    2828 
    29 #include <limits.h> 
    3029#include <string.h> 
     30 
     31char scanstring[] = "  1 23\00045\000\00067 "; 
     32 
     33void 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} 
    3147 
    3248int main( void ) 
    3349{ 
    34     char teststring1[] = "  1 23\045\0\067 "; 
    35     char buffer[15]; 
    3650    FILE * fh; 
    3751    TESTCASE( ( fh = fopen( "testfile", "w+" ) ) != NULL ); 
    38     TESTCASE( fwrite( teststring1, 15, 1, fh ) == 1 ); 
     52    TESTCASE( fwrite( scanstring, 14, 1, fh ) == 1 ); 
    3953    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 
    5078    return TEST_RESULTS; 
    5179} 
  • trunk/functions/stdio/fseek.c

    r376 r382  
    1313#include <_PDCLIB_glue.h> 
    1414 
    15 int fseek( struct _PDCLIB_file_t * _PDCLIB_restrict stream, long offset, int whence ) 
     15int fseek( struct _PDCLIB_file_t * stream, long offset, int whence ) 
    1616{ 
    1717    if ( stream->status & _PDCLIB_FWRITE ) 
  • trunk/functions/stdio/ungetc.c

    r366 r382  
    1111#ifndef REGTEST 
    1212 
    13 int ungetc( int c, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) 
     13int ungetc( int c, struct _PDCLIB_file_t * stream ) 
    1414{ 
    1515    if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE ) 
  • trunk/functions/stdio/vsnprintf.c

    r366 r382  
    1212#ifndef REGTEST 
    1313 
    14 int vsnprintf( char * s, size_t n, const char * format, _PDCLIB_va_list arg ) 
     14int vsnprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg ) 
    1515{ 
    1616    /* TODO: This function should interpret format as multibyte characters.  */ 
  • trunk/functions/stdio/vsprintf.c

    r366 r382  
    1313#ifndef REGTEST 
    1414 
    15 int vsprintf( char * str, const char * format, va_list arg ) 
     15int vsprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, va_list arg ) 
    1616{ 
    17     return vsnprintf( str, 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 */ 
    1818} 
    1919