aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2014-10-08 05:04:31 +0000
committerEitan Adler <eadler@FreeBSD.org>2014-10-08 05:04:31 +0000
commit920aa23dadd77fede3243357de6dd4022265d1f1 (patch)
tree97c53ad826e0b0011bf66e41a68b800304d6629a /usr.bin/w/w.c
parent0999f75a2f82ed0e67b49649e561964edcbe1938 (diff)
downloadsrc-920aa23dadd77fede3243357de6dd4022265d1f1.tar.gz
src-920aa23dadd77fede3243357de6dd4022265d1f1.zip
don't reinvent the wheel: rely on basename(3)
Reviewed by: nwhitehorn
Notes
Notes: svn path=/head/; revision=272728
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r--usr.bin/w/w.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 1b9af5f0cc33..ca5b79e60888 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -68,6 +68,7 @@ static const char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94";
#include <fcntl.h>
#include <kvm.h>
#include <langinfo.h>
+#include <libgen.h>
#include <libutil.h>
#include <limits.h>
#include <locale.h>
@@ -121,7 +122,6 @@ static struct entry {
static void pr_header(time_t *, int);
static struct stat *ttystat(char *);
static void usage(int);
-static int this_is_uptime(const char *s);
char *fmt_argv(char **, char *, char *, size_t); /* ../../bin/ps/fmt.c */
@@ -144,7 +144,7 @@ main(int argc, char *argv[])
use_comma = (*nl_langinfo(RADIXCHAR) != ',');
/* Are we w(1) or uptime(1)? */
- if (this_is_uptime(argv[0]) == 0) {
+ if (strcmp(basename(argv[0]), "uptime") == 0) {
wcmd = 0;
p = "";
} else {
@@ -512,17 +512,3 @@ usage(int wcmd)
(void)fprintf(stderr, "usage: uptime\n");
exit(1);
}
-
-static int
-this_is_uptime(const char *s)
-{
- const char *u;
-
- if ((u = strrchr(s, '/')) != NULL)
- ++u;
- else
- u = s;
- if (strcmp(u, "uptime") == 0)
- return (0);
- return (-1);
-}