]> pd.if.org Git - pdclib/blob - functions/stdio/ungetc.c
Merged branch stdio_rewrite back into trunk.
[pdclib] / functions / stdio / ungetc.c
1 /* $Id$ */
2
3 /* ungetc( int, FILE * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10
11 #ifndef REGTEST
12
13 int ungetc( int c, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
14 {
15     if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE )
16     {
17         return -1;
18     }
19     return stream->ungetbuf[stream->ungetidx++] = (unsigned char) c;
20 }
21
22 #endif
23
24 #ifdef TEST
25 #include <_PDCLIB_test.h>
26
27 int main( void )
28 {
29     /* Testing covered by ftell.c */
30     return TEST_RESULTS;
31 }
32
33 #endif