diff options
| author | jvoisin | 2017-10-31 18:08:09 +0100 |
|---|---|---|
| committer | GitHub | 2017-10-31 18:08:09 +0100 |
| commit | edfbc0752d37e27354d0d9565b1697e6fcb4d47d (patch) | |
| tree | a52d3cfab9afafe9359b7f7c2d970e8cd235c59b /src/sp_config_keywords.c | |
| parent | ee4f2e4a30f119b9348c02ac76185a54f5208e81 (diff) | |
Minor factorization of the keyword parsing code
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 416aaef..b1b22b5 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -182,36 +182,27 @@ int parse_disabled_functions(char *line) { | |||
| 182 | return ret; | 182 | return ret; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | if (df->value && df->value_r) { | 185 | #define MUTUALLY_EXCLUSIVE(X, Y, STR1, STR2) \ |
| 186 | sp_log_err("config", | 186 | if (X && Y) { \ |
| 187 | "Invalid configuration line: 'sp.disabled_functions%s':" | 187 | sp_log_err("config", \ |
| 188 | "'.value' and '.regexp' are mutually exclusives on line %zu.", | 188 | "Invalid configuration line: 'sp.disabled_functions%s': " \ |
| 189 | line, sp_line_no); | 189 | "'.%s' and '.%s' are mutually exclusive on line %zu.", \ |
| 190 | return -1; | 190 | line, STR1, STR2, sp_line_no); \ |
| 191 | } else if (df->r_function && df->function) { | 191 | return 1;\ |
| 192 | sp_log_err("config", | 192 | } |
| 193 | "Invalid configuration line: 'sp.disabled_functions%s': " | 193 | |
| 194 | "'.r_function' and '.function' are mutually exclusive on line %zu.", | 194 | MUTUALLY_EXCLUSIVE(df->value, df->value_r, "value", "regexp"); |
| 195 | line, sp_line_no); | 195 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function"); |
| 196 | return -1; | 196 | MUTUALLY_EXCLUSIVE(df->filename, df->r_filename, "r_filename", "filename"); |
| 197 | } else if (df->r_filename && df->filename) { | 197 | MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret"); |
| 198 | sp_log_err("config", | 198 | #undef MUTUALLY_EXCLUSIVE |
| 199 | "Invalid configuration line: 'sp.disabled_functions%s':" | 199 | |
| 200 | "'.r_filename' and '.filename' are mutually exclusive on line %zu.", | 200 | if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { |
| 201 | line, sp_line_no); | ||
| 202 | return -1; | ||
| 203 | } else if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { | ||
| 204 | sp_log_err("config", | 201 | sp_log_err("config", |
| 205 | "Invalid configuration line: 'sp.disabled_functions%s':" | 202 | "Invalid configuration line: 'sp.disabled_functions%s':" |
| 206 | "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", | 203 | "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", |
| 207 | line, sp_line_no); | 204 | line, sp_line_no); |
| 208 | return -1; | 205 | return -1; |
| 209 | } else if (df->r_ret && df->ret) { | ||
| 210 | sp_log_err("config", | ||
| 211 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 212 | "'.r_ret' and '.ret' are mutually exclusive on line %zu.", | ||
| 213 | line, sp_line_no); | ||
| 214 | return -1; | ||
| 215 | } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) { | 206 | } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) { |
| 216 | sp_log_err("config", | 207 | sp_log_err("config", |
| 217 | "Invalid configuration line: 'sp.disabled_functions%s':" | 208 | "Invalid configuration line: 'sp.disabled_functions%s':" |
