Implement stdio buffering #36

Merged
apio merged 7 commits from stdio-buffers into main 2023-07-22 09:39:02 +00:00
Showing only changes of commit 77022abafd - Show all commits

View File

@ -688,9 +688,18 @@ extern "C"
return f;
}
int ungetc(int, FILE*)
int ungetc(int c, FILE* stream)
{
fail("FIXME: ungetc: not implemented");
if (stream->_buf.index == 0)
return EOF; // No data currently in the read buffer, or no data has been read from it.
if (stream->_buf.mode == _IONBF)
return EOF; // FIXME: C doesn't state that ungetc() should only work on buffered streams.
stream->_buf.index--;
stream->_buf.buffer[stream->_buf.index] = (char)c;
return 0;
}
int setvbuf(FILE* stream, char* buf, int mode, size_t size)