diff --git a/bench_str.csv b/bench_str.csv index fc11938..c4b7ce4 100644 --- a/bench_str.csv +++ b/bench_str.csv @@ -451,3 +451,8 @@ 1400815975,11316714.26,2165050.14,55188.21 1400815990,10826986.93,1780938.43,55188.21 1400816005,10584527.76,1707721.44,55924.05 +1400816427,9376611.56,2006568.41,53092.46 +1400816438,9096902.53,2108994.21,59074.70 +1400816448,9260790.48,2131479.91,55188.21 +1400816458,9303957.38,2110797.39,55924.05 +1400816525,9330370.85,1985782.06,59074.70 diff --git a/src/node.c b/src/node.c index 28e1920..5a6ad50 100644 --- a/src/node.c +++ b/src/node.c @@ -260,11 +260,14 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e edge *e; int rc; int i; + int ov_cnt; // if the pcre_pattern is found, and the pointer is not NULL, then it's // pcre pattern node, we use pcre_exec to match the nodes if (n->pcre_pattern) { info("pcre matching %s on %s\n", n->combined_pattern, path); + ov_cnt = (1 + n->edge_len) * 3; + int ov[ ov_cnt ]; rc = pcre_exec( n->pcre_pattern, /* the compiled pattern */ @@ -273,8 +276,8 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e path_len, /* the length of the subject */ 0, /* start at offset 0 in the subject */ 0, /* default options */ - n->ov, /* output vector for substring information */ - n->ov_cnt); /* number of elements in the output vector */ + ov, /* output vector for substring information */ + ov_cnt); /* number of elements in the output vector */ // info("rc: %d\n", rc ); if (rc < 0) { @@ -293,12 +296,12 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e for (i = 1; i < rc; i++) { - char *substring_start = path + n->ov[2*i]; - int substring_length = n->ov[2*i+1] - n->ov[2*i]; + char *substring_start = path + ov[2*i]; + int substring_length = ov[2*i+1] - ov[2*i]; // info("%2d: %.*s\n", i, substring_length, substring_start); if ( substring_length > 0) { - int restlen = path_len - n->ov[1]; // fully match to the end + int restlen = path_len - ov[1]; // fully match to the end // info("matched item => restlen:%d edges:%d i:%d\n", restlen, n->edge_len, i); e = n->edges[i - 1]; @@ -311,7 +314,7 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e return e->child && e->child->endpoint > 0 ? e->child : NULL; } // get the length of orginal string: $0 - return r3_tree_matchl( e->child, path + (n->ov[1] - n->ov[0]), restlen, entry); + return r3_tree_matchl( e->child, path + (ov[1] - ov[0]), restlen, entry); } } // does not match diff --git a/tests/Makefile.am b/tests/Makefile.am index 8edfa58..dce7b05 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,6 @@ noinst_HEADERS = \ $(NULL) dist_noinst_DATA = \ - bench_str.csv \ $(NULL) if USE_JEMALLOC