home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / libc / stdio / ungetc.c < prev   
Encoding:
C/C++ Source or Header  |  1979-01-10  |  276 b   |  17 lines

  1. #include <stdio.h>
  2.  
  3. ungetc(c, iop)
  4. register FILE *iop;
  5. {
  6.     if (c == EOF)
  7.         return(-1);
  8.     if ((iop->_flag&_IOREAD)==0 || iop->_ptr <= iop->_base)
  9.         if (iop->_ptr == iop->_base && iop->_cnt==0)
  10.             *iop->_ptr++;
  11.         else
  12.             return(-1);
  13.     iop->_cnt++;
  14.     *--iop->_ptr = c;
  15.     return(0);
  16. }
  17.