Subject: bin/24522: fix for -i option to envstat in -current
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <bp007@terran.org>
List: netbsd-bugs
Date: 02/21/2004 23:34:06
>Number: 24522
>Category: bin
>Synopsis: fix for -i option to envstat in -current
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 22 07:35:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Bryan J. Phillippe
>Release: NetBSD 1.6ZH
>Organization:
>Environment:
System: NetBSD neptune 1.6ZH NetBSD 1.6ZH (Neptune 20031230) #22: Fri Jan 23 11:18:55 PST 2004 bryan@neptune:/usr/home/bryan/etc/src/NetBSD/current/src/sys/arch/i386/compile/neptune i386
Architecture: i386
Machine: i386
>Description:
The -i option, for controlling loop interval display, does not
operate when the -r option, for displaying row-format output,
is also specified. There is no reason for this.
>How-To-Repeat:
envstat -ri 2 # will display output only once
>Fix:
The patch included below is one possible solution. Also included
in the patch are some whitespace corrections for style
conformance (spaces to tabs).
Index: envstat.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/envstat/envstat.c,v
retrieving revision 1.17
diff -u -r1.17 envstat.c
--- envstat.c 2 Feb 2004 10:36:19 -0000 1.17
+++ envstat.c 22 Feb 2004 07:19:10 -0000
@@ -162,12 +162,13 @@
if (rflag) {
int i;
+rflag_loop:
for (i = 0 ; i < ns ; i++) {
if ((etds[i].validflags & ENVSYS_FCURVALID) == 0)
continue;
if (ebis[i].units == ENVSYS_INDICATOR &&
- etds[i].cur.data_s == 0)
+ etds[i].cur.data_s == 0)
continue;
printf("%*.*s", (int)width, (int)width, ebis[i].desc);
@@ -180,8 +181,8 @@
printf(": %10d", etds[i].cur.data_s);
break;
case ENVSYS_STEMP: {
- double temp = (etds[i].cur.data_s / 1000000.0)
- - 273.15;
+ double temp = (etds[i].cur.data_s / 1000000.0)
+ - 273.15;
if (celsius)
printf(": %10.3f degC", temp);
else {
@@ -195,19 +196,25 @@
break;
default:
printf(": %10.3f %s",
- etds[i].cur.data_s / 1000000.0,
- envsysunitnames[ebis[i].units]);
+ etds[i].cur.data_s / 1000000.0,
+ envsysunitnames[ebis[i].units]);
break;
}
if (etds[i].validflags & ENVSYS_FFRACVALID) {
printf(" (%5.2f%%)",
- (etds[i].cur.data_s * 100.0) /
- etds[i].max.data_s);
+ (etds[i].cur.data_s * 100.0) /
+ etds[i].max.data_s);
}
printf("\n");
}
+ if (interval) {
+ sleep(interval);
+ fillsensors(fd, etds, ebis, ns);
+ printf("\n");
+ goto rflag_loop;
+ }
exit(0);
}
@@ -226,7 +233,7 @@
if (headrep)
header(width, celsius, ebis, cetds, ns);
- for (;;) {
+ for (;;) {
values(width, celsius, etds, cetds, ns);
if (headrep && (++headcnt == headrep)) {
headcnt = 0;
@@ -264,8 +271,7 @@
/* units */
for (i = 0; i < ns; ++i)
if (cetds[i]) {
- if ((ebis[i].units == ENVSYS_STEMP) &&
- !celsius)
+ if ((ebis[i].units == ENVSYS_STEMP) && !celsius)
s = "degF";
else if (ebis[i].units >= ENVSYS_NSENSORS)
s = envsysunitnames[ENVSYS_NSENSORS];
@@ -296,11 +302,11 @@
switch(etds[i].units) {
case ENVSYS_INDICATOR:
printf(" %*.*s", (int)width, (int)width,
- etds[i].cur.data_us ? "ON" : "OFF");
+ etds[i].cur.data_us ? "ON" : "OFF");
break;
case ENVSYS_STEMP:
temp = (etds[i].cur.data_us / 1000000.0) -
- 273.15;
+ 273.15;
if (!celsius)
temp = (9.0 / 5.0) * temp + 32.0;
printf(" %*.2f", (int)width, temp);
@@ -309,8 +315,8 @@
printf(" %*u", (int)width, etds[i].cur.data_us);
break;
default:
- printf(" %*.2f", (int)width, etds[i].cur.data_s /
- 1000000.0);
+ printf(" %*.2f", (int)width,
+ etds[i].cur.data_s / 1000000.0);
break;
}
}
>Release-Note:
>Audit-Trail:
>Unformatted: