Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/w Make uptime show the correct number of users.



details:   https://anonhg.NetBSD.org/src/rev/79858b54e7e8
branches:  trunk
changeset: 536453:79858b54e7e8
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Sep 16 04:02:21 2002 +0000

description:
Make uptime show the correct number of users.

diffstat:

 usr.bin/w/w.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (61 lines):

diff -r 4e388c779553 -r 79858b54e7e8 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Mon Sep 16 03:41:40 2002 +0000
+++ b/usr.bin/w/w.c     Mon Sep 16 04:02:21 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.51 2002/09/16 01:49:06 mycroft Exp $   */
+/*     $NetBSD: w.c,v 1.52 2002/09/16 04:02:21 christos Exp $  */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.51 2002/09/16 01:49:06 mycroft Exp $");
+__RCSID("$NetBSD: w.c,v 1.52 2002/09/16 04:02:21 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -214,8 +214,8 @@
                if (utx->ut_type != USER_PROCESS)
                        continue;
                ++nusers;
-               if (wcmd == 0 || (sel_user &&
-                   strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name) != 0)))
+               if (sel_user &&
+                   strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name) != 0))
                        continue;
                if ((ep = calloc(1, sizeof(struct entry))) == NULL)
                        err(1, NULL);
@@ -228,7 +228,8 @@
                ep->tv = utx->ut_tv;
                *nextp = ep;
                nextp = &(ep->next);
-               process(ep);
+               if (wcmd != 0)
+                       process(ep);
        }
 #endif
 
@@ -236,8 +237,9 @@
        while ((ut = getutent()) != NULL) {
                if (ut->ut_name[0] == '\0')
                        continue;
-               if (wcmd == 0 || (sel_user &&
-                   strncmp(ut->ut_name, sel_user, sizeof(ut->ut_name) != 0)))
+
+               if (sel_user &&
+                   strncmp(ut->ut_name, sel_user, sizeof(ut->ut_name) != 0))
                        continue;
 
                /* Don't process entries that we have utmpx for */
@@ -262,7 +264,8 @@
                ep->tv.tv_usec = 0;
                *nextp = ep;
                nextp = &(ep->next);
-               process(ep);
+               if (wcmd != 0)
+                       process(ep);
        }
 #endif
 



Home | Main Index | Thread Index | Old Index