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: Fix python indented multi-line commands


> 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.


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