{
return EOF;
}
- if ( stream->ungetidx > 0 )
- {
- return (unsigned char)stream->ungetbuf[ --(stream->ungetidx) ];
- }
- return (unsigned char)stream->buffer[stream->bufidx++];
+
+ char c;
+
+ size_t n = _PDCLIB_getchars( &c, 1, EOF, stream );
+
+ return n == 0 ? EOF : (unsigned char) c;
}
int fgetc( struct _PDCLIB_file_t * stream )
#ifndef REGTEST
#include <_PDCLIB_glue.h>
+#include <stdint.h>
char * gets( char * s )
{
return NULL;
}
char * dest = s;
- while ( ( *dest = stdin->buffer[stdin->bufidx++] ) != '\n' )
- {
- ++dest;
- if ( stdin->bufidx == stdin->bufend )
- {
- if ( _PDCLIB_fillbuffer( stdin ) == EOF )
- {
- break;
- }
- }
+
+ dest += _PDCLIB_getchars( dest, SIZE_MAX, '\n', stdin );
+
+ if(*(dest - 1) == '\n') {
+ *(--dest) = '\0';
+ } else {
+ *dest = '\0';
}
- *dest = '\0';
+
return ( dest == s ) ? NULL : s;
}