X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fungetc.c;h=001735b533c04361648b2c3eb5475cdced99faac;hb=526e9954c39f30819e421cb74e82aa59d5a41013;hp=fdafc9de1054f34ca1e5b09c42ea06507ecf59e2;hpb=e5112b619d1aae8ffc439389cfcbd3b2b4bd2454;p=pdclib diff --git a/functions/stdio/ungetc.c b/functions/stdio/ungetc.c index fdafc9d..001735b 100644 --- a/functions/stdio/ungetc.c +++ b/functions/stdio/ungetc.c @@ -12,8 +12,11 @@ int ungetc( int c, struct _PDCLIB_file_t * stream ) { - /* TODO: Implement. */ - return 0; + if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE ) + { + return -1; + } + return stream->ungetbuf[stream->ungetidx++] = (unsigned char) c; } #endif @@ -23,7 +26,7 @@ int ungetc( int c, struct _PDCLIB_file_t * stream ) int main( void ) { - TESTCASE( NO_TESTDRIVER ); + /* Testing covered by ftell.c */ return TEST_RESULTS; }