X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=parse.c;h=f907a349ff24931044592a3c69ada66672eab722;hb=d090f6f6fa92e66bc448a9bf47b6c52c1fd9c1ba;hp=9015b1d72bd5a527ef36ed0db12646ce01fcc945;hpb=523bfadbd46b375012eb5f3898201455b057a1c4;p=fio.git diff --git a/parse.c b/parse.c index 9015b1d7..f907a349 100644 --- a/parse.c +++ b/parse.c @@ -106,7 +106,7 @@ static unsigned long get_mult_bytes(char c) /* * convert string into decimal value, noting any size suffix */ -static int str_to_decimal(const char *str, long long *val, int kilo) +int str_to_decimal(const char *str, long long *val, int kilo) { int len; @@ -159,8 +159,8 @@ void strip_blank_end(char *p) if (s) p = s; - s = p + strlen(p) - 1; - while (isspace(*s) || iscntrl(*s)) + s = p + strlen(p); + while ((isspace(*s) || iscntrl(*s)) && (s > p)) s--; *(s + 1) = '\0'; @@ -188,8 +188,13 @@ static int check_int(const char *p, int *val) { if (!strlen(p)) return 1; - if (sscanf(p, "%u", val) == 1) - return 0; + if (strstr(p, "0x") || strstr(p, "0X")) { + if (sscanf(p, "%x", val) == 1) + return 0; + } else { + if (sscanf(p, "%u", val) == 1) + return 0; + } return 1; } @@ -556,6 +561,38 @@ static void show_option_help(struct fio_option *o) show_option_values(o); } +static struct fio_option *find_child(struct fio_option *options, + struct fio_option *o) +{ + struct fio_option *__o; + + for (__o = options + 1; __o->name; __o++) + if (__o->parent && !strcmp(__o->parent, o->name)) + return __o; + + return NULL; +} + +static void print_option(struct fio_option *o, struct fio_option *org, + int level) +{ + char name[256], *p; + + if (!o) + return; + if (!org) + org = o; + + p = name; + if (level) + p += sprintf(p, "%s", " "); + + sprintf(p, "%s", o->name); + + printf("%-24s: %s\n", name, o->help); + print_option(find_child(o, org), org, level + 1); +} + int show_cmd_help(struct fio_option *options, const char *name) { struct fio_option *o, *closest; @@ -589,9 +626,10 @@ int show_cmd_help(struct fio_option *options, const char *name) if (show_all || match) { found = 1; if (match) - printf("%20s: %s\n", o->name, o->help); + printf("%24s: %s\n", o->name, o->help); if (show_all) { - printf("%-20s: %s\n", o->name, o->help); + if (!o->parent) + print_option(o, NULL, 0); continue; } }