Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 1/6] parse-options: sanity check PARSE_OPT_NOARG flag

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:09

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help