diff regexParser/cerium/ppe/Print.cc @ 281:b74e3b4b11d7

parallel search done
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Sun, 31 Jan 2016 18:28:58 +0900
parents 6cc1d9779f45
children 87a801c14117
line wrap: on
line diff
--- a/regexParser/cerium/ppe/Print.cc	Sun Jan 31 16:59:43 2016 +0900
+++ b/regexParser/cerium/ppe/Print.cc	Sun Jan 31 18:28:58 2016 +0900
@@ -20,13 +20,25 @@
     ResultPtr prev = NULL;
     for (int i = 0; i < out_task_num ; i++) {
         ResultPtr r = (ResultPtr)w->o_data[i*out_size+0];
+        if (r == NULL) {
+            prev = NULL;
+            continue;
+        }
         StatePtr blockEnd = (StatePtr)w->o_data[i*out_size+2];
         StatePtr blockBegin = (StatePtr)w->o_data[i*out_size+4]; // next Block's blockBegin.
-        if (prev && i != out_task_num-1) {
+        if (prev) {
+            if (i >= out_task_num) break; 
             // 最後のブロックでなく、前の blockEnd が state 1 でない場合)
+#if 0
+printf("task %d prev begin : %p r->begin : %p r->end : %p\n", i,prev->begin,r->begin,r->end);
+printf("blockBegin : %lx blockEnd : %lx : string ",blockBegin->bitState.bitContainer,blockEnd->bitState.bitContainer);
+fwrite(r->begin,r->end - r->begin-1,1,stdout);
+printf(" match %d\n", ((blockBegin->bitState.bitContainer & ~blockEnd->bitState.bitContainer)==0)? 1 : 0  );
+#endif
             if ((blockBegin->bitState.bitContainer & ~blockEnd->bitState.bitContainer)==0) {
                 // 前のブロックの matchBegin から最初 result の end までがマッチ
-                fwrite(prev->begin,r->end - prev->begin,1,stdout);
+                fwrite(prev->begin,r->end - prev->begin-1,1,stdout);
+                if (!r->continued) puts("");
             }
             r = r->next;
         }