Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/grep use setvbuf if available; it is more portable.



details:   https://anonhg.NetBSD.org/src/rev/93e0d053b6f7
branches:  trunk
changeset: 834381:93e0d053b6f7
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Aug 11 19:44:19 2018 +0000

description:
use setvbuf if available; it is more portable.

diffstat:

 usr.bin/grep/grep.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r e85c844a0eb2 -r 93e0d053b6f7 usr.bin/grep/grep.c
--- a/usr.bin/grep/grep.c       Sat Aug 11 19:43:54 2018 +0000
+++ b/usr.bin/grep/grep.c       Sat Aug 11 19:44:19 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grep.c,v 1.12 2014/07/11 16:30:45 christos Exp $       */
+/*     $NetBSD: grep.c,v 1.13 2018/08/11 19:44:19 christos Exp $       */
 /*     $FreeBSD: head/usr.bin/grep/grep.c 211519 2010-08-19 22:55:17Z delphij $        */
 /*     $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $  */
 
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: grep.c,v 1.12 2014/07/11 16:30:45 christos Exp $");
+__RCSID("$NetBSD: grep.c,v 1.13 2018/08/11 19:44:19 christos Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -679,8 +679,13 @@
                }
        }
 
-       if (lbflag)
+       if (lbflag) {
+#ifdef _IOLBF
+               setvbuf(stdout, NULL, _IOLBF, 0);
+#else
                setlinebuf(stdout);
+#endif
+       }
 
        if ((aargc == 0 || aargc == 1) && !Hflag)
                hflag = true;



Home | Main Index | Thread Index | Old Index