From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11968 invoked by alias); 11 Oct 2006 08:02:20 -0000 Received: (qmail 11952 invoked by uid 22791); 11 Oct 2006 08:02:19 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-04.spheriq.net (HELO fra-del-04.spheriq.net) (195.46.51.100) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Oct 2006 08:02:16 +0000 Received: from fra-out-03.spheriq.net (fra-out-03.spheriq.net [195.46.51.131]) by fra-del-04.spheriq.net with ESMTP id k9B829Iu009079 for ; Wed, 11 Oct 2006 08:02:09 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-03.spheriq.net with ESMTP id k9B825Np006333 for ; Wed, 11 Oct 2006 08:02:08 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id k9B821Ru013025 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Wed, 11 Oct 2006 08:02:04 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E3875DA45; Wed, 11 Oct 2006 08:01:50 +0000 (GMT) Received: from mail1.cro.st.com (mail1.cro.st.com [164.129.40.131]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 91D2F47280; Wed, 11 Oct 2006 08:01:50 +0000 (GMT) Received: from st.com (crx1177.cro.st.com [164.129.47.77]) by mail1.cro.st.com (MOS 3.5.8-GR) with ESMTP id CIQ84002 (AUTH "denis pilat"); Wed, 11 Oct 2006 10:01:49 +0200 (CEST) Message-ID: <452CA4EC.9060700@st.com> Date: Wed, 11 Oct 2006 08:02:00 -0000 From: Denis PILAT User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0 MIME-Version: 1.0 To: Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: [TUI] correctly display windows source files References: <452A6905.1040308@st.com> <452B9EB9.4040709@st.com> Content-Type: multipart/mixed; boundary="------------060102070906030002030907" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00100.txt.bz2 This is a multi-part message in MIME format. --------------060102070906030002030907 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 445 > > >That could be so, but I'd prefer that our code didn't do anything that >could fail, even theoretically. We shouldn't call functions with >arguments that invoke undefined or uncertain behavior. > >It should be a simple matter of adding a test for EOF. > You're right, I can not do testing on all hosts and libc. Attached a new proposal. In the case of "'\r'EOF" we keep EOF in "c" variable and we exit the while just below anyway. Denis --------------060102070906030002030907 Content-Type: text/plain; name="tui-source.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tui-source.c.patch" Content-length: 789 2006-10-09 Denis Pilat * tui-source.c (tui_set_source_content): handle source files that contain non unix end-of-line. Index: tui/tui-source.c =================================================================== --- tui/tui-source.c (revision 529) +++ tui/tui-source.c (working copy) @@ -194,6 +194,14 @@ tui_set_source_content (struct symtab *s chars until we do */ while (c != EOF && c != '\n' && c != '\r') c = fgetc (stream); + /* Handle non-'\n' end-of-line. */ + if (c == '\r' && + (c = fgetc (stream)) != '\n' && c != EOF) + { + ungetc (c, stream); + c = '\r'; + } + } } while (c != EOF && c != '\n' && c != '\r' && --------------060102070906030002030907--