svn commit: r267692 - head/usr.bin/sed

Konstantin Belousov kostikbel at gmail.com
Sat Jun 21 05:47:57 UTC 2014


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20140621/1f8c3ab6/attachment.sig>


More information about the svn-src-head mailing list