Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/grep add WITHOUT_GZIP for the tools build.
details: https://anonhg.NetBSD.org/src/rev/b1f948739af9
branches: trunk
changeset: 365315:b1f948739af9
user: christos <christos%NetBSD.org@localhost>
date: Sun Aug 12 09:03:21 2018 +0000
description:
add WITHOUT_GZIP for the tools build.
diffstat:
usr.bin/grep/Makefile | 4 +++-
usr.bin/grep/file.c | 23 ++++++++++++++++++-----
usr.bin/grep/grep.c | 10 ++++++++--
usr.bin/grep/grep.h | 4 +++-
4 files changed, 32 insertions(+), 9 deletions(-)
diffs (174 lines):
diff -r 5c52e9cc4eae -r b1f948739af9 usr.bin/grep/Makefile
--- a/usr.bin/grep/Makefile Sun Aug 12 09:02:02 2018 +0000
+++ b/usr.bin/grep/Makefile Sun Aug 12 09:03:21 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2018/08/12 08:00:32 christos Exp $
+# $NetBSD: Makefile,v 1.10 2018/08/12 09:03:21 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,10 @@
grep.1 zegrep.1 \
grep.1 zfgrep.1
+.if empty(HOST_CPPFLAGS:M*-DWITHOUT_GZIP*)
LDADD+= -lz
DPADD+= ${LIBZ}
+.endif
.if empty(HOST_CPPFLAGS:M*-DWITHOUT_BZ2*)
LDADD+= -lbz2
diff -r 5c52e9cc4eae -r b1f948739af9 usr.bin/grep/file.c
--- a/usr.bin/grep/file.c Sun Aug 12 09:02:02 2018 +0000
+++ b/usr.bin/grep/file.c Sun Aug 12 09:03:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: file.c,v 1.9 2018/08/12 07:53:19 christos Exp $ */
+/* $NetBSD: file.c,v 1.10 2018/08/12 09:03:21 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.9 2018/08/12 07:53:19 christos Exp $");
+__RCSID("$NetBSD: file.c,v 1.10 2018/08/12 09:03:21 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -56,7 +56,9 @@
#define MAXBUFSIZ (32 * 1024)
#define LNBUFBUMP 80
+#ifndef WITHOUT_GZIP
static gzFile gzbufdesc;
+#endif
#ifndef WITHOUT_BZ2
static BZFILE* bzbufdesc;
#endif
@@ -71,16 +73,21 @@
static inline int
grep_refill(struct file *f)
{
- ssize_t nr;
+ ssize_t nr = -1;
int bzerr;
bufpos = buffer;
bufrem = 0;
+#ifndef WITHOUT_GZIP
if (filebehave == FILE_GZIP) {
nr = gzread(gzbufdesc, buffer, MAXBUFSIZ);
+ if (nr == -1)
+ return -1;
+ }
+#endif
#ifndef WITHOUT_BZ2
- } else if (filebehave == FILE_BZIP && bzbufdesc != NULL) {
+ if (filebehave == FILE_BZIP && bzbufdesc != NULL) {
nr = BZ2_bzRead(&bzerr, bzbufdesc, buffer, MAXBUFSIZ);
switch (bzerr) {
case BZ_OK:
@@ -106,9 +113,13 @@
/* Make sure we exit with an error */
nr = -1;
}
+ if (nr == -1)
+ return -1;
+ }
#endif
- } else
+ if (nr == -1) {
nr = read(f->fd, buffer, MAXBUFSIZ);
+ }
if (nr < 0)
return (-1);
@@ -196,9 +207,11 @@
grep_file_init(struct file *f)
{
+#ifndef WITHOUT_GZIP
if (filebehave == FILE_GZIP &&
(gzbufdesc = gzdopen(f->fd, "r")) == NULL)
goto error;
+#endif
#ifndef WITHOUT_BZ2
if (filebehave == FILE_BZIP &&
diff -r 5c52e9cc4eae -r b1f948739af9 usr.bin/grep/grep.c
--- a/usr.bin/grep/grep.c Sun Aug 12 09:02:02 2018 +0000
+++ b/usr.bin/grep/grep.c Sun Aug 12 09:03:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: grep.c,v 1.14 2018/08/12 07:53:19 christos Exp $ */
+/* $NetBSD: grep.c,v 1.15 2018/08/12 09:03:21 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.14 2018/08/12 07:53:19 christos Exp $");
+__RCSID("$NetBSD: grep.c,v 1.15 2018/08/12 09:03:21 christos Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -170,7 +170,9 @@
struct option long_options[] =
{
{"binary-files", required_argument, NULL, BIN_OPT},
+#ifndef WITHOUT_GZIP
{"decompress", no_argument, NULL, DECOMPRESS_OPT},
+#endif
{"help", no_argument, NULL, HELP_OPT},
{"mmap", no_argument, NULL, MMAP_OPT},
{"line-buffered", no_argument, NULL, LINEBUF_OPT},
@@ -340,6 +342,7 @@
case 'g':
grepbehave = GREP_BASIC;
break;
+#ifndef WITHOUT_GZIP
case 'z':
filebehave = FILE_GZIP;
switch(__progname[1]) {
@@ -354,6 +357,7 @@
break;
}
break;
+#endif
}
lastc = '\0';
@@ -600,9 +604,11 @@
strcasecmp("no", optarg) != 0)
errx(2, getstr(3), "--color");
break;
+#ifndef WITHOUT_GZIP
case DECOMPRESS_OPT:
filebehave = FILE_GZIP;
break;
+#endif
case LABEL_OPT:
label = optarg;
break;
diff -r 5c52e9cc4eae -r b1f948739af9 usr.bin/grep/grep.h
--- a/usr.bin/grep/grep.h Sun Aug 12 09:02:02 2018 +0000
+++ b/usr.bin/grep/grep.h Sun Aug 12 09:03:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: grep.h,v 1.9 2018/08/12 07:53:19 christos Exp $ */
+/* $NetBSD: grep.h,v 1.10 2018/08/12 09:03:21 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 $ */
@@ -36,7 +36,9 @@
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
+#ifndef WITHOUT_GZIP
#include <zlib.h>
+#endif
#ifdef WITHOUT_NLS
#define getstr(n) errstr[n]
Home |
Main Index |
Thread Index |
Old Index