summaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-09-28 16:40:25 +0000
committerDenis Vlasenko2008-09-28 16:40:25 +0000
commitbacaff6e5474d6c5f080ce4cd2a55e8ff1ba5c94 (patch)
tree5ca8c92753ef2c2fb7d39f125dc90deb18cfc1b8 /procps/top.c
parent261cf4784fa39fb6cb3b7db99e809a7832d94d0a (diff)
downloadbusybox-1_12_1.zip
busybox-1_12_1.tar.gz
apply post-1.12.0 fixes, bump version to 1.12.11_12_1
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/procps/top.c b/procps/top.c
index 663eac6..46e29a9 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -745,7 +745,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
int iterations;
unsigned lines, col;
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;
@@ -762,10 +762,19 @@ int top_main(int argc UNUSED_PARAM, char **argv)
iterations = 0; /* infinite */
/* 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 */