update error code for compile function

This commit is contained in:
c9s 2014-06-01 02:08:16 +08:00
parent 1a4eb14a05
commit f670f08639
2 changed files with 20 additions and 9 deletions

View file

@ -57,7 +57,8 @@ r3_tree_insert_pathl(n ,"/post/{id}", strlen("/post/{id}") , &route_data );
r3_tree_insert_pathl(n, "/user/{id:\\d+}", strlen("/user/{id:\\d+}"), &route_data );
// let's compile the tree!
r3_tree_compile(n);
char *errstr = NULL;
int errno = r3_tree_compile(n, &errstr);
// dump the compiled tree
@ -108,7 +109,9 @@ int route_data = 3;
// insert the route path into the router tree
r3_tree_insert_routel(n, METHOD_GET | METHOD_POST, "/blog/post", sizeof("/blog/post") - 1, &route_data );
r3_tree_compile(n);
char *errstr = NULL;
int errno;
errno = r3_tree_compile(n, &errstr);
// in your http server handler

View file

@ -55,11 +55,11 @@ static node * create_simple_str_tree() {
START_TEST (test_compile)
{
str_array *t;
node * n = create_simple_str_tree();
node *n;
node *m;
edge *e ;
edge *e;
n = create_simple_str_tree();
#ifdef DEBUG
r3_tree_dump(n, 0);
@ -134,7 +134,10 @@ START_TEST (test_pcre_patterns_insert_2)
r3_tree_insert_path(n, "/zoo", NULL);
r3_tree_insert_path(n, "/foo", NULL);
r3_tree_insert_path(n, "/bar", NULL);
r3_tree_compile(n, NULL);
char *errstr = NULL;
r3_tree_compile(n, &errstr);
r3_tree_dump(n, 0);
node *matched;
matched = r3_tree_match(n, "/post/11/22", NULL);
@ -159,7 +162,10 @@ START_TEST (test_pcre_patterns_insert_3)
r3_tree_insert_path(n, "/foo", NULL);
r3_tree_insert_path(n, "/bar", NULL);
r3_tree_compile(n, NULL);
char *errstr = NULL;
r3_tree_compile(n, &errstr);
r3_tree_dump(n, 0);
node *matched;
@ -205,7 +211,9 @@ START_TEST (testr3_tree_insert_pathl)
r3_tree_insert_path(n, "/post/{handle}", NULL);
r3_tree_insert_path(n, "/post/{handle}-{id}", NULL);
r3_tree_compile(n, NULL);
char * errstr = NULL;
r3_tree_compile(n, &errstr);
#ifdef DEBUG
r3_tree_dump(n, 0);