This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR cli/21688: Fix multi-line/inline command differentiation


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]