diff options
| author | xXx-caillou-xXx | 2017-12-21 15:38:20 +0100 |
|---|---|---|
| committer | jvoisin | 2017-12-21 15:38:20 +0100 |
| commit | f9da3ecb31683f77e899e57f780c04d772490558 (patch) | |
| tree | 9f876d6fe170349aade28de8e51ea21702fb70f5 /src/sp_config_utils.c | |
| parent | 6b6598098a205fadc90c72d510f90b431f77739e (diff) | |
Remove the now useless `validate_str` function
Diffstat (limited to '')
| -rw-r--r-- | src/sp_config_utils.c | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c index 3c1d89d..bf558d4 100644 --- a/src/sp_config_utils.c +++ b/src/sp_config_utils.c | |||
| @@ -2,32 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | size_t sp_line_no; | 3 | size_t sp_line_no; |
| 4 | 4 | ||
| 5 | static int validate_str(const char *value) { | ||
| 6 | int balance = 0; // ghetto [] validation | ||
| 7 | |||
| 8 | if (!strchr(value, '[')) { | ||
| 9 | return 0; | ||
| 10 | } | ||
| 11 | |||
| 12 | for (size_t i = 0; i < strlen(value); i++) { | ||
| 13 | if (value[i] == '[') { | ||
| 14 | balance++; | ||
| 15 | } else if (value[i] == ']') { | ||
| 16 | balance--; | ||
| 17 | } | ||
| 18 | if (balance < 0) { | ||
| 19 | sp_log_err("config", "The string '%s' contains unbalanced brackets.", value); | ||
| 20 | return -1; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | if (balance != 0) { | ||
| 24 | sp_log_err("config", "You forgot to close %d bracket%c in the string '%s'", | ||
| 25 | balance, (balance>1)?'s':' ', value); | ||
| 26 | return -1; | ||
| 27 | } | ||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | |||
| 31 | int parse_keywords(sp_config_functions *funcs, char *line) { | 5 | int parse_keywords(sp_config_functions *funcs, char *line) { |
| 32 | int value_len = 0; | 6 | int value_len = 0; |
| 33 | const char *original_line = line; | 7 | const char *original_line = line; |
| @@ -58,8 +32,8 @@ int parse_keywords(sp_config_functions *funcs, char *line) { | |||
| 58 | return 0; | 32 | return 0; |
| 59 | } | 33 | } |
| 60 | 34 | ||
| 61 | static char *get_string(size_t *consumed, char *restrict line, | 35 | char *get_param(size_t *consumed, char *restrict line, sp_type type, |
| 62 | const char *restrict keyword) { | 36 | const char *restrict keyword) { |
| 63 | enum { IN_ESCAPE, NONE } state = NONE; | 37 | enum { IN_ESCAPE, NONE } state = NONE; |
| 64 | char *original_line = line; | 38 | char *original_line = line; |
| 65 | size_t j = 0; | 39 | size_t j = 0; |
| @@ -122,19 +96,8 @@ err: | |||
| 122 | return NULL; | 96 | return NULL; |
| 123 | } | 97 | } |
| 124 | 98 | ||
| 125 | char *get_param(size_t *consumed, char *restrict line, sp_type type, | ||
| 126 | const char *restrict keyword) { | ||
| 127 | char *retval = get_string(consumed, line, keyword); | ||
| 128 | |||
| 129 | if (retval && 0 == validate_str(retval)) { | ||
| 130 | return retval; | ||
| 131 | } | ||
| 132 | |||
| 133 | return NULL; | ||
| 134 | } | ||
| 135 | |||
| 136 | zend_always_inline sp_list_node *parse_functions_list(char *value) { | 99 | zend_always_inline sp_list_node *parse_functions_list(char *value) { |
| 137 | const char *sep = ">"; | 100 | static const char *sep = ">"; |
| 138 | 101 | ||
| 139 | if (NULL == strchr(value, sep[0])) { | 102 | if (NULL == strchr(value, sep[0])) { |
| 140 | return NULL; | 103 | return NULL; |
