From: Jens Axboe Date: Wed, 7 Sep 2011 20:11:00 +0000 (+0200) Subject: Better parser fix X-Git-Tag: fio-1.58~7 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ba4ddd690a04f39abada885f1b4ea3b228e790a8 Better parser fix The previous one broke all postfixes for ranges, that wasn't very nice. This one allows the proper postfix and +/- as well, as long as the latter is seen before a digit. Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index 2dee446d..f52139f5 100644 --- a/parse.c +++ b/parse.c @@ -187,6 +187,7 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data, int *percent) { const char *p = str; + int digit_seen = 0; if (len < 2) return __get_mult_bytes(str, data, percent); @@ -195,8 +196,10 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data, * Go forward until we hit a non-digit, or +/- sign */ while ((p - str) <= len) { - if (!isdigit((int) *p) && (*p != '+') && (*p != '-')) + if (!isdigit((int) *p) && + (((*p != '+') && (*p != '-')) || digit_seen)) break; + digit_seen |= isdigit(*p); p++; }