From 9d153cc185b4e2327a4aabe645cf1fabd3b4f21b Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 5 Feb 2018 18:13:57 +0100 Subject: Massive simplification of functions hooking --- src/sp_pcre_compat.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src/sp_pcre_compat.c') diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c index 42a11cb..c3f1d86 100644 --- a/src/sp_pcre_compat.c +++ b/src/sp_pcre_compat.c @@ -2,38 +2,40 @@ #include "sp_pcre_compat.h" -sp_pcre* sp_pcre_compile(const char *const pattern) { - sp_pcre* ret = NULL; - const char *pcre_error = NULL; +sp_pcre* sp_pcre_compile(const char* const pattern) { + sp_pcre* ret = NULL; + const char* pcre_error = NULL; #ifdef SP_HAS_PCRE2 - int errornumber; - PCRE2_SIZE erroroffset; - ret = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errornumber, &erroroffset, NULL); + int errornumber; + PCRE2_SIZE erroroffset; + ret = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, + PCRE2_CASELESS, &errornumber, &erroroffset, NULL); #else - int erroroffset; - ret = pcre_compile(pattern, PCRE_CASELESS, &pcre_error, &erroroffset, NULL); + int erroroffset; + ret = pcre_compile(pattern, PCRE_CASELESS, &pcre_error, &erroroffset, NULL); #endif - - if (NULL == ret) { - sp_log_err("config", "Failed to compile '%s': %s on line %zu.", pattern, - pcre_error, sp_line_no); - } - return ret; + + if (NULL == ret) { + sp_log_err("config", "Failed to compile '%s': %s on line %zu.", pattern, + pcre_error, sp_line_no); + } + return ret; } -bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len) { +bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, + size_t len) { int ret = 0; assert(NULL != regexp); assert(NULL != str); #ifdef SP_HAS_PCRE2 - pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(regexp, NULL); - ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); + pcre2_match_data* match_data = + pcre2_match_data_create_from_pattern(regexp, NULL); + ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); #else int vec[30]; - ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, - sizeof(vec) / sizeof(int)); + ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, sizeof(vec) / sizeof(int)); #endif if (ret < 0) { -- cgit v1.3