summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-03-09 14:15:21 +0100
committerJens Axboe <jens.axboe@oracle.com>2009-03-09 14:15:21 +0100
commitb347f9daece7d65a6e596cd3bd0ef3602e40b059 (patch)
tree1849c3a03657f80fc01b34d413330ad6a3e59366
parent853ee7fc686293cd45fbb177c75114ed2489144d (diff)
downloadfio-b347f9daece7d65a6e596cd3bd0ef3602e40b059.tar.gz
fio-b347f9daece7d65a6e596cd3bd0ef3602e40b059.tar.bz2
Allow 0x (or 0X) prefix for any int value to indicate hex base
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--parse.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index d653f5e4..4c6a9ea9 100644
--- a/parse.c
+++ b/parse.c
@@ -112,13 +112,18 @@ static unsigned long get_mult_bytes(char c)
*/
int str_to_decimal(const char *str, long long *val, int kilo)
{
- int len;
+ int len, base;
len = strlen(str);
if (!len)
return 1;
- *val = strtoll(str, NULL, 10);
+ if (strstr(str, "0x") || strstr(str, "0X"))
+ base = 16;
+ else
+ base = 10;
+
+ *val = strtoll(str, NULL, base);
if (*val == LONG_MAX && errno == ERANGE)
return 1;