X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fungetc.c;h=dd0295917e4af81cdee2334f33e4a90f73656e8e;hb=b1fc26afebd4d557ff89a44bc21767a8704c3809;hp=fdafc9de1054f34ca1e5b09c42ea06507ecf59e2;hpb=e5112b619d1aae8ffc439389cfcbd3b2b4bd2454;p=pdclib diff --git a/functions/stdio/ungetc.c b/functions/stdio/ungetc.c index fdafc9d..dd02959 100644 --- a/functions/stdio/ungetc.c +++ b/functions/stdio/ungetc.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* ungetc( int, FILE * ) This file is part of the Public Domain C Library (PDCLib). @@ -12,8 +10,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 +24,7 @@ int ungetc( int c, struct _PDCLIB_file_t * stream ) int main( void ) { - TESTCASE( NO_TESTDRIVER ); + /* Testing covered by ftell.c */ return TEST_RESULTS; }