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

commit c832e4ae0bd56a0571ac3efcf8b374651d4cc0e8
Author: Michel Hermier <[email protected]>
Date:   Thu May 23 12:46:25 2013 +0200

pacman: More f_foreach changes.

diff --git a/src/pacman-g2/add.c b/src/pacman-g2/add.c
index d9bdf96..8c7ba47 100644
--- a/src/pacman-g2/add.c
+++ b/src/pacman-g2/add.c
@@ -92,7 +92,7 @@ int addpkg(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: requires %s"), pacman_dep_getinfo(miss, PM_DEP_TARGET),
pacman_dep_getinfo(miss, PM_DEP_NAME));
@@ -106,7 +106,7 @@ int addpkg(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"),
pacman_dep_getinfo(miss, PM_DEP_TARGET), pacman_dep_getinfo(miss, PM_DEP_NAME));
@@ -114,7 +114,7 @@ int addpkg(list_t *targets)
pacman_list_free(data);
break;
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:
diff --git a/src/pacman-g2/deptest.c b/src/pacman-g2/deptest.c
index a178a20..c6dcaeb 100644
--- a/src/pacman-g2/deptest.c
+++ b/src/pacman-g2/deptest.c
@@ -104,7 +104,7 @@ int deptestpkg(list_t *targets)
*/
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);
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), pacman_dep_getinfo(miss, PM_DEP_NAME));
@@ -121,7 +121,7 @@ int deptestpkg(list_t *targets)
break;
case PM_ERR_CONFLICTING_DEPS:
/* we can't auto-resolve conflicts */
-                               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, _("conflict: %s"), pacman_dep_getinfo(miss, PM_DEP_NAME));
}
diff --git a/src/pacman-g2/package.c b/src/pacman-g2/package.c
index bb1289b..e0754fe 100644
--- a/src/pacman-g2/package.c
+++ b/src/pacman-g2/package.c
@@ -91,11 +91,12 @@ void dump_pkg_full(PM_PKG *pkg, int level)
printf("\n");

if(level > 1) {
-               PM_LIST *i;
+               PM_LIST *i, *pkg_backup = pacman_pkg_getinfo(pkg, 
PM_PKG_BACKUP);
char *root;
+
pacman_get_option(PM_OPT_ROOT, (long *)&root);
fprintf(stdout, "\n");
-               for(i = pacman_list_first(pacman_pkg_getinfo(pkg, 
PM_PKG_BACKUP)); i; i = pacman_list_next(i)) {
+               f_foreach (i, pkg_backup) {
struct stat buf;
char path[PATH_MAX];
char *str = strdup(pacman_list_getdata(i));
@@ -175,7 +176,7 @@ void dump_pkg_files(PM_PKG *pkg)
pkgname = pacman_pkg_getinfo(pkg, PM_PKG_NAME);
pkgfiles = pacman_pkg_getinfo(pkg, PM_PKG_FILES);

-       for(i = pkgfiles; i; i = pacman_list_next(i)) {
+       f_foreach (i, pkgfiles) {
fprintf(stdout, "%s %s%s\n", (char *)pkgname, config->root, (char 
*)pacman_list_getdata(i));
}

@@ -218,7 +219,7 @@ void pkg_fsck(PM_PKG *pkg){
/* maybe this can be used also to get more information about files */
struct stat buf;

-       for(i = pkgfiles; i; i = pacman_list_next(i)) {
+       f_foreach (i, pkgfiles) {
snprintf(path, PATH_MAX, "%s%s", config->root, (char *)pacman_list_getdata(i));
if(lstat(path, &buf) == -1) {
fprintf(stdout, "%s %s\t%s.\n", pkgname, path, strerror(errno));
diff --git a/src/pacman-g2/remove.c b/src/pacman-g2/remove.c
index b6f4055..5442ddb 100644
--- a/src/pacman-g2/remove.c
+++ b/src/pacman-g2/remove.c
@@ -51,7 +51,7 @@ int removepkg(list_t *targets)
/* If the target is a group, ask if its packages should be removed
* (the library can't remove groups for now)
*/
-       for(i = targets; i; i = i->next) {
+       f_foreach (i, targets) {
PM_GRP *grp;

grp = pacman_db_readgrp(db_local, i->data);
@@ -64,7 +64,7 @@ int removepkg(list_t *targets)
MSG(NL, _(":: group %s:\n"), pacman_grp_getinfo(grp, PM_GRP_NAME));
list_display("   ", pkgnames);
all = yesno(_("    Remove whole content? [Y/n] "));
-                       for(lp = pacman_list_first(pkgnames); lp; lp = 
pacman_list_next(lp)) {
+                       f_foreach (lp, pkgnames) {
if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), (char 
*)pacman_list_getdata(lp), i->data)) {
finaltargs = list_add(finaltargs, strdup(pacman_list_getdata(lp)));
}
@@ -87,13 +87,14 @@ int removepkg(list_t *targets)
return(1);
}
/* and add targets to it */
-       for(i = finaltargs; i; i = i->next) {
+       f_foreach (i, finaltargs) {
if(pacman_trans_addtarget(i->data) == -1) {
int found=0;
/* check for regex */
if(config->regex) {
-                               PM_LIST *k;
-                               for(k = pacman_db_getpkgcache(db_local); k; k = 
pacman_list_next(k)) {
+                               PM_LIST *k, *db_pkgcache = 
pacman_db_getpkgcache(db_local);
+
+                               f_foreach (k, db_pkgcache) {
PM_PKG *p = pacman_list_getdata(k);
char *pkgname = pacman_pkg_getinfo(p, PM_PKG_NAME);
int match = pacman_reg_match(pkgname, i->data);
@@ -123,7 +124,7 @@ int removepkg(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: is required by %s\n"), pacman_dep_getinfo(miss, PM_DEP_TARGET),
pacman_dep_getinfo(miss, PM_DEP_NAME));
@@ -140,10 +141,10 @@ int removepkg(list_t *targets)
/* Warn user in case of dangerous operation
*/
if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & 
PM_TRANS_FLAG_CASCADE) {
-               PM_LIST *lp;
+               PM_LIST *lp, *packages = 
pacman_trans_getinfo(PM_TRANS_PACKAGES);
/* list transaction targets */
i = NULL;
-               for(lp = 
pacman_list_first(pacman_trans_getinfo(PM_TRANS_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);
i = list_add(i, strdup(pacman_pkg_getinfo(pkg, PM_PKG_NAME)));
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to