X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffgetc.c;fp=functions%2Fstdio%2Ffgetc.c;h=61f52fdd4208a84a3000a1e937619d92191b85b7;hb=8f9245802657360edcf9f0ab7b7794c296d05cdd;hp=ae7a8356685540e2582a1c5dcc7a9b350a530c18;hpb=d9be4032fa26b8714ec95e1da2c0928f9c79dd44;p=pdclib.old diff --git a/functions/stdio/fgetc.c b/functions/stdio/fgetc.c index ae7a835..61f52fd 100644 --- a/functions/stdio/fgetc.c +++ b/functions/stdio/fgetc.c @@ -18,11 +18,12 @@ int fgetc_unlocked( struct _PDCLIB_file_t * stream ) { 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 )