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:
parent
b4951bfea3
commit
c9908b5971
44
free.c
44
free.c
@ -297,23 +297,23 @@ int main(int argc, char **argv)
|
|||||||
* the header, and the words need to be right align to
|
* the header, and the words need to be right align to
|
||||||
* beginning of a number. */
|
* beginning of a number. */
|
||||||
if (flags & FREE_WIDE) {
|
if (flags & FREE_WIDE) {
|
||||||
printf(_(" total used free shared buffers cache available"));
|
printf(_(" total used free shared buffers cache available"));
|
||||||
} else {
|
} else {
|
||||||
printf(_(" total used free shared buff/cache available"));
|
printf(_(" total used free shared buff/cache available"));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("%-7s", _("Mem:"));
|
printf("%-7s", _("Mem:"));
|
||||||
printf(" %10s", scale_size(kb_main_total, flags, args));
|
printf(" %11s", scale_size(kb_main_total, flags, args));
|
||||||
printf(" %10s", scale_size(kb_main_used, flags, args));
|
printf(" %11s", scale_size(kb_main_used, flags, args));
|
||||||
printf(" %10s", scale_size(kb_main_free, flags, args));
|
printf(" %11s", scale_size(kb_main_free, flags, args));
|
||||||
printf(" %10s", scale_size(kb_main_shared, flags, args));
|
printf(" %11s", scale_size(kb_main_shared, flags, args));
|
||||||
if (flags & FREE_WIDE) {
|
if (flags & FREE_WIDE) {
|
||||||
printf(" %10s", scale_size(kb_main_buffers, flags, args));
|
printf(" %11s", scale_size(kb_main_buffers, flags, args));
|
||||||
printf(" %10s", scale_size(kb_main_cached, flags, args));
|
printf(" %11s", scale_size(kb_main_cached, flags, args));
|
||||||
} else {
|
} 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");
|
printf("\n");
|
||||||
/*
|
/*
|
||||||
* Print low vs. high information, if the user requested it.
|
* Print low vs. high information, if the user requested it.
|
||||||
@ -323,29 +323,29 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (flags & FREE_LOHI) {
|
if (flags & FREE_LOHI) {
|
||||||
printf("%-7s", _("Low:"));
|
printf("%-7s", _("Low:"));
|
||||||
printf(" %10s", scale_size(kb_low_total, flags, args));
|
printf(" %11s", scale_size(kb_low_total, flags, args));
|
||||||
printf(" %10s", scale_size(kb_low_total - kb_low_free, flags, args));
|
printf(" %11s", 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_free, flags, args));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("%-7s", _("High:"));
|
printf("%-7s", _("High:"));
|
||||||
printf(" %10s", scale_size(kb_high_total, flags, args));
|
printf(" %11s", scale_size(kb_high_total, flags, args));
|
||||||
printf(" %10s", scale_size(kb_high_total - kb_high_free, flags, args));
|
printf(" %11s", 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_free, flags, args));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%-7s", _("Swap:"));
|
printf("%-7s", _("Swap:"));
|
||||||
printf(" %10s", scale_size(kb_swap_total, flags, args));
|
printf(" %11s", scale_size(kb_swap_total, flags, args));
|
||||||
printf(" %10s", scale_size(kb_swap_used, flags, args));
|
printf(" %11s", scale_size(kb_swap_used, flags, args));
|
||||||
printf(" %10s", scale_size(kb_swap_free, flags, args));
|
printf(" %11s", scale_size(kb_swap_free, flags, args));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (flags & FREE_TOTAL) {
|
if (flags & FREE_TOTAL) {
|
||||||
printf("%-7s", _("Total:"));
|
printf("%-7s", _("Total:"));
|
||||||
printf(" %10s", scale_size(kb_main_total + kb_swap_total, flags, args));
|
printf(" %11s", scale_size(kb_main_total + kb_swap_total, flags, args));
|
||||||
printf(" %10s", scale_size(kb_main_used + kb_swap_used, flags, args));
|
printf(" %11s", 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_free + kb_swap_free, flags, args));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
Loading…
Reference in New Issue
Block a user