Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=521f7f4f12c322f5c8bdfbc77fd5f66598411c7b
commit 521f7f4f12c322f5c8bdfbc77fd5f66598411c7b Author: Michel Hermier <herm...@frugalware.org> Date: Thu May 23 12:00:31 2013 +0200 libpacman: More f_foreach changes. diff --git a/lib/libpacman/conflict.c b/lib/libpacman/conflict.c index 0b7d916..a35d4ef 100644 --- a/lib/libpacman/conflict.c +++ b/lib/libpacman/conflict.c @@ -248,7 +248,8 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans, pmlist_t **skip_list) pmtranspkg_t *p2 = j->data; if (p2->pkg_new != NULL) { pmlist_t *ret = chk_fileconflicts(p1->pkg_new->files, p2->pkg_new->files); - for(k = ret; k; k = k->next) { + + f_foreach (k, ret) { pmconflict_t *conflict = _pacman_malloc(sizeof(pmconflict_t)); if(conflict == NULL) { continue; @@ -265,7 +266,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans, pmlist_t **skip_list) /* CHECK 2: check every target against the filesystem */ dbpkg = NULL; - for (j = p1->pkg_new->files; j; j = j->next) { + f_foreach (j, p1->pkg_new->files) { char *filestr = (char*)j->data; snprintf(path, PATH_MAX, "%s%s", trans->handle->root, filestr); @@ -294,7 +295,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans, pmlist_t **skip_list) /* Check if the conflicting file has been moved to another package/target */ if(!ok) { /* Look at all the targets */ - for(k = trans->packages; k && !ok; k = k->next) { + f_foreach (k, trans->packages) { pmtranspkg_t *p2 = k->data; /* As long as they're not the current package */ @@ -304,8 +305,9 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans, pmlist_t **skip_list) _pacman_db_read(db, INFRQ_FILES, p2->pkg_local); } /* If it used to exist in there, but doesn't anymore */ - if(p2->pkg_local && !f_stringlist_find (p2->pkg_new->files, filestr) && f_stringlist_find (p2->pkg_local->files, filestr)) { - ok = 1; + if (p2->pkg_local && + !f_stringlist_find (p2->pkg_new->files, filestr) && + f_stringlist_find (p2->pkg_local->files, filestr)) { /* Add to the "skip list" of files that we shouldn't remove during an upgrade. * * This is a workaround for the following scenario: @@ -323,6 +325,8 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans, pmlist_t **skip_list) * ones, looking for files that jump to different packages. */ *skip_list = _pacman_list_add(*skip_list, strdup(filestr)); + ok = 1; + break; } } } diff --git a/lib/libpacman/deps.c b/lib/libpacman/deps.c index f2e2855..d8986c3 100644 --- a/lib/libpacman/deps.c +++ b/lib/libpacman/deps.c @@ -456,9 +456,11 @@ void _pacman_removedeps(pmtrans_t *trans) return; } - for (i = trans->packages; i; i = i->next, NULL) { + f_foreach (i, trans->packages) { pmtranspkg_t *transpkg = i->data; - for(j = (_pacman_pkg_getinfo(transpkg->pkg_local, PM_PKG_DEPENDS)); j; j = j->next) { + FList *transpkg_depends = _pacman_pkg_getinfo(transpkg->pkg_local, PM_PKG_DEPENDS); + + f_foreach (j, transpkg_depends) { pmdepend_t depend; pmpkg_t *dep; int needed = 0; @@ -534,23 +536,27 @@ int _pacman_resolvedeps (pmtrans_t *trans, pmlist_t *deps, pmlist_t **data) } _pacman_log(PM_LOG_FLOW1, _("resolving targets dependencies")); - for(i = deps; i; i = i->next) { + f_foreach (i, deps) { pmdepmissing_t *miss = i->data; pmpkg_t *ps = NULL; /* find the package in one of the repositories */ /* check literals */ - for(j = trans->handle->dbs_sync; !ps && j; j = j->next) { - ps = _pacman_db_get_pkgfromcache(j->data, miss->depend.name); + f_foreach (j, trans->handle->dbs_sync) { + if ((ps = _pacman_db_get_pkgfromcache(j->data, miss->depend.name)) != NULL) { + break; + } } /* check provides */ - for(j = trans->handle->dbs_sync; !ps && j; j = j->next) { + f_foreach (j, trans->handle->dbs_sync) { pmlist_t *provides; + provides = _pacman_db_whatprovides(j->data, miss->depend.name); if(provides) { ps = provides->data; + FREELISTPTR(provides); + break; } - FREELISTPTR(provides); } if(ps == NULL) { _pacman_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)"), diff --git a/lib/libpacman/package.c b/lib/libpacman/package.c index d0356fa..1e547bd 100644 --- a/lib/libpacman/package.c +++ b/lib/libpacman/package.c @@ -395,7 +395,7 @@ pmpkg_t *_pacman_pkg_isin(const char *needle, pmlist_t *haystack) return(NULL); } - for(lp = haystack; lp; lp = lp->next) { + f_foreach (lp, haystack) { pmpkg_t *info = lp->data; if(info && !strcmp(info->name, needle)) { diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c index 956de0b..a258247 100644 --- a/lib/libpacman/pacman.c +++ b/lib/libpacman/pacman.c @@ -267,10 +267,11 @@ int pacman_db_setserver(pmdb_t *db, char *url) } } else { pmlist_t *i; - for(i = handle->dbs_sync; i && !found; i = i->next) { + f_foreach (i, handle->dbs_sync) { pmdb_t *sdb = i->data; if(strcmp(db->treename, sdb->treename) == 0) { found = 1; + break; } } } diff --git a/lib/libpacman/server.c b/lib/libpacman/server.c index 4bc5778..0c01416 100644 --- a/lib/libpacman/server.c +++ b/lib/libpacman/server.c @@ -240,7 +240,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const char *localpath, } /* get each file in the list */ - for(lp = files; lp; lp = lp->next) { + f_foreach (lp, files) { char *fn = (char *)lp->data; if(f_stringlist_find (complete, fn)) { diff --git a/lib/libpacman/trans.c b/lib/libpacman/trans.c index 26d347b..79c023d 100644 --- a/lib/libpacman/trans.c +++ b/lib/libpacman/trans.c @@ -219,16 +219,22 @@ pmpkg_t *_pacman_dblist_get_pkg(pmlist_t *dblist, const char *pkg_name, int flag pmlist_t *i; pmpkg_t *pkg = NULL; - for (i = dblist; i && !pkg; i = i->next) { + f_foreach (i, dblist) { pmdb_t *db = i->data; - pkg = _pacman_db_get_pkgfromcache(db, pkg_name); + + if ((pkg = _pacman_db_get_pkgfromcache(db, pkg_name)) != NULL) { + break; + } } if (pkg == NULL && flags & PM_TRANS_FLAG_ALLOWPROVIDEREPLACEMENT) { _pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), pkg_name); - for (i = dblist; i && !pkg; i = i->next) { + f_foreach (i, dblist) { pmdb_t *db = i->data; - pkg = _pacman_db_search_provider (db, pkg_name); + + if ((pkg = _pacman_db_search_provider (db, pkg_name)) != NULL) { + break; + } } } if (pkg == NULL) { @@ -829,12 +835,13 @@ int _pacman_sync_prepare (pmtrans_t *trans, pmlist_t **data) pmlist_t *n, *o; for(n = trans->packages; n && !pfound; n = n->next) { pmsyncpkg_t *sp = n->data; - for(o = sp->pkg_new->provides; o && !pfound; o = o->next) { + f_foreach (o, sp->pkg_new->provides) { if(!strcmp(m->data, o->data)) { /* found matching provisio -- we're good to go */ _pacman_log(PM_LOG_FLOW2, _("found '%s' as a provision for '%s' -- conflict aborted"), sp->pkg_new->name, (char *)o->data); pfound = 1; + break; } } } diff --git a/lib/libpacman/trans_sysupgrade.c b/lib/libpacman/trans_sysupgrade.c index 7eb418a..10f8e38 100644 --- a/lib/libpacman/trans_sysupgrade.c +++ b/lib/libpacman/trans_sysupgrade.c @@ -135,8 +135,12 @@ int _pacman_sync_sysupgrade(pmtrans_t *trans) pmpkg_t *spkg = NULL; pmsyncpkg_t *ps; - for(j = dbs_sync; !spkg && j; j = j->next) { - spkg = _pacman_db_get_pkgfromcache(j->data, local->name); + f_foreach (j, dbs_sync) { + pmdb_t *db = j->data; + + if ((spkg = _pacman_db_get_pkgfromcache(db, local->name)) != NULL) { + break; + } } if(spkg == NULL) { _pacman_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name); _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git