Remove duplicate code in parser
authorJens Axboe <jaxboe@fusionio.com>
Wed, 31 Aug 2011 18:55:27 +0000 (12:55 -0600)
committerJens Axboe <jaxboe@fusionio.com>
Wed, 31 Aug 2011 18:55:27 +0000 (12:55 -0600)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
parse.c

diff --git a/parse.c b/parse.c
index efb5e3d0d9228a68606dda3cb312040943095620..425411e9860bbada8be0c02988fd71beea3c2c43 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -196,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++;
        }
@@ -491,18 +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;
 
-               if (!posval_sort(o, posval)) {
-                       if (o->roff1)
-                               cp = (char **) o->roff1;
-                       else
-                               cp = td_var(data, o->off1);
-                       *cp = strdup(ptr);
-
-                       if (fn)
-                               ret = fn(data, ptr);
-
-                       return ret;
-               }
+               if (!posval_sort(o, posval))
+                       goto match;
 
                ret = 1;
                for (i = 0; i < PARSE_MAX_VP; i++) {
@@ -516,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