Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=86050809b83a07b03937304dccc98b70cbe92aec

commit 86050809b83a07b03937304dccc98b70cbe92aec
Author: Michel Hermier <herm...@frugalware.org>
Date:   Mon Nov 18 16:11:07 2013 +0100

libpacman: Replace find_pkginsync with _pacman_trans_find.

diff --git a/lib/libpacman/sync.c b/lib/libpacman/sync.c
index d3a460c..0a62f38 100644
--- a/lib/libpacman/sync.c
+++ b/lib/libpacman/sync.c
@@ -91,24 +91,6 @@ void _pacman_sync_free(void *data)
free(ps);
}

-/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
- * If found, return a pointer to the respective pmsyncpkg_t*
- */
-pmsyncpkg_t *find_pkginsync(char *needle, pmlist_t *haystack)
-{
-       pmlist_t *i;
-       pmsyncpkg_t *ps;
-
-       for(i = haystack; i != NULL ; i = i->next) {
-               ps = i->data;
-               if(ps && !strcmp(ps->pkg_name, needle)) {
-                       return(ps);
-               }
-       }
-
-       return(NULL);
-}
-
int _pacman_sync_addtarget(pmtrans_t *trans, const char *name)
{
char targline[PKG_FULLNAME_LEN];
@@ -195,7 +177,7 @@ int _pacman_sync_addtarget(pmtrans_t *trans, const char 
*name)
}

