From 0d9b0b03edcfef64580123067aade23575e093c4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 25 May 2018 16:47:03 +0100 Subject: [PATCH] [Minor] Add more suggestions --- src/rspamadm/rspamadm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c index df68f6139..1df301f08 100644 --- a/src/rspamadm/rspamadm.c +++ b/src/rspamadm/rspamadm.c @@ -389,7 +389,19 @@ main (gint argc, gchar **argv, gchar **env) /* Try fuzz search */ rspamd_fprintf (stderr, "Suggested commands:\n"); PTR_ARRAY_FOREACH (all_commands, i, cmd) { - if (rspamd_strings_levenshtein_distance (cmd->name, 0, cmd_name, 0, 1) == 1) { + gsize clen, inplen; + + clen = strlen (cmd->name); + inplen = strlen (cmd_name); + + if (rspamd_strings_levenshtein_distance (cmd->name, clen, + cmd_name, inplen, 1) == 1) { + rspamd_fprintf (stderr, "%s\n", cmd->name); + } + else if ((clen > inplen && + rspamd_substring_search (cmd->name, clen, cmd_name, inplen) != -1) || + (inplen > clen && + rspamd_substring_search (cmd_name, inplen, cmd->name, clen) != -1)) { rspamd_fprintf (stderr, "%s\n", cmd->name); } } -- 2.39.5