Refactoring match function

This commit is contained in:
c9s 2014-05-16 21:02:02 +08:00
parent 2381f54dc4
commit 9c53003871
2 changed files with 15 additions and 7 deletions

View file

@ -226,13 +226,13 @@ node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry) {
// info("try matching: %s\n", path);
edge *e;
int rc;
int i;
// 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);
int rc;
int i;
rc = pcre_exec(
n->pcre_pattern, /* the compiled pattern */
@ -286,14 +286,12 @@ node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry) {
return NULL;
}
e = r3_node_find_edge_str(n, path, path_len);
if (e) {
if ( (e = r3_node_find_edge_str(n, path, path_len)) != NULL ) {
int restlen = path_len - e->pattern_len;
if(restlen) {
if(restlen > 0) {
return r3_tree_match(e->child, path + e->pattern_len, restlen, entry);
} else {
return e->child;
}
return e->child;
}
return NULL;
}

View file

@ -33,3 +33,13 @@
1400244914,6346830.19
1400244932,6610181.08
1400245102,6404550.11
1400245168,6085174.66
1400245176,6400679.76
1400245216,6416409.15
1400245227,6485899.37
1400245230,5862573.02
1400245233,6526163.60
1400245281,6205337.09
1400245289,6217947.43
1400245304,5527542.93
1400245311,6423151.81

1 1400242718 5649455.80
33 1400244914 6346830.19
34 1400244932 6610181.08
35 1400245102 6404550.11
36 1400245168 6085174.66
37 1400245176 6400679.76
38 1400245216 6416409.15
39 1400245227 6485899.37
40 1400245230 5862573.02
41 1400245233 6526163.60
42 1400245281 6205337.09
43 1400245289 6217947.43
44 1400245304 5527542.93
45 1400245311 6423151.81