提交 e70871d8 编写于 作者: H Hani Benhabiles 提交者: Luiz Capitulino

readline: Make completion strings always unique

There is no need to clutter the user's choices with repeating the same value
multiple times.
Signed-off-by: NHani Benhabiles <hani@linux.com>
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
上级 e3bb532c
......@@ -263,6 +263,12 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
void readline_add_completion(ReadLineState *rs, const char *str)
{
if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
int i;
for (i = 0; i < rs->nb_completions; i++) {
if (!strcmp(rs->completions[i], str)) {
return;
}
}
rs->completions[rs->nb_completions++] = g_strdup(str);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册