From f670f08639d7028262b7142b06a31371effe72f9 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 1 Jun 2014 02:08:16 +0800 Subject: [PATCH] update error code for compile function --- README.md | 7 +++++-- tests/check_tree.c | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6fc241b..16315e0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tests/check_tree.c b/tests/check_tree.c index 49779a8..ee43441 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -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);