From e70871d8b5c92e40cedd6fd0b7687c4f0b6ce3ff Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:35 +0100 Subject: 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: Hani Benhabiles Signed-off-by: Luiz Capitulino --- util/readline.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util/readline.c') diff --git a/util/readline.c b/util/readline.c index 8baec55509..7214e8407c 100644 --- a/util/readline.c +++ b/util/readline.c @@ -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); } } -- cgit v1.2.1