]> pd.if.org Git - pdclib/blobdiff - functions/stdio/ungetc.c
Whitespace cleanups.
[pdclib] / functions / stdio / ungetc.c
index fdafc9de1054f34ca1e5b09c42ea06507ecf59e2..dc5260b63a1a769bd37650e4be1fbad0c67f24e6 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
 
 #ifdef TEST
-#include <_PDCLIB_test.h>
+
+#include "_PDCLIB_test.h"
 
 int main( void )
 {
-    TESTCASE( NO_TESTDRIVER );
+    /* Testing covered by ftell.c */
     return TEST_RESULTS;
 }