From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18774 invoked by alias); 17 Oct 2014 08:28:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 18757 invoked by uid 89); 17 Oct 2014 08:28:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 17 Oct 2014 08:28:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9H8S7Z9014111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Oct 2014 04:28:07 -0400 Received: from localhost.localdomain (ovpn-112-31.ams2.redhat.com [10.36.112.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9H8S5g1030824; Fri, 17 Oct 2014 04:28:06 -0400 Message-ID: <5440D315.5030200@redhat.com> Date: Fri, 17 Oct 2014 08:28:00 -0000 From: Phil Muldoon MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: Substitute '\' with '\\' in extended-prompt References: <87tx33l4l6.fsf@codesourcery.com> In-Reply-To: <87tx33l4l6.fsf@codesourcery.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00457.txt.bz2 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 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