Module Name: src
Committed By: christos
Date: Fri Apr 26 19:39:19 UTC 2019
Modified Files:
src/external/bsd/top/dist/machine: m_netbsd.c
Log Message:
for "countable" lwp names, try to display name*<count> instead of truncating.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/top/dist/machine/m_netbsd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/top/dist/machine/m_netbsd.c
diff -u src/external/bsd/top/dist/machine/m_netbsd.c:1.21 src/external/bsd/top/dist/machine/m_netbsd.c:1.22
--- src/external/bsd/top/dist/machine/m_netbsd.c:1.21 Tue Oct 30 17:15:09 2018
+++ src/external/bsd/top/dist/machine/m_netbsd.c Fri Apr 26 15:39:19 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m_netbsd.c,v 1.21 2018/10/30 21:15:09 kre Exp $ */
+/* $NetBSD: m_netbsd.c,v 1.22 2019/04/26 19:39:19 christos Exp $ */
/*
* top - a top users display for Unix
@@ -37,12 +37,12 @@
* Andrew Doran <[email protected]>
*
*
- * $Id: m_netbsd.c,v 1.21 2018/10/30 21:15:09 kre Exp $
+ * $Id: m_netbsd.c,v 1.22 2019/04/26 19:39:19 christos Exp $
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: m_netbsd.c,v 1.21 2018/10/30 21:15:09 kre Exp $");
+__RCSID("$NetBSD: m_netbsd.c,v 1.22 2019/04/26 19:39:19 christos Exp $");
#endif
#include <sys/param.h>
@@ -879,6 +879,26 @@ format_next_proc(caddr_t handle, char *(
}
static char *
+countable(char *p, size_t l)
+{
+ static const char digits[] = "0123456789";
+ size_t first = strcspn(p, digits);
+ size_t last = strspn(p + first, digits);
+ size_t len = first + last;
+ if (p[len] || last == 0)
+ return p;
+ if (len < l)
+ return p;
+ if (l < last + 1)
+ return p;
+ size_t start = l - last - 1;
+ p[start] = '*';
+ memmove(p + start + 1, p + first, len - first);
+ p[l] = '\0';
+ return p;
+}
+
+static char *
format_next_lwp(caddr_t handle, char *(*get_userid)(int))
{
struct kinfo_proc2 *pp;
@@ -946,7 +966,7 @@ format_next_lwp(caddr_t handle, char *(*
format_time(cputime),
100.0 * weighted_cpu(l_, pct, pl),
100.0 * pct,
- printable(pl->l_name),
+ countable(printable(pl->l_name), 9),
get_command(hp->sel, pp));
/* return the result */