From 7b8d844d3a215213a277d9a84b016fda9fcdc3ea Mon Sep 17 00:00:00 2001 From: gabor Date: Mon, 28 Nov 2011 20:00:31 +0000 Subject: - Fix behavior of --null to match GNU grep PR: bin/162906 Submitted by: Jan Beich MFC after: 3 days --- usr.bin/grep/util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 785961b..447e8c5 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -246,9 +246,9 @@ procfile(const char *fn) printf("%u\n", c); } if (lflag && !qflag && c != 0) - printf("%s\n", fn); + printf("%s%c", fn, nullflag ? 0 : '\n'); if (Lflag && !qflag && c == 0) - printf("%s\n", fn); + printf("%s%c", fn, nullflag ? 0 : '\n'); if (c && !cflag && !lflag && !Lflag && binbehave == BINFILE_BIN && f->binary && !qflag) printf(getstr(8), fn); @@ -440,13 +440,13 @@ printline(struct str *line, int sep, regmatch_t *matches, int m) int i, n = 0; if (!hflag) { - if (nullflag == 0) + if (!nullflag) { fputs(line->file, stdout); - else { + ++n; + } else { printf("%s", line->file); putchar(0); } - ++n; } if (nflag) { if (n > 0) -- cgit v1.1