]> pd.if.org Git - pdclib/blobdiff - functions/stdio/ungetc.c
Merged branch stdio_rewrite back into trunk.
[pdclib] / functions / stdio / ungetc.c
index fdafc9de1054f34ca1e5b09c42ea06507ecf59e2..f85ca9ce96344f423a096807ce6a42cbafc22acc 100644 (file)
 
 #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;
 }