This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/3] Set stdin/stdout/stderr to binary mode in cygwin.
- From: Yao Qi <yao at codesourcery dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: <gdb-patches at sourceware dot org>
- Date: Thu, 1 Aug 2013 16:09:39 +0800
- Subject: Re: [PATCH 3/3] Set stdin/stdout/stderr to binary mode in cygwin.
- References: <1375087546-22591-1-git-send-email-yao at codesourcery dot com> <1375087546-22591-4-git-send-email-yao at codesourcery dot com> <83r4ehxtey dot fsf at gnu dot org>
On 07/29/2013 11:44 PM, Eli Zaretskii wrote:
>> + setmode (fileno (stdin), O_BINARY);
>> >+ setmode (fileno (stdout), O_BINARY);
>> >+ setmode (fileno (stderr), O_BINARY);
> Do you really need all 3 of the standard handles in binary mode? I
> thought the problem was only with output?
Setting stdin in binary mode is for another purpose, should go to a
separated patch. Sorry for the confusion. Patch below is to only set
stdout and stderr in binary mode.
--
Yao (éå)
gdb:
2013-08-01 Pedro Alves <pedro@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* main.c [__MINGW32__]: Include fcntl.h and windows.h.
(captured_main) [__MINGW32__]: Set stdout and stderr to
binary mode if GDB is using cygwin pty.
---
gdb/main.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index 3a2fee6..6a79df9 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -47,6 +47,11 @@
#include "filenames.h"
#include "filestuff.h"
+#ifdef __MINGW32__
+#include <fcntl.h>
+#include <windows.h>
+#endif
+
/* The selected interpreter. This will be used as a set command
variable, so it should always be malloc'ed - since
do_setshow_command will free it. */
@@ -384,6 +389,13 @@ captured_main (void *data)
other operation is performed. */
setvbuf (stdout, NULL, _IONBF, BUFSIZ);
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+ /* In textmode, a '\n' is automatically expanded into "\r\n". This
+ results in expect seeing "\r\r\n". The tests aren't prepared
+ currently for other forms of eol. As a workaround, we force the
+ output to binary mode. */
+ setmode (fileno (stdout), O_BINARY);
+ setmode (fileno (stderr), O_BINARY);
}
#endif
--
1.7.7.6