www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/09/08/06:24:26

Date: Sat, 08 Sep 2001 13:20:15 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: pavenis AT lanet DOT lv
Message-Id: <7263-Sat08Sep2001132012+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De, djgpp-workers AT delorie DOT com
In-reply-to: <Pine.A41.4.05.10109081013060.53626-100000@ieva06> (message from
Andris Pavenis on Sat, 8 Sep 2001 10:21:26 +0300 (WET))
Subject: Re: Problem with sed3028b.zip
References: <Pine DOT A41 DOT 4 DOT 05 DOT 10109081013060 DOT 53626-100000 AT ieva06>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Sat, 8 Sep 2001 10:21:26 +0300 (WET)
> From: Andris Pavenis <pavenis AT lanet DOT lv>
>    /* I added some substitution which is never done: no 'b' in input file   */
>    system ("sed -e 's:b:a:g' <sedtest.in >sedtest.out");

You don't need this with GNU Sed: you could use "sed -e ''" instead.

> Testing result ...^M
> sedtest.in sedtest.out differ: char 8193, line 2731^M

It was a bug, allright; thanks for a simple test case.  I think the
patch below fixes it; please try it.

--- sed/execute.c~1	Sat Jan  1 12:09:08 2000
+++ sed/execute.c	Sat Sep  8 13:03:40 2001
@@ -273,7 +273,11 @@ line_undosify(lbuf, from, ch)
   size_t lbuf_len = lbuf->length;
 
   /* Remove character CH from the end of the line starting at offset FROM.  */
-  if (lbuf_len > from && lbuf->text[lbuf_len-1] == ch)
+  if ((lbuf_len > from
+       /* This is for the case where CR was read in the previous call,
+	  but its LF buddy was only read now.  */
+       || (lbuf_len == from && ch == '\r'))
+      && lbuf->text[lbuf_len-1] == ch)
     lbuf->length--;
 #endif
 }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019