isblank() implementation.
[minix.git] / lib / libc / stdio / ungetc.c
blobe78bf265caa6464259db7ca78b5b4a0a59d371e8
1 /*
2 * ungetc.c - push a character back onto an input stream
3 */
4 /* $Header$ */
6 #include <stdio.h>
7 #include "loc_incl.h"
9 int
10 ungetc(int ch, FILE *stream)
12 unsigned char *p;
14 if (ch == EOF || !io_testflag(stream,_IOREADING))
15 return EOF;
16 if (stream->_ptr == stream->_buf) {
17 if (stream->_count != 0) return EOF;
18 stream->_ptr++;
20 stream->_count++;
21 p = --(stream->_ptr); /* ??? Bloody vax assembler !!! */
22 /* ungetc() in sscanf() shouldn't write in rom */
23 if (*p != (unsigned char) ch)
24 *p = (unsigned char) ch;
25 return ch;