Bug 1350 - sed continuation lines in text don't work
Summary: sed continuation lines in text don't work
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 2.2-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bruce Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1996-06-25 22:00 UTC by plm
Modified: 1996-09-18 22:45 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description plm 1996-06-25 22:00:01 UTC
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.

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.
How-To-Repeat: 
sed '1a\
hallo\
xxx
'

Output:
": extra characters at the end of x command
Comment 1 Mark Valentine 1996-06-26 00:52:18 UTC
> 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/>
Comment 2 Wolfram Schneider freebsd_committer freebsd_triage 1996-09-18 22:44:57 UTC
State Changed
From-To: open->closed

should be fixed in compile.c, revision 1.7 



Comment 3 Wolfram Schneider freebsd_committer freebsd_triage 1996-09-18 22:44:57 UTC
Responsible Changed
From-To: freebsd-bugs->bde