diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-05-20 18:45:01 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-05-22 12:50:47 +0000 |
| commit | 121ea39942ce8756f4f6c9e45e5c8b60ad819d15 (patch) | |
| tree | 887b7fa3249337fb8aebfbec2df231656120c16a /config.c | |
| parent | config: add url.protocols (diff) | |
config: url.protocols: make it comma separated, for consistency
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1012,10 +1012,20 @@ parse_section_url(const char *key, const char *value, struct config *conf, char *copy = xstrdup(value); - for (char *prot = strtok(copy, " "); + for (char *prot = strtok(copy, ","); prot != NULL; - prot = strtok(NULL, " ")) + prot = strtok(NULL, ",")) { + + /* Strip leading whitespace */ + while (isspace(*prot)) + prot++; + + /* Strip trailing whitespace */ + size_t len = strlen(prot); + while (len > 0 && isspace(prot[len - 1])) + prot[--len] = '\0'; + size_t chars = mbstowcs(NULL, prot, 0); if (chars == (size_t)-1) { LOG_AND_NOTIFY_ERRNO( @@ -1034,9 +1044,9 @@ parse_section_url(const char *key, const char *value, struct config *conf, mbstowcs(conf->url.protocols[idx], prot, chars + 1); wcscpy(&conf->url.protocols[idx][chars], L"://"); - size_t len = chars + 3; /* Include the "://" */ - if (len > conf->url.max_prot_len) - conf->url.max_prot_len = len; + chars += 3; /* Include the "://" */ + if (chars > conf->url.max_prot_len) + conf->url.max_prot_len = chars; } free(copy); |
