aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/subcmd/parse-options.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/subcmd/parse-options.c')
-rw-r--r--tools/lib/subcmd/parse-options.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 981bb4481fd5..3284bb14ae78 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -314,12 +314,19 @@ static int get_value(struct parse_opt_ctx_t *p,
314 314
315static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options) 315static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options)
316{ 316{
317retry:
317 for (; options->type != OPTION_END; options++) { 318 for (; options->type != OPTION_END; options++) {
318 if (options->short_name == *p->opt) { 319 if (options->short_name == *p->opt) {
319 p->opt = p->opt[1] ? p->opt + 1 : NULL; 320 p->opt = p->opt[1] ? p->opt + 1 : NULL;
320 return get_value(p, options, OPT_SHORT); 321 return get_value(p, options, OPT_SHORT);
321 } 322 }
322 } 323 }
324
325 if (options->parent) {
326 options = options->parent;
327 goto retry;
328 }
329
323 return -2; 330 return -2;
324} 331}
325 332
@@ -333,6 +340,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
333 if (!arg_end) 340 if (!arg_end)
334 arg_end = arg + strlen(arg); 341 arg_end = arg + strlen(arg);
335 342
343retry:
336 for (; options->type != OPTION_END; options++) { 344 for (; options->type != OPTION_END; options++) {
337 const char *rest; 345 const char *rest;
338 int flags = 0; 346 int flags = 0;
@@ -426,6 +434,12 @@ match:
426 } 434 }
427 if (abbrev_option) 435 if (abbrev_option)
428 return get_value(p, abbrev_option, abbrev_flags); 436 return get_value(p, abbrev_option, abbrev_flags);
437
438 if (options->parent) {
439 options = options->parent;
440 goto retry;
441 }
442
429 return -2; 443 return -2;
430} 444}
431 445