svn commit: r209312 - head/usr.bin/systat

Alexander Motin mav at FreeBSD.org
Fri Jun 18 18:18:04 UTC 2010


Author: mav
Date: Fri Jun 18 18:18:03 2010
New Revision: 209312
URL: http://svn.freebsd.org/changeset/base/209312

Log:
  Do not print first digits of IRQ number if whole number doesn't fit.

Modified:
  head/usr.bin/systat/vmstat.c

Modified: head/usr.bin/systat/vmstat.c
==============================================================================
--- head/usr.bin/systat/vmstat.c	Fri Jun 18 18:15:40 2010	(r209311)
+++ head/usr.bin/systat/vmstat.c	Fri Jun 18 18:18:03 2010	(r209312)
@@ -254,24 +254,23 @@ initkre(void)
 					cp1++;
 				if (cp1 != cp && *cp1 == ':' &&
 				    *(cp1 + 1) == ' ') {
+					sz = strlen(cp);
 					*cp1 = '\0';
 					cp1 = cp1 + 2;
 					cp2 = strdup(cp);
-					bcopy(cp1, cp, strlen(cp1) + 1);
-					strcat(cp, " ");
-					strcat(cp, cp2);
+					bcopy(cp1, cp, sz - (cp1 - cp) + 1);
+					/* If line is long - drop "irq",
+					   if too long - drop "irqN". */
+					if (sz <= 10 + 1) {
+						strcat(cp, " ");
+						strcat(cp, cp2);
+					} else if (sz <= 10 + 4) {
+						strcat(cp, " ");
+						strcat(cp, cp2 + 3);
+					}
 					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 = nextcp;
 		}


More information about the svn-src-all mailing list