From patchwork Sat Jan 4 18:34:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37184 Received: (qmail 872 invoked by alias); 4 Jan 2020 18:34:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 379 invoked by uid 89); 4 Jan 2020 18:34:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.192.34) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Jan 2020 18:34:17 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id D00C92C414 for ; Sat, 4 Jan 2020 12:34:15 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id noFbiCiLx3Qi0noFbi0tiN; Sat, 04 Jan 2020 12:34:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2nQIGBQSpRYlexrPPmghAKI2fJwkAK3b6VXgSDYLp3c=; b=NylgrXRFvm75C8G5yME0x3cqhN RAL2i8nbEayOhGvSuptxW654S7CAOgZ3JuEIlTsyzxxV4bN7y+0ivwB5vkvisaGwxHI0yFEW7l2TY SGEZ2JmHbbaPycoichCz+MEPp; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:48942 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1inoFb-0026Lh-MR; Sat, 04 Jan 2020 11:34:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 14/24] Handle ambiguity in tui_partial_win_by_name Date: Sat, 4 Jan 2020 11:34:00 -0700 Message-Id: <20200104183410.17114-15-tom@tromey.com> In-Reply-To: <20200104183410.17114-1-tom@tromey.com> References: <20200104183410.17114-1-tom@tromey.com> This changes tui_partial_win_by_name to correctly handle an ambiguous name prefix. This will be important once the user can register new window types. 2020-01-04 Tom Tromey * tui/tui-win.c (tui_partial_win_by_name): Handle ambiguity correctly. Change-Id: I59aaacd697eeab649164183457ef722dae58d60d --- gdb/ChangeLog | 5 +++++ gdb/tui/tui-win.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 8206f3e6965..6eab125d731 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -694,18 +694,27 @@ tui_scroll_right_command (const char *arg, int from_tty) static struct tui_win_info * tui_partial_win_by_name (gdb::string_view name) { + struct tui_win_info *best = nullptr; + if (name != NULL) { for (tui_win_info *item : all_tui_windows ()) { const char *cur_name = item->name (); - if (startswith (cur_name, name)) + if (name == cur_name) return item; + if (startswith (cur_name, name)) + { + if (best != nullptr) + error (_("Window name \"%*s\" is ambiguous"), + (int) name.size (), name.data ()); + best = item; + } } } - return NULL; + return best; } /* Set focus to the window named by 'arg'. */