Rev 8730 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8718 | turbocat | 1 | #include |
2 | #include |
||
3 | // non standard realization - support for virtually change ONLY ONE char |
||
4 | |||
5 | int ungetc(int c, FILE* file) |
||
6 | { |
||
7 | int res; |
||
8 | |||
9 | if(!file){ |
||
10 | errno = EBADF; |
||
11 | return EOF; |
||
12 | } |
||
13 | |||
14 | if (file->mode != _STDIO_F_R){ |
||
15 | errno = EACCES; |
||
16 | return EOF; |
||
17 | } |
||
18 | |||
19 | if (file->position > file->start_size || file->position == 0 || c == EOF || file->__ungetc_emu_buff != EOF) |
||
20 | { |
||
21 | errno = EOF; |
||
22 | return EOF; |
||
23 | } |
||
24 | |||
25 | file->__ungetc_emu_buff = c; |
||
26 | file->position--; |
||
27 | return c; |
||
28 | } |