xref: /csrg-svn/lib/libc/stdio/ungetc.c (revision 17951)
1 /*	ungetc.c	4.3	85/02/13	*/
2 
3 #include <stdio.h>
4 
5 ungetc(c, iop)
6 	register FILE *iop;
7 {
8 	if (c == EOF || (iop->_flag & (_IOREAD|_IORW)) == 0 ||
9 	    iop->_ptr == NULL || iop->_base == NULL)
10 		return (EOF);
11 
12 	if (iop->_ptr == iop->_base)
13 		iop->_ptr++;
14 
15 	iop->_cnt++;
16 	*--iop->_ptr = c;
17 
18 	return (c);
19 }
20