From ak03@gte.com  Fri Jun 14 14:34:17 2002
Return-Path: <ak03@gte.com>
Received: from h132-197-179-27.gte.com (h132-197-179-27.gte.com [132.197.179.27])
	by hub.freebsd.org (Postfix) with ESMTP
	id 10E3F37B438; Fri, 14 Jun 2002 14:34:17 -0700 (PDT)
Received: from kanpc.gte.com (localhost [IPv6:::1])
	by h132-197-179-27.gte.com (8.12.3/8.12.3) with ESMTP id g5ELUlAW087208;
	Fri, 14 Jun 2002 17:30:49 -0400 (EDT)
	(envelope-from ak03@kanpc.gte.com)
Received: (from ak03@localhost)
	by kanpc.gte.com (8.12.4/8.12.4/Submit) id g5ELUkQm087207;
	Fri, 14 Jun 2002 17:30:46 -0400 (EDT)
Message-Id: <200206142130.g5ELUkQm087207@kanpc.gte.com>
Date: Fri, 14 Jun 2002 17:30:46 -0400 (EDT)
From: Alexander Kabaev <ak03@gte.com>
Reply-To: Alexander Kabaev <ak03@gte.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: sobomax@freebsd.org, tjr@freebsd.org
Subject: sed was broken in rev. 1.22 of main.c 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         39310
>Category:       bin
>Synopsis:       sed was broken in rev. 1.22 of main.c
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    sobomax
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 14 14:40:01 PDT 2002
>Closed-Date:    Sun Jun 16 04:33:24 PDT 2002
>Last-Modified:  Sun Jun 16 04:33:24 PDT 2002
>Originator:     Alexander Kabaev
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD kanpc.gte.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Thu Jun 13 12:38:33 EDT 2002 root@kanpc.gte.com:/usr/obj/usr/src/sys/KANPC i386


	
>Description:
	The revision 1.22 commit resulted in sed 'N' function to broke.
	The N function tries to append data to the space and call mf_fgets
	to fetch the next line. mf_fgets function resets the space length
	to 0 for no reason, thus causing the previous content of the space
	to be overwritten instead of being appended to.
>How-To-Repeat:
	The following sed script from the teTex port does not work 
	as expected, causing the port build to fail:

        : again
        /\.$/{
                N
                s/\.\n/\
./
                t again
        }

>Fix:

Index: main.c
===================================================================
RCS file: /usr/ncvs/src/usr.bin/sed/main.c,v
retrieving revision 1.23
diff -u -r1.23 main.c
--- main.c	14 Jun 2002 02:20:05 -0000	1.23
+++ main.c	14 Jun 2002 21:20:48 -0000
@@ -315,7 +315,6 @@
 		firstfile = 1;
 	}
 
-	sp->len = 0;
 	for (;;) {
 		if (f != NULL && (c = getc(f)) != EOF) {
 			(void)ungetc(c, f);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sobomax 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Fri Jun 14 16:01:20 PDT 2002 
Responsible-Changed-Why:  

Over to that revision's author. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39310 
State-Changed-From-To: open->closed 
State-Changed-By: sobomax 
State-Changed-When: Sun Jun 16 04:33:12 PDT 2002 
State-Changed-Why:  
Fixed, thank you for submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39310 
>Unformatted:
