From plm@plm.xs4all.nl  Tue Jun 25 13:59:36 1996
Received: from magigimmix.xs4all.nl (magigimmix.xs4all.nl [194.109.6.25])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id NAA19033
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 25 Jun 1996 13:59:34 -0700 (PDT)
Received: from asterix.xs4all.nl (asterix.xs4all.nl [194.109.6.11]) by magigimmix.xs4all.nl (8.7.5/XS4ALL) with ESMTP id WAA03084 for <FreeBSD-gnats-submit@freebsd.org>; Tue, 25 Jun 1996 22:59:31 +0200 (MET DST)
Received: from plm.xs4all.nl (uucp@localhost) by asterix.xs4all.nl (8.7.5/8.7.2) with UUCP id WAA13443 for FreeBSD-gnats-submit@freebsd.org; Tue, 25 Jun 1996 22:56:21 +0200 (MET DST)
Received: (from plm@localhost) by plm.xs4all.nl (8.7.5/8.7.3) id WAA00862; Tue, 25 Jun 1996 22:54:55 +0200 (MET DST)
Message-Id: <199606252054.WAA00862@plm.xs4all.nl>
Date: Tue, 25 Jun 1996 22:54:55 +0200 (MET DST)
From: Peter Mutsaers <plm@xs4all.nl>
Reply-To: plm@xs4all.nl
To: FreeBSD-gnats-submit@freebsd.org
Subject: sed bug
X-Send-Pr-Version: 3.2

>Number:         1350
>Category:       bin
>Synopsis:       sed continuation lines in text don't work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bde
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 25 14:00:01 PDT 1996
>Closed-Date:    Wed Sep 18 14:44:57 PDT 1996
>Last-Modified:  Wed Sep 18 14:45:52 PDT 1996
>Originator:     Peter Mutsaers
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:

>Environment:


>Description:

Sed commands a,i,c are followed by lines of text, where newlines are
escaped. Currently only one line can follow. The second line is interpreted
like a new sed command.

>How-To-Repeat:

sed '1a\
hallo\
xxx
'

Output:
": extra characters at the end of x command

>Fix:
	
Remove revision 1.5 from compile.c
This was supposed to fix a bug in dealing with continuation lines
but somehow introduced this bug.

>Release-Note:
>Audit-Trail:

From: mark@linus.demon.co.uk (Mark Valentine)
To: plm@xs4all.nl, freebsd-bugs@freefall.freebsd.org,
        FreeBSD-gnats-submit@freebsd.org,
        gnats@freefall.freebsd.org (GNATS Management)
Cc:  Subject: Re: bin/1350: sed bug
Date: Tue, 25 Jun 1996 23:52:18 +0000

 > From: Peter Mutsaers <plm@xs4all.nl>
 > Date: Tue 25 Jun, 1996
 > Subject: bin/1350: sed bug
 
 > Remove revision 1.5 from compile.c
 > This was supposed to fix a bug in dealing with continuation lines
 > but somehow introduced this bug.
 
 My old patch attached to the (now closed) PR bin/908 fixes the original
 problem without introducing the new one.
 
 (There was a reason I chose the somewhat inelegant writing of '\0' into
 lbuf rather than do it properly with a new flag variable like Keith tried
 to do - it meant a textually smaller change which I had a better chance of
 understanding!)
 
 I'm too lazy to repeat the minor edits it took me to get the regression
 tests running in December, and the test suite showed some signs of bit rot,
 so I didn't go to the bother of writing a case to test for the bug reported
 in bin/908...
 
 Here's the (slightly bigger now) version of my patch against the new
 compile.c (the original was a 10 character edit):
 
 --- compile.c.ctm	Wed Jun 19 21:42:20 1996
 +++ compile.c	Tue Jun 25 23:24:17 1996
 @@ -615,7 +615,7 @@
  static char *
  compile_text()
  {
 -	int asize, esc_nl, size;
 +	int asize, size;
  	char *text, *p, *op, *s;
  	char lbuf[_POSIX2_LINE_MAX + 1];
  
 @@ -626,15 +626,13 @@
  		op = s = text + size;
  		p = lbuf;
  		EATSPACE();
 -		for (esc_nl = 0; *p != '\0'; p++) {
 -			if (*p == '\\' && *p++ == '\0') {
 -				esc_nl = 1;
 -				break;
 -			}
 +		for (; *p != '\0'; p++) {
 +			if (*p == '\\')
 +				*p++ = '\0';
  			*s++ = *p;
  		}
  		size += s - op;
 -		if (!esc_nl) {
 +		if (p[-2] != '\0') {
  			*s = '\0';
  			break;
  		}
 
 		Mark.
 
 -- 
 Mark Valentine at Home <mailto:mv@pobox.com> <http://www.pobox.com/~mv/>
State-Changed-From-To: open->closed 
State-Changed-By: wosch 
State-Changed-When: Wed Sep 18 14:44:57 PDT 1996 
State-Changed-Why:  
should be fixed in compile.c, revision 1.7 



Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Wed Sep 18 14:44:57 PDT 1996 
Responsible-Changed-Why:  
>Unformatted:
