diff options
author | Ed Maste <emaste@FreeBSD.org> | 2017-05-26 02:30:26 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2017-05-26 02:30:26 +0000 |
commit | 8bf4606408257f6e6eb440f169c83e6707049e3b (patch) | |
tree | 168c293501bda10b1890f90f56cadfbcb9188f05 /usr.bin/grep/util.c | |
parent | 052311172549357d2a7949ea0863cb4dd96ff001 (diff) | |
download | src-8bf4606408257f6e6eb440f169c83e6707049e3b.tar.gz src-8bf4606408257f6e6eb440f169c83e6707049e3b.zip |
bsdgrep: correct assumptions to prepare for chunking
Correct a couple of minor BSD grep assumptions that are valid for line
processing but not future chunk-based processing.
Submitted by: Kyle Evans <kevans91@ksu.edu>
Reviewed by: bapt, cem
Differential Revision: https://reviews.freebsd.org/D10824
Notes
Notes:
svn path=/head/; revision=318914
Diffstat (limited to 'usr.bin/grep/util.c')
-rw-r--r-- | usr.bin/grep/util.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 7b0a50b1b8af..6d20ef35454e 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -61,7 +61,7 @@ static bool first_match = true; * other useful bits */ struct parsec { - regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ + regmatch_t matches[MAX_MATCHES]; /* Matches made */ struct str ln; /* Current line */ size_t lnstart; /* Position in line */ size_t matchidx; /* Latest match index */ @@ -295,7 +295,7 @@ procfile(const char *fn) /* Print the matching line, but only if not quiet/binary */ if (t == 0 && printmatch) { printline(&pc, ':'); - while (pc.matchidx >= MAX_LINE_MATCHES) { + while (pc.matchidx >= MAX_MATCHES) { /* Reset matchidx and try again */ pc.matchidx = 0; if (procline(&pc) == 0) @@ -401,7 +401,7 @@ procline(struct parsec *pc) lastmatches = 0; startm = matchidx; retry = 0; - if (st > 0) + if (st > 0 && pc->ln.dat[st - 1] != fileeol) leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ for (i = 0; i < patterns; i++) { @@ -483,7 +483,7 @@ procline(struct parsec *pc) } /* avoid excessive matching - skip further patterns */ if ((color == NULL && !oflag) || qflag || lflag || - matchidx >= MAX_LINE_MATCHES) { + matchidx >= MAX_MATCHES) { pc->lnstart = nst; lastmatches = 0; break; |