/* add the package to the transaction */
-       if(!find_pkginsync(spkg->name, trans->packages)) {
+       if(!_pacman_trans_find(trans, spkg->name)) {
pmpkg_t *dummy = NULL;
if(pkg_local) {
dummy = _pacman_pkg_new(pkg_local->name, pkg_local->version);
@@ -288,7 +270,7 @@ int _pacman_sync_prepare(pmtrans_t *trans, pmlist_t **data)
for(i = list; i; i = i->next) {
/* add the dependencies found by resolvedeps to the transaction set */
pmpkg_t *spkg = i->data;
-                       if(!find_pkginsync(spkg->name, trans->packages)) {
+                       if(!_pacman_trans_find(trans, spkg->name)) {
pmsyncpkg_t *ps = _pacman_sync_new(PM_SYNC_TYPE_DEPEND, spkg, NULL);
if(ps == NULL) {
ret = -1;
@@ -378,7 +360,7 @@ int _pacman_sync_prepare(pmtrans_t *trans, pmlist_t **data)
continue;
}

-                               ps = find_pkginsync(miss->target, 
trans->packages);
+                               ps = _pacman_trans_find(trans, miss->target);
if(ps == NULL) {
_pacman_log(PM_LOG_DEBUG, _("'%s' not found in transaction set -- skipping"),
miss->target);
@@ -429,7 +411,7 @@ int _pacman_sync_prepare(pmtrans_t *trans, pmlist_t **data)
rmpkg = miss->depend.name;
}
if(rmpkg) {
-                                                       pmsyncpkg_t *rsync = 
find_pkginsync(rmpkg, trans->packages);
+                                                       pmsyncpkg_t *rsync = 
_pacman_trans_find(trans, rmpkg);
pmsyncpkg_t *spkg = NULL;
_pacman_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
trans->packages = _pacman_list_remove(trans->packages, rsync, ptr_cmp, (void 
**)&spkg);
@@ -447,7 +429,7 @@ int _pacman_sync_prepare(pmtrans_t *trans, pmlist_t **data)
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, 
NULL, &doremove);
asked = _pacman_stringlist_append(asked, miss->depend.name);
if(doremove) {
-                                                       pmsyncpkg_t *rsync = 
find_pkginsync(miss->depend.name, trans->packages);
+                                                       pmsyncpkg_t *rsync = 
_pacman_trans_find(trans, miss->depend.name);
pmpkg_t *q = _pacman_pkg_new(miss->depend.name, NULL);
if(q == NULL) {
if(data) {
@@ -544,7 +526,7 @@ int _pacman_sync_prepare(pmtrans_t *trans, pmlist_t **data)
int errorout = 0;
for(i = deps; i; i = i->next) {
pmdepmissing_t *miss = i->data;
-                                       if(!find_pkginsync(miss->depend.name, 
trans->packages)) {
+                                       if(!_pacman_trans_find(trans, 
miss->depend.name)) {
int pfound = 0;
/* If miss->depend.name depends on something that miss->target and a
* package in final both provide, then it's okay...  */
diff --git a/lib/libpacman/sync.h b/lib/libpacman/sync.h
index beb19a7..79f9221 100644
--- a/lib/libpacman/sync.h
+++ b/lib/libpacman/sync.h
@@ -38,7 +38,6 @@ struct __pmsyncpkg_t {

pmsyncpkg_t *_pacman_sync_new(int type, pmpkg_t *spkg, void *data);
void _pacman_sync_free(void *data);
-pmsyncpkg_t *find_pkginsync(char *needle, pmlist_t *haystack);

const pmtrans_ops_t _pacman_sync_pmtrans_opts;

diff --git a/lib/libpacman/trans.c b/lib/libpacman/trans.c
index 9811507..575394e 100644
--- a/lib/libpacman/trans.c
+++ b/lib/libpacman/trans.c
@@ -208,6 +208,25 @@ void _pacman_trans_event(pmtrans_t *trans, unsigned char 
event, void *data1, voi
}
}

+/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
+ * If found, return a pointer to the respective pmsyncpkg_t*
+ */
+pmsyncpkg_t *_pacman_trans_find(const pmtrans_t *trans, const char *pkgname)
+{
+       pmlist_t *i;
+
+       ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, NULL));
+
+       for(i = trans->packages; i != NULL ; i = i->next) {
+               pmsyncpkg_t *ps = i->data;
+
+               if(ps && !strcmp(ps->pkg->name, pkgname)) {
+                       break;
+               }
+       }
+       return NULL;
+}
+
int _pacman_trans_set_state(pmtrans_t *trans, int new_state)
{
/* Sanity checks */
diff --git a/lib/libpacman/trans.h b/lib/libpacman/trans.h
index ffd770c..af8c2a7 100644
--- a/lib/libpacman/trans.h
+++ b/lib/libpacman/trans.h
@@ -97,6 +97,7 @@ int _pacman_trans_init(pmtrans_t *trans, pmtranstype_t type, 
unsigned int flags,
void _pacman_trans_fini(pmtrans_t *trans);

void _pacman_trans_event(pmtrans_t *trans, unsigned char, void *, void *);
+pmsyncpkg_t *_pacman_trans_find(const pmtrans_t *trans, const char *pkgname);
int _pacman_trans_set_state(pmtrans_t *trans, int new_state);
int _pacman_trans_addtarget(pmtrans_t *trans, const char *target);
int _pacman_trans_prepare(pmtrans_t *trans, pmlist_t **data);
diff --git a/lib/libpacman/trans_sysupgrade.c b/lib/libpacman/trans_sysupgrade.c
index 5ed110e..1ddf1ac 100644
--- a/lib/libpacman/trans_sysupgrade.c
+++ b/lib/libpacman/trans_sysupgrade.c
@@ -106,7 +106,7 @@ int _pacman_sync_sysupgrade(pmtrans_t *trans, pmdb_t 
*db_local, pmlist_t *dbs_sy
}
dummy->requiredby = _pacman_list_strdup(lpkg->requiredby);
/* check if spkg->name is already in the packages list. */
-                                                               ps = 
find_pkginsync(spkg->name, trans->packages);
+                                                               ps = 
_pacman_trans_find(trans, spkg->name);
if(ps) {
/* found it -- just append to the replaces list */
ps->data = _pacman_list_add(ps->data, dummy);
@@ -187,7 +187,7 @@ int _pacman_sync_sysupgrade(pmtrans_t *trans, pmdb_t 
*db_local, pmlist_t *dbs_sy
_pacman_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"),
local->name, local->version, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
-                       if(!find_pkginsync(spkg->name, trans->packages)) {
+                       if(!_pacman_trans_find(trans, spkg->name)) {
pmpkg_t *dummy = _pacman_pkg_new(local->name, local->version);
if(dummy == NULL) {
goto error;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to