From 04e11c9209f88b878d6bef0b56a4d8345c89c217 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 10 Feb 2008 19:44:20 +0000 Subject: getpot: add support for "a+" specifier for nonnegative int parameters. By Vladimir Dronnikov . 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 --- procps/top.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'procps') 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) int count, lines, col; unsigned interval; int iterations; - char *sinterval, *siterations; + char *sinterval; SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; #if ENABLE_FEATURE_USE_TERMIOS struct termios new_settings; @@ -757,15 +757,12 @@ int top_main(int argc, char **argv) iterations = 0; /* infinite */ /* do normal option parsing */ - opt_complementary = "-"; - getopt32(argv, "d:n:b", &sinterval, &siterations); + opt_complementary = "-:n+"; + getopt32(argv, "d:n:b", &sinterval, &iterations); if (option_mask32 & 0x1) { /* Need to limit it to not overflow poll timeout */ interval = xatou16(sinterval); // -d } - if (option_mask32 & 0x2) - iterations = xatoi_u(siterations); // -n - //if (option_mask32 & 0x4) // -b /* change to /proc */ xchdir("/proc"); -- cgit v1.2.3