diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-02-02 16:16:19 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-02-07 01:48:11 +0100 |
commit | 1631255357c248ed827c14ce51e3648c74d0adbf (patch) | |
tree | 8374920862550194b2b40d369066506cf2474f83 | |
parent | ec339969d9479d21256ac3954d9292fa83f9a017 (diff) | |
download | pacman-1631255357c248ed827c14ce51e3648c74d0adbf.tar.gz pacman-1631255357c248ed827c14ce51e3648c74d0adbf.tar.xz |
use strtok_r to parse multi-value config options
This prevents multiple spaces between values from being
parsed as empty values.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/conf.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 95dce355..218ffb46 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -404,17 +404,14 @@ static int process_cleanmethods(alpm_list_t *values, static void setrepeatingoption(char *ptr, const char *option, alpm_list_t **list) { - char *q; + char *val, *saveptr; - while((q = strchr(ptr, ' '))) { - *q = '\0'; - *list = alpm_list_add(*list, strdup(ptr)); - pm_printf(ALPM_LOG_DEBUG, "config: %s: %s\n", option, ptr); - ptr = q; - ptr++; + val = strtok_r(ptr, " ", &saveptr); + while(val) { + *list = alpm_list_add(*list, strdup(val)); + pm_printf(ALPM_LOG_DEBUG, "config: %s: %s\n", option, val); + val = strtok_r(NULL, " ", &saveptr); } - *list = alpm_list_add(*list, strdup(ptr)); - pm_printf(ALPM_LOG_DEBUG, "config: %s: %s\n", option, ptr); } static int _parse_options(const char *key, char *value, |