From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31053 invoked by alias); 21 Mar 2006 10:22:25 -0000 Received: (qmail 31045 invoked by uid 22791); 21 Mar 2006 10:22:24 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-03.spheriq.net (HELO fra-del-03.spheriq.net) (195.46.51.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 21 Mar 2006 10:22:22 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-03.spheriq.net with ESMTP id k2LAMJA7010321 for ; Tue, 21 Mar 2006 10:22:19 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-01.spheriq.net with ESMTP id k2LAMGeF008656 for ; Tue, 21 Mar 2006 10:22:18 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id k2LAMDbX004363 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Tue, 21 Mar 2006 10:22:15 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 10A11DA4A; Tue, 21 Mar 2006 10:22:08 +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 4371247340; Tue, 21 Mar 2006 10:26:00 +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 CGZ95929 (AUTH "denis pilat"); Tue, 21 Mar 2006 11:22:00 +0100 (CET) Message-ID: <441FD3C7.1090504@st.com> Date: Tue, 21 Mar 2006 15:30: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@sources.redhat.com, bash-maintainers@gnu.org Subject: Re: [patch-readline] history file reading References: <44196BC6.4050503@st.com> Content-Type: multipart/mixed; boundary="------------080100090005090107070302" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.01 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-03/txt/msg00240.txt.bz2 This is a multi-part message in MIME format. --------------080100090005090107070302 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1303 Eli Zaretskii wrote: >>Date: Thu, 16 Mar 2006 14:44:38 +0100 >>From: Denis PILAT >> >>On minGW host, history file are open in text mode, that's imply windows >>specific >>carriage return to be inserted ( \n -> \r\n conversion performed) and >>prevents windows history file to be compliant with linux one's. >>When using current history file for windows, "^M" appears at each end of >>line. >> >>This patch fixes this problem. >> >> > >Thanks. > >However, I think there's a better fix: teach readline to always remove >any CRs before an LF character, even on Posix platforms. That way, >even if the history file was edited by some Windows editor that >doesn't honor the end-of-line format, it can still be read on any OS. >And as a bonus, we might get a cleaner code, without ugly OS-dependent >#ifdef's. > >Unless Chet and others disagree, would you like to prepare a patch >along these lines? > > > This new version of my patch changes the way we read history files to allow "\r\n" in end-of-line. I don't change any more the way we write history files. -- Denis 2006-03-21 Denis Pilat * histfile.c (read_history_range): remove '\r' character from history lines to allow reading files with Windows like end-of-line on unix host. --------------080100090005090107070302 Content-Type: text/plain; name="histfile.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="histfile.patch" Content-length: 519 Index: histfile.c =================================================================== --- histfile.c (revision 386) +++ histfile.c (working copy) @@ -228,7 +228,11 @@ for (line_end = line_start; line_end < bufend; line_end++) if (*line_end == '\n') { - *line_end = '\0'; + /* allow reading files with Windows like end-of-line */ + if ( line_end - 1 >= line_start && *( line_end - 1 ) =='\r' ) + *( line_end - 1 ) = '\0'; + else + *line_end = '\0'; if (*line_start) add_history (line_start); --------------080100090005090107070302--