From 958f7ee86037ce42d9de3fdc9f7f25b9a2e1ff6c Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Thu, 20 Oct 2005 20:34:31 +0000 Subject: remove dupes from group lists in sync --- src/pacman/list.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/pacman/list.c') diff --git a/src/pacman/list.c b/src/pacman/list.c index 9f58c3ee..1556a675 100644 --- a/src/pacman/list.c +++ b/src/pacman/list.c @@ -170,4 +170,26 @@ void PM_LIST_display(const char *title, PM_LIST *list) } } +/* Filter out any duplicate strings in a PM_LIST + * + * Not the most efficient way, but simple to implement -- we assemble + * a new list, using is_in() to check for dupes at each iteration. + * + * This function takes a PM_LIST* and returns a list_t* + * + */ +list_t *PM_LIST_remove_dupes(PM_LIST *list) +{ + PM_LIST *i; + list_t *newlist = NULL; + + for(i = alpm_list_first(list); i; i = alpm_list_next(i)) { + char *data = alpm_list_getdata(i); + if(!list_is_strin(data, newlist)) { + newlist = list_add(newlist, strdup(data)); + } + } + return newlist; +} + /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3