diff options
author | Jakob Gruber <jakob.gruber@gmail.com> | 2011-02-20 14:42:05 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-04-21 00:33:13 +0200 |
commit | c3f3d0b81ab3f36910b16a7aab5e787960ff20d7 (patch) | |
tree | e0e88d9156cb0037e4111a1cb2869ca58a962218 /src | |
parent | ecf15be0a760b6209bd3794a4d36b17282f97f70 (diff) | |
download | pacman-c3f3d0b81ab3f36910b16a7aab5e787960ff20d7.tar.gz pacman-c3f3d0b81ab3f36910b16a7aab5e787960ff20d7.tar.xz |
Refactor display_targets for readability
Row handling is moved to its own function in preparation for verbose
package lists.
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/util.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c index 47d0f00d..8d5ada61 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -518,11 +518,12 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) } } } + /* prepare a list of pkgs to display */ void display_targets(const alpm_list_t *pkgs, int install) { char *str; - const char *label; + const char *title, *label; double size; const alpm_list_t *i; off_t isize = 0, dlsize = 0; @@ -532,7 +533,6 @@ void display_targets(const alpm_list_t *pkgs, int install) return; } - printf("\n"); for(i = pkgs; i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); @@ -546,12 +546,14 @@ void display_targets(const alpm_list_t *pkgs, int install) targets = alpm_list_add(targets, str); } - if(install) { - pm_asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); - list_display(str, targets); - free(str); - printf("\n"); + title = install ? _("Targets (%d):") : _("Remove (%d):"); + pm_asprintf(&str, title, alpm_list_count(pkgs)); + + printf("\n"); + list_display(str, targets); + printf("\n"); + if(install) { size = humanize_size(dlsize, 'M', 1, &label); printf(_("Total Download Size: %.2f %s\n"), size, label); if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY)) { @@ -559,15 +561,11 @@ void display_targets(const alpm_list_t *pkgs, int install) printf(_("Total Installed Size: %.2f %s\n"), size, label); } } else { - pm_asprintf(&str, _("Remove (%d):"), alpm_list_count(targets)); - list_display(str, targets); - free(str); - printf("\n"); - size = humanize_size(isize, 'M', 1, &label); printf(_("Total Removed Size: %.2f %s\n"), size, label); } + free(str); FREELIST(targets); } |