Subject: bin/2259: 'w' shows idle time "1days"
To: None <gnats-bugs@NetBSD.ORG>
From: Matt Beal <beal@dilbert.umiacs.umd.edu>
List: netbsd-bugs
Date: 03/24/1996 22:09:16
>Number:         2259
>Category:       bin
>Synopsis:       'w' shows idle time "1days"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 24 22:35:01 1996
>Last-Modified:
>Originator:     Matt Beal
>Organization:
UMIACS, University of Maryland
>Release:        NetBSD-1.1B (supped 3/21)
>Environment:
System: NetBSD dilbert.umiacs.umd.edu 1.1B NetBSD 1.1B (DILBERT) #17: Fri Mar 22 17:19:15 EST 1996 root@:/usr/src-1.1B/sys/arch/i386/compile/DILBERT i386


>Description:
	'w' improperly indicates # of days in idle field, i.e. "1days"
>How-To-Repeat:
	% w
	USER    TTY FROM              LOGIN@  IDLE WHAT
	foo     p0  -                 ??     1days -
>Fix:
diff -c -r1.1 pr_time.c
*** pr_time.c   1996/03/25 02:44:56     1.1
--- pr_time.c   1996/03/25 02:56:24
***************
*** 89,97 ****
  pr_idle(idle)
        time_t idle;
  {
        /* If idle more than 36 hours, print as a number of days. */
        if (idle >= 36 * SECSPERHOUR)
!               (void)printf(" %ddays ", idle / SECSPERDAY);
  
        /* If idle more than an hour, print as HH:MM. */
        else if (idle >= SECSPERHOUR)
--- 89,101 ----
  pr_idle(idle)
        time_t idle;
  {
+       int days;
+ 
        /* If idle more than 36 hours, print as a number of days. */
+       days = idle / SECSPERDAY;
        if (idle >= 36 * SECSPERHOUR)
!               (void)printf("%s%dday%c ", days == 1 ? "  " : " ",
!                       days, days == 1 ? ' ' : 's');
  
        /* If idle more than an hour, print as HH:MM. */
        else if (idle >= SECSPERHOUR)
>Audit-Trail:
>Unformatted: