Mercurial > hg > Applications > Grep
view regexParser/grepWalk.cc @ 242:6aebc4d7dd75
fix condition generateSequentialSearch
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 21 Jan 2016 16:12:10 +0900 |
parents | b809e7b62986 |
children | e51cac73e42a |
line wrap: on
line source
#include <stdio.h> #include "grepWalk.h" #include "subsetConstruction.h" void grepMatch(TransitionGeneratorPtr tg,Buffer buff); void grep(TransitionGeneratorPtr tg,Buffer buff); void grepSkip(TransitionGeneratorPtr tg,Buffer buff); void grepMatch(TransitionGeneratorPtr tg,Buffer buff) { fwrite(buff.matchBegin,buff.buffptr-buff.matchBegin,1,stdout); puts("\n"); grepSkip(tg,buff); } void grep(TransitionGeneratorPtr tg,Buffer buff,unsigned long d) { unsigned char c = *buff.buffptr++; if (c=='\0') return; StatePtr state = tg->stateList; while (state->bitState.bitContainer != d) state = state->next; // 配列へのアクセスへ変更 CharClassWalkerPtr ccw = createCharClassWalker(state->cc); CharClassPtr cc = NULL; bool found = false; while (hasNext(ccw)) { cc = getNext(ccw); unsigned long begin = cc->cond.range.begin; unsigned long end = cc->cond.range.end; if (begin == end) { if (c == begin) found = true; else found = false; } else { if (c < begin) found = false; else if (c < end) found = true; } if (found == true) break; } if (found == false) { grepSkip(tg,buff); } else if (found == true && (cc->nextState.bitContainer | 2)) { // Accept grepMatch(tg,buff); } else { grep(tg,buff,cc->nextState.bitContainer); } } void grepSkip(TransitionGeneratorPtr tg,Buffer buff) { buff.matchBegin = buff.buffptr; grep(tg,buff,1); // 1 is initState } void grepWalk(TransitionGeneratorPtr tg, Buffer buff) { grepSkip(tg,buff); }