Module Name: src Committed By: christos Date: Sat Aug 21 13:22:19 UTC 2021
Modified Files: src/usr.bin/systat: extern.h main.c systat.1 vmstat.c Log Message: PR/56331: Paul Goyette: Add -z option to display 0 instead of ' ' in vmstat. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/systat/extern.h cvs rdiff -u -r1.55 -r1.56 src/usr.bin/systat/main.c cvs rdiff -u -r1.51 -r1.52 src/usr.bin/systat/systat.1 cvs rdiff -u -r1.89 -r1.90 src/usr.bin/systat/vmstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/systat/extern.h diff -u src/usr.bin/systat/extern.h:1.47 src/usr.bin/systat/extern.h:1.48 --- src/usr.bin/systat/extern.h:1.47 Fri Jan 25 10:31:11 2019 +++ src/usr.bin/systat/extern.h Sat Aug 21 09:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.47 2019/01/25 15:31:11 christos Exp $ */ +/* $NetBSD: extern.h,v 1.48 2021/08/21 13:22:19 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -64,6 +64,7 @@ extern int turns; extern gid_t egid; extern float hertz; extern double etime; +extern bool showzero; struct inpcb; #ifdef INET6 Index: src/usr.bin/systat/main.c diff -u src/usr.bin/systat/main.c:1.55 src/usr.bin/systat/main.c:1.56 --- src/usr.bin/systat/main.c:1.55 Fri Jan 25 10:31:11 2019 +++ src/usr.bin/systat/main.c Sat Aug 21 09:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.55 2019/01/25 15:31:11 christos Exp $ */ +/* $NetBSD: main.c,v 1.56 2021/08/21 13:22:19 christos Exp $ */ /*- * Copyright (c) 1980, 1992, 1993 @@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: main.c,v 1.55 2019/01/25 15:31:11 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.56 2021/08/21 13:22:19 christos Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -81,6 +81,7 @@ int allcounter; sig_atomic_t needsredraw = 0; float hertz; double etime; +bool showzero = false; static WINDOW *wload; /* one line window for load average */ @@ -105,7 +106,7 @@ main(int argc, char **argv) egid = getegid(); (void)setegid(getgid()); - while ((ch = getopt(argc, argv, "M:N:bnw:t:")) != -1) + while ((ch = getopt(argc, argv, "M:N:bnw:t:z")) != -1) switch(ch) { case 'M': memf = optarg; @@ -121,11 +122,14 @@ main(int argc, char **argv) break; case 't': if ((turns = atoi(optarg)) <= 0) - errx(1, "turns <= 0."); + errx(EXIT_FAILURE, "turns <= 0."); break; case 'w': if ((naptime = strtod(optarg, NULL)) <= 0) - errx(1, "interval <= 0."); + errx(EXIT_FAILURE, "interval <= 0."); + break; + case 'z': + showzero = true; break; case '?': default: @@ -177,7 +181,7 @@ main(int argc, char **argv) kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); if (kd == NULL) - errx(1, "%s", errbuf); + errx(EXIT_FAILURE, "%s", errbuf); /* Get rid of privs for now. */ if (nlistf == NULL && memf == NULL) @@ -195,7 +199,7 @@ main(int argc, char **argv) * routines to minimize update work by curses. */ if (initscr() == NULL) - errx(1, "couldn't initialize screen"); + errx(EXIT_FAILURE, "couldn't initialize screen"); CMDLINE = LINES - 1; wnd = (*curmode->c_open)(); @@ -248,9 +252,9 @@ main(int argc, char **argv) static void usage(void) { - fprintf(stderr, "usage: systat [-bn] [-M core] [-N system] [-w wait] " - "[-t turns]\n\t\t[display] [refresh-interval]\n"); - exit(1); + fprintf(stderr, "usage: %s [-bnz] [-M core] [-N system] [-w wait] " + "[-t turns]\n\t\t[display] [refresh-interval]\n", getprogname()); + exit(EXIT_FAILURE); } @@ -366,7 +370,7 @@ die(int signo) clrtoeol(); refresh(); endwin(); - exit(0); + exit(EXIT_SUCCESS); } void @@ -417,7 +421,7 @@ nlisterr(struct nlist name_list[]) clrtoeol(); refresh(); endwin(); - exit(1); + exit(EXIT_FAILURE); } bool Index: src/usr.bin/systat/systat.1 diff -u src/usr.bin/systat/systat.1:1.51 src/usr.bin/systat/systat.1:1.52 --- src/usr.bin/systat/systat.1:1.51 Fri Dec 28 07:21:53 2018 +++ src/usr.bin/systat/systat.1 Sat Aug 21 09:22:19 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: systat.1,v 1.51 2018/12/28 12:21:53 wiz Exp $ +.\" $NetBSD: systat.1,v 1.52 2021/08/21 13:22:19 christos Exp $ .\" .\" Copyright (c) 1985, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 .\" -.Dd December 26, 2018 +.Dd August 21, 2021 .Dt SYSTAT 1 .Os .Sh NAME @@ -37,7 +37,7 @@ .Nd display system statistics in a full-screen view .Sh SYNOPSIS .Nm -.Op Fl bn +.Op Fl bnz .Op Fl M Ar core .Op Fl N Ar system .Op Fl t Ar turns @@ -141,6 +141,8 @@ This is provided for backwards compatibi specified with the .Fl w flag. +.It Fl z +Display 0 instead of space when there is no data. .El .Pp Certain characters cause immediate action by Index: src/usr.bin/systat/vmstat.c diff -u src/usr.bin/systat/vmstat.c:1.89 src/usr.bin/systat/vmstat.c:1.90 --- src/usr.bin/systat/vmstat.c:1.89 Sat Jul 24 09:42:05 2021 +++ src/usr.bin/systat/vmstat.c Sat Aug 21 09:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vmstat.c,v 1.89 2021/07/24 13:42:05 simonb Exp $ */ +/* $NetBSD: vmstat.c,v 1.90 2021/08/21 13:22:19 christos Exp $ */ /*- * Copyright (c) 1983, 1989, 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif -__RCSID("$NetBSD: vmstat.c,v 1.89 2021/07/24 13:42:05 simonb Exp $"); +__RCSID("$NetBSD: vmstat.c,v 1.90 2021/08/21 13:22:19 christos Exp $"); #endif /* not lint */ /* @@ -743,7 +743,7 @@ puthumanint_scale(u_int64_t n, int l, in if (move(l, c) != OK) return; - if (n == 0) { + if (n == 0 && !showzero) { hline(' ', w); return; } @@ -783,7 +783,7 @@ putint(int n, int l, int c, int w) if (move(l, c) != OK) return; - if (n == 0) { + if (n == 0 && !showzero) { hline(' ', w); return; } @@ -805,7 +805,7 @@ putfloat(double f, int l, int c, int w, if (move(l, c) != OK) return; - if (nz && f == 0.0) { + if (nz && f == 0.0 && !showzero) { hline(' ', w); return; }