X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=5b8e10f9f2e936ef55817c2d44b291e7c868e9f4;hp=144794aa09b34d903e2e44969ba788adc70de25f;hb=de98bd30b02bd89a78059d162b2c8426e889703d;hpb=266506958a1dbaa41800f0b1170217d81c702f47 diff --git a/parse.c b/parse.c index 144794aa..5b8e10f9 100644 --- a/parse.c +++ b/parse.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "parse.h" #include "debug.h" @@ -51,11 +51,11 @@ static void show_option_range(struct fio_option *o, int (*logger)(const char *format, ...)) { if (o->type == FIO_OPT_FLOAT_LIST){ - if (o->minfp == MINDOUBLE && o->maxfp == MAXDOUBLE) + if (o->minfp == DBL_MIN && o->maxfp == DBL_MAX) return; logger("%20s: min=%f", "range", o->minfp); - if (o->maxfp != MAXDOUBLE) + if (o->maxfp != DBL_MAX) logger(", max=%f", o->maxfp); logger("\n"); } else { @@ -140,6 +140,19 @@ static unsigned long get_mult_time(char c) } } +static int is_separator(char c) +{ + switch (c) { + case ':': + case '-': + case ',': + case '/': + return 1; + default: + return 0; + } +} + static unsigned long long __get_mult_bytes(const char *p, void *data, int *percent) { @@ -153,8 +166,13 @@ static unsigned long long __get_mult_bytes(const char *p, void *data, c = strdup(p); - for (i = 0; i < strlen(c); i++) + for (i = 0; i < strlen(c); i++) { c[i] = tolower(c[i]); + if (is_separator(c[i])) { + c[i] = '\0'; + break; + } + } if (!strcmp("pib", c)) { pow = 5; @@ -502,12 +520,27 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, break; } case FIO_OPT_FLOAT_LIST: { + char *cp2; + + if (first) { + /* + ** Initialize precision to 0 and zero out list + ** in case specified list is shorter than default + */ + ul2 = 0; + ilp = td_var(data, o->off2); + *ilp = ul2; + + flp = td_var(data, o->off1); + for(i = 0; i < o->maxlen; i++) + flp[i].u.f = 0.0; + } if (curr >= o->maxlen) { log_err("the list exceeding max length %d\n", o->maxlen); return 1; } - if (!str_to_float(ptr, &uf)){ + if (!str_to_float(ptr, &uf)) { log_err("not a floating point value: %s\n", ptr); return 1; } @@ -525,6 +558,23 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, flp = td_var(data, o->off1); flp[curr].u.f = uf; + /* + ** Calculate precision for output by counting + ** number of digits after period. Find first + ** period in entire remaining list each time + */ + cp2 = strchr(ptr, '.'); + if (cp2 != NULL) { + int len = 0; + + while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9') + len++; + + ilp = td_var(data, o->off2); + if (len > *ilp) + *ilp = len; + } + break; } case FIO_OPT_STR_STORE: { @@ -1092,8 +1142,8 @@ void option_init(struct fio_option *o) o->maxval = UINT_MAX; } if (o->type == FIO_OPT_FLOAT_LIST) { - o->minfp = MINDOUBLE; - o->maxfp = MAXDOUBLE; + o->minfp = DBL_MIN; + o->maxfp = DBL_MAX; } if (o->type == FIO_OPT_STR_SET && o->def) { log_err("Option %s: string set option with"