Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/top/dist/machine for "countable" lwp names, try...
details: https://anonhg.NetBSD.org/src/rev/2762922f5f95
branches: trunk
changeset: 450822:2762922f5f95
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 26 19:39:19 2019 +0000
description:
for "countable" lwp names, try to display name*<count> instead of truncating.
diffstat:
external/bsd/top/dist/machine/m_netbsd.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diffs (60 lines):
diff -r ca5e4c87046b -r 2762922f5f95 external/bsd/top/dist/machine/m_netbsd.c
--- a/external/bsd/top/dist/machine/m_netbsd.c Fri Apr 26 19:17:05 2019 +0000
+++ b/external/bsd/top/dist/machine/m_netbsd.c Fri Apr 26 19:39:19 2019 +0000
@@ -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 <ad%NetBSD.org@localhost>
*
*
- * $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 @@
}
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_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 */
Home |
Main Index |
Thread Index |
Old Index