diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-10-03 19:23:03 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-10-03 19:23:03 +0000 |
commit | 3061d292a889eed3e39bca845c7cb7ca03db2002 (patch) | |
tree | a3be9f2251fdc48c2c4821a6ee006508201ca174 /usr.bin/grep | |
parent | be1570cce7b30a560fbe463737aa530bcbb659ca (diff) |
Remove block based mmap optimization. There are newline problems
(PR 3940, 3941) which can be fixed, but if a match starts at the
end of a block and continues into the next block, no match will be
found. Measurements by millert@ showed that the improvements of
this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
Diffstat (limited to 'usr.bin/grep')
-rw-r--r-- | usr.bin/grep/grep.c | 7 | ||||
-rw-r--r-- | usr.bin/grep/grep.h | 5 | ||||
-rw-r--r-- | usr.bin/grep/mmfile.c | 22 | ||||
-rw-r--r-- | usr.bin/grep/util.c | 4 |
4 files changed, 8 insertions, 30 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 3f96ea62a4a..f416f15e9a2 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.30 2004/09/28 20:51:15 jmc Exp $ */ +/* $OpenBSD: grep.c,v 1.31 2004/10/03 19:23:02 otto Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -97,8 +97,6 @@ enum { int first; /* flag whether or not this is our first match */ int tail; /* lines left to print */ int lead; /* number of lines in leading context queue */ -int boleol; /* At least one pattern has a bol or eol */ -size_t maxPatternLen; /* Longest length of all patterns */ extern char *__progname; @@ -193,9 +191,6 @@ add_pattern(char *pat, size_t len) pattern[patterns][len] = '\0'; } ++patterns; - - if (len > maxPatternLen) - maxPatternLen = len; } static void diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h index eccb8800246..cd2ca511455 100644 --- a/usr.bin/grep/grep.h +++ b/usr.bin/grep/grep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.h,v 1.11 2004/05/07 14:51:42 millert Exp $ */ +/* $OpenBSD: grep.h,v 1.12 2004/10/03 19:23:02 otto Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -67,8 +67,7 @@ extern int Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag, Pflag, Sflag, Rflag, Zflag, bflag, cflag, hflag, iflag, lflag, nflag, qflag, sflag, vflag, wflag, xflag; -extern int binbehave, boleol; -extern size_t maxPatternLen; +extern int binbehave; extern int first, lead, matchall, patterns, tail; extern char **pattern; diff --git a/usr.bin/grep/mmfile.c b/usr.bin/grep/mmfile.c index 532ef7fae31..0f1af57cf13 100644 --- a/usr.bin/grep/mmfile.c +++ b/usr.bin/grep/mmfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmfile.c,v 1.8 2004/01/18 19:05:24 otto Exp $ */ +/* $OpenBSD: mmfile.c,v 1.9 2004/10/03 19:23:02 otto Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -38,7 +38,6 @@ #include "grep.h" #define MAX_MAP_LEN 1048576 -#define BLOCKSIZE 32768 mmf_t * mmopen(char *fn, char *mode) @@ -89,22 +88,9 @@ mmfgetln(mmf_t *mmf, size_t *l) if (mmf->ptr >= mmf->end) return NULL; - if ((lflag || qflag) && !wflag && !boleol) { - /* Find starting point to search. */ - if (mmf->ptr == mmf->base) - p = mmf->ptr; - else - p = mmf->ptr - maxPatternLen; - /* Move the start pointer ahead for next iteration */ - if (mmf->end - mmf->ptr > BLOCKSIZE) - mmf->ptr += BLOCKSIZE; - else - mmf->ptr = mmf->end; - } else { - for (p = mmf->ptr; mmf->ptr < mmf->end; ++mmf->ptr) - if (*mmf->ptr == '\n') - break; - } + for (p = mmf->ptr; mmf->ptr < mmf->end; ++mmf->ptr) + if (*mmf->ptr == '\n') + break; *l = mmf->ptr - p; ++mmf->ptr; diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index e06d8745724..f168fe5ae90 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.28 2004/09/16 00:20:32 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.29 2004/10/03 19:23:02 otto Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -292,7 +292,6 @@ fastcomp(fastgrep_t *fg, const char *pattern) eol++; fg->eol = 1; fg->patternLen--; - boleol = 1; } /* Remove beginning-of-line character ('^'). */ @@ -300,7 +299,6 @@ fastcomp(fastgrep_t *fg, const char *pattern) bol++; fg->bol = 1; fg->patternLen--; - boleol = 1; } /* Remove enclosing [[:<:]] and [[:>:]] (word match). */ |