Signed-off-by: Jens Axboe <axboe@fb.com>
+ if (best_option != -1 && string_distance_ok(name, best_distance))
log_err("Did you mean %s?\n", l_opts[best_option].name);
}
log_err("Did you mean %s?\n", l_opts[best_option].name);
}
+ if (best_option != -1 && string_distance_ok(name, best_distance))
log_err("Did you mean %s?\n", fio_options[best_option].name);
free(name);
log_err("Did you mean %s?\n", fio_options[best_option].name);
free(name);
+/*
+ * Make a guess of whether the distance from 's1' is significant enough
+ * to warrant printing the guess. We set this to a 1/2 match.
+ */
+int string_distance_ok(const char *opt, int distance)
+{
+ size_t len;
+
+ len = strlen(opt);
+ len = (len + 1) / 2;
+ return distance <= len;
+}
+
static struct fio_option *find_child(struct fio_option *options,
struct fio_option *o)
{
static struct fio_option *find_child(struct fio_option *options,
struct fio_option *o)
{
extern int str_to_float(const char *str, double *val, int is_time);
extern int string_distance(const char *s1, const char *s2);
extern int str_to_float(const char *str, double *val, int is_time);
extern int string_distance(const char *s1, const char *s2);
+extern int string_distance_ok(const char *s1, int dist);
/*
* Handlers for the options
/*
* Handlers for the options