xref: /csrg-svn/lib/libc/stdio/ungetc.c (revision 17951)
1*17951Sserge /*	ungetc.c	4.3	85/02/13	*/
215084Ssam 
32037Swnj #include <stdio.h>
42037Swnj 
52037Swnj ungetc(c, iop)
615084Ssam 	register FILE *iop;
72037Swnj {
8*17951Sserge 	if (c == EOF || (iop->_flag & (_IOREAD|_IORW)) == 0 ||
9*17951Sserge 	    iop->_ptr == NULL || iop->_base == NULL)
10*17951Sserge 		return (EOF);
11*17951Sserge 
12*17951Sserge 	if (iop->_ptr == iop->_base)
13*17951Sserge 		iop->_ptr++;
14*17951Sserge 
152037Swnj 	iop->_cnt++;
162037Swnj 	*--iop->_ptr = c;
17*17951Sserge 
1815084Ssam 	return (c);
192037Swnj }
20