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>
This commit is contained in:
parent
73fcf17041
commit
0ee3ce70a8
4 changed files with 16 additions and 20 deletions
|
@ -663,12 +663,12 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rate_human = humanize_size((off_t)rate, '\0', 0, &rate_label);
|
rate_human = humanize_size((off_t)rate, '\0', &rate_label);
|
||||||
xfered_human = humanize_size(xfered, '\0', 1, &xfered_label);
|
xfered_human = humanize_size(xfered, '\0', &xfered_label);
|
||||||
|
|
||||||
printf(" %ls%-*s ", wcfname, padwid, "");
|
printf(" %ls%-*s ", wcfname, padwid, "");
|
||||||
printf("%6.1f %3s %4.f%s/s ",
|
printf("%6.1f %3s %4.f%c/s ",
|
||||||
xfered_human, xfered_label, rate_human, rate_label);
|
xfered_human, xfered_label, rate_human, rate_label[0]);
|
||||||
if(eta_h == 0) {
|
if(eta_h == 0) {
|
||||||
printf("%02u:%02u", eta_m, eta_s);
|
printf("%02u:%02u", eta_m, eta_s);
|
||||||
} else if(eta_h < 100) {
|
} else if(eta_h < 100) {
|
||||||
|
|
|
@ -120,14 +120,14 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
|
||||||
deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
||||||
deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
||||||
|
|
||||||
size = humanize_size(alpm_pkg_get_size(pkg), 'K', 1, &label);
|
size = humanize_size(alpm_pkg_get_size(pkg), 'K', &label);
|
||||||
if(from == PKG_FROM_SYNCDB) {
|
if(from == PKG_FROM_SYNCDB) {
|
||||||
printf(_("Download Size : %6.2f %s\n"), size, label);
|
printf(_("Download Size : %6.2f %s\n"), size, label);
|
||||||
} else if(from == PKG_FROM_FILE) {
|
} else if(from == PKG_FROM_FILE) {
|
||||||
printf(_("Compressed Size: %6.2f %s\n"), size, label);
|
printf(_("Compressed Size: %6.2f %s\n"), size, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 1, &label);
|
size = humanize_size(alpm_pkg_get_isize(pkg), 'K', &label);
|
||||||
printf(_("Installed Size : %6.2f %s\n"), size, label);
|
printf(_("Installed Size : %6.2f %s\n"), size, label);
|
||||||
|
|
||||||
string_display(_("Packager :"), alpm_pkg_get_packager(pkg));
|
string_display(_("Packager :"), alpm_pkg_get_packager(pkg));
|
||||||
|
|
|
@ -775,7 +775,7 @@ static alpm_list_t *create_verbose_row(alpm_pkg_t *pkg, int install)
|
||||||
ret = alpm_list_add(ret, str);
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
/* and size */
|
/* 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);
|
pm_asprintf(&str, "%.2f %s", size, label);
|
||||||
ret = alpm_list_add(ret, str);
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
|
@ -838,19 +838,19 @@ void display_targets(const alpm_list_t *pkgs, int install)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if(install) {
|
if(install) {
|
||||||
size = humanize_size(dlsize, 'M', 1, &label);
|
size = humanize_size(dlsize, 'M', &label);
|
||||||
printf(_("Total Download Size: %.2f %s\n"), size, label);
|
printf(_("Total Download Size: %.2f %s\n"), size, label);
|
||||||
if(!(config->flags & ALPM_TRANS_FLAG_DOWNLOADONLY)) {
|
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);
|
printf(_("Total Installed Size: %.2f %s\n"), size, label);
|
||||||
/* only show this net value if different from raw installed size */
|
/* only show this net value if different from raw installed size */
|
||||||
if(rsize > 0) {
|
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);
|
printf(_("Net Upgrade Size: %.2f %s\n"), size, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size = humanize_size(isize, 'M', 1, &label);
|
size = humanize_size(isize, 'M', &label);
|
||||||
printf(_("Total Removed Size: %.2f %s\n"), size, 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
|
* @return the size in the appropriate unit
|
||||||
*/
|
*/
|
||||||
double humanize_size(off_t bytes, const char target_unit, int long_labels,
|
double humanize_size(off_t bytes, const char target_unit, const char **label)
|
||||||
const char **label)
|
|
||||||
{
|
{
|
||||||
static const char *shortlabels[] = {"B", "K", "M", "G",
|
static const char *labels[] = {"B", "KiB", "MiB", "GiB",
|
||||||
"T", "P", "E", "Z", "Y"};
|
|
||||||
static const char *longlabels[] = {"B", "KiB", "MiB", "GiB",
|
|
||||||
"TiB", "PiB", "EiB", "ZiB", "YiB"};
|
"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;
|
double val = (double)bytes;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
for(index = 0; index < unitcount - 1; 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;
|
break;
|
||||||
} else if(target_unit == '\0' && val <= 2048.0 && val >= -2048.0) {
|
} else if(target_unit == '\0' && val <= 2048.0 && val >= -2048.0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,7 +53,7 @@ char *strtrim(char *str);
|
||||||
char *strreplace(const char *str, const char *needle, const char *replace);
|
char *strreplace(const char *str, const char *needle, const char *replace);
|
||||||
alpm_list_t *strsplit(const char *str, const char splitchar);
|
alpm_list_t *strsplit(const char *str, const char splitchar);
|
||||||
void string_display(const char *title, const char *string);
|
void string_display(const char *title, const char *string);
|
||||||
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);
|
||||||
int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
|
int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
|
||||||
void list_display(const char *title, const alpm_list_t *list);
|
void list_display(const char *title, const alpm_list_t *list);
|
||||||
void list_display_linebreak(const char *title, const alpm_list_t *list);
|
void list_display_linebreak(const char *title, const alpm_list_t *list);
|
||||||
|
|
Loading…
Add table
Reference in a new issue