source: trunk/minix/lib/stdio/ungetc.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 618 bytes
Line 
1/*
2 * ungetc.c - push a character back onto an input stream
3 */
4/* $Header: /cvsup/minix/src/lib/stdio/ungetc.c,v 1.1.1.1 2005/04/21 14:56:36 beng Exp $ */
5
6#include <stdio.h>
7#include "loc_incl.h"
8
9int
10ungetc(int ch, FILE *stream)
11{
12 unsigned char *p;
13
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++;
19 }
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;
26}
Note: See TracBrowser for help on using the repository browser.