summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2008-12-01 18:03:06 +0000
committernaddy <naddy@openbsd.org>2008-12-01 18:03:06 +0000
commitdfea33b35c0d8fa8896a97cc5dc94c5ffd653480 (patch)
tree7702130ed73e93cba3fd09bac7982b3f48c5c455
parentleak memory in the realloc function until we find out who has a pointer (diff)
downloadwireguard-openbsd-dfea33b35c0d8fa8896a97cc5dc94c5ffd653480.tar.xz
wireguard-openbsd-dfea33b35c0d8fa8896a97cc5dc94c5ffd653480.zip
Add a function to print a floating point field and use this to fix the
SEConds field in the iostat view. ok and help canacar@
-rw-r--r--usr.bin/systat/engine.c22
-rw-r--r--usr.bin/systat/engine.h3
-rw-r--r--usr.bin/systat/iostat.c6
3 files changed, 26 insertions, 5 deletions
diff --git a/usr.bin/systat/engine.c b/usr.bin/systat/engine.c
index 54f2df32fbd..79c0c7c6a99 100644
--- a/usr.bin/systat/engine.c
+++ b/usr.bin/systat/engine.c
@@ -1,4 +1,4 @@
-/* $Id: engine.c,v 1.5 2008/10/31 06:50:09 canacar Exp $ */
+/* $Id: engine.c,v 1.6 2008/12/01 18:03:06 naddy Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -811,6 +811,26 @@ print_fld_uint(field_def *fld, unsigned int size)
tb_end();
}
+void
+print_fld_float(field_def *fld, double f, int prec)
+{
+ int len;
+
+ if (fld == NULL)
+ return;
+
+ len = fld->width;
+ if (len < 1)
+ return;
+
+ tb_start();
+ if (tbprintf("%*.*f", len, prec, f) > len)
+ print_fld_str(fld, "*");
+ else
+ print_fld_tb(fld);
+ tb_end();
+}
+
/* ordering */
diff --git a/usr.bin/systat/engine.h b/usr.bin/systat/engine.h
index 6225cd69826..8aef3485ff3 100644
--- a/usr.bin/systat/engine.h
+++ b/usr.bin/systat/engine.h
@@ -1,4 +1,4 @@
-/* $Id: engine.h,v 1.3 2008/10/31 06:50:09 canacar Exp $ */
+/* $Id: engine.h,v 1.4 2008/12/01 18:03:06 naddy Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -114,6 +114,7 @@ void print_fld_ssize(field_def *fld, int64_t size);
void print_fld_bw(field_def *fld, double bw);
void print_fld_rate(field_def *fld, double rate);
void print_fld_uint(field_def *fld, unsigned int size);
+void print_fld_float(field_def *fld, double f, int prec);
void print_fld_bar(field_def *fld, int value);
void print_fld_tb(field_def *fld);
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index ceaa06b21d5..8d779b88fcf 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.33 2008/07/22 08:05:02 thib Exp $ */
+/* $OpenBSD: iostat.c,v 1.34 2008/12/01 18:03:06 naddy Exp $ */
/* $NetBSD: iostat.c,v 1.5 1996/05/10 23:16:35 thorpej Exp $ */
/*
@@ -199,7 +199,7 @@ showtotal(void)
print_fld_size(FLD_IO_WRITE, wsum);
print_fld_size(FLD_IO_RTPS, rtsum);
print_fld_size(FLD_IO_WTPS, wtsum);
- print_fld_size(FLD_IO_SEC, mssum);
+ print_fld_float(FLD_IO_SEC, mssum, 1);
end_line();
}
@@ -212,7 +212,7 @@ showdrive(int dn)
print_fld_size(FLD_IO_WRITE, cur.dk_wbytes[dn]/ etime);
print_fld_size(FLD_IO_RTPS, cur.dk_rxfer[dn] / etime);
print_fld_size(FLD_IO_WTPS, cur.dk_wxfer[dn] / etime);
- print_fld_size(FLD_IO_SEC, ATIME(cur.dk_time, dn) / etime);
+ print_fld_float(FLD_IO_SEC, ATIME(cur.dk_time, dn) / etime, 1);
end_line();
}