*/
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;
void strip_blank_end(char *p)
{
- char *s;
+ char *start = p, *s;
s = strchr(p, ';');
if (s)
p = s;
s = p + strlen(p);
- while ((isspace(*s) || iscntrl(*s)) && (s > p))
+ while ((isspace(*s) || iscntrl(*s)) && (s > start))
s--;
*(s + 1) = '\0';
}
case FIO_OPT_STR_VAL_TIME:
is_time = 1;
+ case FIO_OPT_INT:
case FIO_OPT_STR_VAL:
case FIO_OPT_STR_VAL_INT: {
fio_opt_str_val_fn *fn = o->cb;
if (fn)
ret = fn(data, &ull);
else {
- if (o->type == FIO_OPT_STR_VAL_INT) {
+ if (o->type == FIO_OPT_STR_VAL_INT ||
+ o->type == FIO_OPT_INT) {
if (first)
val_store(ilp, ull, o->off1, data);
if (!more && o->off2)
break;
}
- case FIO_OPT_INT:
case FIO_OPT_BOOL: {
fio_opt_int_fn *fn = o->cb;