X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffgetc.c;fp=functions%2Fstdio%2Ffgetc.c;h=61f52fdd4208a84a3000a1e937619d92191b85b7;hb=b852731d2bc40ce2208264cdb55cc8e27944c890;hp=ae7a8356685540e2582a1c5dcc7a9b350a530c18;hpb=e6d28b5afddd8b3e3564af2264aa8b705e711b67;p=pdclib 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 )