- } else if (opt->item->cls == OPT_CL_BOOL && !strncmp("no-", str, 3) && !strncmp(opt->name, str+3, len-3)) {
- if (strlen(opt->name) == len-3)
- return opt;
+ } else if (opt->item->cls == OPT_CL_BOOL) {
+ if (opt->flags & OPT_NEGATIVE) {
+ // If the option is called no-X, match X as well
+ if (!strncmp("no-", opt->name, 3) && !strncmp(opt->name+3, str, len)) {
+ if (strlen(opt->name) == len+3)
+ return opt;
+ } else
+ continue;
+ } else {
+ // Match no-X as well
+ if (!strncmp("no-", str, 3) && !strncmp(opt->name, str+3, len-3)) {
+ if (strlen(opt->name) == len-3)
+ return opt;
+ } else
+ continue;
+ }