From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9046 invoked by alias); 1 Aug 2013 08:10:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9037 invoked by uid 89); 1 Aug 2013 08:10:28 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 01 Aug 2013 08:10:27 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1V4nxk-0005W8-6z from Yao_Qi@mentor.com ; Thu, 01 Aug 2013 01:10:20 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 1 Aug 2013 01:10:19 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Thu, 1 Aug 2013 01:10:19 -0700 Message-ID: <51FA17C3.9070307@codesourcery.com> Date: Thu, 01 Aug 2013 08:10:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Eli Zaretskii CC: Subject: Re: [PATCH 3/3] Set stdin/stdout/stderr to binary mode in cygwin. References: <1375087546-22591-1-git-send-email-yao@codesourcery.com> <1375087546-22591-4-git-send-email-yao@codesourcery.com> <83r4ehxtey.fsf@gnu.org> In-Reply-To: <83r4ehxtey.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-08/txt/msg00005.txt.bz2 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 Daniel Jacobowitz Yao Qi * 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 +#include +#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