From dfae7bdd52476673424f8020befef166cf95f3fc Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Fri, 25 Jul 2008 02:02:36 +0200 Subject: src/pacman : rework the display_targets function. We had a lot of duplicated code here. The code handling the showsize option needed to be there three times : 1) for install part of -S 2) for remove part of -S (conflict removal) 3) for -R This patch introduce a new display_targets(pkglist, install) function which can handle the 3 cases above. We pass install == 1 for case 1), and install == 0 for case 2) and 3). Now we can finally get the benefit of an old patch which handled the ShowSize option consistently in the 3 cases above, without an awful lot of duplicated code : http://www.archlinux.org/pipermail/pacman-dev/2008-January/011029.html Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- src/pacman/remove.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/pacman/remove.c') diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 83947cae..f091fa4d 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -125,21 +125,16 @@ int pacman_remove(alpm_list_t *targets) if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) { /* list transaction targets */ - alpm_list_t *lst = NULL; - /* create a new list of package names only */ - for(i = alpm_trans_get_pkgs(); i; i = alpm_list_next(i)) { - pmpkg_t *pkg = alpm_list_getdata(i); - lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg))); - } + alpm_list_t *pkglist = alpm_trans_get_pkgs(); + + display_targets(pkglist, 0); printf("\n"); - list_display(_("Targets:"), lst); - FREELIST(lst); + /* get confirmation */ - if(yesno(1, _("\nDo you want to remove these packages?")) == 0) { + if(yesno(1, _("Do you want to remove these packages?")) == 0) { retval = 1; goto cleanup; } - printf("\n"); } /* Step 3: actually perform the removal */ -- cgit v1.2.3