diff options
Diffstat (limited to 'src/sp_var_parser.c')
| -rw-r--r-- | src/sp_var_parser.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/sp_var_parser.c b/src/sp_var_parser.c index d0ae67c..330fa54 100644 --- a/src/sp_var_parser.c +++ b/src/sp_var_parser.c | |||
| @@ -20,26 +20,22 @@ static sp_list_node *parse_str_tokens(const char *str, const sp_conf_token token | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | static bool is_var_name_valid(const char *name) { | 22 | static bool is_var_name_valid(const char *name) { |
| 23 | static pcre *regexp_const = NULL; | 23 | static sp_pcre *regexp_const = NULL; |
| 24 | static pcre *regexp_var = NULL; | 24 | static sp_pcre *regexp_var = NULL; |
| 25 | const char *pcre_error; | ||
| 26 | int pcre_error_offset; | ||
| 27 | 25 | ||
| 28 | if (!name) { | 26 | if (!name) { |
| 29 | return false; | 27 | return false; |
| 30 | } | 28 | } |
| 31 | if (NULL == regexp_var || NULL == regexp_const) { | 29 | if (NULL == regexp_var || NULL == regexp_const) { |
| 32 | regexp_var = sp_pcre_compile(REGEXP_VAR, PCRE_CASELESS, &pcre_error, | 30 | regexp_var = sp_pcre_compile(REGEXP_VAR); |
| 33 | &pcre_error_offset, NULL); | 31 | regexp_const = sp_pcre_compile(REGEXP_CONST); |
| 34 | regexp_const = sp_pcre_compile(REGEXP_CONST, PCRE_CASELESS, &pcre_error, | ||
| 35 | &pcre_error_offset, NULL); | ||
| 36 | } | 32 | } |
| 37 | if (NULL == regexp_var || NULL == regexp_const) { | 33 | if (NULL == regexp_var || NULL == regexp_const) { |
| 38 | sp_log_err("config", "Could not compile regexp."); | 34 | sp_log_err("config", "Could not compile regexp."); |
| 39 | return false; | 35 | return false; |
| 40 | } | 36 | } |
| 41 | if (0 > sp_pcre_exec(regexp_var, NULL, name, strlen(name), 0, 0, NULL, 0) && | 37 | if ((false == sp_is_regexp_matching(regexp_var, name)) && |
| 42 | 0 > sp_pcre_exec(regexp_const, NULL, name, strlen(name), 0, 0, NULL, 0)) { | 38 | (false == sp_is_regexp_matching(regexp_const, name))) { |
| 43 | return false; | 39 | return false; |
| 44 | } | 40 | } |
| 45 | return true; | 41 | return true; |
