From ef67aedfe62bd103a07d1f6e6a8264adf8fd799f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 May 2020 21:50:49 -0500 Subject: Fix 32 bit option parsing for long long optflag values. --- lib/args.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/args.c b/lib/args.c index 89c82ca7..83bceaf0 100644 --- a/lib/args.c +++ b/lib/args.c @@ -132,6 +132,7 @@ struct getoptflagstate // Use getoptflagstate to parse one command line option from argv static int gotflag(struct getoptflagstate *gof, struct opts *opt) { + unsigned long long i; int type; // Did we recognize this option? @@ -143,7 +144,6 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) // Might enabling this switch off something else? if (toys.optflags & opt->dex[0]) { struct opts *clr; - unsigned long long i = 1; // Forget saved argument for flag we switch back off for (clr=gof->opts, i=1; clr; clr = clr->next, i<<=1) @@ -158,7 +158,6 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) if (toys.optflags & gof->excludes) { struct opts *bad; - unsigned i = 1; for (bad=gof->opts, i=1; bad ;bad = bad->next, i<<=1) { if (opt == bad || !(i & toys.optflags)) continue; @@ -327,7 +326,7 @@ void parse_optflaglist(struct getoptflagstate *gof) // (This goes right to left so we need the whole list before we can start.) idx = 0; for (new = gof->opts; new; new = new->next) { - unsigned long long u = 1L<c == 1) new->c = 0; new->dex[1] = u; @@ -400,7 +399,7 @@ void get_optflags(void) // Iterate through command line arguments, skipping argv[0] for (gof.argc=1; toys.argv[gof.argc]; gof.argc++) { gof.arg = toys.argv[gof.argc]; - catch = NULL; + catch = 0; // Parse this argument if (gof.stopearly>1) goto notflag; -- cgit v1.2.3