From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su75Y-0000PP-LL for qemu-devel@nongnu.org; Wed, 25 Jul 2012 15:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su75X-0002Za-M3 for qemu-devel@nongnu.org; Wed, 25 Jul 2012 15:17:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su75X-0002ZW-E1 for qemu-devel@nongnu.org; Wed, 25 Jul 2012 15:17:39 -0400 Date: Wed, 25 Jul 2012 16:18:13 -0300 From: Luiz Capitulino Message-ID: <20120725161813.538012f0@doriath.home> In-Reply-To: References: <1343235256-26310-1-git-send-email-lcapitulino@redhat.com> <1343235256-26310-8-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: mdroth@linux.vnet.ibm.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, armbru@redhat.com On Wed, 25 Jul 2012 18:45:21 +0100 Peter Maydell wrote: > On 25 July 2012 17:54, Luiz Capitulino wrote: > > (Subject should be "to be", not "be".) > > > A future commit will add a new qapi script which escapes that character. > > > > Signed-off-by: Luiz Capitulino > > --- > > scripts/qapi.py | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/scripts/qapi.py b/scripts/qapi.py > > index e062336..9aa518f 100644 > > --- a/scripts/qapi.py > > +++ b/scripts/qapi.py > > @@ -21,7 +21,9 @@ def tokenize(data): > > elif data[0] == "'": > > data = data[1:] > > string = '' > > - while data[0] != "'": > > + while True: > > + if data[0] == "'" and string[len(string)-1] != "\\": > > + break > > string += data[0] > > data = data[1:] > > data = data[1:] > > Won't this cause us to look at string[-1] if > the input data has two ' characters in a row? Non escaped? If you meant '' that's a zero length string and should work, but if you meant 'foo '' bar' that's illegal, because ' characters should be escaped. I don't doubt bad things will happen in that case, but in general we don't do much error detection in the qapi scripts and improving that is beyond this series' scope. > (also, maybe infinite loop if the input string has an > unterminated ' ?) Yes, that's how I found out I needed this patch :) PS: Peter, I get claustrophobic when reading emails from you :) PPS: I'm joking, don't get me wrong! :)