From 2897182459dbb129c30723d7c7a92cd0a24da565 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 12 Nov 2010 14:42:46 +0100 Subject: [PATCH] isl_options_parse: accept prefix before or after "no" on boolean options Signed-off-by: Sven Verdoolaege --- isl_arg.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/isl_arg.c b/isl_arg.c index 17c67ff..4b94f5f 100644 --- a/isl_arg.c +++ b/isl_arg.c @@ -599,9 +599,22 @@ static int parse_bool_option(struct isl_arg *decl, const char *arg, return 1; } - if (strncmp(arg, "--no-", 5)) + if (strncmp(arg, "--", 2)) + return 0; + arg += 2; + + if (prefix) { + size_t prefix_len = strlen(prefix); + if (strncmp(arg, prefix, prefix_len) == 0 && + arg[prefix_len] == '-') { + arg += prefix_len + 1; + prefix = NULL; + } + } + + if (strncmp(arg, "no-", 3)) return 0; - arg += 5; + arg += 3; if (prefix) { size_t prefix_len = strlen(prefix); -- 2.7.4