Refactoring match function
This commit is contained in:
parent
2381f54dc4
commit
9c53003871
2 changed files with 15 additions and 7 deletions
12
src/node.c
12
src/node.c
|
@ -226,13 +226,13 @@ node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry) {
|
||||||
// info("try matching: %s\n", path);
|
// info("try matching: %s\n", path);
|
||||||
|
|
||||||
edge *e;
|
edge *e;
|
||||||
|
int rc;
|
||||||
|
int i;
|
||||||
|
|
||||||
// if the pcre_pattern is found, and the pointer is not NULL, then it's
|
// 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
|
// pcre pattern node, we use pcre_exec to match the nodes
|
||||||
if (n->pcre_pattern) {
|
if (n->pcre_pattern) {
|
||||||
info("pcre matching %s on %s\n", n->combined_pattern, path);
|
info("pcre matching %s on %s\n", n->combined_pattern, path);
|
||||||
int rc;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
rc = pcre_exec(
|
rc = pcre_exec(
|
||||||
n->pcre_pattern, /* the compiled pattern */
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = r3_node_find_edge_str(n, path, path_len);
|
if ( (e = r3_node_find_edge_str(n, path, path_len)) != NULL ) {
|
||||||
if (e) {
|
|
||||||
int restlen = path_len - e->pattern_len;
|
int restlen = path_len - e->pattern_len;
|
||||||
if(restlen) {
|
if(restlen > 0) {
|
||||||
return r3_tree_match(e->child, path + e->pattern_len, restlen, entry);
|
return r3_tree_match(e->child, path + e->pattern_len, restlen, entry);
|
||||||
} else {
|
|
||||||
return e->child;
|
|
||||||
}
|
}
|
||||||
|
return e->child;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,3 +33,13 @@
|
||||||
1400244914,6346830.19
|
1400244914,6346830.19
|
||||||
1400244932,6610181.08
|
1400244932,6610181.08
|
||||||
1400245102,6404550.11
|
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
|
||||||
|
|
|
Loading…
Reference in a new issue