From jbeich@tormail.net  Sun Nov 27 17:01:17 2011
Return-Path: <jbeich@tormail.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 24CC5106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 27 Nov 2011 17:01:17 +0000 (UTC)
	(envelope-from jbeich@tormail.net)
Received: from server2.hudsonvalleyhost.com (server2.hudsonvalleyhost.com [66.7.195.77])
	by mx1.freebsd.org (Postfix) with ESMTP id D637E8FC0A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 27 Nov 2011 17:01:16 +0000 (UTC)
Received: from tor-exit-readme-1wh2.kromyon.net ([209.236.66.136]:46908 helo=internal.tormail.net)
	by server2.hudsonvalleyhost.com with esmtpsa (TLSv1:RC4-SHA:128)
	(Exim 4.69)
	(envelope-from <jbeich@tormail.net>)
	id 1RUi6L-003QIj-SV
	for FreeBSD-gnats-submit@freebsd.org; Sun, 27 Nov 2011 12:01:15 -0500
Received: from jbeich by internal.tormail.net with local (Exim 4.63)
	(envelope-from <jbeich@tormail.net>)
	id 1RUi5g-0007C8-UK
	for FreeBSD-gnats-submit@freebsd.org; Sun, 27 Nov 2011 17:00:36 +0000
Message-Id: <1RUi5g-0007C8-UK@internal.tormail.net>
Date: Sun, 27 Nov 2011 22:51:32 +0600
From: Jan Beich <jbeich@tormail.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] bsdgrep(1): treat --null like gnugrep(1)

>Number:         162906
>Category:       bin
>Synopsis:       [patch] bsdgrep(1): treat --null like gnugrep(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gabor
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 27 17:10:10 UTC 2011
>Closed-Date:    Thu Dec 01 13:54:45 UTC 2011
>Last-Modified:  Thu Dec 01 13:54:45 UTC 2011
>Originator:     Jan Beich
>Release:        FreeBSD 10.0-CURRENT r228005M amd64
>Organization:
>Environment:
>Description:
http://docs.freebsd.org/cgi/mid.cgi?4ED22F3B.6070707
>How-To-Repeat:
$ echo t >a; echo t >b; echo t >c

$ gnugrep --null . ? | vis
a\^@t
b\^@t
c\^@t

$ bsdgrep --null . ? | vis
a\^@:t
b\^@:t
c\^@:t

$ gnugrep -l --null . /usr/include/md*.h | vis
/usr/include/md2.h\^@/usr/include/md4.h\^@/usr/include/md5.h\^@

$ bsdgrep -l --null . /usr/include/md*.h | vis
/usr/include/md2.h
/usr/include/md4.h
/usr/include/md5.h
>Fix:
--- null.diff begins here ---
Index: usr.bin/grep/util.c
===================================================================
--- usr.bin/grep/util.c	(revision 228003)
+++ usr.bin/grep/util.c	(working copy)
@@ -246,9 +248,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 +442,13 @@ printline(struct str *line, int sep, regmatch_t *m
 	int i, n = 0;
 
 	if (!hflag) {
-		if (nullflag == 0)
+		if (nullflag == 0) {
 			fputs(line->file, stdout);
-		else {
+			++n;
+		} else {
 			printf("%s", line->file);
 			putchar(0);
 		}
-		++n;
 	}
 	if (nflag) {
 		if (n > 0)
--- null.diff ends here ---
>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/162906: commit references a PR
Date: Mon, 28 Nov 2011 20:00:46 +0000 (UTC)

 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 <jbeich@tormail.net>
   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)
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: gabor 
State-Changed-When: Mon Nov 28 20:20:05 UTC 2011 
State-Changed-Why:  
Committed to HEAD, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=162906 
State-Changed-From-To: patched->closed 
State-Changed-By: gabor 
State-Changed-When: Thu Dec 1 13:54:22 UTC 2011 
State-Changed-Why:  
Merged to 9.X. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=162906 
>Unformatted:
