fix pattern compiler

This commit is contained in:
c9s 2014-06-02 01:05:57 +08:00
parent da2f2311c9
commit 39fc24e3fa
2 changed files with 3 additions and 5 deletions

View file

@ -163,9 +163,6 @@ int r3_tree_compile_patterns(node * n, char **errstr) {
p = cpat;
strncat(p, "^", 1);
p++;
edge *e = NULL;
int opcode_cnt = 0;
for ( int i = 0 ; i < n->edge_len ; i++ ) {
@ -179,7 +176,8 @@ int r3_tree_compile_patterns(node * n, char **errstr) {
char * slug_pat = slug_compile(e->pattern, e->pattern_len);
strcat(p, slug_pat);
} else {
strncat(p++,"(", 1);
strncat(p,"^(", 2);
p += 2;
strncat(p, e->pattern, e->pattern_len);
p += e->pattern_len;

View file

@ -88,7 +88,7 @@ START_TEST (test_slug_count)
ck_assert_int_eq( slug_count(pattern, strlen(pattern), NULL), 2 );
char * pattern2 = "/user/{name:\\d{3}}/to/{id}";
ck_assert_int_eq( slug_count(pattern2, strlen(pattern), NULL), 2 );
ck_assert_int_eq( slug_count(pattern2, strlen(pattern2), NULL), 2 );
}
END_TEST