Index: usr.bin/systat/Makefile =================================================================== --- usr.bin/systat/Makefile +++ usr.bin/systat/Makefile @@ -16,6 +16,6 @@ WARNS?= 1 -LIBADD= ncursesw m devstat kvm +LIBADD= ncursesw m devstat kvm util .include Index: usr.bin/systat/vmstat.c =================================================================== --- usr.bin/systat/vmstat.c +++ usr.bin/systat/vmstat.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -135,7 +136,7 @@ static float cputime(int); static void dinfo(int, int, struct statinfo *, struct statinfo *); static void getinfo(struct Info *); -static void putint(int, int, int, int); +static void putint(int64_t, int, int, int); static void putfloat(double, int, int, int, int, int); static void putlongdouble(long double, int, int, int, int, int); static int ucount(void); @@ -662,10 +663,11 @@ } static void -putint(int n, int l, int lc, int w) +putint(int64_t n, int l, int lc, int w) { int snr; char b[128]; + char buf[128]; move(l, lc); #ifdef DEBUG @@ -678,11 +680,12 @@ addch(' '); return; } - snr = snprintf(b, sizeof(b), "%*d", w, n); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000); + snr = snprintf(b, sizeof(b), "%*jd", w, n); + if (snr != w) { + humanize_number(buf, w, n, "", HN_AUTOSCALE, + HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000); + snr = snprintf(b, sizeof(b), "%*s", w, buf); + } if (snr != w) { while (w-- > 0) addch('*'); @@ -696,6 +699,7 @@ { int snr; char b[128]; + char buf[128]; move(l, lc); #ifdef DEBUG @@ -709,12 +713,11 @@ return; } snr = snprintf(b, sizeof(b), "%*.*f", w, d, f); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0f", w, f); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0fk", w - 1, f / 1000); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0fM", w - 1, f / 1000000); + if (snr != w) { + humanize_number(buf, w, (int64_t)f, "", HN_AUTOSCALE, + HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000); + snr = snprintf(b, sizeof(b), "%*s", w, buf); + } if (snr != w) { while (--w >= 0) addch('*'); @@ -728,6 +731,7 @@ { int snr; char b[128]; + char buf[128]; move(l, lc); #ifdef DEBUG @@ -741,12 +745,11 @@ return; } snr = snprintf(b, sizeof(b), "%*.*Lf", w, d, f); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0Lf", w, f); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0Lfk", w - 1, f / 1000); - if (snr != w) - snr = snprintf(b, sizeof(b), "%*.0LfM", w - 1, f / 1000000); + if (snr != w) { + humanize_number(buf, w, (int64_t)f, "", HN_AUTOSCALE, + HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000); + snr = snprintf(b, sizeof(b), "%*s", w, buf); + } if (snr != w) { while (--w >= 0) addch('*');