[pacman-dev] CVS update of pacman-lib (14 files)

dan at archlinux.org dan at archlinux.org
Mon Jan 29 22:46:34 EST 2007


    Date: Monday, January 29, 2007 @ 22:46:34
  Author: dan
    Path: /home/cvs-pacman/pacman-lib

Modified: lib/libalpm/add.c (1.103 -> 1.104)
          lib/libalpm/alpm.c (1.106 -> 1.107)
          lib/libalpm/alpm_list.c (1.4 -> 1.5)
          lib/libalpm/alpm_list.h (1.2 -> 1.3)
          lib/libalpm/cache.c (1.27 -> 1.28)
          lib/libalpm/conflict.c (1.31 -> 1.32)
          lib/libalpm/deps.c (1.59 -> 1.60)
          lib/libalpm/provide.c (1.8 -> 1.9)
          lib/libalpm/remove.c (1.57 -> 1.58)
          lib/libalpm/server.c (1.16 -> 1.17)
          lib/libalpm/sync.c (1.92 -> 1.93)
          lib/libalpm/trans.c (1.31 -> 1.32)
          lib/libalpm/versioncmp.c (1.9 -> 1.10)
          src/pacman/sync.c (1.99 -> 1.100)

Discussed on IRC for a bit, this makes the following changes for clarity:
* alpm_list_is_in    --> alpm_list_find
* alpm_list_is_strin --> alpm_list_find_str
* Flip parameters of both functions to be inline with rest of alpm_list.

First commit, woohoo.


--------------------------+
 lib/libalpm/add.c        |    6 +++---
 lib/libalpm/alpm.c       |    2 +-
 lib/libalpm/alpm_list.c  |    8 ++++----
 lib/libalpm/alpm_list.h  |    4 ++--
 lib/libalpm/cache.c      |    4 ++--
 lib/libalpm/conflict.c   |    7 ++++---
 lib/libalpm/deps.c       |    6 +++---
 lib/libalpm/provide.c    |    2 +-
 lib/libalpm/remove.c     |    5 +++--
 lib/libalpm/server.c     |    2 +-
 lib/libalpm/sync.c       |   14 +++++++-------
 lib/libalpm/trans.c      |    2 +-
 lib/libalpm/versioncmp.c |    3 ++-
 src/pacman/sync.c        |    4 ++--
 14 files changed, 36 insertions(+), 33 deletions(-)


Index: pacman-lib/lib/libalpm/add.c
diff -u pacman-lib/lib/libalpm/add.c:1.103 pacman-lib/lib/libalpm/add.c:1.104
--- pacman-lib/lib/libalpm/add.c:1.103	Tue Jan 23 22:02:53 2007
+++ pacman-lib/lib/libalpm/add.c	Mon Jan 29 22:46:33 2007
@@ -507,7 +507,7 @@
 				 * eg, /home/httpd/html/index.html may be removed so index.php
 				 * could be used.
 				 */
