summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-10-12 19:32:04 +0200
committerAllan McRae <allan@archlinux.org>2013-10-14 05:01:15 +0200
commit0fc9545546cd6cff95ef32e043efbcbbf89ca89b (patch)
tree3c460a8d257b0d308de9fbda166bc7af3d5f0e7c /src
parent5477f2597b8763adc1ef4b1495e25f87107620c1 (diff)
downloadpacman-0fc9545546cd6cff95ef32e043efbcbbf89ca89b.tar.gz
pacman-0fc9545546cd6cff95ef32e043efbcbbf89ca89b.tar.xz
pacman/util: remove strsplit
strsplit was used in only one place and did the same thing as strtok. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c10
-rw-r--r--src/pacman/util.c34
-rw-r--r--src/pacman/util.h1
3 files changed, 5 insertions, 40 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 24fd57f4..d2114e69 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -325,14 +325,14 @@ static void handler(int signum)
static int parsearg_util_addlist(alpm_list_t **list)
{
- alpm_list_t *split, *item;
+ char *i, *save;
check_optarg();
- split = strsplit(optarg, ',');
- for(item = split; item; item = alpm_list_next(item)) {
- *list = alpm_list_add(*list, item->data);
+
+ for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
+ *list = alpm_list_add(*list, strdup(i));
}
- alpm_list_free(split);
+
return 0;
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 6da1cd40..0e9a4200 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -378,40 +378,6 @@ char *strreplace(const char *str, const char *needle, const char *replace)
return newstr;
}
-/** Splits a string into a list of strings using the chosen character as
- * a delimiter.
- *
- * @param str the string to split
- * @param splitchar the character to split at
- *
- * @return a list containing the duplicated strings
- */
-alpm_list_t *strsplit(const char *str, const char splitchar)
-{
- alpm_list_t *list = NULL;
- const char *prev = str;
- char *dup = NULL;
-
- while((str = strchr(str, splitchar))) {
- dup = strndup(prev, (size_t)(str - prev));
- if(dup == NULL) {
- return NULL;
- }
- list = alpm_list_add(list, dup);
-
- str++;
- prev = str;
- }
-
- dup = strdup(prev);
- if(dup == NULL) {
- return NULL;
- }
- list = alpm_list_add(list, dup);
-
- return list;
-}
-
static size_t string_length(const char *s)
{
int len;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 0a2a6f75..e2297f81 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -54,7 +54,6 @@ int rmrf(const char *path);
void indentprint(const char *str, unsigned short indent, unsigned short cols);
size_t strtrim(char *str);
char *strreplace(const char *str, const char *needle, const char *replace);
-alpm_list_t *strsplit(const char *str, const char splitchar);
void string_display(const char *title, const char *string, unsigned short cols);
double humanize_size(off_t bytes, const char target_unit, int precision,
const char **label);