From patchwork Mon May 5 18:02:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 345816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DB734140300 for ; Tue, 6 May 2014 04:22:37 +1000 (EST) Received: from localhost ([::1]:58991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhNX9-0006nr-Qw for incoming@patchwork.ozlabs.org; Mon, 05 May 2014 14:22:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhNV5-0003S1-Tx for qemu-devel@nongnu.org; Mon, 05 May 2014 14:20:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhNV0-0006ow-5y for qemu-devel@nongnu.org; Mon, 05 May 2014 14:20:27 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:46422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhNUz-0006oR-To; Mon, 05 May 2014 14:20:22 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 8A84840752; Mon, 5 May 2014 22:20:20 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 927876B7; Mon, 5 May 2014 22:02:08 +0400 (MSK) Received: (nullmailer pid 24258 invoked by uid 1000); Mon, 05 May 2014 18:02:06 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 5 May 2014 22:02:01 +0400 Message-Id: <1399312923-24129-21-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399312923-24129-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1399312923-24129-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Hani Benhabiles , Michael Tokarev , Hani Benhabiles Subject: [Qemu-devel] [PULL 20/22] readline: Sort completions before printing them. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hani Benhabiles Signed-off-by: Hani Benhabiles Signed-off-by: Michael Tokarev --- util/readline.c | 7 +++++++ 1 file changed, 7 insertions(+) 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;