From owner-svn-src-all@FreeBSD.ORG Wed Oct 8 05:04:31 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D9DB9B50; Wed, 8 Oct 2014 05:04:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C624460F; Wed, 8 Oct 2014 05:04:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9854VRC044603; Wed, 8 Oct 2014 05:04:31 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9854Vbd044602; Wed, 8 Oct 2014 05:04:31 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201410080504.s9854Vbd044602@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Wed, 8 Oct 2014 05:04:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272728 - head/usr.bin/w X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2014 05:04:32 -0000 Author: eadler Date: Wed Oct 8 05:04:31 2014 New Revision: 272728 URL: https://svnweb.freebsd.org/changeset/base/272728 Log: don't reinvent the wheel: rely on basename(3) Reviewed by: nwhitehorn Modified: head/usr.bin/w/w.c Modified: head/usr.bin/w/w.c ============================================================================== --- head/usr.bin/w/w.c Wed Oct 8 04:42:56 2014 (r272727) +++ head/usr.bin/w/w.c Wed Oct 8 05:04:31 2014 (r272728) @@ -68,6 +68,7 @@ static const char sccsid[] = "@(#)w.c 8. #include #include #include +#include #include #include #include @@ -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); -}