Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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);