From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmWb2-00014E-D7 for qemu-devel@nongnu.org; Mon, 19 May 2014 19:03:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmWaw-0006gh-Ep for qemu-devel@nongnu.org; Mon, 19 May 2014 19:03:52 -0400 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:42194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmWaw-0006gC-9D for qemu-devel@nongnu.org; Mon, 19 May 2014 19:03:46 -0400 Received: by mail-wg0-f52.google.com with SMTP id l18so8626902wgh.35 for ; Mon, 19 May 2014 16:03:45 -0700 (PDT) From: Hani Benhabiles Date: Tue, 20 May 2014 00:03:18 +0100 Message-Id: <1400540600-1328-6-git-send-email-kroosec@gmail.com> In-Reply-To: <1400540600-1328-1-git-send-email-kroosec@gmail.com> References: <1400540600-1328-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH 5/7] readline: Make completion strings always unique. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, stefanha@redhat.com, imammedo@redhat.com There is no need to clutter the user's choices with repeating the same value multiple times. Signed-off-by: Hani Benhabiles --- util/readline.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/readline.c b/util/readline.c index 8baec55..7214e84 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); } } -- 1.8.3.2