]> pd.if.org Git - pdclib/blobdiff - functions/stdio/ungetc.c
Comment cleanups.
[pdclib] / functions / stdio / ungetc.c
index fdafc9de1054f34ca1e5b09c42ea06507ecf59e2..dd0295917e4af81cdee2334f33e4a90f73656e8e 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /* ungetc( int, FILE * )
 
    This file is part of the Public Domain C Library (PDCLib).
 
 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;
 }