Date: Sat, 08 Sep 2001 13:20:15 +0300 From: "Eli Zaretskii" 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: (message from Andris Pavenis on Sat, 8 Sep 2001 10:21:26 +0300 (WET)) Subject: Re: Problem with sed3028b.zip References: 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 Precedence: bulk > Date: Sat, 8 Sep 2001 10:21:26 +0300 (WET) > From: Andris Pavenis > /* I added some substitution which is never done: no 'b' in input file */ > system ("sed -e 's:b:a:g' 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 }