diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-05-21 10:24:37 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-05-21 10:24:57 +0200 |
commit | 9f25d7d347c461254bb2f29ebf86ca49a898783d (patch) | |
tree | 8f1cceb1e67ac32e6ebf4831a4b645226c7c9d65 /src/core | |
parent | e4a69406ba915310c03766081a6952344d588aad (diff) | |
download | weechat-9f25d7d347c461254bb2f29ebf86ca49a898783d.zip |
core: use function string_split to split list items
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-url.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/core/wee-url.c b/src/core/wee-url.c index 6c41bc5b0..bd3ce68c5 100644 --- a/src/core/wee-url.c +++ b/src/core/wee-url.c @@ -940,12 +940,11 @@ weeurl_option_map_cb (void *data, const void *key, const void *value) { CURL *curl; - int index, index_constant, rc; + int i, index, index_constant, rc, num_items; long long_value; long long long_long_value; struct curl_slist *slist; - char *list_copy, *list_entry_walker; - const char *list_entry_start; + char **items; /* make C compiler happy */ (void) hashtable; @@ -1015,27 +1014,18 @@ weeurl_option_map_cb (void *data, } break; case URL_TYPE_LIST: - slist = NULL; - list_copy = malloc (strlen ((const char *)value) + 1); - if (list_copy) + items = string_split (value, "\n", 0, 0, &num_items); + if (items) { - strcpy (list_copy, (const char *)value); - list_entry_start = list_copy; - list_entry_walker = list_copy; - while (*list_entry_walker) + slist = NULL; + for (i = 0; i < num_items; i++) { - if (*list_entry_walker == '\n') - { - *list_entry_walker = '\0'; - slist = curl_slist_append (slist, list_entry_start); - list_entry_start = list_entry_walker + 1; - } - ++list_entry_walker; + slist = curl_slist_append (slist, items[i]); } - slist = curl_slist_append (slist, list_entry_start); - free (list_copy); - curl_easy_setopt (curl, url_options[index].option, + curl_easy_setopt (curl, + url_options[index].option, slist); + string_free_split (items); } break; } |