summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/alpm_list.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-03-01 07:03:05 +0000
committerAaron Griffin <aaron@archlinux.org>2007-03-01 07:03:05 +0000
commit3ebd125e1ad9abbf5fbcb4457adb8288750b379e (patch)
tree04e93b6896fd61d86bca280af0ac8bb5448c08a2 /lib/libalpm/alpm_list.c
parent6075b677fcdeccf2b39ebbd4a089b4ebe016a62e (diff)
downloadpacman-3ebd125e1ad9abbf5fbcb4457adb8288750b379e.tar.xz
* Switched some functions to alpm_pkg_get_* usage as I came across them
* Added some provision switching hackery. This could probably use some refactoring,.. it solves the following case: pkg1 and pkg2 provide 'foo' and are both installed pkg3 depends on 'foo' and so lists 'pkg1' in the REQUIREDBY db section pkg1 is upgraded and no longer provides 'foo' ** This code ensures that the REQUIREDBY of pkg3 is updated to require pkg2 now instead of pkg1
Diffstat (limited to 'lib/libalpm/alpm_list.c')
-rw-r--r--lib/libalpm/alpm_list.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index e118a129..8c387eed 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -457,6 +457,33 @@ int alpm_list_find_str(alpm_list_t *haystack, const char *needle)
return(0);
}
+/**
+ * Calculate the items in list `lhs` that are not present in list `rhs`
+ * @note Entries are not duplicated
+ * @param lhs the first list
+ * @param rhs the second list
+ * @param fn the comparisson function
+ * @return a list containing all items in lhs not present in rhs
+ */
+alpm_list_t *alpm_list_diff(alpm_list_t *lhs, alpm_list_t *rhs, alpm_list_fn_cmp fn)
+{
+ alpm_list_t *i, *j, *ret = NULL;
+ for(i = lhs; i; i = i->next) {
+ int found = 0;
+ for(j = rhs; j; j = j->next) {
+ if(fn(i->data, j->data) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if(!found) {
+ ret = alpm_list_add(ret, i->data);
+ }
+ }
+
+ return(ret);
+}
+
/** @} */
/* vim: set ts=2 sw=2 noet: */