Mercurial > hg > Applications > Grep
comparison regexParser/threadedSearch.cc @ 319:7b8234c090f7
bmSearch
author | mir3636 |
---|---|
date | Sun, 08 May 2016 22:53:20 +0900 |
parents | c9458ffecb87 |
children | da02a7258d54 |
comparison
equal
deleted
inserted
replaced
318:c9458ffecb87 | 319:7b8234c090f7 |
---|---|
18 fwrite(tsv.matchBegin,tsv.matchEnd-tsv.matchBegin,1,stdout); | 18 fwrite(tsv.matchBegin,tsv.matchEnd-tsv.matchBegin,1,stdout); |
19 puts(""); | 19 puts(""); |
20 tsv.matchEnd = NULL; | 20 tsv.matchEnd = NULL; |
21 } | 21 } |
22 tsv.matchBegin = tsv.buff.buffptr; // next char may be matchBegin | 22 tsv.matchBegin = tsv.buff.buffptr; // next char may be matchBegin |
23 // if possible use bmsearch | |
24 while (tsv.buff.buffptr < tsv.buff.buffend) { | |
25 long skip = tsv.tg->maxWordLen; | |
26 for (int k = 0; k < tsv.current->ccvSize; k++) { | |
27 CCVPtr ccv = &tsv.current->ccv[k]; | |
28 if (ccv.w.word) { | |
29 int i = ccv.w.length - 1; | |
30 while (tsv.buff.buffptr[i] == ccv.w.word[i]) { | |
31 if (i == 0) { | |
32 if (ccv->tState) { | |
33 tsv.current = ccv->tState; | |
34 } else { | |
35 tsv.current = nextTState(ccv->state,tsv.tg); | |
36 ccv->tState = tsv.current; | |
37 } | |
38 tsv.buff.buffptr += ccv.w.length - 1; | |
39 return tsv; | |
40 } | |
41 --i; | |
42 } | |
43 skip = min(skip,max(ccv.w.bm->skip[tsv.buff.buffptr[i]],ccv.w.length - i)); | |
44 } | |
45 } | |
46 tsv.buff.buffptr += skip; | |
47 } | |
23 return tsv; | 48 return tsv; |
24 } | 49 } |
25 | 50 |
26 static | 51 static |
27 TSValue stateMatch(TSValue tsv) { | 52 TSValue stateMatch(TSValue tsv) { |