diff options
author | Nathan Jones <nathanj@insightbb.com> | 2007-11-14 01:32:56 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-11-14 03:59:02 +0100 |
commit | 46ec9e3548b5b567c7eb18c360f54a77b6313b12 (patch) | |
tree | 0fd80f989cf93916e68fbd3e54146eb6516d756e /src/pacman/util.c | |
parent | 70a91cbb22bb3ec88d518e2e6c43553c53cde318 (diff) | |
download | pacman-46ec9e3548b5b567c7eb18c360f54a77b6313b12.tar.gz pacman-46ec9e3548b5b567c7eb18c360f54a77b6313b12.tar.xz |
Make it easier to ignore multiple packages.
This makes --ignore and --ignoregroup able to accept multiple
packages/groups by separating each with a comma.
For instance: pacman -Su --ignore kernel26,udev,glibc
This was requested in the comments of FS#8054.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r-- | src/pacman/util.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c index b91ec131..a0402ab0 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -293,6 +293,40 @@ 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, 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, strdup(prev)); + + return(list); +} + void list_display(const char *title, const alpm_list_t *list) { const alpm_list_t *i; |