Stephen Boyd [off-list ref] writes:
On 11/29/10 18:55, Jonathan Nieder wrote:
quoted
+static void check_flags(const struct option *opt)
+{
+ switch (opt->type) {
+ case OPTION_BOOLEAN:
+ case OPTION_BIT:
+ case OPTION_NEGBIT:
+ case OPTION_SET_INT:
+ case OPTION_SET_PTR:
+ case OPTION_NUMBER:
+ break;
+ default: /* (usually accepts an argument) */
+ return;
+ }
+ if ((opt->flags & (PARSE_OPT_OPTARG | PARSE_OPT_NOARG)) == PARSE_OPT_NOARG)
+ return;
+ die("BUG: option '-%c%s' should not accept an argument",
+ !opt->short_name ? '-' : opt->short_name,
+ !opt->short_name ? opt->long_name : "");
+}
+
This check should probably go into parse_options_check()...
Very good suggestion---that way we can check and get diagnosis for all the
errors, not just dying on the first one.