summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-25 05:13:26 +0200
committerDan McGee <dan@archlinux.org>2011-08-25 23:09:52 +0200
commit0ee3ce70a88a42387d19f0d58901fda21b0161b7 (patch)
tree29ed77f1f94445fd92351f3fcc2e3af2891eed1c /src/pacman/util.c
parent73fcf17041cf00e0b6c3082bd354b8eaab412dab (diff)
downloadpacman-0ee3ce70a88a42387d19f0d58901fda21b0161b7.tar.gz
pacman-0ee3ce70a88a42387d19f0d58901fda21b0161b7.tar.xz
Remove short/long label distinction
We only used short labels in one place, and the short label is always the first character of the long label anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index fbc51eba..2de4bd44 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -775,7 +775,7 @@ static alpm_list_t *create_verbose_row(alpm_pkg_t *pkg, int install)
ret = alpm_list_add(ret, str);
/* and size */
- size = humanize_size(alpm_pkg_get_size(pkg), 'M', 1, &label);
+ size = humanize_size(alpm_pkg_get_size(pkg), 'M', &label);
pm_asprintf(&str, "%.2f %s", size, label);
ret = alpm_list_add(ret, str);
@@ -838,19 +838,19 @@ void display_targets(const alpm_list_t *pkgs, int install)
printf("\n");
if(install) {
- size = humanize_size(dlsize, 'M', 1, &label);
+ size = humanize_size(dlsize, 'M', &label);
printf(_("Total Download Size: %.2f %s\n"), size, label);
if(!(config->flags & ALPM_TRANS_FLAG_DOWNLOADONLY)) {
- size = humanize_size(isize, 'M', 1, &label);
+ size = humanize_size(isize, 'M', &label);
printf(_("Total Installed Size: %.2f %s\n"), size, label);
/* only show this net value if different from raw installed size */
if(rsize > 0) {
- size = humanize_size(isize - rsize, 'M', 1, &label);
+ size = humanize_size(isize - rsize, 'M', &label);
printf(_("Net Upgrade Size: %.2f %s\n"), size, label);
}
}
} else {
- size = humanize_size(isize, 'M', 1, &label);
+ size = humanize_size(isize, 'M', &label);
printf(_("Total Removed Size: %.2f %s\n"), size, label);
}
@@ -913,21 +913,17 @@ static char *pkg_get_location(alpm_pkg_t *pkg)
*
* @return the size in the appropriate unit
*/
-double humanize_size(off_t bytes, const char target_unit, int long_labels,
- const char **label)
+double humanize_size(off_t bytes, const char target_unit, const char **label)
{
- static const char *shortlabels[] = {"B", "K", "M", "G",
- "T", "P", "E", "Z", "Y"};
- static const char *longlabels[] = {"B", "KiB", "MiB", "GiB",
+ static const char *labels[] = {"B", "KiB", "MiB", "GiB",
"TiB", "PiB", "EiB", "ZiB", "YiB"};
- static const int unitcount = sizeof(shortlabels) / sizeof(shortlabels[0]);
+ static const int unitcount = sizeof(labels) / sizeof(labels[0]);
- const char **labels = long_labels ? longlabels : shortlabels;
double val = (double)bytes;
int index;
for(index = 0; index < unitcount - 1; index++) {
- if(target_unit != '\0' && shortlabels[index][0] == target_unit) {
+ if(target_unit != '\0' && labels[index][0] == target_unit) {
break;
} else if(target_unit == '\0' && val <= 2048.0 && val >= -2048.0) {
break;