lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <20231208000515.1693746-3-irogers@google.com> Date: Thu, 7 Dec 2023 16:05:15 -0800 From: Ian Rogers <irogers@...gle.com> To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>, Mark Rutland <mark.rutland@....com>, Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>, Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>, Chenyuan Mi <cymi20@...an.edu.cn>, linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org Subject: [PATCH v1 3/3] perf help: Lower levenshtein penality for deleting character The levenshtein penalty for deleting a character was far higher than subsituting or inserting a character. Lower the penalty to match that of inserting a character. Before: ``` $ perf recccord perf: 'recccord' is not a perf-command. See 'perf --help'. ``` After: ``` $ perf recccord perf: 'recccord' is not a perf-command. See 'perf --help'. Did you mean this? record ``` Signed-off-by: Ian Rogers <irogers@...gle.com> --- tools/perf/util/help-unknown-cmd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c index 2ba3369f1620..a0a46e34f8d1 100644 --- a/tools/perf/util/help-unknown-cmd.c +++ b/tools/perf/util/help-unknown-cmd.c @@ -73,10 +73,14 @@ const char *help_unknown_cmd(const char *cmd, struct cmdnames *main_cmds) if (main_cmds->cnt) { /* This reuses cmdname->len for similarity index */ - for (i = 0; i < main_cmds->cnt; ++i) + for (i = 0; i < main_cmds->cnt; ++i) { main_cmds->names[i]->len = - levenshtein(cmd, main_cmds->names[i]->name, 0, 2, 1, 4); - + levenshtein(cmd, main_cmds->names[i]->name, + /*swap_penalty=*/0, + /*substition_penality=*/2, + /*insertion_penality=*/1, + /*deletion_penalty=*/1); + } qsort(main_cmds->names, main_cmds->cnt, sizeof(*main_cmds->names), levenshtein_compare); -- 2.43.0.472.g3155946c3a-goog
Powered by blists - more mailing lists