From ef9aff52b10c71a4cb2b3649deaea270fa3944a0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 31 Jul 2007 22:56:53 +0200 Subject: [PATCH] Parent options didn't recurse properly It only displayed the first found. Add a ->parent_seen and find all matches. Signed-off-by: Jens Axboe --- parse.c | 19 ++++++++++++------- parse.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/parse.c b/parse.c index 962538c0..ffe435a4 100644 --- a/parse.c +++ b/parse.c @@ -566,30 +566,35 @@ static struct fio_option *find_child(struct fio_option *options, { struct fio_option *__o; - for (__o = &options[0]; __o->name; __o++) - if (__o->parent && !strcmp(__o->parent, o->name)) + for (__o = &options[0]; __o->name; __o++) { + if (__o->parent && !strcmp(__o->parent, o->name) + && !__o->parent_seen) { + __o->parent_seen = 1; return __o; + } + } return NULL; } static void print_option(struct fio_option *options, struct fio_option *o, - int level) + struct fio_option *org, int level) { char name[256], *p; - int i; if (!o) return; + if (!org) + org = o; p = name; - for (i = 0; i < level; i++) + if (level) p += sprintf(p, "%s", " "); sprintf(p, "%s", o->name); printf("%-24s: %s\n", name, o->help); - print_option(options, find_child(options, o), level + 1); + print_option(options, find_child(options, org), org, level + 1); } int show_cmd_help(struct fio_option *options, const char *name) @@ -628,7 +633,7 @@ int show_cmd_help(struct fio_option *options, const char *name) printf("%24s: %s\n", o->name, o->help); if (show_all) { if (!o->parent) - print_option(options, o, 0); + print_option(options, o, NULL, 0); continue; } } diff --git a/parse.h b/parse.h index c3b66d75..36ff2b23 100644 --- a/parse.h +++ b/parse.h @@ -46,6 +46,7 @@ struct fio_option { const char *def; /* default setting */ const struct value_pair posval[PARSE_MAX_VP];/* possible values */ const char *parent; /* parent option */ + char parent_seen; }; typedef int (str_cb_fn)(void *, char *); -- 2.25.1