Skip to content

Commit aea6c05

Browse files
committed
Merge branch 'rs/parse-opt-forbid-set-int-0-without-noneg'
Developer support to detect meaningless combination of options. * rs/parse-opt-forbid-set-int-0-without-noneg: parse-options: disallow negating OPTION_SET_INT 0
2 parents f12cb50 + 3284b93 commit aea6c05

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

parse-options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ static void parse_options_check(const struct option *opts)
480480
opts->long_name))
481481
optbug(opts, "uses feature "
482482
"not supported for dashless options");
483+
if (opts->type == OPTION_SET_INT && !opts->defval &&
484+
opts->long_name && !(opts->flags & PARSE_OPT_NONEG))
485+
optbug(opts, "OPTION_SET_INT 0 should not be negatable");
483486
switch (opts->type) {
484487
case OPTION_COUNTUP:
485488
case OPTION_BIT:

0 commit comments

Comments
 (0)