summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2006-04-30 01:39:46 +0000
committerbde <bde@FreeBSD.org>2006-04-30 01:39:46 +0000
commit74fc812af495183b694df399a4a6bf35ac7f5da0 (patch)
tree764f86128eed21c45623b4340b3d7f78dd74f7a9 /usr.bin
parente2a1b6982782a35c57ff7aad9b02821ad95ef37d (diff)
downloadFreeBSD-src-74fc812af495183b694df399a4a6bf35ac7f5da0.zip
FreeBSD-src-74fc812af495183b694df399a4a6bf35ac7f5da0.tar.gz
Edit the interrupt name strings to shorten them. This is believed to
only affect amd64 and i386. alpha uses "intr N" instead of "irqN" and mostly has no device names. ia64 uses only device names. - Edit interrupt names once after they are read from the kernel and not every time they are displayed. - Discard bogus trailing spaces so that the next step doesn't move things to oblivion. - If an interrupt name starts with "irqN:" (as it usually does in on amd64 and i386), then move "irqN" to the end and strip ":", since we have no space for the ":" and don't want to start descriptions with "N" after stripping "irq" in the next step (since "N" would look like a count). This step may need reworking for interrupt names containing several device names -- then moving the irq number to the end would lose it instead of losing some device names. - Remove "irq" from an interrupt name if and only if the original name is too long to display.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/systat/vmstat.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 20583c9..4e0d59b 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -207,7 +207,7 @@ closekre(w)
int
initkre()
{
- char *intrnamebuf, *cp;
+ char *cp, *cp1, *cp2, *intrnamebuf, *nextcp;
int i;
size_t sz;
@@ -249,8 +249,39 @@ initkre()
return(0);
}
for (cp = intrnamebuf, i = 0; i < nintr; i++) {
+ nextcp = cp + strlen(cp) + 1;
+
+ /* Discard trailing spaces. */
+ for (cp1 = nextcp - 1; cp1 > cp && *(cp1 - 1) == ' '; )
+ *--cp1 = '\0';
+
+ /* Convert "irqN: name" to "name irqN". */
+ if (strncmp(cp, "irq", 3) == 0) {
+ cp1 = cp + 3;
+ while (isdigit((u_char)*cp1))
+ cp1++;
+ if (cp1 != cp && *cp1 == ':' &&
+ *(cp1 + 1) == ' ') {
+ *cp1 = '\0';
+ cp1 = cp1 + 2;
+ cp2 = strdup(cp);
+ bcopy(cp1, cp, strlen(cp1) + 1);
+ strcat(cp, " ");
+ strcat(cp, cp2);
+ free(cp2);
+ }
+ }
+
+ /*
+ * Convert "name irqN" to "name N" if the former is
+ * longer than the field width.
+ */
+ if ((cp1 = strstr(cp, "irq")) != NULL &&
+ strlen(cp) > 10)
+ bcopy(cp1 + 3, cp1, strlen(cp1 + 3) + 1);
+
intrname[i] = cp;
- cp += strlen(cp) + 1;
+ cp = nextcp;
}
nextintsrow = INTSROW + 2;
allocinfo(&s);
OpenPOWER on IntegriCloud