Rename count_slug to slug_count

This commit is contained in:
c9s 2014-05-20 23:21:15 +08:00
parent eb81c1cc0b
commit 26c7e8896e
4 changed files with 7 additions and 7 deletions

View file

@ -14,7 +14,7 @@ int strndiff(char * d1, char * d2, unsigned int n);
int strdiff(char * d1, char * d2);
int count_slug(char * p, int len);
int slug_count(char * p, int len);
char * compile_slug(char * str, int len);

View file

@ -421,7 +421,7 @@ node * _r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route
// common prefix not found, insert a new edge for this pattern
if ( prefix_len == 0 ) {
// there are two more slugs, we should break them into several parts
if ( count_slug(path, path_len) > 1 ) {
if ( slug_count(path, path_len) > 1 ) {
int slug_len;
char *p = find_slug_placeholder(path, &slug_len);

View file

@ -35,7 +35,7 @@ int strdiff(char * d1, char * d2) {
/**
* provide a quick way to count slugs, simply search for '{'
*/
int count_slug(char * p, int len) {
int slug_count(char * p, int len) {
int s = 0;
int lev = 0;
while( len-- ) {

View file

@ -69,14 +69,14 @@ START_TEST (test_inside_slug)
}
END_TEST
START_TEST (test_count_slug)
START_TEST (test_slug_count)
{
int slug_len = 0;
char * pattern = "/user/{name:\\s+}/to/{id}";
ck_assert_int_eq( count_slug(pattern, strlen(pattern) ), 2 );
ck_assert_int_eq( slug_count(pattern, strlen(pattern) ), 2 );
char * pattern2 = "/user/{name:\\d{3}}/to/{id}";
ck_assert_int_eq( count_slug(pattern2, strlen(pattern) ), 2 );
ck_assert_int_eq( slug_count(pattern2, strlen(pattern) ), 2 );
}
END_TEST
@ -97,7 +97,7 @@ Suite* r3_suite (void) {
tcase_add_test(tcase, test_find_slug_pattern);
tcase_add_test(tcase, test_find_slug_placeholder);
tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug);
tcase_add_test(tcase, test_count_slug);
tcase_add_test(tcase, test_slug_count);
tcase_add_test(tcase, test_compile_slug);
suite_add_tcase(suite, tcase);