free: Adjust space to really use 9 chars

@steffhip found that while the translation hint said use 9 characters in
the free headers, it really was only 7.

Currently each line is constructed with the following (in non wide format):
Header + 6 Columns.  The header takes 7 characters and each column is 11
characters wide and prefixed with one space. Thus we have
7 + (1 + 11) * 6 = 79 characters for each line

By dropping the leading space for the first column after the header -the
header is already terminated by a colon- one could indeed provide the needed
9 letters for the header and thus have 9 + 11 * 1 + (1 + 11) * 5 = 80 Chars
per line which would fit into one line.
This commit is contained in:
Craig Small 2020-04-24 17:42:58 +10:00
parent 3c079c821a
commit fb0915c3ca
9 changed files with 42 additions and 42 deletions

20
free.c
View File

@ -356,8 +356,8 @@ int main(int argc, char **argv)
printf(_(" total used free shared buff/cache available")); printf(_(" total used free shared buff/cache available"));
} }
printf("\n"); printf("\n");
printf("%-7s", _("Mem:")); printf("%-9s", _("Mem:"));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_TOTAL, ul_int), flags, args)); printf("%11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_TOTAL, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_USED, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_USED, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_FREE, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_FREE, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_SHARED, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_SHARED, ul_int), flags, args));
@ -379,28 +379,28 @@ int main(int argc, char **argv)
* to print the high info, even if it is zero. * to print the high info, even if it is zero.
*/ */
if (flags & FREE_LOHI) { if (flags & FREE_LOHI) {
printf("%-7s", _("Low:")); printf("%-9s", _("Low:"));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_TOTAL, ul_int), flags, args)); printf("%11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_TOTAL, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_USED, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_USED, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_FREE, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_LOW_FREE, ul_int), flags, args));
printf("\n"); printf("\n");
printf("%-7s", _("High:")); printf("%-9s", _("High:"));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_TOTAL, ul_int), flags, args)); printf("%11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_TOTAL, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_USED, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_USED, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_FREE, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_HIGH_FREE, ul_int), flags, args));
printf("\n"); printf("\n");
} }
printf("%-7s", _("Swap:")); printf("%-9s", _("Swap:"));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_TOTAL, ul_int), flags, args)); printf("%11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_TOTAL, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_USED, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_USED, ul_int), flags, args));
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_FREE, ul_int), flags, args)); printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_SWAP_FREE, ul_int), flags, args));
printf("\n"); printf("\n");
if (flags & FREE_TOTAL) { if (flags & FREE_TOTAL) {
printf("%-7s", _("Total:")); printf("%-9s", _("Total:"));
printf(" %11s", scale_size( printf("%11s", scale_size(
MEMINFO_GET(mem_info, MEMINFO_MEM_TOTAL, ul_int) + MEMINFO_GET(mem_info, MEMINFO_MEM_TOTAL, ul_int) +
MEMINFO_GET(mem_info, MEMINFO_SWAP_TOTAL, ul_int), flags, args)); MEMINFO_GET(mem_info, MEMINFO_SWAP_TOTAL, ul_int), flags, args));
printf(" %11s", scale_size( printf(" %11s", scale_size(