From patchwork Thu May 30 19:53:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32927 Received: (qmail 123982 invoked by alias); 30 May 2019 19:53:38 -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 123968 invoked by uid 89); 30 May 2019 19:53:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1718 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 May 2019 19:53:37 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D73183F44 for ; Thu, 30 May 2019 19:53:36 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C6287ADD0 for ; Thu, 30 May 2019 19:53:35 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 01/24] Fix latent bug in custom word point completion handling Date: Thu, 30 May 2019 20:53:10 +0100 Message-Id: <20190530195333.20448-2-palves@redhat.com> In-Reply-To: <20190530195333.20448-1-palves@redhat.com> References: <20190530195333.20448-1-palves@redhat.com> Without this fix, if we switch the "print" completer to custom word point handling, we regress gdb.base/completion.exp like this: (gdb) p "break1.c FAIL: gdb.base/completion.exp: complete 'p "break1' (timeout) The problem is that completing an expression that starts with double quotes, and resolves to a filename, like this: (gdb) p "break1[TAB] would change from this, with current master: (gdb) p "break1.c"| ^^^^^^^^^^| \- cursor here to this: (gdb) p "break1.c | ^^^^^^^^^^| \- quote replaced by space The issue is that completer.c:advance_to_completion_word misses telling the completion tracker to emulate readline's handling of completing a string when rl_find_completion_word returns a delimiter. This commit fixes the latent bug. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * completer.c (advance_to_completion_word): Handle delimiters. --- gdb/completer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/completer.c b/gdb/completer.c index 24c84466307..d652cb8a24f 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -365,11 +365,18 @@ advance_to_expression_complete_word_point (completion_tracker &tracker, info.quote_characters = gdb_completer_quote_characters; info.basic_quote_characters = rl_basic_quote_characters; + int delimiter; const char *start - = gdb_rl_find_completion_word (&info, NULL, NULL, text); + = gdb_rl_find_completion_word (&info, NULL, &delimiter, text); tracker.advance_custom_word_point_by (start - text); + if (delimiter) + { + tracker.set_quote_char (delimiter); + tracker.set_suppress_append_ws (true); + } + return start; }