Module Name:    src
Committed By:   kre
Date:           Sun Jun 16 22:44:01 UTC 2024

Modified Files:
        src/usr.bin/systat: main.c

Log Message:
Revert previous, and switch to using real arithmetic.

Ever since this code was first committed to the CSRG SCCS
tree, in Oct 1983, it has contained either
        int dellave;
or more recently:
        static int dellave;
(that change is irrelevant, as is the move of the declaration
from systat.h into main.c)

And then in main() initialised it as:
        dellave = 0.0;

It seems clear to me that the variable really should have been a
double since day one.   All its uses were in floating point contexts.

So, undo the change to use int constants, and instead just make
"dellave" (the load average delta) be a double.

This should make the load average bar which appears at the
top of most systat display screens more sensitive to showing
when the load average is increasing or decreasing (showing
it using '>' or '<' instead of '|' which is used when there
is not much change since last time).


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/systat/main.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/main.c
diff -u src/usr.bin/systat/main.c:1.57 src/usr.bin/systat/main.c:1.58
--- src/usr.bin/systat/main.c:1.57	Fri Jun 14 17:15:45 2024
+++ src/usr.bin/systat/main.c	Sun Jun 16 22:44:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.57 2024/06/14 17:15:45 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.58 2024/06/16 22:44:01 kre 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.57 2024/06/14 17:15:45 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.58 2024/06/16 22:44:01 kre Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -59,7 +59,7 @@ __RCSID("$NetBSD: main.c,v 1.57 2024/06/
 #include "extern.h"
 #include "drvstats.h"
 
-static int     dellave;
+static double	dellave;
 
 kvm_t *kd;
 char	*memf = NULL;
@@ -237,7 +237,7 @@ main(int argc, char **argv)
 	curmode->c_flags |= CF_INIT;
 	labels();
 
-	dellave = 0;
+	dellave = 0.0;
 
 	display(0);
 	if (!bflag) {
@@ -291,13 +291,13 @@ display(int signo)
 	if (curmode->c_flags & CF_LOADAV) {
 		j = 5.0*avenrun[0] + 0.5;
 		dellave -= avenrun[0];
-		if (dellave >= 0)
+		if (dellave >= 0.0)
 			c = '<';
 		else {
 			c = '>';
 			dellave = -dellave;
 		}
-		if (dellave < 1)
+		if (dellave < 0.1)
 			c = '|';
 		dellave = avenrun[0];
 		wmove(wload, 0, 0);

Reply via email to