isl_options_parse: accept prefix before or after "no" on boolean options
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 12 Nov 2010 13:42:46 +0000 (14:42 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 12 Nov 2010 15:10:17 +0000 (16:10 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_arg.c

index 17c67ff..4b94f5f 100644 (file)
--- 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);