diff options
author | dillon <dillon@FreeBSD.org> | 1998-12-24 23:27:33 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 1998-12-24 23:27:33 +0000 |
commit | 6a839215a1d7392cab6930a931882a4e3451bc51 (patch) | |
tree | e80ee87d946e254e20e30d5119e1ec26194ef69f /usr.bin/w | |
parent | 46bb1eee7922211ea3e4eb585e73987cda707a3d (diff) | |
download | FreeBSD-src-6a839215a1d7392cab6930a931882a4e3451bc51.zip FreeBSD-src-6a839215a1d7392cab6930a931882a4e3451bc51.tar.gz |
No __profname bozoness, no strstr() bozoness... test argv[0] against
"uptime" the right way. Sheesh.
Diffstat (limited to 'usr.bin/w')
-rw-r--r-- | usr.bin/w/w.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index c40d666..299b0d6 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id: w.c,v 1.29 1998/11/09 01:19:30 steve Exp $"; + "$Id: w.c,v 1.30 1998/12/24 18:20:58 steve Exp $"; #endif /* not lint */ /* @@ -114,10 +114,11 @@ struct entry { struct kinfo_proc *dkp; /* debug option proc list */ } *ep, *ehead = NULL, **nextp = &ehead; -static void pr_header __P((time_t *, int)); +static void pr_header __P((time_t *, int)); static struct stat *ttystat __P((char *)); -static void usage __P((int)); +static void usage __P((int)); +static int this_is_uptime __P((const char *s)); char *fmt_argv __P((char **, char *, int)); /* ../../bin/ps/fmt.c */ @@ -141,7 +142,7 @@ main(argc, argv) (void) setlocale(LC_ALL, ""); /* Are we w(1) or uptime(1)? */ - if (strstr(argv[0], "uptime")) { + if (this_is_uptime(argv[0]) == 0) { wcmd = 0; p = ""; } else { @@ -494,3 +495,19 @@ usage(wcmd) "usage: uptime\n"); exit (1); } + +static int +this_is_uptime(s) + const char *s; +{ + const char *u; + + if ((u = strrchr(s, '/')) != NULL) + ++u; + else + u = s; + if (strcmp(u, "uptime") == 0) + return(0); + return(-1); +} + |