svn commit: trunk/busybox/procps

vda at busybox.net vda at busybox.net
Mon Dec 18 14:20:02 UTC 2006


Author: vda
Date: 2006-12-18 06:20:01 -0800 (Mon, 18 Dec 2006)
New Revision: 16992

Log:
ps: fix buglet, add microoptimization


Modified:
   trunk/busybox/procps/ps.c


Changeset:
Modified: trunk/busybox/procps/ps.c
===================================================================
--- trunk/busybox/procps/ps.c	2006-12-18 14:10:46 UTC (rev 16991)
+++ trunk/busybox/procps/ps.c	2006-12-18 14:20:01 UTC (rev 16992)
@@ -216,18 +216,16 @@
 		// POSIX: Any field need not be meaningful in all
 		// implementations. In such a case a hyphen ( '-' )
 		// should be output in place of the field value.
-		if (!*p) {
-			*p++ = '-';
-			*p = '\0';
+		if (!p[0]) {
+			p[0] = '-';
+			p[1] = '\0';
 		}
 		len = strlen(p);
 		p += len;
 		len = out[i].width - len + 1;
 		if (++i == out_cnt) /* do not pad last field */
 			break;
-		while (len--)
-			*p++ = ' ';
-		*p = '\0';
+		p += sprintf(p, "%*s", len, "");
 	}
 	printf("%.*s\n", terminal_width, buffer);
 }




More information about the busybox-cvs mailing list