On Sat, 21 Jun 2014, Pedro Giffuni wrote:

Il giorno 21/giu/2014, alle ore 00:47, Konstantin Belousov 
<kostik...@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
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to