| 5189 | */ |
| 5190 | |
| 5191 | int |
| 5192 | optfn_boolean( |
| 5193 | int optidx, int req, boolean negated, |
| 5194 | char *opts, char *op) |
| 5195 | { |
| 5196 | if (req == do_init) { |
| 5197 | return optn_ok; |
| 5198 | } |
| 5199 | if (req == do_set) { |
| 5200 | boolean nosexchange = FALSE; |
| 5201 | int ln = 0; |
| 5202 | |
| 5203 | if (!allopt[optidx].addr) |
| 5204 | return optn_ok; /* silent retreat */ |
| 5205 | |
| 5206 | /* option that must come from config file? */ |
| 5207 | if (!go.opt_initial && (allopt[optidx].setwhere == set_in_config)) |
| 5208 | return optn_err; |
| 5209 | |
| 5210 | /* options that must NOT come from config file */ |
| 5211 | if (go.opt_initial && allopt[optidx].setwhere == set_wiznofuz) |
| 5212 | return optn_err; |
| 5213 | |
| 5214 | op = string_for_opt(opts, TRUE); |
| 5215 | if (op != empty_optstr) { |
| 5216 | if (negated) { |
| 5217 | config_error_add( |
| 5218 | "Negated boolean '%s' should not have a parameter", |
| 5219 | allopt[optidx].name); |
| 5220 | return optn_silenterr; |
| 5221 | } |
| 5222 | /* length is greater than 0 or we wouldn't have gotten here */ |
| 5223 | ln = (int) strlen(op); |
| 5224 | if (!strncmpi(op, "true", ln) |
| 5225 | || !strncmpi(op, "yes", ln) |
| 5226 | || !strcmpi(op, "on") |
| 5227 | || (digit(*op) && atoi(op) == 1)) { |
| 5228 | negated = FALSE; |
| 5229 | } else if (!strncmpi(op, "false", ln) |
| 5230 | || !strncmpi(op, "no", ln) |
| 5231 | || !strcmpi(op, "off") |
| 5232 | || (digit(*op) && atoi(op) == 0)) { |
| 5233 | negated = TRUE; |
| 5234 | } else if (!allopt[optidx].valok) { |
| 5235 | config_error_add("'%s' is not valid for a boolean", opts); |
| 5236 | return optn_silenterr; |
| 5237 | } |
| 5238 | } |
| 5239 | if (iflags.debug_fuzzer && !go.opt_initial) { |
| 5240 | /* don't randomly toggle this/these */ |
| 5241 | if ((optidx == opt_silent) |
| 5242 | || (optidx == opt_perm_invent)) |
| 5243 | return optn_ok; |
| 5244 | } |
| 5245 | /* Before the change */ |
| 5246 | switch (optidx) { |
| 5247 | case opt_female: |
| 5248 | if (!strncmpi(opts, "female", max(ln, 3))) { |
nothing calls this directly
no test coverage detected