From 44cc09fd53e749808200829c1acc66f7044fbaa7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 23 Aug 2013 16:35:58 +0200 Subject: c version bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/argparser.c') diff --git a/src/argparser.c b/src/argparser.c index b15f499..e0f53bf 100644 --- a/src/argparser.c +++ b/src/argparser.c @@ -564,6 +564,7 @@ void args_opts_put(char* name, char** values) value = (args_Array*)malloc(sizeof(args_Array)); value->values = (void**)values; map_put(&args_opts, name, value); + value->used = false; } else value->values = (void**)values; @@ -596,7 +597,10 @@ void args_opts_put_count(char* name, long count) */ long args_opts_used(char* name) { - return args_opts_get_count(name) > 0; + args_Array* value = (args_Array*)map_get(&args_opts, name); + if (value == null) + return false; + return value->used; } @@ -976,8 +980,13 @@ void args_support_alternatives() { char* alt = *(opts + i); char* std = args_optmap_get_standard(alt); - args_opts_put(alt, args_opts_get(std)); - args_opts_put_count(alt, args_opts_get_count(std)); + args_Array* value_std = (args_Array*)map_get(&args_opts, std); + args_Array* value_alt; + + args_opts_put(alt, (char**)value_std->values); + value_alt = (args_Array*)map_get(&args_opts, alt); + value_alt->count = value_std->count; + value_alt->used = value_std->used; } } @@ -1404,6 +1413,7 @@ long args_parse(int argc, char** argv) args_opts_new(opt); if (argptr >= i) args_opts_append(opt, arg); + ((args_Array*)map_get(&args_opts, opt))->used = true; } } -- cgit v1.2.3-70-g09d2