qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/7] readline: Make completion strings always unique


From: Hani Benhabiles
Subject: [Qemu-devel] [PATCH 5/7] readline: Make completion strings always unique.
Date: Tue, 20 May 2014 00:03:18 +0100

There is no need to clutter the user's choices with repeating the same value
multiple times.

Signed-off-by: Hani Benhabiles <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]