From owner-freebsd-hackers Sat Jun 15 16:25:08 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA24168 for hackers-outgoing; Sat, 15 Jun 1996 16:25:08 -0700 (PDT) Received: from jraynard.demon.co.uk (jraynard.demon.co.uk [158.152.42.77]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id QAA24148 for ; Sat, 15 Jun 1996 16:24:57 -0700 (PDT) Received: (from fhackers@localhost) by jraynard.demon.co.uk (8.6.12/8.6.12) id WAA13002; Sat, 15 Jun 1996 22:23:59 GMT Date: Sat, 15 Jun 1996 22:23:59 GMT Message-Id: <199606152223.WAA13002@jraynard.demon.co.uk> From: James Raynard To: mark@linus.demon.co.uk CC: hackers@FreeBSD.ORG In-reply-to: <199606120112.CAA07808@linus.demon.co.uk> (mark@linus.demon.co.uk) Subject: Re: small sed bugfix (PR#908) Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Can I tempt anyone to review and/or commit the tiny fix for an annoying > sed bug which I submitted in December, with a view to having this or a > similar fix in 2.1.5? It doesn't seem to make the sed regressions tests > any noisier than they already were... Are there any sed gurus in the house who can comment on this? If not, perhaps you might be better to advised to mail the author, who appears to be Diomidis Spinellis Cheers James > I'm appending a copy of . > > Cheers, > > Mark. > > -- 8< ------------------------------------------------------------------------- > > Problem Report bin/908 > > sed bug with trailing backslashes > > Confidential > no > Severity > serious > Priority > medium > Responsible > freebsd-bugs@freebsd.org > State > open > Class > sw-bug > Submitter-Id > current-users > Arrival-Date > Thu Dec 21 17:00:01 PST 1995 > Last-Modified > Wed Dec 27 23:30:01 PST 1995 > Originator > Mark Valentine > Organization > Release > FreeBSD 2.2-CURRENT i386 > Environment > > n/a > > > Description > > Sed misinterprets the pair of backslashes at the end of line 2 of > the following script, resulting in line 3 being taken as part of > the inserted text. > > 1i\ > char foo[] = "\\ > s/$/\\n\\/ > $a\ > "; > > GNU sed and SunOS 4.1.3 sed insert a single line ending with a > backslash, and treat line three as a substition command. > > > How-To-Repeat > > $ echo test | sed -f > char foo[] = "\ > s/$/\n\/ > test > "; > > $ echo test | /usr/gnu/bin/sed -f > char foo[] = "\ > test\n\ > "; > > > Fix > Audit-Trail > > From: mark@linus.demon.co.uk (Mark Valentine) > To: FreeBSD-gnats-submit@FreeBSD.ORG > Cc: Subject: Re: bin/908: sed bug with trailing backslashes > Date: Thu, 28 Dec 1995 07:19:57 +0000 > > > From: Mark Valentine > > Date: Thu 21 Dec, 1995 > > Subject: bin/908: sed bug with trailing backslashes > > > >Description: > > > > Sed misinterprets the pair of backslashes at the end of line 2 of > > the following script, resulting in line 3 being taken as part of > > the inserted text. > > > > 1i\ > > char foo[] = "\\ > > s/$/\\n\\/ > > $a\ > > "; > > This small patch to usr.bin/sed/compile.c seems to fix it. It replaces > escaping backslashes in the input buffer with NULs, and uses those to > determine whether the newline was escaped, rather than looking for a > (possibly escaped) preceding backslash. > > --- compile.c.dist Wed Aug 16 21:21:55 1995 > +++ compile.c Thu Dec 28 06:32:03 1995 > @@ -628,11 +628,11 @@ > EATSPACE(); > for (; *p; p++) { > if (*p == '\\') > - p++; > + *p++ = '\0'; > *s++ = *p; > } > size += s - op; > - if (p[-2] != '\\') { > + if (p[-2] != '\0') { > *s = '\0'; > break; > } > > This patch doesn't seem to break any of the regression tests. > > Mark. > > Unformatted > > -- 8< ------------------------------------------------------------------------- > > -- > Mark Valentine at Home > >