From 3ebbe289896a698b99c91b797440563272dcd716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 27 Jan 2019 07:35:28 +0700 Subject: parse-options: allow ll_callback with OPTION_CALLBACK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OPTION_CALLBACK is much simpler/safer to use, but parse_opt_cb does not allow access to parse_opt_ctx_t, which sometimes is useful (e.g. to obtain the prefix). Extending parse_opt_cb to take parse_opt_cb could result in a lot of changes. Instead let's just allow ll_callback to be used with OPTION_CALLBACK. The user will have to be careful, not to change anything in ctx, or return wrong result code. But that's the price for ll_callback. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- parse-options-cb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'parse-options-cb.c') diff --git a/parse-options-cb.c b/parse-options-cb.c index ec01ef722b..2733393546 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -171,8 +171,10 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset) * parse_options(). */ enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx, - const struct option *opt, int unset) + const struct option *opt, + const char *arg, int unset) { + BUG_ON_OPT_ARG(arg); return PARSE_OPT_UNKNOWN; } -- cgit v1.2.3