# HG changeset patch # User Masataka Kohagura # Date 1451296934 -32400 # Node ID 11b6332f0a423651c6ca59f80485a7e7e59d5d29 # Parent b0ae5273925cb00966bfba5c25568445f79a8291 fix tgv.tg->totalStateCount increment diff -r b0ae5273925c -r 11b6332f0a42 regexParser/subsetConstraction.cc --- a/regexParser/subsetConstraction.cc Mon Dec 28 16:42:02 2015 +0900 +++ b/regexParser/subsetConstraction.cc Mon Dec 28 19:02:14 2015 +0900 @@ -207,11 +207,11 @@ } CharClassPtr allocateCCState(CharClassPtr cc, TGValue tgv) { - if (cc->left != NULL) { + if (cc->left) { allocateCCState(cc->left,tgv); } cc->state = createCCState(cc,tgv); - if (cc->right != NULL) { + if (cc->right) { allocateCCState(cc->right,tgv); } return cc; @@ -219,14 +219,16 @@ StatePtr createState(TGValue tgv,NodePtr n) { StatePtr s = NEW(State); - s->stateNum = n->stateNum = ++tgv.tg->totalStateCount; + s->stateNum = n->stateNum = tgv.tg->totalStateCount; s->next = tgv.tg->stateList; tgv.tg->stateList = s; s->node = n; BitVector bi = createBitVector(n->stateNum); s->bitState = bi; if (n->cc) { - CharClassPtr cc = allocateCCState(n->cc,tgv); + allocateCCState(n->cc,tgv); + } else { + tgv.tg->totalStateCount++; } s->cc = n->cc; return s; @@ -267,7 +269,7 @@ tgv1.asterisk = false; n->stateNum = tgv.startState->stateNum; n->nextStateNum = tgv.endState->stateNum; - n->state = tgv.startState; + n->state = tgv.startState;; n->nextState = tgv.endState; return tgv1; } else { @@ -318,7 +320,7 @@ TransitionGeneratorPtr createTransitionGenerator() { TransitionGeneratorPtr tg = NEW(TransitionGenerator); - tg->totalStateCount = -1; + tg->totalStateCount = 0; tg->stack = NULL; tg->stateArray = NULL; tg->stateList = NULL; @@ -326,10 +328,11 @@ } TGValue createTGValue() { - TransitionGeneratorPtr tg = createTransitionGenerator(); TGValue tgv; + tgv.startState = NULL; + tgv.endState = NULL; tgv.asterisk = false; - tgv.tg = tg; + tgv.tg = createTransitionGenerator(); return tgv; } diff -r b0ae5273925c -r 11b6332f0a42 regexParser/test/ccMerge.cc --- a/regexParser/test/ccMerge.cc Mon Dec 28 16:42:02 2015 +0900 +++ b/regexParser/test/ccMerge.cc Mon Dec 28 19:02:14 2015 +0900 @@ -19,15 +19,15 @@ int main(int argc, char **argv) { - RegexInfo riRegex; + RegexInfo ri; NodePtr n = NULL; StatePtr s = NULL; TGValue tgv = createTGValue(); for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) { - riRegex.ptr = (unsigned char*)argv[i+1]; i++; - printf("regex : %s\n",riRegex.ptr); - NodePtr nMerge = regex(&riRegex); + ri.ptr = (unsigned char*)argv[i+1]; i++; + printf("regex : %s\n",ri.ptr); + NodePtr nMerge = regex(&ri); StatePtr sMerge = createState(tgv,nMerge); setState(sMerge->cc,sMerge->bitState); if (s == NULL) {