From eu@www.svzserv.kemerovo.su  Fri Mar 11 11:31:11 2005
Return-Path: <eu@www.svzserv.kemerovo.su>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4E91B16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Mar 2005 11:31:11 +0000 (GMT)
Received: from www.svzserv.kemerovo.su (www.svzserv.kemerovo.su [213.184.65.80])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0AB2343D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Mar 2005 11:31:10 +0000 (GMT)
	(envelope-from eu@www.svzserv.kemerovo.su)
Received: from www.svzserv.kemerovo.su (smmsp@localhost [127.0.0.1])
	by www.svzserv.kemerovo.su (8.12.11/8.12.11) with ESMTP id j2BBV72k079057
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Mar 2005 18:31:07 +0700 (KRAT)
	(envelope-from eu@www.svzserv.kemerovo.su)
Received: (from root@localhost)
	by www.svzserv.kemerovo.su (8.12.11/8.12.11/Submit) id j2BBV7Rq079056;
	Fri, 11 Mar 2005 18:31:07 +0700 (KRAT)
	(envelope-from eu)
Message-Id: <200503111131.j2BBV7Rq079056@www.svzserv.kemerovo.su>
Date: Fri, 11 Mar 2005 18:31:07 +0700 (KRAT)
From: Eugene Grosbein <eugen@kuzbass.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] add support for line buffered output to sed(1)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         78692
>Category:       bin
>Synopsis:       [PATCH] add support for line buffered output to sed(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 11 11:40:02 GMT 2005
>Closed-Date:    Fri May 27 11:13:31 GMT 2005
>Last-Modified:  Fri May 27 11:13:31 GMT 2005
>Originator:     Eugene Grosbein
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD www.svzserv.kemerovo.su 4.10-STABLE FreeBSD 4.10-STABLE #1: Thu Jun 17 13:32:02 KRAST 2004 eu@www.svzserv.kemerovo.su:/home4/obj/home/src/sys/WWW i386

>Description:

	The following patch introduces new command line option -l
	for sed(1) that makes its output stream line buffered.
	This makes it possible to use sed(1) for realtime
	text processing that is sometimes need.

	For example, syslog.conf(5) can pipe messages to a command
	that uses sed(1) to process its input. Then the stream volume
	is low, it may take hours to get an output from sed(1) currently.

>How-To-Repeat:
	See description.

>Fix:

	'sed -l' uses line buffered output

--- usr.bin/sed/main.c.orig	Fri Mar 11 18:07:14 2005
+++ usr.bin/sed/main.c	Fri Mar 11 18:11:30 2005
@@ -128,7 +128,7 @@
 	fflag = 0;
 	inplace = NULL;
 
-	while ((c = getopt(argc, argv, "Eae:f:i:n")) != -1)
+	while ((c = getopt(argc, argv, "Eae:f:i:ln")) != -1)
 		switch (c) {
 		case 'E':
 			rflags = REG_EXTENDED;
@@ -151,6 +151,9 @@
 		case 'i':
 			inplace = optarg;
 			break;
+		case 'l':
+			if(setlinebuf(stdout) != 0)
+				warnx("setlinebuf: the request cannot be honored");
 		case 'n':
 			nflag = 1;
 			break;
--- usr.bin/sed/sed.1.orig	Fri Mar 11 18:27:47 2005
+++ usr.bin/sed/sed.1	Fri Mar 11 18:29:37 2005
@@ -43,11 +43,11 @@
 .Nd stream editor
 .Sh SYNOPSIS
 .Nm
-.Op Fl Ean
+.Op Fl Ealn
 .Ar command
 .Op Ar
 .Nm
-.Op Fl Ean
+.Op Fl Ealn
 .Op Fl e Ar command
 .Op Fl f Ar command_file
 .Op Fl i Ar extension
@@ -109,6 +109,8 @@
 .Ar extension
 when in-place editing files, as you risk corruption or partial content
 in situations where disk space is exhausted, etc.
+.It Fl l
+Make stdout line buffered.
 .It Fl n
 By default, each line of input is echoed to the standard output after
 all of the commands have been applied to it.
>Release-Note:
>Audit-Trail:

From: Eugene Grosbein <eugen@kuzbass.ru>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/78692: [PATCH] add support for line buffered output to sed(1)
Date: Fri, 11 Mar 2005 20:17:42 +0700

 Hi!
 
 The patch misses "break" just before "case 'n':";
 with the exception of this bug it just works.

From: Giorgos Keramidas <keramida@freebsd.org>
To: Eugene Grosbein <eugen@kuzbass.ru>
Cc: bug-followup@freebsd.org
Subject: Re: bin/78692: [PATCH] add support for line buffered output to sed(1)
Date: Sun, 13 Mar 2005 04:16:42 +0200

 On 2005-03-11 18:31, Eugene Grosbein <eugen@kuzbass.ru> wrote:
 > --- usr.bin/sed/sed.1.orig	Fri Mar 11 18:27:47 2005
 > +++ usr.bin/sed/sed.1	Fri Mar 11 18:29:37 2005
 > @@ -43,11 +43,11 @@
 >  .Nd stream editor
 >  .Sh SYNOPSIS
 >  .Nm
 > -.Op Fl Ean
 > +.Op Fl Ealn
 >  .Ar command
 >  .Op Ar
 >  .Nm
 > -.Op Fl Ean
 > +.Op Fl Ealn
 >  .Op Fl e Ar command
 >  .Op Fl f Ar command_file
 >  .Op Fl i Ar extension
 > @@ -109,6 +109,8 @@
 >  .Ar extension
 >  when in-place editing files, as you risk corruption or partial content
 >  in situations where disk space is exhausted, etc.
 > +.It Fl l
 > +Make stdout line buffered.
 
 Hi,
 
 "stdout" is something that depends on an understanding of how stdio.h
 works in ANSI C.  Since the executable of sed is pretty much
 language-agnostic and we can't expect all the users of FreeBSD to be C
 programmers, I'd probably write this as:
 
 	.It Fl l
 	Make output line buffered.
 
 Other than this minor detail, the manpage diff looks fine (as long as we
 don't forget to bump the date too when it is committed).
 

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: Giorgos Keramidas <keramida@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/78692: [PATCH] add support for line buffered output to sed(1)
Date: Sun, 13 Mar 2005 11:28:49 +0700

 > "stdout" is something that depends on an understanding of how stdio.h
 > works in ANSI C.  Since the executable of sed is pretty much
 > language-agnostic and we can't expect all the users of FreeBSD to be C
 > programmers, I'd probably write this as:
 > 
 > 	.It Fl l
 > 	Make output line buffered.
 
 That's nice. I just was too lazy and took description of '-l'
 from tcpdump(1) manual page :-)
 
 Eugene
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Mon May 9 18:10:27 GMT 2005 
Responsible-Changed-Why:  
I'll handle this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78692 
State-Changed-From-To: open->patched 
State-Changed-By: glebius 
State-Changed-When: Tue May 10 13:46:02 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78692 
State-Changed-From-To: patched->closed 
State-Changed-By: glebius 
State-Changed-When: Fri May 27 11:13:12 GMT 2005 
State-Changed-Why:  
Merge done. 

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