diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-08 10:13:11 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-08 10:13:11 +0100 |
commit | c9807d787d2d9ee5ed9f614c74573e47c8b359ab (patch) | |
tree | 0fd7761d6ad2ac2d9fd72a7591442378e86e711f /coreutils | |
parent | cb9c3894e50ecd5e940bb8a248fdb49da8e0c918 (diff) | |
download | busybox-c9807d787d2d9ee5ed9f614c74573e47c8b359ab.tar.gz |
nice: code shrink
function old new delta
nice_main 157 152 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/nice.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/coreutils/nice.c b/coreutils/nice.c index d6818cf00..aa8b06cce 100644 --- a/coreutils/nice.c +++ b/coreutils/nice.c @@ -26,7 +26,7 @@ #include "libbb.h" int nice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int nice_main(int argc, char **argv) +int nice_main(int argc UNUSED_PARAM, char **argv) { int old_priority, adjustment; @@ -40,18 +40,21 @@ int nice_main(int argc, char **argv) adjustment = 10; /* Set default adjustment. */ if (argv[0][0] == '-') { - if (argv[0][1] == 'n') { /* -n */ - if (argv[0][2]) { /* -nNNNN (w/o space) */ - argv[0] += 2; argv--; argc++; + char *nnn = argv[0] + 1; + if (nnn[0] == 'n') { /* -n */ + nnn += 1; + if (!nnn[0]) { /* "-n NNN" */ + nnn = *++argv; } - } else { /* -NNN (NNN may be negative) == -n NNN */ - argv[0] += 1; argv--; argc++; + /* else: "-nNNN" (w/o space) */ } - if (argc < 4) { /* Missing priority and/or utility! */ + /* else: "-NNN" (NNN may be negative) - same as "-n NNN" */ + + if (!nnn || !argv[1]) { /* Missing priority or PROG! */ bb_show_usage(); } - adjustment = xatoi_range(argv[1], INT_MIN/2, INT_MAX/2); - argv += 2; + adjustment = xatoi_range(nnn, INT_MIN/2, INT_MAX/2); + argv++; } { /* Set our priority. */ |