aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-05-01 15:26:42 +0100
committerMichael Tokarev <mjt@tls.msk.ru>2014-05-07 21:00:44 +0400
commit307b2f01488ae0fab18a8f0538e7c750842e74dd (patch)
treefee40bf3691c896856f38e9c6e775c4cb549de5b /util
parent6ad7c326a1b62a71a83b46de79b8d8391bb768ff (diff)
downloadqemu-307b2f01488ae0fab18a8f0538e7c750842e74dd.zip
qemu-307b2f01488ae0fab18a8f0538e7c750842e74dd.tar.gz
qemu-307b2f01488ae0fab18a8f0538e7c750842e74dd.tar.bz2
readline: Sort completions before printing them.
Signed-off-by: Hani Benhabiles <hani@linux.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'util')
-rw-r--r--util/readline.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/readline.c b/util/readline.c
index a3fd2cb..8baec55 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -272,6 +272,11 @@ void readline_set_completion_index(ReadLineState *rs, int index)
rs->completion_index = index;
}
+static int completion_comp(const void *a, const void *b)
+{
+ return strcmp(*(const char **) a, *(const char **) b);
+}
+
static void readline_completion(ReadLineState *rs)
{
int len, i, j, max_width, nb_cols, max_prefix;
@@ -295,6 +300,8 @@ static void readline_completion(ReadLineState *rs)
if (len > 0 && rs->completions[0][len - 1] != '/')
readline_insert_char(rs, ' ');
} else {
+ qsort(rs->completions, rs->nb_completions, sizeof(char *),
+ completion_comp);
rs->printf_func(rs->opaque, "\n");
max_width = 0;
max_prefix = 0;