diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-01-03 03:19:54 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-01-03 09:10:38 -0500 |
commit | b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4 (patch) | |
tree | 66f45f717f76deb0e564013c68772f948037fe88 /tools/lib/subcmd/parse-options.c | |
parent | 1f2ed153b916c95a49a1ca9d7107738664224b7f (diff) |
tools lib subcmd: Add OPT_STRING_OPTARG_SET option
To allow string options with a default argument and variable set when
the option is used.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1483431600-19887-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/subcmd/parse-options.c')
-rw-r--r-- | tools/lib/subcmd/parse-options.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 3284bb14ae78..8aad81151d50 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c | |||
@@ -213,6 +213,9 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
213 | else | 213 | else |
214 | err = get_arg(p, opt, flags, (const char **)opt->value); | 214 | err = get_arg(p, opt, flags, (const char **)opt->value); |
215 | 215 | ||
216 | if (opt->set) | ||
217 | *(bool *)opt->set = true; | ||
218 | |||
216 | /* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */ | 219 | /* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */ |
217 | if (opt->flags & PARSE_OPT_NOEMPTY) { | 220 | if (opt->flags & PARSE_OPT_NOEMPTY) { |
218 | const char *val = *(const char **)opt->value; | 221 | const char *val = *(const char **)opt->value; |