From f0c94259d66f123330bcd101227904396cb98624 Mon Sep 17 00:00:00 2001 From: Gabor Kovesdan Date: Mon, 28 Nov 2011 20:00:31 +0000 Subject: [PATCH] - 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(-) diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 785961b1c6b3..447e8c538ecb 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)