NetBSD Problem Report #45981

From www@NetBSD.org  Sat Feb 11 00:06:14 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 8E95363DF8B
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 11 Feb 2012 00:06:14 +0000 (UTC)
Message-Id: <20120211000613.6F4A463BCF4@www.NetBSD.org>
Date: Sat, 11 Feb 2012 00:06:13 +0000 (UTC)
From: uwe@NetBSD.org
Reply-To: uwe@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: sed(1) "c" command should start a next cycle
X-Send-Pr-Version: www-1.0

>Number:         45981
>Category:       bin
>Synopsis:       sed(1) "c" command should start a next cycle
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 11 00:10:00 +0000 2012
>Closed-Date:    Sat May 11 23:08:12 +0000 2013
>Last-Modified:  Sat May 11 23:08:12 +0000 2013
>Originator:     Valeriy E. Ushakov
>Release:        current
>Organization:
>Environment:
NetBSD felix 5.99.56 NetBSD 5.99.56 (FELIX) #0: Sun Oct 30 04:49:01 MSK 2011  uwe@shravaka:/mnt/netbsd/cvs/src/sys/arch/landisk/compile/FELIX landisk

>Description:
sed(1) "c" command is in some sense a shorthand for "i"+"d", so,
like "d" it should start the next cycle.  This is explicitly documented
in v7 man page:

  Delete the pattern space.  With 0 or 1 address or at the end of a
  2-address range, place text on the output.  Start the next cycle.

GNU sed and Plan 9 sed do that.

O'Reilly "sed & awk" book also says:

  The change command clears the pattern space, having the same effect
  on the pattern space as the delete command.  No command following
  the change command in the script is applied.


Our sed(1) does NOT do that and continues with the script.

>How-To-Repeat:
$ echo | sed -e '
c\
c1
c\
c2
'
c1
c2

Note that both "c1" and "c2" are printed.

Other sed versions I tested (v7, plan9, gnu) only print "c1".

>Fix:
Index: usr.bin/sed/process.c
===================================================================
RCS file: /cvsroot/src/usr.bin/sed/process.c,v
retrieving revision 1.38
diff -u -p -r1.38 process.c
--- usr.bin/sed/process.c       13 Apr 2009 07:29:55 -0000      1.38
+++ usr.bin/sed/process.c       11 Feb 2012 00:05:06 -0000
@@ -168,7 +168,7 @@ redirect:
                                psl = 0;
                                if (cp->a2 == NULL || lastaddr)
                                        (void)printf("%s", cp->t);
-                               break;
+                               goto new;
                        case 'd':
                                pd = 1;
                                goto new;

>Release-Note:

>Audit-Trail:
From: "Valeriy E. Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45981 CVS commit: src/usr.bin/sed
Date: Sun, 17 Mar 2013 21:02:55 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Sun Mar 17 21:02:55 UTC 2013

 Modified Files:
 	src/usr.bin/sed: process.c sed.1

 Log Message:
 The change ("c") command should start a new cycle.

 Apply one line patch I posted in PR #45981 and document this in the
 manual page.


 To generate a diff of this commit:
 cvs rdiff -u -r1.38 -r1.39 src/usr.bin/sed/process.c
 cvs rdiff -u -r1.29 -r1.30 src/usr.bin/sed/sed.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Valeriy E. Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45981 CVS commit: src/usr.bin/sed
Date: Sun, 17 Mar 2013 21:13:05 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Sun Mar 17 21:13:04 UTC 2013

 Modified Files:
 	src/usr.bin/sed: sed.1

 Log Message:
 Bump date for previous (PR #45981): the change ("c") command starts a
 new cycle.


 To generate a diff of this commit:
 cvs rdiff -u -r1.30 -r1.31 src/usr.bin/sed/sed.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45981 CVS commit: [netbsd-6] src/usr.bin/sed
Date: Sat, 11 May 2013 21:59:30 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Sat May 11 21:59:29 UTC 2013

 Modified Files:
 	src/usr.bin/sed [netbsd-6]: process.c sed.1

 Log Message:
 Pull up following revision(s) (requested by uwe in ticket #888):
 	usr.bin/sed/process.c: revision 1.39
 	usr.bin/sed/sed.1: revision 1.30
 	usr.bin/sed/sed.1: revision 1.31
 The change ("c") command should start a new cycle.
 Apply one line patch I posted in PR #45981 and document this in the
 manual page.
 Bump date for previous (PR #45981): the change ("c") command starts a
 new cycle.


 To generate a diff of this commit:
 cvs rdiff -u -r1.38 -r1.38.8.1 src/usr.bin/sed/process.c
 cvs rdiff -u -r1.27 -r1.27.20.1 src/usr.bin/sed/sed.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Sat, 11 May 2013 23:08:12 +0000
State-Changed-Why:
Committed and pulled up to 6.x


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.