1*15084Ssam /* ungetc.c 4.2 83/09/25 */ 2*15084Ssam 32037Swnj #include <stdio.h> 42037Swnj 52037Swnj ungetc(c, iop) 6*15084Ssam register FILE *iop; 72037Swnj { 82037Swnj if (c == EOF) 9*15084Ssam return (-1); 10*15084Ssam if ((iop->_flag&_IOREAD) == 0 || iop->_ptr <= iop->_base) 11*15084Ssam if (iop->_ptr == iop->_base && iop->_cnt == 0) 122037Swnj *iop->_ptr++; 132037Swnj else 14*15084Ssam return (EOF); 152037Swnj iop->_cnt++; 162037Swnj *--iop->_ptr = c; 17*15084Ssam return (c); 182037Swnj } 19