date and time created 83/11/10 16:04:16 by ralph
[unix-history] / usr / src / lib / libc / stdio / ungetc.c
CommitLineData
bec69c1e
SL
1/* ungetc.c 4.2 83/09/25 */
2
52dc310d
BJ
3#include <stdio.h>
4
5ungetc(c, iop)
bec69c1e 6 register FILE *iop;
52dc310d
BJ
7{
8 if (c == EOF)
bec69c1e
SL
9 return (-1);
10 if ((iop->_flag&_IOREAD) == 0 || iop->_ptr <= iop->_base)
11 if (iop->_ptr == iop->_base && iop->_cnt == 0)
52dc310d
BJ
12 *iop->_ptr++;
13 else
bec69c1e 14 return (EOF);
52dc310d
BJ
15 iop->_cnt++;
16 *--iop->_ptr = c;
bec69c1e 17 return (c);
52dc310d 18}