summaryrefslogtreecommitdiff
path: root/libguile/fports.c
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2023-06-20 16:04:59 -0700
committerMichael Gran <spk121@yahoo.com>2025-03-23 10:26:40 -0700
commitaf96820e072d18c49ac03e80c6f3466d568dc77d (patch)
tree8a4ac5114a091cb2f54f845aabf613b2ef45ac76 /libguile/fports.c
parentadbf2156ab5939e6909e035017995ba555886dc2 (diff)
downloadguile-main.tar.gz
Windows 11: for fport input from the console, ignore terminal returnsHEADmain
There is an apparent bug in Windows 11 (not Windows 10) where, when reading from an fd backed by the Console, a single return character will always be available. * libguile/posix-w32.c (console_has_return_keyevent_w32): new procedure * libguile/posix-w32.h: declare console_has_return_keyevent_w32 * libguile/fports.c [__MINGW32__](fport_input_waiting): ignore return keyevent
Diffstat (limited to 'libguile/fports.c')
-rw-r--r--libguile/fports.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libguile/fports.c b/libguile/fports.c
index e355c3358..51c5b3736 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -59,6 +59,9 @@
#include "pairs.h"
#include "ports-internal.h"
#include "posix.h"
+#ifdef __MINGW32__
+# include "posix-w32.h"
+#endif
#include "read.h"
#include "strings.h"
#include "symbols.h"
@@ -483,7 +486,17 @@ fport_input_waiting (SCM port)
if (poll (&pollfd, 1, 0) < 0)
scm_syserror ("fport_input_waiting");
- return pollfd.revents & POLLIN ? 1 : 0;
+ if ((pollfd.revents & POLLIN) == 0)
+ return 0;
+
+#ifdef __MINGW32__
+ /* Work around Windows 11 bug where there's always a return character
+ * in the console input queue. */
+ if (console_has_return_keyevent_w32 (fdes))
+ return 0;
+#endif
+
+ return 1;
}