diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-10 19:44:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-10 19:44:20 +0000 |
commit | 04e11c9209f88b878d6bef0b56a4d8345c89c217 (patch) | |
tree | dc67a11b65d3d7e4a03b955dd2f5d1b3c7721b2f /procps | |
parent | 9304d6ea92f7fc1529669800b75456d549cf1bfc (diff) | |
download | busybox-w32-04e11c9209f88b878d6bef0b56a4d8345c89c217.tar.gz busybox-w32-04e11c9209f88b878d6bef0b56a4d8345c89c217.tar.bz2 busybox-w32-04e11c9209f88b878d6bef0b56a4d8345c89c217.zip |
getpot: add support for "a+" specifier for nonnegative int parameters.
By Vladimir Dronnikov <dronnikov at gmail.com>.
fdisk and top are converted as an example.
function old new delta
getopt32 1340 1370 +30
top_main 1137 1120 -17
fdisk_main 3033 2949 -84
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 30/-101) Total: -71 bytes
Diffstat (limited to 'procps')
-rw-r--r-- | procps/top.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/procps/top.c b/procps/top.c index 4df58f227..37b6a0cdb 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -740,7 +740,7 @@ int top_main(int argc, char **argv) | |||
740 | int count, lines, col; | 740 | int count, lines, col; |
741 | unsigned interval; | 741 | unsigned interval; |
742 | int iterations; | 742 | int iterations; |
743 | char *sinterval, *siterations; | 743 | char *sinterval; |
744 | SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; | 744 | SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; |
745 | #if ENABLE_FEATURE_USE_TERMIOS | 745 | #if ENABLE_FEATURE_USE_TERMIOS |
746 | struct termios new_settings; | 746 | struct termios new_settings; |
@@ -757,15 +757,12 @@ int top_main(int argc, char **argv) | |||
757 | iterations = 0; /* infinite */ | 757 | iterations = 0; /* infinite */ |
758 | 758 | ||
759 | /* do normal option parsing */ | 759 | /* do normal option parsing */ |
760 | opt_complementary = "-"; | 760 | opt_complementary = "-:n+"; |
761 | getopt32(argv, "d:n:b", &sinterval, &siterations); | 761 | getopt32(argv, "d:n:b", &sinterval, &iterations); |
762 | if (option_mask32 & 0x1) { | 762 | if (option_mask32 & 0x1) { |
763 | /* Need to limit it to not overflow poll timeout */ | 763 | /* Need to limit it to not overflow poll timeout */ |
764 | interval = xatou16(sinterval); // -d | 764 | interval = xatou16(sinterval); // -d |
765 | } | 765 | } |
766 | if (option_mask32 & 0x2) | ||
767 | iterations = xatoi_u(siterations); // -n | ||
768 | //if (option_mask32 & 0x4) // -b | ||
769 | 766 | ||
770 | /* change to /proc */ | 767 | /* change to /proc */ |
771 | xchdir("/proc"); | 768 | xchdir("/proc"); |