From 8a219147ce130f175605e849307f9be86ab719b7 Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka Date: Fri, 17 Oct 2014 21:52:29 +0900 Subject: [PATCH] grep: line buffered for output of file names in grep --line-buffered Now grep --line-buffered sets not only matched lines but file names to line buffered. * src/grep.c (static bool line_buffered): Remove var. (prline): Remove it. (main): Remove it, and use setvbuf(). --- src/grep.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/grep.c b/src/grep.c index a0f2620..3de5674 100644 --- a/src/grep.c +++ b/src/grep.c @@ -835,7 +835,6 @@ static int list_files; /* List matching files. */ static bool no_filenames; /* Suppress file names. */ static intmax_t max_count; /* Stop after outputting this many lines from an input file. */ -static bool line_buffered; /* Use line buffering. */ static char *label = NULL; /* Fake filename for stdin */ @@ -1098,9 +1097,6 @@ prline (char const *beg, char const *lim, char sep) } lastout = lim; - - if (line_buffered) - fflush (stdout); } /* Print pending lines of trailing context prior to LIM. Trailing context ends @@ -2408,7 +2404,7 @@ main (int argc, char **argv) break; case LINE_BUFFERED_OPTION: - line_buffered = true; + setvbuf (stdout, NULL, _IOLBF, 0); break; case LABEL_OPTION: -- 2.1.1