diff options
| author | jvoisin | 2018-02-05 17:27:45 +0100 |
|---|---|---|
| committer | GitHub | 2018-02-05 17:27:45 +0100 |
| commit | 4cbca117a3f2ef2d6695504970378ec4c483d19f (patch) | |
| tree | 2fe9d10ddf5fdff1c1c0f4cf0cf7cbb16d274e27 /src/sp_var_parser.c | |
| parent | f0a956e825a83ff3a58d4714a92fbb945f6c8841 (diff) | |
Compatibility layer for pcre2
This should close #129
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; |
