Index: vmstat.c =================================================================== --- vmstat.c (revision 184659) +++ vmstat.c (working copy) @@ -290,7 +290,6 @@ if (devstat_checkversion(NULL) < 0) errx(1, "%s", devstat_errbuf); - argv = getdrivedata(argv); } @@ -546,15 +545,16 @@ static void -prthuman(u_int64_t val, int size) +prthuman(u_int64_t val, int size, int flags) { char buf[10]; - int flags; if (size < 5 || size > 9) errx(1, "doofus"); - flags = HN_B | HN_NOSPACE | HN_DECIMAL; - humanize_number(buf, size, val, "", HN_AUTOSCALE, flags); + flags |= HN_NOSPACE | HN_DECIMAL; + if (humanize_number(buf, size, val, "", HN_AUTOSCALE, flags) < size + 1) + size--; /* A minor hack to skip empty space */ + printf("%*s", size, buf); } @@ -692,9 +692,9 @@ #define rate(x) (((x) + halfuptime) / uptime) /* round */ if (hflag) { printf(" "); - prthuman(total.t_avm * (u_int64_t)sum.v_page_size, 7); + prthuman(total.t_avm * (u_int64_t)sum.v_page_size, 5, HN_B); printf(" "); - prthuman(total.t_free * (u_int64_t)sum.v_page_size, 6); + prthuman(total.t_free * (u_int64_t)sum.v_page_size, 5, HN_B); printf(" "); } else { printf(" %7d ", vmstat_pgtok(total.t_avm)); @@ -715,10 +715,12 @@ (void)printf("%3lu ", (unsigned long)rate(sum.v_pdpages - osum.v_pdpages)); devstats(); - (void)printf("%4lu %4lu %4lu", - (unsigned long)rate(sum.v_intr - osum.v_intr), - (unsigned long)rate(sum.v_syscall - osum.v_syscall), - (unsigned long)rate(sum.v_swtch - osum.v_swtch)); + prthuman(rate(sum.v_intr - osum.v_intr), 5, 0); + printf(" "); + prthuman(rate(sum.v_syscall - osum.v_syscall), 5, 0); + printf(" "); + prthuman(rate(sum.v_swtch - osum.v_swtch), 5, 0); + printf(" "); if (Pflag) pcpustats(ncpus, cpumask, maxid); else @@ -747,7 +749,7 @@ int i, num_shown; num_shown = (num_selected < maxshowdevs) ? num_selected : maxshowdevs; - (void)printf(" procs memory page%*s", 19, ""); + (void)printf(" procs memory page%*s", 19, ""); if (num_shown > 1) (void)printf(" disks %*s", num_shown * 4 - 7, ""); else if (num_shown == 1) @@ -760,8 +762,8 @@ } printf("\n"); } else - printf("cpu\n"); - (void)printf(" r b w avm fre flt re pi po fr sr "); + printf(" cpu\n"); + (void)printf(" r b w avm free flt re pi po fr sr "); for (i = 0; i < num_devices; i++) if ((dev_select[i].selected) && (dev_select[i].selected <= maxshowdevs)) @@ -774,7 +776,7 @@ printf(" us sy id"); printf("\n"); } else - printf(" us sy id\n"); + printf(" us sy id\n"); if (wresized != 0) doresize(); hdrcnt = winlines;