Implement stdio buffering #36
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user