aboutsummaryrefslogtreecommitdiff
path: root/lib/args.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-09-11 16:35:14 -0500
committerRob Landley <rob@landley.net>2015-09-11 16:35:14 -0500
commite5354ca12a232b3f97726214254a868771cb70d1 (patch)
treeba373c24ede64b8a18f11a02cf834ce99aa586bf /lib/args.c
parentd067571abb2b7934f3350c90ca891beb987c68fd (diff)
downloadtoybox-e5354ca12a232b3f97726214254a868771cb70d1.tar.gz
Replace toys.exithelp with help_exit() in lib.
Diffstat (limited to 'lib/args.c')
-rw-r--r--lib/args.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/args.c b/lib/args.c
index d5fbb17d..594a1b47 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -136,7 +136,7 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
// Did we recognize this option?
if (!opt) {
if (gof->noerror) return 1;
- error_exit("Unknown option %s", gof->arg);
+ help_exit("Unknown option %s", gof->arg);
}
// Might enabling this switch off something else?
@@ -163,7 +163,7 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
if (opt == bad || !(i & toys.optflags)) continue;
if (toys.optflags & bad->dex[2]) break;
}
- error_exit("No '%c' with '%c'", opt->c, bad->c);
+ help_exit("No '%c' with '%c'", opt->c, bad->c);
}
// Does this option take an argument?
@@ -187,10 +187,10 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
char *s = "Missing argument to ";
struct longopts *lo;
- if (opt->c != -1) error_exit("%s-%c", s, opt->c);
+ if (opt->c != -1) help_exit("%s-%c", s, opt->c);
for (lo = gof->longopts; lo->opt != opt; lo = lo->next);
- error_exit("%s--%.*s", s, lo->len, lo->str);
+ help_exit("%s--%.*s", s, lo->len, lo->str);
}
if (type == ':') *(opt->arg) = (long)arg;
@@ -204,8 +204,8 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
} else if (type == '#' || type == '-') {
long l = atolx(arg);
if (type == '-' && !ispunct(*arg)) l*=-1;
- if (l < opt->val[0].l) error_exit("-%c < %ld", opt->c, opt->val[0].l);
- if (l > opt->val[1].l) error_exit("-%c > %ld", opt->c, opt->val[1].l);
+ if (l < opt->val[0].l) help_exit("-%c < %ld", opt->c, opt->val[0].l);
+ if (l > opt->val[1].l) help_exit("-%c > %ld", opt->c, opt->val[1].l);
*(opt->arg) = l;
} else if (CFG_TOYBOX_FLOAT && type == '.') {
@@ -213,9 +213,9 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
*f = strtod(arg, &arg);
if (opt->val[0].l != LONG_MIN && *f < opt->val[0].f)
- error_exit("-%c < %lf", opt->c, (double)opt->val[0].f);
+ help_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);
+ help_exit("-%c > %lf", opt->c, (double)opt->val[1].f);
}
if (!gof->nodash_now) gof->arg = "";
@@ -384,7 +384,6 @@ void get_optflags(void)
// Option parsing is a two stage process: parse the option string into
// a struct opts list, then use that list to process argv[];
- toys.exithelp++;
// Allocate memory for optargs
saveflags = 0;
while (toys.argv[saveflags++]);
@@ -475,10 +474,10 @@ notflag:
// Sanity check
if (toys.optc<gof.minargs)
- error_exit("Need%s %d argument%s", letters[!!(gof.minargs-1)],
+ help_exit("Need%s %d argument%s", letters[!!(gof.minargs-1)],
gof.minargs, letters[!(gof.minargs-1)]);
if (toys.optc>gof.maxargs)
- error_exit("Max %d argument%s", gof.maxargs, letters[!(gof.maxargs-1)]);
+ help_exit("Max %d argument%s", gof.maxargs, letters[!(gof.maxargs-1)]);
if (gof.requires && !(gof.requires & toys.optflags)) {
struct opts *req;
char needs[32], *s = needs;
@@ -487,9 +486,8 @@ notflag:
if (req->flags & 1) *(s++) = req->c;
*s = 0;
- error_exit("Needs %s-%s", s[1] ? "one of " : "", needs);
+ help_exit("Needs %s-%s", s[1] ? "one of " : "", needs);
}
- toys.exithelp = 0;
if (CFG_TOYBOX_FREE) {
llist_traverse(gof.opts, free);