From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 15:51:13 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F6411065678; Mon, 29 Aug 2011 15:51:13 +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 0FB9C8FC19; Mon, 29 Aug 2011 15:51:13 +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 p7TFpCvQ002976; Mon, 29 Aug 2011 15:51:12 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TFpCxM002972; Mon, 29 Aug 2011 15:51:12 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108291551.p7TFpCxM002972@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 29 Aug 2011 15:51:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225246 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 15:51:13 -0000 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';