svn commit: trunk/busybox/procps

vda at busybox.net vda at busybox.net
Thu Sep 25 11:42:10 UTC 2008


Author: vda
Date: 2008-09-25 04:42:10 -0700 (Thu, 25 Sep 2008)
New Revision: 23491

Log:
top: fix "top -d 1" (bug 5144)



Modified:
   trunk/busybox/procps/top.c


Changeset:
Modified: trunk/busybox/procps/top.c
===================================================================
--- trunk/busybox/procps/top.c	2008-09-25 11:17:10 UTC (rev 23490)
+++ trunk/busybox/procps/top.c	2008-09-25 11:42:10 UTC (rev 23491)
@@ -894,7 +894,7 @@
 	unsigned lines, col;
 	int lines_rem;
 	unsigned interval;
-	char *sinterval;
+	char *str_interval, *str_iterations;
 	SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
 #if ENABLE_FEATURE_USE_TERMIOS
 	struct termios new_settings;
@@ -917,11 +917,20 @@
 #endif
 
 	/* all args are options; -n NUM */
-	opt_complementary = "-:n+";
-	if (getopt32(argv, "d:n:b", &sinterval, &iterations) & OPT_d) {
+	opt_complementary = "-";
+	col = getopt32(argv, "d:n:b", &str_interval, &str_iterations);
+	if (col & OPT_d) {
+		/* work around for "-d 1" -> "-d -1" done by getopt32 */
+		if (str_interval[0] == '-')
+			str_interval++;
 		/* Need to limit it to not overflow poll timeout */
-		interval = xatou16(sinterval); /* -d */
+		interval = xatou16(str_interval);
 	}
+	if (col & OPT_n) {
+		if (str_iterations[0] == '-')
+			str_iterations++;
+		iterations = xatou(str_iterations);
+	}
 
 	/* change to /proc */
 	xchdir("/proc");




More information about the busybox-cvs mailing list