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

commit e26ccc71f3172c16f8c99688495625f458569fc9
Author: Michel Hermier <[email protected]>
Date:   Thu May 23 12:26:00 2013 +0200

pacman: More f_foreach change.

diff --git a/src/pacman-g2/add.c b/src/pacman-g2/add.c
index 25cc280..d9bdf96 100644
--- a/src/pacman-g2/add.c
+++ b/src/pacman-g2/add.c
@@ -48,7 +48,7 @@ int addpkg(list_t *targets)

/* Check for URL targets and process them
*/
-       for(i = targets; i; i = i->next) {
+       f_foreach (i, targets) {
if(strstr(i->data, "://")) {
char *str = pacman_fetch_pkgurl(i->data);
if(str == NULL) {
@@ -74,7 +74,7 @@ int addpkg(list_t *targets)

/* and add targets to it */
MSG(NL, _("loading package data... "));
-       for(i = targets; i; i = i->next) {
+       f_foreach (i, targets) {
if(pacman_trans_addtarget(i->data) == -1) {
ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, 
pacman_strerror(pm_errno));
retval = 1;
diff --git a/src/pacman-g2/deptest.c b/src/pacman-g2/deptest.c
index 80ec9e4..a178a20 100644
--- a/src/pacman-g2/deptest.c
+++ b/src/pacman-g2/deptest.c
@@ -79,7 +79,7 @@ int deptestpkg(list_t *targets)
goto cleanup;
}
strcpy(str, "name=dummy|version=1.0-1");
-       for(i = targets; i; i = i->next) {
+       f_foreach (i, targets) {
str = (char *)realloc(str, strlen(str)+8+strlen(i->data)+1);
strcat(str, "|depend=");
strcat(str, i->data);
diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c
index dd5fab2..8ea627d 100644
--- a/src/pacman-g2/pacman-g2.c
+++ b/src/pacman-g2/pacman-g2.c
@@ -618,7 +618,7 @@ int main(int argc, char *argv[])
FREE(config->cachedir);
pacman_get_option(PM_OPT_CACHEDIR, (long *)&config->cachedir);

-       for(lp = config->op_s_ignore; lp; lp = lp->next) {
+       f_foreach (lp, config->op_s_ignore) {
if(pacman_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) {
ERR(NL, _("failed to set option IGNOREPKG (%s)\n"), pacman_strerror(pm_errno));
cleanup(1);
diff --git a/src/pacman-g2/ps.c b/src/pacman-g2/ps.c
index 23a3218..6bb7457 100644
--- a/src/pacman-g2/ps.c
+++ b/src/pacman-g2/ps.c
@@ -215,7 +215,7 @@ int pspkg(int countonly)

list_t* ret = ps_parse(fpout);

-       for (i = ret; i; i = i->next) {
+       f_foreach (i, ret) {
ps_t *ps = i->data;
if (!ps)
continue;
diff --git a/src/pacman-g2/query.c b/src/pacman-g2/query.c
index 3e8ae76..fde1238 100644
--- a/src/pacman-g2/query.c
+++ b/src/pacman-g2/query.c
@@ -51,14 +51,14 @@ int querypkg(list_t *targets)
int done = 0, errors = 0;

if(config->op_q_search) {
-               for(i = targets; i; i = i->next) {
+               f_foreach (i, targets) {
pacman_set_option(PM_OPT_NEEDLES, (long)i->data);
}
ret = pacman_db_search(db_local);
if(ret == NULL) {
return(1);
}
-               for(j = ret; j; j = pacman_list_next(j)) {
+               f_foreach (j, ret) {
PM_PKG *pkg = pacman_list_getdata(j);

printf("local/%s %s-%s [Desc: %s]\n",
@@ -76,7 +76,7 @@ int querypkg(list_t *targets)
printf(_(":: the database seems to be consistent\n"));
return(0);
}
-               for(j = ret; j; j = pacman_list_next(j)) {
+               f_foreach (j, ret) {
char *str = pacman_list_getdata(j);
printf(":: %s\n", str);
}
@@ -112,7 +112,7 @@ int querypkg(list_t *targets)
grpname = pacman_grp_getinfo(grp, PM_GRP_NAME);
pkgnames = pacman_grp_getinfo(grp, PM_GRP_PKGNAMES);

-                                       for(lq = pkgnames; lq; lq = 
pacman_list_next(lq)) {
+                                       f_foreach (lq, pkgnames) {
MSG(NL, "%s %s\n", grpname, (char *)pacman_list_getdata(lq));
}
}
@@ -120,7 +120,7 @@ int querypkg(list_t *targets)
PM_GRP *grp = pacman_db_readgrp(db_local, package);
if(grp) {
PM_LIST *lq, *pkgnames = pacman_grp_getinfo(grp, PM_GRP_PKGNAMES);
-                                       for(lq = pkgnames; lq; lq = 
pacman_list_next(lq)) {
+                                       f_foreach (lq, pkgnames) {
MSG(NL, "%s %s\n", package, (char *)pacman_list_getdata(lq));
}
} else {
@@ -164,7 +164,7 @@ int querypkg(list_t *targets)
errors++;
} else {
PM_LIST *lp;
-                               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+                               f_foreach (lp, data) {
PM_PKG *pkg = pacman_list_getdata(lp);
printf(_("%s %s is an owner of %s\n"), (char *)pacman_pkg_getinfo(pkg, 
PM_PKG_NAME),
(char *)pacman_pkg_getinfo(pkg, PM_PKG_VERSION), package);
@@ -204,7 +204,7 @@ int querypkg(list_t *targets)
}
if(config->op_q_foreign) {
int match = 0;
-                                               for(i = pmc_syncs; i; i = 
i->next) {
+                                               f_foreach (i, pmc_syncs) {
PM_DB *db = i->data;
for(j = pacman_db_getpkgcache(db); j; j = pacman_list_next(j)) {
PM_PKG *pkg = pacman_list_getdata(j);
diff --git a/src/pacman-g2/sync.c b/src/pacman-g2/sync.c
index 90dc812..797587e 100644
--- a/src/pacman-g2/sync.c
+++ b/src/pacman-g2/sync.c
@@ -62,7 +62,7 @@ static int sync_synctree(int level, list_t *syncs)
list_t *i;
int success = 0, ret;

-       for(i = syncs; i; i = i->next) {
+       f_foreach (i, syncs) {
PM_DB *db = i->data;

ret = pacman_db_update((level < 2 ? 0 : 1), db);
@@ -88,18 +88,18 @@ static int sync_search(list_t *syncs, list_t *targets)
PM_LIST *ret;
PM_PKG *ipkg;

-       for(i = syncs; i; i = i->next) {
+       f_foreach (i, syncs) {
PM_DB *db = i->data;
PM_LIST *lp;

-               for(j = targets; j; j = j->next) {
+               f_foreach (j, targets) {
pacman_set_option(PM_OPT_NEEDLES, (long)j->data);
}
ret = pacman_db_search(db);
if(ret == NULL) {
continue;
}
-               for(lp = ret; lp; lp = pacman_list_next(lp)) {
+               f_foreach (lp, ret) {
PM_PKG *pkg = pacman_list_getdata(lp);
char *name = (char *)pacman_pkg_getinfo(pkg, PM_PKG_NAME);

@@ -128,9 +128,10 @@ static int sync_group(int level, list_t *syncs, list_t 
*targets)
int ret = 0;

if(targets) {
-               for(i = targets; i; i = i->next) {
+               f_foreach (i, targets) {
int found = 0;
-                       for(j = syncs; j; j = j->next) {
+
+                       f_foreach (j, syncs) {
PM_DB *db = j->data;
PM_GRP *grp = pacman_db_readgrp(db, i->data);

@@ -146,7 +147,7 @@ static int sync_group(int level, list_t *syncs, list_t 
*targets)
}
}
} else {
-               for(j = syncs; j; j = j->next) {
+               f_foreach (j, syncs) {
PM_DB *db = j->data;
PM_LIST *lp;

@@ -169,7 +170,7 @@ static int sync_info(list_t *syncs, list_t *targets)
list_t *i, *j;

if(targets) {
-               for(i = targets; i; i = i->next) {
+               f_foreach (i, targets) {
int found = 0;

for(j = syncs; j && !found; j = j->next) {
@@ -192,7 +193,7 @@ static int sync_info(list_t *syncs, list_t *targets)
}
}
} else {
-               for(j = syncs; j; j = j->next) {
+               f_foreach (j, syncs) {
PM_DB *db = j->data;
PM_LIST *lp;

@@ -212,15 +213,16 @@ static int sync_list(list_t *syncs, list_t *targets)
list_t *ls = NULL;

if(targets) {
-               for(i = targets; i; i = i->next) {
+               f_foreach (i, targets) {
list_t *j;
PM_DB *db = NULL;

-                       for(j = syncs; j && !db; j = j->next) {
+                       f_foreach (j, syncs) {
PM_DB *d = j->data;

if(strcmp(i->data, (char *)pacman_db_getinfo(d, PM_DB_TREENAME)) == 0) {
db = d;
+                                       break;
}
}

@@ -236,7 +238,7 @@ static int sync_list(list_t *syncs, list_t *targets)
ls = syncs;
}

-       for(i = ls; i; i = i->next) {
+       f_foreach (i, ls) {
PM_LIST *lp;
PM_DB *db = i->data;

@@ -342,7 +344,7 @@ int syncpkg(list_t *targets)
* when sysupgrade'ing with an older version of pacman-g2.
*/
data = pacman_trans_getinfo(PM_TRANS_PACKAGES);
-               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+               f_foreach (lp, data) {
PM_SYNCPKG *ps = pacman_list_getdata(lp);
PM_PKG *spkg = pacman_sync_getinfo(ps, PM_SYNC_PKG);
if (!strcmp("pacman-g2", pacman_pkg_getinfo(spkg, PM_PKG_NAME)) && f_list_count 
(data) > 1) {
@@ -375,7 +377,7 @@ int syncpkg(list_t *targets)
}
} else {
/* process targets */
-               for(i = targets; i; i = i->next) {
+               f_foreach (i, targets) {
char *targ = i->data;
if(pacman_trans_addtarget(targ) == -1) {
PM_GRP *grp = NULL;
@@ -391,7 +393,7 @@ int syncpkg(list_t *targets)
goto cleanup;
}
/* target not found: check if it's a group */
-                               for(j = pmc_syncs; j; j = j->next) {
+                               f_foreach (j, pmc_syncs) {
PM_DB *db = j->data;
grp = pacman_db_readgrp(db, targ);
if(grp) {
@@ -405,11 +407,11 @@ int syncpkg(list_t *targets)
pkgs = f_stringlist_uniques (pmpkgs);
list_display("   ", pkgs);
if(yesno(_(":: Install whole content? [Y/n] "))) {
-                                                       for(k = pkgs; k; k = 
k->next) {
+                                                       f_foreach (k, pkgs) {
targets = list_add(targets, strdup(k->data));
}
} else {
-                                                       for(k = pkgs; k; k = 
k->next) {
+                                                       f_foreach (k, pkgs) {
char *pkgname = k->data;
if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) {
targets = list_add(targets, strdup(pkgname));
@@ -421,7 +423,7 @@ int syncpkg(list_t *targets)
}
/* targ is not a group, see if it's a regex */
if(!found && config->regex) {
-                                       for(j = pmc_syncs; j; j = j->next) {
+                                       f_foreach (j, pmc_syncs) {
PM_DB *db = j->data;
PM_LIST *k;
for(k = pacman_db_getpkgcache(db); k; k = pacman_list_next(k)) {
@@ -470,7 +472,7 @@ int syncpkg(list_t *targets)
ERR(NL, _("failed to prepare transaction (%s)\n"), pacman_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
-                               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+                               f_foreach (lp, data) {
PM_DEPMISS *miss = pacman_list_getdata(lp);
MSG(NL, ":: %s: %s %s", pacman_dep_getinfo(miss, PM_DEP_TARGET),
(long)pacman_dep_getinfo(miss, PM_DEP_TYPE) == PM_DEP_TYPE_DEPEND ? 
_("requires") : _("is required by"),
@@ -485,7 +487,7 @@ int syncpkg(list_t *targets)
pacman_list_free(data);
break;
case PM_ERR_CONFLICTING_DEPS:
-                               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+                               f_foreach (lp, data) {
PM_DEPMISS *miss = pacman_list_getdata(lp);

MSG(NL, _(":: %s: conflicts with %s"),
@@ -525,7 +527,7 @@ int syncpkg(list_t *targets)
unsigned long totalusize = 0;
double mb, umb;

-               for(lp = pacman_list_first(packages); lp; lp = 
pacman_list_next(lp)) {
+               f_foreach (lp, packages) {
PM_SYNCPKG *ps = pacman_list_getdata(lp);
PM_PKG *pkg = pacman_sync_getinfo(ps, PM_SYNC_PKG);
char *pkgname, *pkgver;
@@ -609,7 +611,7 @@ int syncpkg(list_t *targets)
ERR(NL, _("failed to commit transaction (%s)\n"), pacman_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_FILE_CONFLICTS:
-                               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+                               f_foreach (lp, data) {
PM_CONFLICT *conflict = pacman_list_getdata(lp);
switch((long)pacman_conflict_getinfo(conflict, PM_CONFLICT_TYPE)) {
case PM_CONFLICT_TYPE_TARGET:
@@ -630,7 +632,7 @@ int syncpkg(list_t *targets)
pacman_list_free(data);
break;
case PM_ERR_PKG_CORRUPTED:
-                               for(lp = pacman_list_first(data); lp; lp = 
pacman_list_next(lp)) {
+                               f_foreach (lp, data) {
MSG(NL, "%s", (char*)pacman_list_getdata(lp));
}
pacman_list_free(data);
diff --git a/src/pacman-g2/util.c b/src/pacman-g2/util.c
index b937ee1..d1f6f3c 100644
--- a/src/pacman-g2/util.c
+++ b/src/pacman-g2/util.c
@@ -94,7 +94,7 @@ char *buildstring(list_t *strlist)
int size = 1;
list_t *lp;

-       for(lp = strlist; lp; lp = lp->next) {
+       f_foreach (lp, strlist) {
size += strlen(lp->data) + 1;
}
str = (char *)malloc(size);
@@ -102,7 +102,7 @@ char *buildstring(list_t *strlist)
ERR(NL, _("failed to allocated %d bytes\n"), size);
}
str[0] = '\0';
-       for(lp = strlist; lp; lp = lp->next) {
+       f_foreach (lp, strlist) {
strcat(str, lp->data);
strcat(str, " ");
}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to