diff options
author | Elliott Hughes <enh@google.com> | 2019-03-29 13:39:41 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-29 13:39:41 -0700 |
commit | d4952191e4a16a7c29e0b2952d71fd86334bf48c (patch) | |
tree | 818308423a4b5cb604e41b2bba846102949d6e3a /toolbox/upstream-netbsd/usr.bin/grep/grep.c | |
parent | f33436d7208e35f640d058f6cf9a1ca8b71d1849 (diff) | |
parent | 0b2474d84fba8c038d174ee13022d0234e2d1f1e (diff) |
Merge "BSD grep: sync with upstream." am: a42823b264 am: 1a420368d8
am: 0b2474d84f
Change-Id: I02cc77ba673fd298623f44164da7b2b0957d9000
Diffstat (limited to 'toolbox/upstream-netbsd/usr.bin/grep/grep.c')
-rw-r--r-- | toolbox/upstream-netbsd/usr.bin/grep/grep.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/toolbox/upstream-netbsd/usr.bin/grep/grep.c b/toolbox/upstream-netbsd/usr.bin/grep/grep.c index 1ea6ed3aad..bad2a7398a 100644 --- a/toolbox/upstream-netbsd/usr.bin/grep/grep.c +++ b/toolbox/upstream-netbsd/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $NetBSD: grep.c,v 1.12 2014/07/11 16:30:45 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.12 2014/07/11 16:30:45 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 @@ static const char optstr[] = 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}, @@ -197,7 +199,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'}, @@ -338,6 +342,7 @@ main(int argc, char *argv[]) case 'g': grepbehave = GREP_BASIC; break; +#ifndef WITHOUT_GZIP case 'z': filebehave = FILE_GZIP; switch(__progname[1]) { @@ -352,6 +357,7 @@ main(int argc, char *argv[]) break; } break; +#endif } lastc = '\0'; @@ -491,9 +497,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; @@ -596,9 +604,11 @@ main(int argc, char *argv[]) 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; @@ -679,8 +689,13 @@ main(int argc, char *argv[]) } } - if (lbflag) + if (lbflag) { +#ifdef _IOLBF + setvbuf(stdout, NULL, _IOLBF, 0); +#else setlinebuf(stdout); +#endif + } if ((aargc == 0 || aargc == 1) && !Hflag) hflag = true; |