Rename compile_slug to slug_compile
This commit is contained in:
parent
99819c4bbb
commit
85001c6327
5 changed files with 10 additions and 9 deletions
|
@ -12,7 +12,7 @@
|
|||
|
||||
int slug_count(char * p, int len);
|
||||
|
||||
char * compile_slug(char * str, int len);
|
||||
char * slug_compile(char * str, int len);
|
||||
|
||||
bool contains_slug(char * str);
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ void r3_tree_compile_patterns(node * n) {
|
|||
for ( int i = 0 ; i < n->edge_len ; i++ ) {
|
||||
e = n->edges[i];
|
||||
if ( e->has_slug ) {
|
||||
char * slug_pat = compile_slug(e->pattern, e->pattern_len);
|
||||
char * slug_pat = slug_compile(e->pattern, e->pattern_len);
|
||||
strcat(p, slug_pat);
|
||||
} else {
|
||||
strncat(p++,"(", 1);
|
||||
|
|
|
@ -122,7 +122,7 @@ char * find_slug_pattern(char *s1, int *len) {
|
|||
/**
|
||||
* @param char * sep separator
|
||||
*/
|
||||
char * compile_slug(char * str, int len)
|
||||
char * slug_compile(char * str, int len)
|
||||
{
|
||||
char *s1 = NULL, *o = NULL;
|
||||
char *pat = NULL;
|
||||
|
|
|
@ -385,3 +385,4 @@
|
|||
1400593210,13568445.16
|
||||
1400593219,13704926.07
|
||||
1400599508,13991454.07
|
||||
1400599553,13826120.84
|
||||
|
|
|
|
@ -12,19 +12,19 @@
|
|||
#include "r3_str.h"
|
||||
#include "str_array.h"
|
||||
|
||||
START_TEST (test_compile_slug)
|
||||
START_TEST (test_slug_compile)
|
||||
{
|
||||
char * path = "/user/{id}";
|
||||
ck_assert_str_eq( compile_slug(path, strlen(path) ) , "/user/([^/]+)" );
|
||||
ck_assert_str_eq( slug_compile(path, strlen(path) ) , "/user/([^/]+)" );
|
||||
|
||||
char * path2 = "/what/{id}-foo";
|
||||
ck_assert_str_eq( compile_slug(path2, strlen(path2) ) , "/what/([^/]+)-foo" );
|
||||
ck_assert_str_eq( slug_compile(path2, strlen(path2) ) , "/what/([^/]+)-foo" );
|
||||
|
||||
char * path3 = "-{id}";
|
||||
ck_assert_str_eq(compile_slug(path3, strlen(path3)), "-([^/]+)" );
|
||||
ck_assert_str_eq(slug_compile(path3, strlen(path3)), "-([^/]+)" );
|
||||
|
||||
char * path4 = "-{idx:\\d{3}}";
|
||||
ck_assert_str_eq(compile_slug(path4, strlen(path4)), "-(\\d{3})" );
|
||||
ck_assert_str_eq(slug_compile(path4, strlen(path4)), "-(\\d{3})" );
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -98,7 +98,7 @@ Suite* r3_suite (void) {
|
|||
tcase_add_test(tcase, test_find_slug_placeholder);
|
||||
tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug);
|
||||
tcase_add_test(tcase, test_slug_count);
|
||||
tcase_add_test(tcase, test_compile_slug);
|
||||
tcase_add_test(tcase, test_slug_compile);
|
||||
|
||||
suite_add_tcase(suite, tcase);
|
||||
return suite;
|
||||
|
|
Loading…
Reference in a new issue