This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] PR cli/21688: Fix multi-line/inline command differentiation
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>, Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Jerome Guitton <guitton at adacore dot com>
- Date: Fri, 30 Jun 2017 12:14:00 +0100
- Subject: Re: [PATCH] PR cli/21688: Fix multi-line/inline command differentiation
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7A77F61B90
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A77F61B90
- References: <20170629020527.468-1-sergiodj@redhat.com> <90d0a1563dea6893b5dbcd8df19d0285@polymtl.ca> <87d19mmv7q.fsf@redhat.com> <e59e76927e4c52e0c0e2685bc659dfaf@polymtl.ca> <87fueil9jx.fsf@redhat.com>
On 06/29/2017 11:21 PM, Sergio Durigan Junior wrote:
> +/* Return true if NAME is the only command between COMMAND_START and
> + COMMAND_END. This is useful when we want to know whether the
> + command is inline (i.e., has arguments like 'python command1') or
> + is the start of a multi-line command block. */
> +
> +static bool
> +command_name_equals_not_inline (const char *command_start,
> + const char *command_end,
> + const char *name)
> +{
> + return (command_end - command_start == strlen (name)
> + && startswith (command_start, name));
> +}
...
> - else if (command_name_equals (cmd, "python"))
> + else if (command_name_equals_not_inline (p_start, p_end, "python"))
> {
Does this handle command aliases? It doesn't look like it.
> + set define_cmd_inline {
> + { "if 1" " >$" "inline if 1" }
> + { "python print ('hello')" " >$" "inline python command" }
For example, what if you write instead:
{ "py print ('hello')" " >$" "inline python command" }
and/or you do:
(gdb) alias foo=python
and then:
{ "foo print ('hello')" " >$" "inline python command" }
Thanks,
Pedro Alves