From ac8f40ea7813ec0b550b0bfa2857fcee977b1fa4 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Sat, 23 Jun 2018 22:45:18 +0000 Subject: [PATCH] top(1): Use basename instead of a homegrown alternative --- usr.bin/top/machine.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 14ab1b529ae0..88182d6b39af 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -992,11 +993,7 @@ format_next_process(struct handle * xhandle, char *(*get_userid)(int), int flags 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')