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: Substitute '\' with '\\' in extended-prompt


On 17/10/14 05:09, Yao Qi wrote:
>
> Hi Phil,
> Why do we do the substitute in extended-prompt in your extended-prompt
> patch <https://sourceware.org/ml/gdb-patches/2011-08/msg00236.html> as
> below?
>
>> +    def before_prompt_hook(self, current):
>> +        if self.value is not '':
>> +            newprompt = gdb.prompt.substitute_prompt(self.value)
>> +            return newprompt.replace('\\', '\\\\')
>                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> +        else:
>> +            return None
>
> I don't see any explanations on this in comments or email.

The lacks of a comment really bothers me!  The short answer is I can't
remember why this is needed.  I think it likely that if "\\" is passed
to readline it is parsed out.

See from the documentation:

+@item @var{\\}
+Substitute a backslash.

So the additional escape sequences are needed (for readline) after the
prompt command substitution.  I think if memory serves, to escape an
escape character, you need the four "\"'s but in the prompt command
language we only specify two.

However I have not looked at it in detail yet, but that is my first
guess. If you remove it, do the Python prompt tests fail?  I'll do
some archaeology and try to find out why today.  However, if it is
blocking your work, and without the substitution all the tests still
pass, then I would suggest we remove it for now.  We can always add it
back, and the next release of GDB is not terribly soon.

Cheers

Phil





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