Page MenuHomeFreeBSD

D13105.1777989814.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D13105.1777989814.diff

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 <bsd.prog.mk>
Index: usr.bin/systat/vmstat.c
===================================================================
--- usr.bin/systat/vmstat.c
+++ usr.bin/systat/vmstat.c
@@ -54,7 +54,9 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <inttypes.h>
#include <langinfo.h>
+#include <libutil.h>
#include <nlist.h>
#include <paths.h>
#include <signal.h>
@@ -135,7 +137,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 +664,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 +681,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), "%*" PRIi64, 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 +700,7 @@
{
int snr;
char b[128];
+ char buf[128];
move(l, lc);
#ifdef DEBUG
@@ -709,12 +714,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 +732,7 @@
{
int snr;
char b[128];
+ char buf[128];
move(l, lc);
#ifdef DEBUG
@@ -741,12 +746,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('*');

File Metadata

Mime Type
text/plain
Expires
Tue, May 5, 2:03 PM (13 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28564589
Default Alt Text
D13105.1777989814.diff (2 KB)

Event Timeline