diff options
| author | Hani Benhabiles | 2014-05-28 00:39:35 +0200 |
|---|---|---|
| committer | Luiz Capitulino | 2014-06-11 16:10:29 +0200 |
| commit | e70871d8b5c92e40cedd6fd0b7687c4f0b6ce3ff (patch) | |
| tree | 7aad8d67e7af09d10ca54f1f08a3f47044e99eff | |
| parent | monitor: Add host_net_add device argument completion (diff) | |
| download | qemu-e70871d8b5c92e40cedd6fd0b7687c4f0b6ce3ff.tar.gz qemu-e70871d8b5c92e40cedd6fd0b7687c4f0b6ce3ff.tar.xz qemu-e70871d8b5c92e40cedd6fd0b7687c4f0b6ce3ff.zip | |
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 <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
| -rw-r--r-- | util/readline.c | 6 |
1 files changed, 6 insertions, 0 deletions
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); } } |
