From 40fa19002ab6c47646729d259b6a12abc3c223b4 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 1 Jun 2014 02:56:29 +0800 Subject: [PATCH] Add const for slug_compile --- include/r3_str.h | 6 +++--- src/str.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/r3_str.h b/include/r3_str.h index 371451c..36be184 100644 --- a/include/r3_str.h +++ b/include/r3_str.h @@ -12,13 +12,13 @@ int slug_count(const char * p, int len); -char * slug_compile(char * str, int len); +char * slug_compile(const char * str, int len); bool contains_slug(const char * str); -char * slug_find_pattern(char *s1, int *len); +char * slug_find_pattern(const char *s1, int *len); -char * slug_find_placeholder(char *s1, int *len); +char * slug_find_placeholder(const char *s1, int *len); char * inside_slug(const char * needle, int needle_len, char *offset); diff --git a/src/str.c b/src/str.c index bcd6540..3d97d19 100644 --- a/src/str.c +++ b/src/str.c @@ -78,7 +78,7 @@ char * inside_slug(const char * needle, int needle_len, char *offset) { s1--; } - char * end = needle + needle_len; + const char * end = needle + needle_len; while( (s2 + 1) < end ) { if ( *s2 == '}' ) { found_s2 = 1; @@ -92,7 +92,7 @@ char * inside_slug(const char * needle, int needle_len, char *offset) { return NULL; } -char * slug_find_placeholder(char *s1, int *len) { +char * slug_find_placeholder(const char *s1, int *len) { char *c; char *s2; int cnt = 0; @@ -124,7 +124,7 @@ char * slug_find_placeholder(char *s1, int *len) { /** * given a slug string, duplicate the pattern string of the slug */ -char * slug_find_pattern(char *s1, int *len) { +char * slug_find_pattern(const char *s1, int *len) { char *c; char *s2; int cnt = 1; @@ -153,7 +153,7 @@ char * slug_find_pattern(char *s1, int *len) { /** * @param char * sep separator */ -char * slug_compile(char * str, int len) +char * slug_compile(const char * str, int len) { char *s1 = NULL, *o = NULL; char *pat = NULL;