From f46a0535ef7753d3e0b4702753ef19a8e185f269 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 20 Oct 2003 20:13:50 +0000 Subject: [PATCH] When a numeric field overflows its width, try formatting the number in 'kilo' or 'mega' with appropriate suffix instead of filling the field with stars. --- usr.bin/systat/devs.c | 2 +- usr.bin/systat/vmstat.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c index 309253eee6d5..d37cf2d5ad98 100644 --- a/usr.bin/systat/devs.c +++ b/usr.bin/systat/devs.c @@ -138,7 +138,7 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused, if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, &select_generation, generation, s1->dinfo->devices, num_devices, NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1) - errx(1, "%s", devstat_errbuf); + errx(1, "%d %s", __LINE__, devstat_errbuf); return(1); } diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 92a5e83d79aa..6a11f4651555 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -678,11 +678,10 @@ putint(n, l, lc, w) return; } snprintf(b, sizeof(b), "%*d", w, n); - if ((int)strlen(b) > w) { - while (w-- > 0) - addch('*'); - return; - } + if ((int)strlen(b) > w) + snprintf(b, sizeof(b), "%*dK", w - 1, n / 1000); + if ((int)strlen(b) > w) + snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000); addstr(b); }