X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffgets.c;h=a3c41e94085eb3f8fa610d57c926dfa8115c36ef;hb=360b2c123dbd0750d38d89abbbcce24248f58e75;hp=a82818ad23542f9eaef5a14abc1883913b1024a5;hpb=0d54a75af25ca44411e7c4190cc2a93a390e61a2;p=pdclib.old diff --git a/functions/stdio/fgets.c b/functions/stdio/fgets.c index a82818a..a3c41e9 100644 --- a/functions/stdio/fgets.c +++ b/functions/stdio/fgets.c @@ -13,7 +13,7 @@ #define _PDCLIB_GLUE_H _PDCLIB_GLUE_H #include <_PDCLIB_glue.h> -char * fgets( char * s, int size, struct _PDCLIB_file_t * stream ) +char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) { if ( size <= 1 ) { @@ -21,16 +21,16 @@ char * fgets( char * s, int size, struct _PDCLIB_file_t * stream ) *s = '\0'; return s; } - if ( _PDCLIB_prepread( stdin ) == EOF ) + if ( _PDCLIB_prepread( stream ) == EOF ) { return NULL; } char * dest = s; - while ( ( ( *dest = stdin->buffer[stdin->bufidx++] ) != '\n' ) && --size > 0 ) + while ( ( ( *dest = stream->buffer[stream->bufidx++] ) != '\n' ) && --size > 0 ) { - if ( stdin->bufidx == stdin->bufend ) + if ( stream->bufidx == stream->bufend ) { - if ( _PDCLIB_fillbuffer( stdin ) == EOF ) + if ( _PDCLIB_fillbuffer( stream ) == EOF ) { /* EOF adds \0, error leaves target indeterminate, so we can just add the \0 anyway.