libc: Partially implement ungetc

This commit is contained in:
apio 2022-10-23 11:12:54 +02:00
parent 51580bb846
commit d75de5f423

View File

@ -170,9 +170,14 @@ extern "C"
return fgetc(stdin); return fgetc(stdin);
} }
int ungetc(int, FILE*) int ungetc(int c, FILE* stream)
{ {
NOT_IMPLEMENTED("ungetc"); if (stream->f_bufoff > 0)
{
stream->f_bufoff--;
stream->f_buf[stream->f_bufoff] = (char)c;
}
else { NOT_IMPLEMENTED("ungetc with buffer that has not been read"); }
} }
int ferror(FILE* stream) int ferror(FILE* stream)