aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-06-22 15:36:25 -0500
committerRob Landley <rob@landley.net>2013-06-22 15:36:25 -0500
commit4d3b3da2746f6b71b4f1f2649a800818e88a1b66 (patch)
tree760dc1ad532c3e40c93f5c111587ba9c2593f5a2
parent3a489e4f02f2003c972e5bdf7780266a5a495dd8 (diff)
downloadtoybox-4d3b3da2746f6b71b4f1f2649a800818e88a1b66.tar.gz
Option type @ counts number of occurrences, it doesn't take an argument.
-rw-r--r--lib/args.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/args.c b/lib/args.c
index 0efad075..ae608e03 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -142,7 +142,9 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
// Does this option take an argument?
gof->arg++;
type = opt->type;
- if (type) {
+
+ if (type == '@') ++*(opt->arg);
+ else if (type) {
char *arg = gof->arg;
// Handle "-xblah" and "-x blah", but also a third case: "abxc blah"
@@ -176,7 +178,7 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
error_exit("-%c < %lf", opt->c, (double)opt->val[0].f);
if (opt->val[1].l != LONG_MAX && *f > opt->val[1].f)
error_exit("-%c > %lf", opt->c, (double)opt->val[1].f);
- } else if (type == '@') ++*(opt->arg);
+ }
if (!gof->nodash_now) gof->arg = "";
}