From d79194419ba59abef54a9a56a06271e230902271 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 11 Jul 2014 18:44:25 +0300 Subject: [PATCH] Fix reading input without echoing on MS-Windows. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode when not echoing input. Fixes: debbugs:17839 --- src/ChangeLog | 1 + src/minibuf.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index a016f3cadc2..282b79eef12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,7 @@ * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r', not only on '\n'. + [WINDOWSNT]: Switch stdin to binary mode when not echoing input. * sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty) [DOS_NT]: Implement for WINDOWSNT. diff --git a/src/minibuf.c b/src/minibuf.c index c77f5955d86..5b6c9154621 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -22,6 +22,10 @@ along with GNU Emacs. If not, see . */ #include #include +#ifdef WINDOWSNT +#include /* For O_BINARY, O_TEXT. */ +#endif + #include "lisp.h" #include "commands.h" #include "character.h" @@ -240,6 +244,9 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, if (hide_char) { emacs_get_tty (fileno (stdin), &etty); +#ifdef WINDOWSNT + _setmode (fileno (stdin), O_BINARY); +#endif suppress_echo_on_tty (fileno (stdin)); } @@ -278,6 +285,9 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, { fprintf (stdout, "\n"); emacs_set_tty (fileno (stdin), &etty, 0); +#ifdef WINDOWSNT + _setmode (fileno (stdin), O_TEXT); +#endif } if (len || c == '\n' || c == '\r') -- 2.11.4.GIT