mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 03:49:02 +00:00
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.
This commit is contained in:
parent
484288de56
commit
f46a0535ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121291
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user