Module Name:    src
Committed By:   christos
Date:           Sun Aug 12 07:53:19 UTC 2018

Modified Files:
        src/usr.bin/grep: Makefile file.c grep.c grep.h

Log Message:
add WITHOUT_BZ2 for tools build.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/grep/Makefile
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/grep/file.c src/usr.bin/grep/grep.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/grep/grep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/grep/Makefile
diff -u src/usr.bin/grep/Makefile:1.6 src/usr.bin/grep/Makefile:1.7
--- src/usr.bin/grep/Makefile:1.6	Sat Aug 11 15:43:54 2018
+++ src/usr.bin/grep/Makefile	Sun Aug 12 03:53:19 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2018/08/11 19:43:54 christos Exp $
+#	$NetBSD: Makefile,v 1.7 2018/08/12 07:53:19 christos Exp $
 #	$FreeBSD: head/usr.bin/grep/Makefile 210389 2010-07-22 19:11:57Z gabor $
 #	$OpenBSD: Makefile,v 1.6 2003/06/25 15:00:04 millert Exp $
 
@@ -17,8 +17,13 @@ MLINKS=	grep.1 egrep.1	\
 	grep.1 zegrep.1	\
 	grep.1 zfgrep.1
 
-LDADD=	-lz -lbz2
-DPADD=	${LIBZ} ${LIBBZ2}
+LDADD+=	-lz
+DPADD+=	${LIBZ}
+
+.if empty(HOST_CPPFLAGS:M(*-DWITHOUT_BZ2*)
+LDADD+=	-lz
+DPADD+=	${LIBZ}
+.endif
 
 .if empty(HOST_CPPFLAGS:M*-DWITHOUT_NLS*)
 .PATH: ${.CURDIR}/nls

Index: src/usr.bin/grep/file.c
diff -u src/usr.bin/grep/file.c:1.8 src/usr.bin/grep/file.c:1.9
--- src/usr.bin/grep/file.c:1.8	Sat Aug 11 12:03:37 2018
+++ src/usr.bin/grep/file.c	Sun Aug 12 03:53:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: file.c,v 1.8 2018/08/11 16:03:37 christos Exp $	*/
+/*	$NetBSD: file.c,v 1.9 2018/08/12 07:53:19 christos Exp $	*/
 /*	$FreeBSD: head/usr.bin/grep/file.c 211496 2010-08-19 09:28:59Z des $	*/
 /*	$OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $	*/
 
@@ -35,7 +35,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: file.c,v 1.8 2018/08/11 16:03:37 christos Exp $");
+__RCSID("$NetBSD: file.c,v 1.9 2018/08/12 07:53:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -57,7 +57,9 @@ __RCSID("$NetBSD: file.c,v 1.8 2018/08/1
 #define	LNBUFBUMP	80
 
 static gzFile gzbufdesc;
+#ifndef WITHOUT_BZ2
 static BZFILE* bzbufdesc;
+#endif
 
 static unsigned char buffer[MAXBUFSIZ];
 static unsigned char *bufpos;
@@ -75,9 +77,10 @@ grep_refill(struct file *f)
 	bufpos = buffer;
 	bufrem = 0;
 
-	if (filebehave == FILE_GZIP)
+	if (filebehave == FILE_GZIP) {
 		nr = gzread(gzbufdesc, buffer, MAXBUFSIZ);
-	else if (filebehave == FILE_BZIP && bzbufdesc != NULL) {
+#ifndef WITHOUT_BZ2
+	} else if (filebehave == FILE_BZIP && bzbufdesc != NULL) {
 		nr = BZ2_bzRead(&bzerr, bzbufdesc, buffer, MAXBUFSIZ);
 		switch (bzerr) {
 		case BZ_OK:
@@ -103,6 +106,7 @@ grep_refill(struct file *f)
 			/* Make sure we exit with an error */
 			nr = -1;
 		}
+#endif
 	} else
 		nr = read(f->fd, buffer, MAXBUFSIZ);
 
@@ -196,9 +200,11 @@ grep_file_init(struct file *f)
 	    (gzbufdesc = gzdopen(f->fd, "r")) == NULL)
 		goto error;
 
+#ifndef WITHOUT_BZ2
 	if (filebehave == FILE_BZIP &&
 	    (bzbufdesc = BZ2_bzdopen(f->fd, "r")) == NULL)
 		goto error;
+#endif
 
 	/* Fill read buffer, also catches errors early */
 	if (grep_refill(f) != 0)
Index: src/usr.bin/grep/grep.h
diff -u src/usr.bin/grep/grep.h:1.8 src/usr.bin/grep/grep.h:1.9
--- src/usr.bin/grep/grep.h:1.8	Sun May  6 18:27:00 2012
+++ src/usr.bin/grep/grep.h	Sun Aug 12 03:53:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.h,v 1.8 2012/05/06 22:27:00 joerg Exp $	*/
+/*	$NetBSD: grep.h,v 1.9 2018/08/12 07:53:19 christos Exp $	*/
 /*	$OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $	*/
 /*	$FreeBSD: head/usr.bin/grep/grep.h 211496 2010-08-19 09:28:59Z des $	*/
 
@@ -29,7 +29,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef WITHOUT_BZ2
 #include <bzlib.h>
+#endif
 #include <limits.h>
 #include <regex.h>
 #include <stdbool.h>

Index: src/usr.bin/grep/grep.c
diff -u src/usr.bin/grep/grep.c:1.13 src/usr.bin/grep/grep.c:1.14
--- src/usr.bin/grep/grep.c:1.13	Sat Aug 11 15:44:19 2018
+++ src/usr.bin/grep/grep.c	Sun Aug 12 03:53:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.13 2018/08/11 19:44:19 christos Exp $	*/
+/*	$NetBSD: grep.c,v 1.14 2018/08/12 07:53:19 christos Exp $	*/
 /* 	$FreeBSD: head/usr.bin/grep/grep.c 211519 2010-08-19 22:55:17Z delphij $	*/
 /*	$OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $	*/
 
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: grep.c,v 1.13 2018/08/11 19:44:19 christos Exp $");
+__RCSID("$NetBSD: grep.c,v 1.14 2018/08/12 07:53:19 christos Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -197,7 +197,9 @@ struct option long_options[] =
 	{"no-filename",		no_argument,		NULL, 'h'},
 	{"with-filename",	no_argument,		NULL, 'H'},
 	{"ignore-case",		no_argument,		NULL, 'i'},
+#ifndef WITHOUT_BZ2
 	{"bz2decompress",	no_argument,		NULL, 'J'},
+#endif
 	{"files-with-matches",	no_argument,		NULL, 'l'},
 	{"files-without-match", no_argument,            NULL, 'L'},
 	{"max-count",		required_argument,	NULL, 'm'},
@@ -491,9 +493,11 @@ main(int argc, char *argv[])
 			iflag =  true;
 			cflags |= REG_ICASE;
 			break;
+#ifndef WITHOUT_BZ2
 		case 'J':
 			filebehave = FILE_BZIP;
 			break;
+#endif
 		case 'L':
 			lflag = false;
 			Lflag = true;

Reply via email to