From 973a2cb85cfeaa39843cd8791936142d419912a0 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 17 Nov 2015 21:17:18 +0800 Subject: [PATCH] Move private functions to private header files --- Makefile.am | 2 +- gen_route_tests.rb | 2 +- include/r3.h | 2 +- include/{r3_str.h => r3_slug.h} | 6 +++--- package.json | 2 +- src/edge.c | 2 +- src/node.c | 3 ++- src/slug.c | 2 +- src/slug.h | 4 ++-- src/str.c | 8 ++++---- src/token.c | 2 +- tests/bench.c | 2 +- tests/check_gvc.c | 2 +- tests/check_json.c | 2 +- tests/check_routes.c | 2 +- tests/check_slug.c | 2 +- tests/check_str_array.c | 2 +- tests/check_tree.c | 2 +- 18 files changed, 25 insertions(+), 24 deletions(-) rename include/{r3_str.h => r3_slug.h} (90%) diff --git a/Makefile.am b/Makefile.am index 5be955f..ba1e6aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ r3_include_HEADERS = \ include/r3.h \ include/r3_define.h \ include/r3_list.h \ - include/r3_str.h \ + include/r3_slug.h \ include/r3_gvc.h \ include/r3_json.h \ include/str_array.h \ diff --git a/gen_route_tests.rb b/gen_route_tests.rb index fbf7a20..ada5c4c 100644 --- a/gen_route_tests.rb +++ b/gen_route_tests.rb @@ -10,7 +10,7 @@ puts < #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" START_TEST (test_routes) diff --git a/include/r3.h b/include/r3.h index 3dc712c..9445beb 100644 --- a/include/r3.h +++ b/include/r3.h @@ -14,7 +14,7 @@ #include #include "r3_define.h" #include "str_array.h" -#include "r3_str.h" +#include "r3_slug.h" #ifdef __cplusplus extern "C" { diff --git a/include/r3_str.h b/include/r3_slug.h similarity index 90% rename from include/r3_str.h rename to include/r3_slug.h index f87f115..0f1a8eb 100644 --- a/include/r3_str.h +++ b/include/r3_slug.h @@ -4,8 +4,8 @@ * * Distributed under terms of the MIT license. */ -#ifndef R3_STR_H -#define R3_STR_H +#ifndef R3_SLUG_H +#define R3_SLUG_H #ifdef __cplusplus extern "C" { @@ -27,4 +27,4 @@ char * r3_inside_slug(const char * needle, int needle_len, char *offset, char ** } #endif -#endif /* !R3_STR_H */ +#endif /* !R3_SLUG_H */ diff --git a/package.json b/package.json index ff40218..061026a 100644 --- a/package.json +++ b/package.json @@ -5,5 +5,5 @@ "description": "high-performance path dispatching library", "keywords": ["path", "dispatch", "performance", "r3", "c9s"], "license": "MIT", - "src": ["3rdparty/zmalloc.c", "3rdparty/zmalloc.h", "include/r3.h", "include/r3.hpp", "include/r3_define.h", "include/r3_gvc.h", "include/r3_json.h", "include/r3_list.h", "include/r3_str.h", "include/str_array.h", "src/edge.c", "src/gvc.c", "src/json.c", "src/list.c", "src/match_entry.c", "src/node.c", "src/slug.c", "src/slug.h", "src/str.c", "src/token.c"] + "src": ["3rdparty/zmalloc.c", "3rdparty/zmalloc.h", "include/r3.h", "include/r3.hpp", "include/r3_define.h", "include/r3_gvc.h", "include/r3_json.h", "include/r3_list.h", "include/r3_slug.h", "include/str_array.h", "src/edge.c", "src/gvc.c", "src/json.c", "src/list.c", "src/match_entry.c", "src/node.c", "src/slug.c", "src/slug.h", "src/str.c", "src/token.c"] } diff --git a/src/edge.c b/src/edge.c index f254eec..7d7923e 100644 --- a/src/edge.c +++ b/src/edge.c @@ -16,7 +16,7 @@ // PCRE #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "slug.h" #include "zmalloc.h" diff --git a/src/node.c b/src/node.c index 07a9495..df217e6 100644 --- a/src/node.c +++ b/src/node.c @@ -9,8 +9,9 @@ #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "slug.h" +#include "str.h" #include "zmalloc.h" #ifdef __GNUC__ diff --git a/src/slug.c b/src/slug.c index fe31fcb..d6702c5 100644 --- a/src/slug.c +++ b/src/slug.c @@ -9,7 +9,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "slug.h" #include "zmalloc.h" diff --git a/src/slug.h b/src/slug.h index 89d4c18..fefafe7 100644 --- a/src/slug.h +++ b/src/slug.h @@ -4,8 +4,8 @@ * * Distributed under terms of the MIT license. */ -#ifndef R3_SLUG_H -#define R3_SLUG_H +#ifndef SLUG_H +#define SLUG_H typedef struct { /** diff --git a/src/str.c b/src/str.c index 826d797..435c376 100644 --- a/src/str.c +++ b/src/str.c @@ -10,7 +10,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "str.h" #include "slug.h" #include "zmalloc.h" @@ -141,10 +141,10 @@ char * r3_slug_find_pattern(const char *s1, int *len) { * given a slug string, duplicate the parameter name string of the slug */ char * r3_slug_find_name(const char *s1, int *len) { - char *c; - char *s2; + char * c; + char * s2; int cnt = 0; - c = s1; + c = (char*) s1; while(1) { if(*c == '{') cnt++; diff --git a/src/token.c b/src/token.c index e2d4391..093b32d 100644 --- a/src/token.c +++ b/src/token.c @@ -10,7 +10,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "str_array.h" #include "zmalloc.h" diff --git a/tests/bench.c b/tests/bench.c index 7f95ac4..2462174 100644 --- a/tests/bench.c +++ b/tests/bench.c @@ -12,7 +12,7 @@ #include /* va_list, va_start, va_arg, va_end */ #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" #include "bench.h" diff --git a/tests/check_gvc.c b/tests/check_gvc.c index 94f218e..368ea9e 100644 --- a/tests/check_gvc.c +++ b/tests/check_gvc.c @@ -10,7 +10,7 @@ #include #include "r3.h" #include "r3_gvc.h" -#include "r3_str.h" +#include "r3_slug.h" #include "bench.h" START_TEST (test_gvc_render_dot) diff --git a/tests/check_json.c b/tests/check_json.c index 8bd2cc4..1fa48fe 100644 --- a/tests/check_json.c +++ b/tests/check_json.c @@ -10,7 +10,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "r3_json.h" #include "zmalloc.h" diff --git a/tests/check_routes.c b/tests/check_routes.c index 60d6594..d3409ba 100644 --- a/tests/check_routes.c +++ b/tests/check_routes.c @@ -7,7 +7,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" START_TEST (test_routes) diff --git a/tests/check_slug.c b/tests/check_slug.c index b57c7b8..d85b6e9 100644 --- a/tests/check_slug.c +++ b/tests/check_slug.c @@ -9,7 +9,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" #include "slug.h" diff --git a/tests/check_str_array.c b/tests/check_str_array.c index 0c38851..4dbac5b 100644 --- a/tests/check_str_array.c +++ b/tests/check_str_array.c @@ -9,7 +9,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" START_TEST (test_str_array) diff --git a/tests/check_tree.c b/tests/check_tree.c index 8a9bd34..ddabb6e 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -4,7 +4,7 @@ #include #include #include "r3.h" -#include "r3_str.h" +#include "r3_slug.h" #include "zmalloc.h" #include "bench.h"