diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-20 19:19:49 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-20 19:19:49 +0000 |
commit | 08e650ea2bf94699d9581cd5ee6be577fa6bc387 (patch) | |
tree | bdec721ccd2070da067ced60c664aa3968955de0 /usr.bin/grep | |
parent | c489022db00397c1a6671f0d328a85388288f1bc (diff) |
Close PR 3358 by changing the loop from do {} while -> for; tdeval@ OK
Diffstat (limited to 'usr.bin/grep')
-rw-r--r-- | usr.bin/grep/util.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index b19b571fc17..744a211d8ed 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.15 2003/07/10 19:16:22 dhartmei Exp $ */ +/* $OpenBSD: util.c,v 1.16 2003/07/20 19:19:48 millert Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -400,8 +400,8 @@ grep_search(fastgrep_t *fg, unsigned char *data, int dataLen, regmatch_t *pmatch } } else if (fg->reversedSearch) { /* Quick Search algorithm. */ - j = dataLen; - do { + for (j = dataLen; j >= fg->patternLen; + j -= fg->qsBc[data[j - fg->patternLen - 1]]) { if (grep_cmp(fg->pattern, data + j - fg->patternLen, fg->patternLen) == -1) { rtrnVal = 0; @@ -409,12 +409,7 @@ grep_search(fastgrep_t *fg, unsigned char *data, int dataLen, regmatch_t *pmatch pmatch->rm_eo = j; break; } - - /* Shift if within bounds, otherwise, we are done. */ - if (j - fg->patternLen - 1 < 0) - break; - j -= fg->qsBc[data[j - fg->patternLen - 1]]; - } while (j >= 0); + } } else { /* Quick Search algorithm. */ j = 0; |