From owner-svn-src-head@FreeBSD.ORG Mon Nov 28 20:00:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6086106566C; Mon, 28 Nov 2011 20:00:31 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5CE88FC0A; Mon, 28 Nov 2011 20:00:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pASK0Vdi006651; Mon, 28 Nov 2011 20:00:31 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pASK0VfU006649; Mon, 28 Nov 2011 20:00:31 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201111282000.pASK0VfU006649@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 28 Nov 2011 20:00:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228093 - head/usr.bin/grep X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2011 20:00:32 -0000 Author: gabor Date: Mon Nov 28 20:00:31 2011 New Revision: 228093 URL: http://svn.freebsd.org/changeset/base/228093 Log: - Fix behavior of --null to match GNU grep PR: bin/162906 Submitted by: Jan Beich MFC after: 3 days Modified: head/usr.bin/grep/util.c Modified: head/usr.bin/grep/util.c ============================================================================== --- head/usr.bin/grep/util.c Mon Nov 28 19:53:16 2011 (r228092) +++ head/usr.bin/grep/util.c Mon Nov 28 20:00:31 2011 (r228093) @@ -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, reg 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)