Add support for backwards holes
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 445812159585cf1dc490f6a294e278dbe4d2ffca..425411e9860bbada8be0c02988fd71beea3c2c43 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -26,11 +26,14 @@ static int vp_cmp(const void *p1, const void *p2)
        return strlen(vp2->ival) - strlen(vp1->ival);
 }
 
-static void posval_sort(struct fio_option *o, struct value_pair *vpmap)
+static int posval_sort(struct fio_option *o, struct value_pair *vpmap)
 {
        const struct value_pair *vp;
        int entries;
 
+       if (!o->posval[0].ival)
+               return 0;
+
        memset(vpmap, 0, PARSE_MAX_VP * sizeof(struct value_pair));
 
        for (entries = 0; entries < PARSE_MAX_VP; entries++) {
@@ -42,6 +45,7 @@ static void posval_sort(struct fio_option *o, struct value_pair *vpmap)
        }
 
        qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp);
+       return 1;
 }
 
 static void show_option_range(struct fio_option *o, FILE *out)
@@ -192,10 +196,10 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data,
                return __get_mult_bytes(str, data, percent);
 
         /*
-         * Go forward until we hit a non-digit
+         * Go forward until we hit a non-digit, or +/- sign
          */
        while ((p - str) <= len) {
-               if (!isdigit((int) *p))
+               if (!isdigit((int) *p) && (*p != '+') && (*p != '-'))
                        break;
                p++;
        }
@@ -487,7 +491,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        case FIO_OPT_STR_STORE: {
                fio_opt_str_fn *fn = o->cb;
 
-               posval_sort(o, posval);
+               if (!posval_sort(o, posval))
+                       goto match;
 
                ret = 1;
                for (i = 0; i < PARSE_MAX_VP; i++) {
@@ -501,6 +506,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                ret = 0;
                                if (vp->cb)
                                        fn = vp->cb;
+match:
                                if (o->roff1)
                                        cp = (char **) o->roff1;
                                else