1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 08:18:51 -05:00

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>
This commit is contained in:
Andrew Gregory 2013-10-12 13:32:04 -04:00 committed by Allan McRae
parent 5477f2597b
commit 0fc9545546
3 changed files with 5 additions and 40 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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);