BSD 3 development
[unix-history] / usr / src / libc / stdio / ungetc.c
CommitLineData
18e5fa7e
BJ
1#include <stdio.h>
2
3ungetc(c, iop)
4register 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}