free: fixing the layout broken with the -w introduction

For some reason I thought the columns are left justified
and consequently modified the header incorrectly when
implementing the -w/--wide feature.
With this commit the column width was increased by 1
so that the default layout is 79 characters wide
and allows to display 11 digits per column.
This commit is contained in:
Jaromir Capik 2014-08-20 13:21:22 +02:00
parent b4951bfea3
commit c9908b5971

40
free.c
View File

@ -303,17 +303,17 @@ int main(int argc, char **argv)
}
printf("\n");
printf("%-7s", _("Mem:"));
printf(" %10s", scale_size(kb_main_total, flags, args));
printf(" %10s", scale_size(kb_main_used, flags, args));
printf(" %10s", scale_size(kb_main_free, flags, args));
printf(" %10s", scale_size(kb_main_shared, flags, args));
printf(" %11s", scale_size(kb_main_total, flags, args));
printf(" %11s", scale_size(kb_main_used, flags, args));
printf(" %11s", scale_size(kb_main_free, flags, args));
printf(" %11s", scale_size(kb_main_shared, flags, args));
if (flags & FREE_WIDE) {
printf(" %10s", scale_size(kb_main_buffers, flags, args));
printf(" %10s", scale_size(kb_main_cached, flags, args));
printf(" %11s", scale_size(kb_main_buffers, flags, args));
printf(" %11s", scale_size(kb_main_cached, flags, args));
} else {
printf(" %10s", scale_size(kb_main_buffers+kb_main_cached, flags, args));
printf(" %11s", scale_size(kb_main_buffers+kb_main_cached, flags, args));
}
printf(" %10s", scale_size(kb_main_available, flags, args));
printf(" %11s", scale_size(kb_main_available, flags, args));
printf("\n");
/*
* Print low vs. high information, if the user requested it.
@ -323,29 +323,29 @@ int main(int argc, char **argv)
*/
if (flags & FREE_LOHI) {
printf("%-7s", _("Low:"));
printf(" %10s", scale_size(kb_low_total, flags, args));
printf(" %10s", scale_size(kb_low_total - kb_low_free, flags, args));
printf(" %10s", scale_size(kb_low_free, flags, args));
printf(" %11s", scale_size(kb_low_total, flags, args));
printf(" %11s", scale_size(kb_low_total - kb_low_free, flags, args));
printf(" %11s", scale_size(kb_low_free, flags, args));
printf("\n");
printf("%-7s", _("High:"));
printf(" %10s", scale_size(kb_high_total, flags, args));
printf(" %10s", scale_size(kb_high_total - kb_high_free, flags, args));
printf(" %10s", scale_size(kb_high_free, flags, args));
printf(" %11s", scale_size(kb_high_total, flags, args));
printf(" %11s", scale_size(kb_high_total - kb_high_free, flags, args));
printf(" %11s", scale_size(kb_high_free, flags, args));
printf("\n");
}
printf("%-7s", _("Swap:"));
printf(" %10s", scale_size(kb_swap_total, flags, args));
printf(" %10s", scale_size(kb_swap_used, flags, args));
printf(" %10s", scale_size(kb_swap_free, flags, args));
printf(" %11s", scale_size(kb_swap_total, flags, args));
printf(" %11s", scale_size(kb_swap_used, flags, args));
printf(" %11s", scale_size(kb_swap_free, flags, args));
printf("\n");
if (flags & FREE_TOTAL) {
printf("%-7s", _("Total:"));
printf(" %10s", scale_size(kb_main_total + kb_swap_total, flags, args));
printf(" %10s", scale_size(kb_main_used + kb_swap_used, flags, args));
printf(" %10s", scale_size(kb_main_free + kb_swap_free, flags, args));
printf(" %11s", scale_size(kb_main_total + kb_swap_total, flags, args));
printf(" %11s", scale_size(kb_main_used + kb_swap_used, flags, args));
printf(" %11s", scale_size(kb_main_free + kb_swap_free, flags, args));
printf("\n");
}
fflush(stdout);