aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-12-29 03:18:34 -0600
committerRob Landley <rob@landley.net>2012-12-29 03:18:34 -0600
commit8abf095265341f1db12abb1497b5c92b683c6890 (patch)
tree391df1b23d24d48b9a857c34f07728888244721a /lib
parent63e042cf95ce4ce21af465a845cdbdc780ead108 (diff)
downloadtoybox-8abf095265341f1db12abb1497b5c92b683c6890.tar.gz
Ashwini Sharma pointed out that my previous tweak to [!abc] groups still didn't get the error reporting right (test case "touch -d 12 -r f2 f1"). This says "no 'r' with 'd'" for that, and still shouldn't be able to fall off the end of the list (segfault) because an option can't conflict with itself (that's what the ~(1<<i) on lib/args.c line 317 is for).
Diffstat (limited to 'lib')
-rw-r--r--lib/args.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/args.c b/lib/args.c
index e4b774b4..67c7788a 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -132,8 +132,10 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
struct opts *bad;
unsigned i = 1;
- for (bad=gof->opts; opt == bad || !(gof->excludes & i); bad = bad->next)
- i<<=1;
+ for (bad=gof->opts, i=1; ;bad = bad->next, i<<=1) {
+ if (opt == bad || !(i & toys.optflags)) continue;
+ if (toys.optflags & bad->dex[2]) break;
+ }
error_exit("No '%c' with '%c'", opt->c, bad->c);
}