aboutsummaryrefslogtreecommitdiffstats
path: root/testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch')
-rw-r--r--testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch31
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch b/testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch
new file mode 100644
index 0000000000..1c53789e82
--- /dev/null
+++ b/testing/idris2/0001-Flush-standard-out-after-writing-prompt-to-it.patch
@@ -0,0 +1,31 @@
+From bd1d67f89bbbf28d8d8d56214b05568195be27b3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
+Date: Sun, 28 Feb 2021 10:00:20 +0100
+Subject: [PATCH] Flush standard out after writing prompt to it
+
+On Unix-like operating systems stdio.h is usually line-buffered. As
+putStr uses fputs(3) from stdio.h internally, output will be written to
+standard out after a newline character is written to the buffer. Since
+the prompt does not contain a newline, it will only be written to
+standard output after the user presses return. I encountered this issue
+on Alpine Linux which uses musl libc (instead of glibc). However, I
+believe this issue is likely also reproducible with glibc. This commit
+fixes this issue by flushing standard output after writing the prompt to
+it. Surprisingly, `src/Idris/IDEMode/REPL.idr` already does this
+correctly, `src/Idris/REPL.idr` does not though.
+---
+ src/Idris/REPL.idr | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/Idris/REPL.idr b/src/Idris/REPL.idr
+index d1aede40..53f3eca6 100644
+--- a/src/Idris/REPL.idr
++++ b/src/Idris/REPL.idr
+@@ -897,6 +897,7 @@ mutual
+ = do ns <- getNS
+ opts <- get ROpts
+ coreLift (putStr (prompt (evalMode opts) ++ show ns ++ "> "))
++ coreLift (fflush stdout)
+ inp <- coreLift getLine
+ end <- coreLift $ fEOF stdin
+ if end