Mercurial > hg > Applications > Grep
diff regexParser/cerium/CeriumMain.cc @ 292:868f01f1ba8e
maximum match
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 01 Feb 2016 21:52:57 +0900 |
parents | f2491681914e |
children | 948428caf616 |
line wrap: on
line diff
--- a/regexParser/cerium/CeriumMain.cc Mon Feb 01 12:20:16 2016 +0900 +++ b/regexParser/cerium/CeriumMain.cc Mon Feb 01 21:52:57 2016 +0900 @@ -30,21 +30,22 @@ static TSValue stateSkip(TSValue tsv) { tsv.current = tsv.tg->stateStart->tState; - tsv.buff.matchBegin = tsv.buff.buffptr; + if (tsv.matchEnd) { + ResultPtr r = NEW(Result); + r->continued = false; + r->begin = tsv.matchBegin; + r->end = tsv.buff.buffptr; + *tsv.blk->resultEnd = r; + r->next = NULL; + tsv.blk->resultEnd = &r->next; + tsv.matchEnd=NULL; + } return tsv; } static TSValue stateMatch(TSValue tsv) { - ResultPtr r = NEW(Result); - r->continued = false; - r->begin = tsv.buff.matchBegin; - r->end = tsv.buff.buffptr; - *tsv.resultEnd = r; - r->next = NULL; - tsv.resultEnd = &r->next; - tsv.buff.buffptr--; - tsv = stateSkip(tsv); + tsv.matchEnd = tsv.buff.buffptr; // next char of the match return tsv; } @@ -56,7 +57,7 @@ prev = r; break; } - fwrite(r->begin,r->end - r->begin-1,1,stdout); + fwrite(r->begin,r->end - r->begin,1,stdout); puts(""); } return prev;