aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-08-23 16:35:58 +0200
committerMattias Andrée <maandree@operamail.com>2013-08-23 16:35:58 +0200
commit44cc09fd53e749808200829c1acc66f7044fbaa7 (patch)
treed7d637473affac0d4da96bc98468748c6751ecb0 /src
parentfix variadic issue (diff)
downloadargparser-3.0.tar.gz
argparser-3.0.tar.bz2
argparser-3.0.tar.xz
c version bug fix3.0
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/argparser.c16
-rw-r--r--src/argparser.h5
2 files changed, 18 insertions, 3 deletions
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;
}
}
diff --git a/src/argparser.h b/src/argparser.h
index 32e2dd5..668e340 100644
--- a/src/argparser.h
+++ b/src/argparser.h
@@ -115,6 +115,11 @@ typedef struct
*/
long count;
+ /**
+ * Whether the item is used, that is, the data exists even if the count is zero
+ */
+ long used;
+
} args_Array;