diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 9be13eea..bab534d0 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -101,6 +101,9 @@ extern "C" /* Read a character from standard input. */ int getchar(void); + /* Push a character back to stream so that it can be read again. */ + int ungetc(int c, FILE* stream); + /* Read a line from stream. */ char* fgets(char* buf, size_t size, FILE* stream); diff --git a/libc/src/stdio.cpp b/libc/src/stdio.cpp index bdcd82e4..d58cae21 100644 --- a/libc/src/stdio.cpp +++ b/libc/src/stdio.cpp @@ -46,6 +46,12 @@ static int fdopen_check_compatible_mode(int fd, int new_flags) extern "C" { + int fflush(FILE*) + { + // FIXME: Files are not buffered right now. + return 0; + } + FILE* fopen(const char* path, const char* mode) { int flags; @@ -479,4 +485,9 @@ extern "C" if (!f) close(fd); return f; } + + int ungetc(int, FILE*) + { + fail("FIXME: ungetc: not implemented"); + } }