diff options
| author | jvoisin | 2017-10-23 22:47:46 +0200 |
|---|---|---|
| committer | GitHub | 2017-10-23 22:47:46 +0200 |
| commit | a8ab6484c1cf08bb5669b2f46f933845cc81f077 (patch) | |
| tree | 06bcfc62b03c2113277385073294bcb27f30d643 /src/sp_config_keywords.c | |
| parent | a50fe60a3d736bce1a1838d4e736f80af1ee7bbc (diff) | |
Implement the .line filter
Close #48
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 097d08b..168ee1c 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -145,6 +145,7 @@ int parse_disabled_functions(char *line) { | |||
| 145 | int ret = 0; | 145 | int ret = 0; |
| 146 | bool enable = true, disable = false; | 146 | bool enable = true, disable = false; |
| 147 | char *pos = NULL; | 147 | char *pos = NULL; |
| 148 | char *line_number = NULL; | ||
| 148 | sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); | 149 | sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); |
| 149 | df->pos = -1; | 150 | df->pos = -1; |
| 150 | 151 | ||
| @@ -172,6 +173,7 @@ int parse_disabled_functions(char *line) { | |||
| 172 | {parse_php_type, SP_TOKEN_RET_TYPE, &(df->ret_type)}, | 173 | {parse_php_type, SP_TOKEN_RET_TYPE, &(df->ret_type)}, |
| 173 | {parse_str, SP_TOKEN_LOCAL_VAR, &(df->var)}, | 174 | {parse_str, SP_TOKEN_LOCAL_VAR, &(df->var)}, |
| 174 | {parse_str, SP_TOKEN_VALUE_ARG_POS, &(pos)}, | 175 | {parse_str, SP_TOKEN_VALUE_ARG_POS, &(pos)}, |
| 176 | {parse_str, SP_TOKEN_LINE_NUMBER, &(line_number)}, | ||
| 175 | {0}}; | 177 | {0}}; |
| 176 | 178 | ||
| 177 | ret = parse_keywords(sp_config_funcs_disabled_functions, line); | 179 | ret = parse_keywords(sp_config_funcs_disabled_functions, line); |
| @@ -252,6 +254,17 @@ int parse_disabled_functions(char *line) { | |||
| 252 | } | 254 | } |
| 253 | } | 255 | } |
| 254 | 256 | ||
| 257 | if (line_number) { | ||
| 258 | errno = 0; | ||
| 259 | char *endptr; | ||
| 260 | df->line = strtoul(line_number, &endptr, 10); | ||
| 261 | if (errno != 0 || endptr == line_number) { | ||
| 262 | sp_log_err("config", "Failed to parse arg '%s' of `line` on line %zu.", | ||
| 263 | line_number, sp_line_no); | ||
| 264 | return -1; | ||
| 265 | } | ||
| 266 | } | ||
| 267 | |||
| 255 | if (df->function) { | 268 | if (df->function) { |
| 256 | df->functions_list = parse_functions_list(df->function); | 269 | df->functions_list = parse_functions_list(df->function); |
| 257 | } | 270 | } |
