From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66974 invoked by alias); 30 Jun 2017 13:02:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 66243 invoked by uid 89); 30 Jun 2017 13:02:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=exercises, pyt 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; Fri, 30 Jun 2017 13:02:03 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CECE83F3F; Fri, 30 Jun 2017 13:02:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4CECE83F3F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4CECE83F3F Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DBC760A98; Fri, 30 Jun 2017 13:01:51 +0000 (UTC) Subject: Re: [PATCH] PR cli/21688: Detect aliases when issuing python/compile/guile commands (and fix last commit) To: Sergio Durigan Junior , GDB Patches References: <2f8ebe75-29a9-71bb-008a-d4272441acac@redhat.com> <20170630123426.2124-1-sergiodj@redhat.com> Cc: Simon Marchi , Jerome Guitton From: Pedro Alves Message-ID: <68b70606-368f-63ba-b410-5d03865337df@redhat.com> Date: Fri, 30 Jun 2017 13:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170630123426.2124-1-sergiodj@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00823.txt.bz2 On 06/30/2017 01:34 PM, Sergio Durigan Junior wrote: > @@ -966,6 +952,8 @@ process_next_line (char *p, struct command_line **command, int parse_commands, > const char *cmd_name = p; > struct cmd_list_element *cmd > = lookup_cmd_1 (&cmd_name, cmdlist, NULL, 1); > + const char *lookup_cmd = skip_spaces_const (cmd_name); > + bool inline_cmd = *lookup_cmd != '\0'; The "lookup_cmd" in my suggestion: ~~~~~ lookup_cmd = skip_spaces_const (cmd_name); ~~~~~ was a typo/pasto from "lookup_cmd_1"... I meant: cmd_name = skip_spaces_const (cmd_name); Fine with me to use a new variable like you had, but it should have a name that actually means something related to the task at hand. "cmd_arg" or something. > /* Note that we ignore the inline "guile command" form here. */ > *command = build_command_line (guile_control, ""); > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index 06bf5a4..6160c4b 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,6 +1,12 @@ > 2017-06-30 Sergio Durigan Junior > > PR cli/21688 > + * gdb.python/py-cmd.exp (test_python_inline_or_multiline): Add new > + tests for alias commands and trailing whitespace. > + > +2017-06-30 Sergio Durigan Junior > + > + PR cli/21688 > * gdb.python/py-cmd.exp (test_python_inline_or_multiline): New > procedure. Call it. > > diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp > index 39bb785..287ecda 100644 > --- a/gdb/testsuite/gdb.python/py-cmd.exp > +++ b/gdb/testsuite/gdb.python/py-cmd.exp > @@ -194,12 +194,25 @@ proc test_python_inline_or_multiline { } { > { "end" " >$" "multi-line first end" } > { "end" "hello\r\n" "multi-line last end" } } > > + # This also tests trailing whitespace on the command. > + set define_cmd_alias_not_inline { > + { "if 1" " >$" "multi-line if 1 alias" } > + { "py " " >$" "multi-line python command alias" } > + { "print ('hello')" " >$" "multi-line print alias" } > + { "end" " >$" "multi-line first end alias" } > + { "end" "hello\r\n" "multi-line last end alias" } } > + > set define_cmd_inline { > { "if 1" " >$" "inline if 1" } > { "python print ('hello')" " >$" "inline python command" } > { "end" "hello\r\n" "inline end" } } > > - foreach t [list $define_cmd_not_inline $define_cmd_inline] { > + set define_cmd_alias_inline { > + { "if 1" " >$" "inline if 1 alias" } > + { "py print ('hello')" " >$" "inline python command alias" } > + { "end" "hello\r\n" "inline end alias" } } > + Any reason you didn't add a test for the "alias foo=python" case? We want to be sure that aliases that are not abbreviations are handled too. "py" is probably really implemented as a disambiguating alias, due to "python-interactive", but it could be an abbreviation too [py, pyt, pyth], etc. I think an explicit test for a non-abbreviation alias would be good, to be sure the code isn't just doing a "startswith"-like check. Otherwise, I'm going to ask for a test that exercises abbreviations, like for example "compil", but you don't want that. :-) Thanks, Pedro Alves