aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-15 02:54:18 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-15 02:54:18 +0100
commit74290b5f977894eb1fb92b6a2e978b6fdbd76bde (patch)
tree122b6835fa572b9a3da5ac3f39eb8f41119ab9cc
parentadd constant for empty suffix (diff)
downloadsha3sum-74290b5f977894eb1fb92b6a2e978b6fdbd76bde.tar.gz
sha3sum-74290b5f977894eb1fb92b6a2e978b6fdbd76bde.tar.bz2
sha3sum-74290b5f977894eb1fb92b6a2e978b6fdbd76bde.tar.xz
select last value of the options
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/common.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/common.c b/src/common.c
index 48b33d8..a021ff6 100644
--- a/src/common.c
+++ b/src/common.c
@@ -39,14 +39,16 @@
-#define USER_ERROR(string) \
+#define USER_ERROR(string) \
(fprintf(stderr, "%s: %s.\n", execname, string), 1)
-
-#define ADD(arg, desc, ...) \
- (arg ? args_add_option(args_new_argumented(NULL, arg, 0, __VA_ARGS__, NULL), desc) \
+#define ADD(arg, desc, ...) \
+ (arg ? args_add_option(args_new_argumented(NULL, arg, 0, __VA_ARGS__, NULL), desc) \
: args_add_option(args_new_argumentless(NULL, 0, __VA_ARGS__, NULL), desc))
+#define LAST(arg) \
+ (args_opts_get(arg)[args_opts_get_count(arg) - 1])
+
/**
@@ -529,12 +531,12 @@ int run(int argc, char* argv[], libkeccak_generalised_spec_t* restrict gspec, co
args_parse(argc, argv);
if (args_opts_used("-h")) return args_help(0), 0;
- if (args_opts_used("-R")) gspec->bitrate = atol(args_opts_get("-R")[0]);
- if (args_opts_used("-C")) gspec->capacity = atol(args_opts_get("-C")[0]);
- if (args_opts_used("-N")) gspec->output = atol(args_opts_get("-N")[0]);
- if (args_opts_used("-S")) gspec->state_size = atol(args_opts_get("-S")[0]);
- if (args_opts_used("-W")) gspec->word_size = atol(args_opts_get("-W")[0]);
- if (args_opts_used("-Z")) squeezes = atol(args_opts_get("-Z")[0]);
+ if (args_opts_used("-R")) gspec->bitrate = atol(LAST("-R"));
+ if (args_opts_used("-C")) gspec->capacity = atol(LAST("-C"));
+ if (args_opts_used("-N")) gspec->output = atol(LAST("-N"));
+ if (args_opts_used("-S")) gspec->state_size = atol(LAST("-S"));
+ if (args_opts_used("-W")) gspec->word_size = atol(LAST("-W"));
+ if (args_opts_used("-Z")) squeezes = atol(LAST("-Z"));
if (args_opts_used("-u")) presentation = REPRESENTATION_UPPER_CASE;
if (args_opts_used("-l")) presentation = REPRESENTATION_LOWER_CASE;
if (args_opts_used("-b")) presentation = REPRESENTATION_BINARY;