1 #ifndef lint 2 static char sccsid[] = "@(#)ungetc.c 5.1 (Berkeley) 06/05/85"; 3 #endif not lint 4 5 #include <stdio.h> 6 7 ungetc(c, iop) 8 register FILE *iop; 9 { 10 if (c == EOF || (iop->_flag & (_IOREAD|_IORW)) == 0 || 11 iop->_ptr == NULL || iop->_base == NULL) 12 return (EOF); 13 14 if (iop->_ptr == iop->_base) 15 iop->_ptr++; 16 17 iop->_cnt++; 18 *--iop->_ptr = c; 19 20 return (c); 21 } 22