Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jun 2018 22:45:18 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335589 - head/usr.bin/top
Message-ID:  <201806232245.w5NMjIqP089407@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sat Jun 23 22:45:18 2018
New Revision: 335589
URL: https://svnweb.freebsd.org/changeset/base/335589

Log:
  top(1): Use basename instead of a homegrown alternative

Modified:
  head/usr.bin/top/machine.c

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c	Sat Jun 23 20:12:30 2018	(r335588)
+++ head/usr.bin/top/machine.c	Sat Jun 23 22:45:18 2018	(r335589)
@@ -29,6 +29,7 @@
 
 #include <assert.h>
 #include <err.h>
+#include <libgen.h>
 #include <kvm.h>
 #include <math.h>
 #include <paths.h>
@@ -992,11 +993,7 @@ format_next_process(struct handle * xhandle, char *(*g
 			dst = argbuf;
 
 			/* Extract cmd name from argv */
-			cmd = strrchr(*args, '/');
-			if (cmd == NULL)
-				cmd = *args;
-			else
-				cmd++;
+			cmd = basename(*args);
 
 			for (; (src = *args++) != NULL; ) {
 				if (*src == '\0')



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806232245.w5NMjIqP089407>