From 2a0bae50e3611a6bd2d584f7a85677b74f1aa71b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 12 Jul 2014 10:47:40 +0300 Subject: [PATCH] Minor fix for read_minibuf_noninteractive on MS-Windows. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode only if it is connected to a terminal. Fixes: debbugs:17839 --- src/ChangeLog | 5 +++++ src/minibuf.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9265051e311..9d5dff49166 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-07-12 Eli Zaretskii + + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch + stdin to binary mode only if it is connected to a terminal. + 2014-07-11 Paul Eggert Coalesce extern decls. diff --git a/src/minibuf.c b/src/minibuf.c index 1f2fb1fdf3f..e2450b53964 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -241,7 +241,8 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, { emacs_get_tty (fileno (stdin), &etty); #ifdef WINDOWSNT - _setmode (fileno (stdin), O_BINARY); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_BINARY); #endif suppress_echo_on_tty (fileno (stdin)); } @@ -282,7 +283,8 @@ 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); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_TEXT); #endif } -- 2.11.4.GIT