X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Fungetc.c;h=f85ca9ce96344f423a096807ce6a42cbafc22acc;hp=fdafc9de1054f34ca1e5b09c42ea06507ecf59e2;hb=393020b6e48719d27699dea6b29e53025bbd5123;hpb=f408c1fd633015089d2a0fc6bc31c9f61eeae0a9 diff --git a/functions/stdio/ungetc.c b/functions/stdio/ungetc.c index fdafc9d..f85ca9c 100644 --- a/functions/stdio/ungetc.c +++ b/functions/stdio/ungetc.c @@ -10,10 +10,13 @@ #ifndef REGTEST -int ungetc( int c, struct _PDCLIB_file_t * stream ) +int ungetc( int c, struct _PDCLIB_file_t * _PDCLIB_restrict 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; }