diff options
Diffstat (limited to 'usr/klibc/stdio/ungetc.c')
-rw-r--r-- | usr/klibc/stdio/ungetc.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/usr/klibc/stdio/ungetc.c b/usr/klibc/stdio/ungetc.c new file mode 100644 index 0000000..fe328ac --- /dev/null +++ b/usr/klibc/stdio/ungetc.c @@ -0,0 +1,17 @@ +/* + * ungetc.c + */ + +#include "stdioint.h" + +int ungetc(int c, FILE *file) +{ + struct _IO_file_pvt *f = stdio_pvt(file); + + if (f->obytes || f->data <= f->buf) + return EOF; + + *(--f->data) = c; + f->ibytes++; + return c; +} |