if (add_cmd_list(main_cmds, &other_cmds) < 0) {
fprintf(stderr, "ERROR: Failed to allocate command list for unknown command.\n"); goto end;
}
qsort(main_cmds->names, main_cmds->cnt, sizeof(main_cmds->names), cmdname_compare);
uniq(main_cmds);
if (main_cmds->cnt) { /* This reuses cmdname->len for similarity index */ for (i = 0; i < main_cmds->cnt; ++i) {
main_cmds->names[i]->len =
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);
best_similarity = main_cmds->names[0]->len;
n = 1; while (n < main_cmds->cnt && best_similarity == main_cmds->names[n]->len)
++n;
}
if (autocorrect && n == 1) { constchar *assumed = main_cmds->names[0]->name;
main_cmds->names[0] = NULL;
clean_cmdnames(&other_cmds);
fprintf(stderr, "WARNING: You called a perf program named '%s', " "which does not exist.\n" "Continuing under the assumption that you meant '%s'\n",
cmd, assumed); if (autocorrect > 0) {
fprintf(stderr, "in %0.1f seconds automatically...\n",
(float)autocorrect/10.0);
poll(NULL, 0, autocorrect * 100);
} return assumed;
}
fprintf(stderr, "perf: '%s' is not a perf-command. See 'perf --help'.\n", cmd);
if (main_cmds->cnt && best_similarity < 6) {
fprintf(stderr, "\nDid you mean %s?\n",
n < 2 ? "this": "one of these");
for (i = 0; i < n; i++)
fprintf(stderr, "\t%s\n", main_cmds->names[i]->name);
}
end:
clean_cmdnames(&other_cmds); return NULL;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.