# HG changeset patch
# User Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
# Date 1448000349 -32400
# Node ID 6401c708f5ddb35159863d2017360619c0b97ce0
# Parent  70069d4647a053a13759a841e38d19a4b50d563f
fix printBitVectorList (print Loop when include asterisk node)

diff -r 70069d4647a0 -r 6401c708f5dd c/regexParser/bitVector.h
--- a/c/regexParser/bitVector.h	Thu Nov 19 17:48:36 2015 +0900
+++ b/c/regexParser/bitVector.h	Fri Nov 20 15:19:09 2015 +0900
@@ -8,4 +8,6 @@
     BitVectorPtr bi;
     bitVectorList* initBvl;
     bitVectorList* next[256];
+    bool isLoopAnker;
+    bool isLoop;
 }BitVectorList, *BitVectorListPtr;
diff -r 70069d4647a0 -r 6401c708f5dd c/regexParser/createBitVectorList.cc
--- a/c/regexParser/createBitVectorList.cc	Thu Nov 19 17:48:36 2015 +0900
+++ b/c/regexParser/createBitVectorList.cc	Fri Nov 20 15:19:09 2015 +0900
@@ -62,38 +62,43 @@
             }
             printf("input char : %c\n",i);
             printf("next state : ");bitPrint(bvl->next[i]->bi);
+            bvl->isLoop = bvl->isLoopAnker;
         }
     }
 
     for (int i = 0; i < 256; i++) {
-        if (bvl->next[i] != NULL) {
+        if ((bvl->next[i] != NULL) && !(bvl->isLoop && bvl->isLoopAnker)) {
+        // if ((bvl->next[i] != NULL) ) {
             printBitVectorList(bvl->next[i]);
         }
     }
 }
 
-BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr) {
+BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr, bool &fromAsterisk) {
     bool leftIsOr, rightIsOr;
     if (n->Value.character == '*') {
-        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr);
+        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk);
         unsigned char repertChar = 0;
         for (int i = 0; i < 256; i++) {
             if (prev->next[i] != NULL) repertChar = i;
         }
-        setNextBitVectorList(repertChar, prev->next[repertChar], bvl); // here
+        setNextBitVectorList(repertChar, bvl, prev->next[repertChar]); // here
+        bvl->isLoopAnker = true;
+        fromAsterisk = true;
+
         return prev;
     } else if (n->Value.character == '|') {
-        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr);
+        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk);
         setNextBitVectorList(n->left->Value.character, prev, bvl);
-        bvl = descendTreeNode(n->right, bvl, prev, rightIsOr);
+        bvl = descendTreeNode(n->right, bvl, prev, rightIsOr, fromAsterisk);
         setNextBitVectorList(n->right->Value.character, prev, bvl);
         fromOr = true;
         return prev;
     } else if (n->Value.character == '+') {
-        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr);
+        bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk);
         setNextBitVectorList(n->left->Value.character, prev, bvl);
         prev = bvl;
-        bvl = descendTreeNode(n->right, bvl, prev, rightIsOr);
+        bvl = descendTreeNode(n->right, bvl, prev, rightIsOr, fromAsterisk);
 
         if (leftIsOr){
             for (int i = 0; i < 256; i++)
@@ -122,7 +127,8 @@
 BitVectorListPtr createBitVectorList(NodePtr n) {
     BitVectorListPtr bvl = initBitVector();
     bool fromOr = false;
-    descendTreeNode(n, bvl, bvl, fromOr);
+    bool fromAsterisk = false;
+    descendTreeNode(n, bvl, bvl, fromOr, fromAsterisk);
     printBitVectorList(bvl);
     return bvl;
 }