This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 5/8] Allow defining a user command inside a user command
On 04/19/2018 08:15 PM, Tom Tromey wrote:
> build_command_line (enum command_control_type type, const char *args)
> {
> if ((args == NULL || *args == '\0')
> - && (type == if_control || type == while_control))
> - error (_("if/while commands require arguments."));
> + && (type == if_control || type == while_control
> + || type == define_control))
> + error (_("if/while/define commands require arguments."));
I'd vote for splitting those up:
if (args == NULL || *args == '\0')
{
switch (type)
{
case if_control:
error (_("if commands require arguments."));
case while_control:
error (_("while commands require arguments."));
case define_control:
error (_("define commands require arguments."));
}
}
> +/* Define a user-defined command. If COMMANDS is NULL, then this is
> + an interactive call and the commands will be read from the user.
Isn't this conflating top-level "define" command, with interactive
input? I imagine that a top-level "define" command in e.g., gdbinit will
considered "interactive call" according to the above, while in truth,
it's not really interactive, according to FROM_TTY.
> + Otherwise, it is a "define" command in a script and the commands
> + are provided.
Similarly, can't you write a "define" command inside a "define"
command interactively on the command line?
>In the non-interactive case, various prompts and
> + warnings are disabled. */
> +
> static void
> -define_command (const char *comname, int from_tty)
> +do_define_command (const char *comname, int from_tty,
> + const counted_command_line *commands)
> {
Thanks,
Pedro Alves