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

Bruce Evans brde at optusnet.com.au
Sat Jun 21 08:48:31 UTC 2014


On Sat, 21 Jun 2014, Pedro Giffuni wrote:

> Il giorno 21/giu/2014, alle ore 00:47, Konstantin Belousov <kostikbel at gmail.com> ha scritto:
>
>> On Fri, Jun 20, 2014 at 09:41:30PM +0000, Pedro F. Giffuni wrote:
>>> 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)
>>> ...
>>> @@ -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 :).

The ifdef is nonsense.  _IONBUF and setvbuf() are far more portable than
EOPNOTSUPP, since they are in C90 while EOPNOTSUPP wasn't even in POSIX
until 2001.  (POSIX spelled it ENOTSUP, but other OSes spelled it EOPNOTSUPP,
so now everyone except C has both.)

Before C90, setvbuf() was unportable and there were ifdef messes to use
it if available, else use setbuf(), but setbuf() can't do much.

The 'c' variable is abused.

Bruce


More information about the svn-src-all mailing list