Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 2014 01:06:02 -0500
From:      Pedro Giffuni <pfg@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r267692 - head/usr.bin/sed
Message-ID:  <BE9F2DB0-5C97-41DA-853E-F01BA39D3319@freebsd.org>
In-Reply-To: <20140621054744.GN3991@kib.kiev.ua>
References:  <201406202141.s5KLfU2J047433@svn.freebsd.org> <20140621054744.GN3991@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help


Il giorno 21/giu/2014, alle ore 00:47, Konstantin Belousov <kostikbel@gmail.com> ha scritto:

> On Fri, Jun 20, 2014 at 09:41:30PM +0000, Pedro F. Giffuni wrote:
>> Author: pfg
>> Date: Fri Jun 20 21:41:30 2014
>> New Revision: 267692
>> URL: http://svnweb.freebsd.org/changeset/base/267692
>> 
>> Log:
>>  Add -u (unbuffered output) after GNU sed.
>> 
>>  Obtained from:	NetBSD
>>  MFC after:	1 week
>> 
>> Modified:
>>  head/usr.bin/sed/main.c
>>  head/usr.bin/sed/sed.1
>> 
>> Modified: head/usr.bin/sed/main.c
>> ==============================================================================
>> --- head/usr.bin/sed/main.c	Fri Jun 20 21:35:39 2014	(r267691)
>> +++ head/usr.bin/sed/main.c	Fri Jun 20 21:41:30 2014	(r267692)
>> @@ -132,7 +132,7 @@ main(int argc, char *argv[])
>> 	fflag = 0;
>> 	inplace = NULL;
>> 
>> -	while ((c = getopt(argc, argv, "EI:ae:f:i:lnr")) != -1)
>> +	while ((c = getopt(argc, argv, "EI:ae:f:i:lnru")) != -1)
>> 		switch (c) {
>> 		case 'r':		/* Gnu sed compat */
>> 		case 'E':
>> @@ -168,6 +168,16 @@ main(int argc, char *argv[])
>> 		case 'n':
>> 			nflag = 1;
>> 			break;
>> +		case 'u':
>> +#ifdef _IONBF
>> +			c = setvbuf(stdout, NULL, _IONBF, 0);
>> +#else
>> +			c = -1;
>> +			errno = EOPNOTSUPP;
>> +#endif
>> +			if (c)
> 
> Why doing it that way ? IMO the conditional is useless and even wrong.
> FreeBSD provides the _IONBF, _IONBF is required by C99.
> 
> If some other system lacks _IONBF, it should get compiler error instead
> of silently accepting non-working code.

I was just trying to keep the code somewhat in sync with NetBSD: as of lately their emphasis is portability and for them it’s important to be build all their system in weird platforms.

I agree it’s ugly though, so unless someone thinks we should care I will clean it up :).

Pedro.


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BE9F2DB0-5C97-41DA-853E-F01BA39D3319>