/*
 *			u n g e t c . c
 */

/*)LIBRARY
*/

#ifdef	DOCUMENTATION

title	ungetc	Push back a character onto an input file
index		Push back onto an input file

synopsis
	.s.nf
	ungetc(c, iop);
	char		c;
	FILE		*iop;

description

	Push one character back on the indicated stream.

bugs
#endif

#include	<stdio.h>

#ifndef	decusc_stdio

ungetc(c, fd)
char		c;
register FILE	*fd;
/*
 * Push the byte back on the input stream
 */
{
	
	if ((fd->_flag & _IOREAD) == 0
	 || fd->_ptr <= fd->_base) {
	    if (fd->_ptr == fd->_base && fd->_cnt == 0)
		*fd->_ptr++;
	    else
		_error("ungetc\n");
	}
	fd->_cnt++;
	*--fd->_ptr = c;
}

#endif

