Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | |||
5 | int |
||
6 | ungetc(int c, FILE *f) |
||
7 | { |
||
8 | if (c == EOF |
||
9 | || (f->_flag & (_IOREAD|_IORW)) == 0 |
||
10 | || f->_ptr == NULL |
||
11 | || f->_base == NULL) |
||
12 | return EOF; |
||
13 | |||
14 | if (f->_ptr == f->_base) |
||
15 | { |
||
16 | if (f->_cnt == 0) |
||
17 | f->_ptr++; |
||
18 | else |
||
19 | return EOF; |
||
20 | } |
||
21 | |||
22 | f->_cnt++; |
||
23 | *--f->_ptr = c; |
||
24 | |||
25 | return c; |
||
26 | } |