Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Aug 2011 15:51:12 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225246 - user/gabor/grep/trunk
Message-ID:  <201108291551.p7TFpCxM002972@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Mon Aug 29 15:51:12 2011
New Revision: 225246
URL: http://svn.freebsd.org/changeset/base/225246

Log:
  - Add support for bz[ef]?grep
  
  Submitted by:	dim

Modified:
  user/gabor/grep/trunk/Makefile
  user/gabor/grep/trunk/grep.1
  user/gabor/grep/trunk/grep.c

Modified: user/gabor/grep/trunk/Makefile
==============================================================================
--- user/gabor/grep/trunk/Makefile	Mon Aug 29 13:01:23 2011	(r225245)
+++ user/gabor/grep/trunk/Makefile	Mon Aug 29 15:51:12 2011	(r225246)
@@ -25,13 +25,19 @@ LINKS=	${BINDIR}/grep ${BINDIR}/egrep \
 	${BINDIR}/grep ${BINDIR}/fgrep \
 	${BINDIR}/grep ${BINDIR}/zgrep \
 	${BINDIR}/grep ${BINDIR}/zegrep \
-	${BINDIR}/grep ${BINDIR}/zfgrep
+	${BINDIR}/grep ${BINDIR}/zfgrep \
+	${BINDIR}/grep ${BINDIR}/bzgrep \
+	${BINDIR}/grep ${BINDIR}/bzegrep \
+	${BINDIR}/grep ${BINDIR}/bzfgrep
 
 MLINKS= grep.1 egrep.1 \
 	grep.1 fgrep.1 \
 	grep.1 zgrep.1 \
 	grep.1 zegrep.1 \
-	grep.1 zfgrep.1
+	grep.1 zfgrep.1 \
+	grep.1 bzgrep.1 \
+	grep.1 bzegrep.1 \
+	grep.1 bzfgrep.1
 .endif
 
 LDADD=	-lz -lbz2

Modified: user/gabor/grep/trunk/grep.1
==============================================================================
--- user/gabor/grep/trunk/grep.1	Mon Aug 29 13:01:23 2011	(r225245)
+++ user/gabor/grep/trunk/grep.1	Mon Aug 29 15:51:12 2011	(r225246)
@@ -35,7 +35,8 @@
 .Os
 .Sh NAME
 .Nm grep , egrep , fgrep ,
-.Nm zgrep , zegrep , zfgrep
+.Nm zgrep , zegrep , zfgrep ,
+.Nm bzgrep , bzegrep , bzfgrep
 .Nd file pattern searcher
 .Sh SYNOPSIS
 .Nm grep
@@ -103,6 +104,19 @@ or
 .Xr gzip 1
 compression utilities.
 .Pp
+.Nm bzgrep ,
+.Nm bzegrep ,
+and
+.Nm bzfgrep
+act like
+.Nm grep ,
+.Nm egrep ,
+and
+.Nm fgrep ,
+respectively, but accept input files compressed with the
+.Xr bzip2 1
+compression utility.
+.Pp
 The following options are available:
 .Bl -tag -width indent
 .It Fl A Ar num , Fl Fl after-context Ns = Ns Ar num
@@ -457,6 +471,7 @@ looking for either 19, 20, or 25.
 .Xr ed 1 ,
 .Xr ex 1 ,
 .Xr gzip 1 ,
+.Xr bzip2 1 ,
 .Xr sed 1 ,
 .Xr re_format 7
 .Sh STANDARDS

Modified: user/gabor/grep/trunk/grep.c
==============================================================================
--- user/gabor/grep/trunk/grep.c	Mon Aug 29 13:01:23 2011	(r225245)
+++ user/gabor/grep/trunk/grep.c	Mon Aug 29 15:51:12 2011	(r225246)
@@ -313,7 +313,7 @@ int
 main(int argc, char *argv[])
 {
 	char **aargv, **eargv, *eopts;
-	char *ep;
+	char *pn, *ep;
 	unsigned long long l;
 	unsigned int aargc, eargc, i;
 	int c, lastc, needpattern, newarg, prevoptind;
@@ -327,30 +327,21 @@ main(int argc, char *argv[])
 	/* Check what is the program name of the binary.  In this
 	   way we can have all the funcionalities in one binary
 	   without the need of scripting and using ugly hacks. */
-	switch (__progname[0]) {
+	pn = __progname;
+	if (pn[0] == 'b' && pn[1] == 'z') {
+		filebehave = FILE_BZIP;
+		pn += 2;
+	} else if (pn[0] == 'z') {
+		filebehave = FILE_GZIP;
+		pn += 1;
+	}
+	switch (pn[0]) {
 	case 'e':
 		grepbehave = GREP_EXTENDED;
 		break;
 	case 'f':
 		grepbehave = GREP_FIXED;
 		break;
-	case 'g':
-		grepbehave = GREP_BASIC;
-		break;
-	case 'z':
-		filebehave = FILE_GZIP;
-		switch(__progname[1]) {
-		case 'e':
-			grepbehave = GREP_EXTENDED;
-			break;
-		case 'f':
-			grepbehave = GREP_FIXED;
-			break;
-		case 'g':
-			grepbehave = GREP_BASIC;
-			break;
-		}
-		break;
 	}
 
 	lastc = '\0';



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108291551.p7TFpCxM002972>