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 <jaxboe@fusionio.com>
diff --git a/parse.c b/parse.c
index 2dee446..f52139f 100644
--- a/parse.c
+++ b/parse.c
@@ -187,6 +187,7 @@
int *percent)
{
const char *p = str;
+ int digit_seen = 0;
if (len < 2)
return __get_mult_bytes(str, data, percent);
@@ -195,8 +196,10 @@
* 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++;
}