parse: fix misparse of bs=64k-128k
We failed parsing the postfix for this case, resulting in
64 and 128k being the result (instead of 64k and 128k).
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/parse.c b/parse.c
index 51cefca..5b8e10f 100644
--- a/parse.c
+++ b/parse.c
@@ -140,6 +140,19 @@
}
}
+static int is_separator(char c)
+{
+ switch (c) {
+ case ':':
+ case '-':
+ case ',':
+ case '/':
+ return 1;
+ default:
+ return 0;
+ }
+}
+
static unsigned long long __get_mult_bytes(const char *p, void *data,
int *percent)
{
@@ -153,8 +166,13 @@
c = strdup(p);
- for (i = 0; i < strlen(c); i++)
+ for (i = 0; i < strlen(c); i++) {
c[i] = tolower(c[i]);
+ if (is_separator(c[i])) {
+ c[i] = '\0';
+ break;
+ }
+ }
if (!strcmp("pib", c)) {
pow = 5;