3 /* fgets( char *, int, FILE * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 #define _PDCLIB_GLUE_H _PDCLIB_GLUE_H
14 #include <_PDCLIB_glue.h>
16 char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
20 /* TODO: This is the letter of the standard, but is it the right thing to do? */
24 if ( _PDCLIB_prepread( stream ) == EOF )
29 while ( ( ( *dest = stream->buffer[stream->bufidx++] ) != '\n' ) && --size > 0 )
31 if ( stream->bufidx == stream->bufend )
33 if ( _PDCLIB_fillbuffer( stream ) == EOF )
35 /* EOF adds \0, error leaves target indeterminate, so we can
36 just add the \0 anyway.
51 #include <_PDCLIB_test.h>
55 TESTCASE( NO_TESTDRIVER );