This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Fix python indented multi-line commands
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Wed, 13 Aug 2008 21:21:26 +0300
- Subject: Re: Fix python indented multi-line commands
- References: <g7tvk3$lck$1@ger.gmane.org>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: Thiago Jung Bauermann <bauerman@br.ibm.com>
> Date: Wed, 13 Aug 2008 03:40:03 -0300
>
> Today, if you try to use indentation in Python code within GDB you will
> get this error:
>
> (gdb) python
> >def foo ():
> > print 'hooray'
> >end
> File "<string>", line 2
> print 'hooray'
> ^
> IndentationError: expected an indented block
>
> The patch below, extracted from the python branch, fixes the problem.
Thanks!
> /* Read one line from the input stream. If the command is an "else" or
> - "end", return such an indication to the caller. */
> + "end", return such an indication to the caller. If SPECIAL_PROCESSING
> + is true, strip leading and trailing whitespace in the line and attempt
> + to recognize GDB control commands. Otherwise, only "end" is
> + recognized. */
>
> static enum misc_command_type
> -read_next_line (struct command_line **command)
> +read_next_line (struct command_line **command, int special_processing)
Please don't call variables by mysterious names such as
"special_processing". Please give that variable a meaningful name
that would explain the purpose of this flag even without reading the
code of the callers of this function.