diff options
author | Jim Warner <james.warner@comcast.net> | 2022-06-15 00:00:00 -0500 |
---|---|---|
committer | Craig Small <csmall@dropbear.xyz> | 2022-06-19 20:58:51 +1000 |
commit | eef0c8c5903576a37de14fe1d11340fffc1badfd (patch) | |
tree | 02af9a12586364489fa0eefa3c440faad90871cc | |
parent | 30ef314c3630e3b2bd75bf17079c0253a0079337 (diff) | |
download | procps-ng-eef0c8c5903576a37de14fe1d11340fffc1badfd.tar.gz |
top: modify 'focus' strv function to display 'n/a' too <=== port of newlib fc3ba30a
______________________________ original newlib message
This commit just brings that 'bot_focus_strv' function
up to the same standard as the vanilla 'bot_focus_str'
guy. Namely, if there is no cmdline or environ for any
process, that bottom window will now display an 'n/a'.
[ with the nature of those string vectors, it wasn't ]
[ the same simple process found for regular strings. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
-rw-r--r-- | top/top.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -5165,9 +5165,11 @@ static int bot_focus_strv (const char *hdr, const char **strv) { if (strv) { // we're a little careless with overhead here (it's a one time cost) memset(Bot_buf, '\0', sizeof(Bot_buf)); - n = (void*)&strv[0] - (void*)strv[0]; + n = (char*)&strv[0] - strv[0]; if (n >= sizeof(Bot_buf)) n = sizeof(Bot_buf) - 1; memcpy(Bot_buf, strv[0], n); + if (!Bot_buf[0] || (!strcmp(Bot_buf, "-") && n <= sizeof(char*))) + strcpy(Bot_buf, "n/a"); for (nsav= 0, p = Bot_buf; strv[nsav] != NULL; nsav++) { p += strlen(strv[nsav]) + 1; if ((p - Bot_buf) >= sizeof(Bot_buf)) |