X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=9015b1d72bd5a527ef36ed0db12646ce01fcc945;hp=57865b112e7a9118a9a4e6fc3dd0a60a0d66a9a8;hb=c7173db634637926296ba8a9201bc8edcddbc1a3;hpb=0f3e35efd9f63ad1a504a7d09fdf12bb3ece13f9 diff --git a/parse.c b/parse.c index 57865b11..9015b1d7 100644 --- a/parse.c +++ b/parse.c @@ -142,12 +142,24 @@ void strip_blank_front(char **p) while (isspace(*s)) s++; + + *p = s; } void strip_blank_end(char *p) { - char *s = p + strlen(p) - 1; - + char *s; + + s = strchr(p, ';'); + if (s) + *s = '\0'; + s = strchr(p, '#'); + if (s) + *s = '\0'; + if (s) + p = s; + + s = p + strlen(p) - 1; while (isspace(*s) || iscntrl(*s)) s--; @@ -450,9 +462,9 @@ int parse_option(const char *opt, struct fio_option *options, void *data) { struct fio_option *o; char *pre, *post; - char tmp[64]; + char *tmp; - strncpy(tmp, opt, sizeof(tmp) - 1); + tmp = strdup(opt); pre = strchr(tmp, '='); if (pre) { @@ -468,13 +480,17 @@ int parse_option(const char *opt, struct fio_option *options, void *data) if (!o) { fprintf(stderr, "Bad option %s\n", tmp); + free(tmp); return 1; } - if (!handle_option(o, post, data)) + if (!handle_option(o, post, data)) { + free(tmp); return 0; + } fprintf(stderr, "fio: failed parsing %s\n", opt); + free(tmp); return 1; }