diff options
author | Gavin Howard <yzena.tech@gmail.com> | 2021-03-18 20:55:36 -0600 |
---|---|---|
committer | Gavin Howard <yzena.tech@gmail.com> | 2021-03-18 20:55:36 -0600 |
commit | 52670bd9b9a59d2a7bacd41681fa124c5b5ee2f9 (patch) | |
tree | d80b4abbdef1609afd3ed4855825829b35020ad0 | |
parent | 925993a715f58f58b0ec8b727f1014452d41060d (diff) | |
download | bc-52670bd9b9a59d2a7bacd41681fa124c5b5ee2f9.tar.gz |
Make sure output is flushed before a read
I found this bug by a script I wrote to do aviation related stuff, a
script that would prompt for input without using newlines (because it
used `-P` in its hash-bang line).
-rw-r--r-- | src/program.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/program.c b/src/program.c index d4e386d4..6ab79473 100644 --- a/src/program.c +++ b/src/program.c @@ -1928,6 +1928,10 @@ void bc_program_exec(BcProgram *p) { case BC_INST_READ: { + // We want to flush output before + // this in case there is a prompt. + bc_file_flush(&vm.fout); + bc_program_read(p); ip = bc_vec_top(&p->stack); |