-				if(alpm_list_is_strin(pathname, handle->noextract)) {
+				if(alpm_list_find_str(handle->noextract, pathname)) {
 					alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname);
 					archive_read_data_skip (archive);
 					continue;
@@ -516,7 +516,7 @@
 				if(!stat(expath, &buf) && !S_ISDIR(buf.st_mode)) {
 					/* file already exists */
 					if(!pmo_upgrade || oldpkg == NULL) {
-						nb = alpm_list_is_strin(pathname, info->backup);
+						nb = alpm_list_find_str(info->backup, pathname);
 					} else {
 						/* op == PM_TRANS_TYPE_UPGRADE */
 						md5_orig = _alpm_needbackup(pathname, oldpkg->backup);
@@ -525,7 +525,7 @@
 							nb = 1;
 						}
 					}
-					if(alpm_list_is_strin(pathname, handle->noupgrade)) {
+					if(alpm_list_find_str(handle->noupgrade, pathname)) {
 						notouch = 1;
 						nb = 0;
 					}
Index: pacman-lib/lib/libalpm/alpm.c
diff -u pacman-lib/lib/libalpm/alpm.c:1.106 pacman-lib/lib/libalpm/alpm.c:1.107
--- pacman-lib/lib/libalpm/alpm.c:1.106	Thu Jan 25 21:13:16 2007
+++ pacman-lib/lib/libalpm/alpm.c	Mon Jan 29 22:46:33 2007
@@ -265,7 +265,7 @@
 	ASSERT(handle->trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
 	ASSERT(handle->trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
 
-	if(!alpm_list_is_in(db, handle->dbs_sync)) {
+	if(!alpm_list_find(handle->dbs_sync, db)) {
 		RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
 	}
 
Index: pacman-lib/lib/libalpm/alpm_list.c
diff -u pacman-lib/lib/libalpm/alpm_list.c:1.4 pacman-lib/lib/libalpm/alpm_list.c:1.5
--- pacman-lib/lib/libalpm/alpm_list.c:1.4	Wed Jan 24 03:51:51 2007
+++ pacman-lib/lib/libalpm/alpm_list.c	Mon Jan 29 22:46:33 2007
@@ -309,7 +309,7 @@
 { /* TODO does removing the strdup here cause invalid free's anywhere? */
 	alpm_list_t *lp = list, *newlist = NULL;
 	while(lp) {
-		if(!alpm_list_is_in(lp->data, newlist)) {
+		if(!alpm_list_find(newlist, lp->data)) {
 			newlist = alpm_list_add(newlist, lp->data);
 		}
 		lp = lp->next;
@@ -426,7 +426,7 @@
  *  @param haystack the list to search
  *  @return 1 if `needle` is found, 0 otherwise
  */
-int alpm_list_is_in(const void *needle, alpm_list_t *haystack)
+int alpm_list_find(alpm_list_t *haystack, const void *needle)
 {
 	alpm_list_t *lp = haystack;
 	while(lp) {
@@ -440,12 +440,12 @@
 
 /* Test for existence of a string in a alpm_list_t
 */
-/** Is a _string_ in the list (optimization of alpm_list_is_in for strings)
+/** Is a _string_ in the list (optimization of alpm_list_find for strings)
  *  @param needle the string to compare
  *  @param haystack the list to search
  *  @return 1 if `needle` is found, 0 otherwise
  */
-int alpm_list_is_strin(const char *needle, alpm_list_t *haystack)
+int alpm_list_find_str(alpm_list_t *haystack, const char *needle)
 {
 	alpm_list_t *lp = haystack;
 	while(lp) {
Index: pacman-lib/lib/libalpm/alpm_list.h
diff -u pacman-lib/lib/libalpm/alpm_list.h:1.2 pacman-lib/lib/libalpm/alpm_list.h:1.3
--- pacman-lib/lib/libalpm/alpm_list.h:1.2	Wed Jan 24 03:51:51 2007
+++ pacman-lib/lib/libalpm/alpm_list.h	Mon Jan 29 22:46:33 2007
@@ -64,8 +64,8 @@
 
 /* misc */
 int alpm_list_count(const alpm_list_t *list);
-int alpm_list_is_in(const void *needle, alpm_list_t *haystack);
-int alpm_list_is_strin(const char *needle, alpm_list_t *haystack);
+int alpm_list_find(alpm_list_t *haystack, const void *needle);
+int alpm_list_find_str(alpm_list_t *haystack,const char *needle);
 
 #endif /* _ALPM_LIST_H */
 
Index: pacman-lib/lib/libalpm/cache.c
diff -u pacman-lib/lib/libalpm/cache.c:1.27 pacman-lib/lib/libalpm/cache.c:1.28
--- pacman-lib/lib/libalpm/cache.c:1.27	Wed Jan 24 03:51:51 2007
+++ pacman-lib/lib/libalpm/cache.c	Mon Jan 29 22:46:33 2007
@@ -202,7 +202,7 @@
 		pmpkg_t *pkg = lp->data;
 
 		for(i = pkg->groups; i; i = i->next) {
-			if(!alpm_list_is_strin(i->data, db->grpcache)) {
+			if(!alpm_list_find_str(db->grpcache, i->data)) {
 				pmgrp_t *grp = _alpm_grp_new();
 
 				STRNCPY(grp->name, (char *)i->data, GRP_NAME_LEN);
@@ -215,7 +215,7 @@
 					pmgrp_t *grp = j->data;
 
 					if(strcmp(grp->name, i->data) == 0) {
-						if(!alpm_list_is_strin(pkg->name, grp->packages)) {
+						if(!alpm_list_find_str(grp->packages, pkg->name)) {
 							grp->packages = alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
 						}
 					}
Index: pacman-lib/lib/libalpm/conflict.c
diff -u pacman-lib/lib/libalpm/conflict.c:1.31 pacman-lib/lib/libalpm/conflict.c:1.32
--- pacman-lib/lib/libalpm/conflict.c:1.31	Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/conflict.c	Mon Jan 29 22:46:33 2007
@@ -240,7 +240,7 @@
 					if(strcmp(filestr, ".INSTALL") == 0) {
 						continue;
 					}
-					if(alpm_list_is_strin(filestr, p2->files)) {
+					if(alpm_list_find_str(p2->files, filestr)) {
 						pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
 						if(conflict == NULL) {
 							_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"),
@@ -284,7 +284,7 @@
 						_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg->name);
 						_alpm_db_read(db, INFRQ_FILES, dbpkg);
 					}
-					if(dbpkg && alpm_list_is_strin(j->data, dbpkg->files)) {
+					if(dbpkg && alpm_list_find_str(dbpkg->files, j->data)) {
 						ok = 1;
 					}
 					/* Make sure that the supposedly-conflicting file is not actually just
@@ -315,7 +315,8 @@
 									_alpm_db_read(db, INFRQ_FILES, dbpkg2);
 								}
 								/* If it used to exist in there, but doesn't anymore */
-								if(dbpkg2 && !alpm_list_is_strin(filestr, p1->files) && alpm_list_is_strin(filestr, dbpkg2->files)) {
+								if(dbpkg2 && !alpm_list_find_str(p1->files, filestr)
+								    && alpm_list_find_str(dbpkg2->files, filestr)) {
 									ok = 1;
 									/* Add to the "skip list" of files that we shouldn't remove during an upgrade.
 									 *
Index: pacman-lib/lib/libalpm/deps.c
diff -u pacman-lib/lib/libalpm/deps.c:1.59 pacman-lib/lib/libalpm/deps.c:1.60
--- pacman-lib/lib/libalpm/deps.c:1.59	Thu Jan 25 21:13:16 2007
+++ pacman-lib/lib/libalpm/deps.c	Mon Jan 29 22:46:33 2007
@@ -363,7 +363,7 @@
 							spkg = k->data;
 						}
 						if(spkg) {
-							if(alpm_list_is_strin(tp->name, spkg->provides)) {
+							if(alpm_list_find_str(spkg->provides, tp->name)) {
 								found = 1;
 							}
 						}
@@ -549,7 +549,7 @@
 		/* check if one of the packages in *list already provides this dependency */
 		for(j = list; j && !found; j = j->next) {
 			pmpkg_t *sp = (pmpkg_t *)j->data;
-			if(alpm_list_is_strin(miss->depend.name, sp->provides)) {
+			if(alpm_list_find_str(sp->provides, miss->depend.name)) {
 				_alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"),
 				          sp->name, miss->depend.name);
 				found = 1;
@@ -602,7 +602,7 @@
 			 * something we're not supposed to.
 			 */
 			int usedep = 1;
-			if(alpm_list_is_strin(sync->name, handle->ignorepkg)) {
+			if(alpm_list_find_str(handle->ignorepkg, sync->name)) {
 				pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
 				QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
 				FREEPKG(dummypkg);
Index: pacman-lib/lib/libalpm/provide.c
diff -u pacman-lib/lib/libalpm/provide.c:1.8 pacman-lib/lib/libalpm/provide.c:1.9
--- pacman-lib/lib/libalpm/provide.c:1.8	Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/provide.c	Mon Jan 29 22:46:33 2007
@@ -42,7 +42,7 @@
 	for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
 		pmpkg_t *info = lp->data;
 
-		if(alpm_list_is_strin(package, info->provides)) {
+		if(alpm_list_find_str(info->provides, package)) {
 			pkgs = alpm_list_add(pkgs, info);
 		}
 	}
Index: pacman-lib/lib/libalpm/remove.c
diff -u pacman-lib/lib/libalpm/remove.c:1.57 pacman-lib/lib/libalpm/remove.c:1.58
--- pacman-lib/lib/libalpm/remove.c:1.57	Tue Jan 23 11:05:21 2007
+++ pacman-lib/lib/libalpm/remove.c	Mon Jan 29 22:46:33 2007
@@ -78,7 +78,8 @@
 	}
 
 	/* ignore holdpkgs on upgrade */
-	if((trans == handle->trans) && alpm_list_is_strin(info->name, handle->holdpkg)) {
+	if((trans == handle->trans)
+	    && alpm_list_find_str(handle->holdpkg, info->name)) {
 		int resp = 0;
 		QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
 		if(!resp) {
@@ -177,7 +178,7 @@
 		FREE(checksum);
 	} if ( !nb && trans->type == PM_TRANS_TYPE_UPGRADE ) {
 		/* check noupgrade */
-		if ( alpm_list_is_strin(file, handle->noupgrade) ) {
+		if ( alpm_list_find_str(handle->noupgrade, file) ) {
 			nb = 1;
 		}
 	}
Index: pacman-lib/lib/libalpm/server.c
diff -u pacman-lib/lib/libalpm/server.c:1.16 pacman-lib/lib/libalpm/server.c:1.17
--- pacman-lib/lib/libalpm/server.c:1.16	Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/server.c	Mon Jan 29 22:46:33 2007
@@ -137,7 +137,7 @@
 			snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn);
 			snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
 
-			if(alpm_list_is_strin(fn, complete)) {
+			if(alpm_list_find_str(complete, fn)) {
 				continue;
 			}
 
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.92 pacman-lib/lib/libalpm/sync.c:1.93
--- pacman-lib/lib/libalpm/sync.c:1.92	Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/sync.c	Mon Jan 29 22:46:34 2007
@@ -137,7 +137,7 @@
 					pmpkg_t *lpkg = m->data;
 					if(strcmp(k->data, lpkg->name) == 0) {
 						_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
-						if(alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
+						if(alpm_list_find_str(handle->ignorepkg, lpkg->name)) {
 							_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
 								lpkg->name, lpkg->version, spkg->name, spkg->version);
 						} else {
@@ -235,7 +235,7 @@
 									local->name, local->version, db->treename, spkg->version);
 			} else if(cmp == 0) {
 				/* versions are identical */
-			} else if(alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
+			} else if(alpm_list_find_str(handle->ignorepkg, spkg->name)) {
 				/* package should be ignored (IgnorePkg) */
 				_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
 									local->name, local->version, spkg->version);
@@ -535,7 +535,7 @@
 				local = _alpm_db_get_pkgfromcache(db_local, miss->depend.name);
 				/* check if this package also "provides" the package it's conflicting with
 				 */
-				if(alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
+				if(alpm_list_find_str(sync->pkg->provides, miss->depend.name)) {
 					/* so just treat it like a "replaces" item so the REQUIREDBY
 					 * fields are inherited properly.
 					 */
@@ -559,8 +559,8 @@
 
 						/* figure out which one was requested in targets.  If they both were,
 						 * then it's still an unresolvable conflict. */
-						target = alpm_list_is_strin(miss->target, trans->targets);
-						depend = alpm_list_is_strin(miss->depend.name, trans->targets);
+						target = alpm_list_find_str(trans->targets, miss->target);
+						depend = alpm_list_find_str(trans->targets, miss->depend.name);
 						if(depend && !target) {
 							_alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"),
 								miss->depend.name);
@@ -591,7 +591,7 @@
 				_alpm_log(PM_LOG_DEBUG, _("resolving package '%s' conflict"), miss->target);
 				if(local) {
 					int doremove = 0;
-					if(!alpm_list_is_strin(miss->depend.name, asked)) {
+					if(!alpm_list_find_str(asked, miss->depend.name)) {
 						QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
 						asked = alpm_list_add(asked, strdup(miss->depend.name));
 						if(doremove) {
@@ -1020,7 +1020,7 @@
 					pmpkg_t *old = j->data;
 					/* merge lists */
 					for(k = old->requiredby; k; k = k->next) {
-						if(!alpm_list_is_strin(k->data, new->requiredby)) {
+						if(!alpm_list_find_str(new->requiredby, k->data)) {
 							/* replace old's name with new's name in the requiredby's dependency list */
 							alpm_list_t *m;
 							pmpkg_t *depender = _alpm_db_get_pkgfromcache(db_local, k->data);
Index: pacman-lib/lib/libalpm/trans.c
diff -u pacman-lib/lib/libalpm/trans.c:1.31 pacman-lib/lib/libalpm/trans.c:1.32
--- pacman-lib/lib/libalpm/trans.c:1.31	Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/trans.c	Mon Jan 29 22:46:34 2007
@@ -116,7 +116,7 @@
 	ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
 	ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
 
-	if(alpm_list_is_strin(target, trans->targets)) {
+	if(alpm_list_find_str(trans->targets, target)) {
 		RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
 	}
 
Index: pacman-lib/lib/libalpm/versioncmp.c
diff -u pacman-lib/lib/libalpm/versioncmp.c:1.9 pacman-lib/lib/libalpm/versioncmp.c:1.10
--- pacman-lib/lib/libalpm/versioncmp.c:1.9	Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/versioncmp.c	Mon Jan 29 22:46:34 2007
@@ -247,7 +247,8 @@
 {
 	int equal = 0;
 
-  if(strcmp(pkg->name, dep->name) == 0 || alpm_list_is_strin(dep->name, pkg->provides)) {
+  if(strcmp(pkg->name, dep->name) == 0
+	    || alpm_list_find_str(pkg->provides, dep->name)) {
 		if(dep->mod == PM_DEP_MOD_ANY) {
 			equal = 1;
 		} else {
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.99 pacman-lib/src/pacman/sync.c:1.100
--- pacman-lib/src/pacman/sync.c:1.99	Wed Jan 24 03:51:51 2007
+++ pacman-lib/src/pacman/sync.c	Mon Jan 29 22:46:34 2007
@@ -159,7 +159,7 @@
 				/* TODO Do not remove the currently installed version EITHER */
 				if(!strcmp(name, n)) {
 					char *ptr = (alpm_pkg_vercmp(version, v) < 0) ? str : s;
-					if(!alpm_list_is_strin(ptr, clean)) {
+					if(!alpm_list_find_str(clean, ptr)) {
 						clean = alpm_list_add(clean, strdup(ptr));
 					}
 				}
@@ -645,7 +645,7 @@
 				for(j = data; j; j = alpm_list_next(j)) {
 					pmpkg_t *p = alpm_list_getdata(j);
 					const char *pkgname = alpm_pkg_get_name(p);
-					if(!alpm_list_is_strin(pkgname, list_remove)) {
+					if(!alpm_list_find_str(list_remove, pkgname)) {
 						list_remove = alpm_list_add(list_remove, strdup(pkgname));
 					}
 				}




More information about the pacman-dev mailing list