DavidGriffith / frotz

Infocom-style interactive fiction player for Unix and DOS (moved to https://gitlab.com/DavidGriffith/frotz)
GNU General Public License v2.0
209 stars 64 forks source link

Fixed prompt not showing properly in dumb frotz #2

Closed blanham closed 10 years ago

blanham commented 10 years ago

Prompt was not showing up until after user submitted a line, because prompts do not end with a newline, which would trigger fflush(). Adding a fflush() of stdout fixes this.

blanham commented 10 years ago

I fixed the indenting, I usually use tabs so I accidentally used them instead of spaces. Looks like the whole file actually uses a mixture of the two, which confused my editor.

It's not a game specific issue, but appeared because I am using musl-libc instead of the GNU libc. Glibc automatically flushes buffers on a read to stdin, while both musl and newlib do not. There's some good commentary on the issue here: http://stackoverflow.com/questions/2123528/does-reading-from-stdin-flush-stdout Looks like an automatic flush is allowed by the standard, but apparently only glibc actually does it. Adding fflush should ensure proper behavior for any C library.

Apparently \help is handled specially, so I also added a call of fflush to fix the display there too.