changeset 235:4aab1e93a971

fix condition grepWalk.cc
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Tue, 19 Jan 2016 17:16:37 +0900
parents df4d04b3c34a
children c90d155c1063
files regexParser/grepWalk.cc regexParser/main.cc
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/regexParser/grepWalk.cc	Tue Jan 19 14:52:33 2016 +0900
+++ b/regexParser/grepWalk.cc	Tue Jan 19 17:16:37 2016 +0900
@@ -15,6 +15,7 @@
 
 void grep(TransitionGeneratorPtr tg,Buffer buff,unsigned long d) {
     unsigned char c = *buff.buffptr++;
+    if (c=='\0') return;
     StatePtr state = tg->stateList;
     bool found = false;
 
@@ -25,8 +26,13 @@
         cc = getNext(ccw);
         unsigned long begin = cc->cond.range.begin;
         unsigned long end = cc->cond.range.end;
-        if (c < begin) found = false;
-        else if (c < end) found = true;
+        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;
     }
 
--- a/regexParser/main.cc	Tue Jan 19 14:52:33 2016 +0900
+++ b/regexParser/main.cc	Tue Jan 19 17:16:37 2016 +0900
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include "regexParser.h"
 #include "subsetConstruction.h"
 #include "node.h"
@@ -58,6 +59,7 @@
         st_mmap_t st_mmap = createSt_mmap(filename,fd);
         Buffer buff = createBuffer(st_mmap);
         grepWalk(tgv.tg,buff);
+        close(fd);
     }
     return 0;
 }