LibC: fflush stdout when reading from stdin

This is the *intended behaviour* per ISO C specification
This commit is contained in:
Bananymous 2025-08-05 03:06:40 +03:00
parent 2e2ee11452
commit 46dd411273
1 changed files with 3 additions and 0 deletions

View File

@ -542,6 +542,9 @@ int getc_unlocked(FILE* file)
if (file->eof) if (file->eof)
return EOF; return EOF;
if (file == stdin && file->buffer_type == _IOLBF && stdout->buffer_type == _IOLBF && stdout->buffer_idx)
fflush(stdout);
// read characters from ungetc // read characters from ungetc
if (file->unget_buf_idx) if (file->unget_buf_idx)
{ {