diff options
author | eadler <eadler@FreeBSD.org> | 2014-10-08 05:04:31 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2014-10-08 05:04:31 +0000 |
commit | e7ee396a15b91cd348d48701771ac1a345d4a7ae (patch) | |
tree | 97c53ad826e0b0011bf66e41a68b800304d6629a /usr.bin/w | |
parent | b83ad553045314fa36efb86e6e2f592f2b5ed360 (diff) | |
download | FreeBSD-src-e7ee396a15b91cd348d48701771ac1a345d4a7ae.zip FreeBSD-src-e7ee396a15b91cd348d48701771ac1a345d4a7ae.tar.gz |
don't reinvent the wheel: rely on basename(3)
Reviewed by: nwhitehorn
Diffstat (limited to 'usr.bin/w')
-rw-r--r-- | usr.bin/w/w.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 1b9af5f..ca5b79e 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); -} |