Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1M0bkC-0006x4-48 for mharc-grub-devel@gnu.org; Sun, 03 May 2009 09:28:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M0bk9-0006wU-7u for grub-devel@gnu.org; Sun, 03 May 2009 09:28:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M0bk3-0006wD-Kv for grub-devel@gnu.org; Sun, 03 May 2009 09:28:31 -0400 Received: from [199.232.76.173] (port=35108 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M0bk3-0006wA-F8 for grub-devel@gnu.org; Sun, 03 May 2009 09:28:27 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]:39548) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M0bk2-0004OG-RY for grub-devel@gnu.org; Sun, 03 May 2009 09:28:27 -0400 Received: by ewy6 with SMTP id 6so3408761ewy.42 for ; Sun, 03 May 2009 06:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=xt/cZiSZ4aXMhHKSoLCqj3OzUNBDg0dBLmMGB5WOPOM=; b=MTT214SXuAXS1+XZ9SE+sKPhRSkzT7sUwDtyCePPUzHhjPIUFEleIijKMzH78ek2Yu 1qKsrMIJAVlkDGVONrCn/yTp29+KY3ffN/PGoUCWxKSTjDXv6lhWZz47WNI25YTPrwW9 qpg6a55unrRJZ3ukRmh92ry6XN7MmPkzg5/5o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=OXlhvmrMZxU3uMRYTt8oyrDhLfGk74OkYk9X8GtvWiZAKGJF/fH18vKUKyYgDYzcr6 ryFjgTItHyDY58s1+o7iF+Ta5k3NS3zptG+sQcz33ZBqsS6LcHfnBAkraXKqQo6U+nh+ dktgjEUgV4xdaeesaUb+oD+/zWT1tMviPjV90= MIME-Version: 1.0 Received: by 10.211.177.12 with SMTP id e12mr1191142ebp.8.1241357305920; Sun, 03 May 2009 06:28:25 -0700 (PDT) In-Reply-To: References: Date: Sun, 3 May 2009 15:28:25 +0200 Message-ID: From: "Vladimir 'phcoder' Serbinenko" To: The development of GRUB 2 Content-Type: multipart/mixed; boundary=0015174c3ef0423d9204690205bc X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [BUGFIX] lexer waits for space to terminate the varname X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2009 13:28:33 -0000 --0015174c3ef0423d9204690205bc Content-Type: multipart/alternative; boundary=0015174c3ef0423d8504690205ba --0015174c3ef0423d8504690205ba Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Sun, May 3, 2009 at 2:52 PM, Bean wrote: > On Sun, May 3, 2009 at 8:39 PM, Vladimir 'phcoder' Serbinenko > wrote: > > > > > > On Sun, May 3, 2009 at 2:37 PM, Bean wrote: > >> > >> Hi, > >> > >> On Sun, May 3, 2009 at 5:12 PM, Vladimir 'phcoder' Serbinenko > >> wrote: > >> > Hello > >> > > >> > On Sat, May 2, 2009 at 4:08 PM, Bean wrote: > >> >> > >> >> Hi, > >> >> > >> >> I think there is problem with this patch. Consider ${aa}, the closing > >> >> character "}" would be left out. > >> >> > >> >> Although you can remedy this by swapping: > >> >> > >> >> { GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, ' ', 1}, > >> >> { GRUB_PARSER_STATE_VARNAME2, GRUB_PARSER_STATE_TEXT, '}', 0}, > >> > > >> > It's not the same starting state. However similar issue exists with ' > ' > >> > and > >> > '\"' > >> > >> Oh right, I copy the wrong sample. > >> > >> >> > >> >> so that '}' would be handled before ' ', but it's still not a good > >> >> practice, as you have added a logic in code that would depend on the > >> >> order of state_transitions, which is not apparent for casual code > >> >> viewer. > >> > > >> > Perhaps we should switch to just ordering the transition rules instead > >> > of > >> > separate code for default value > >> >> > >> >> Also, ' ' might be used for other transition in the future, > >> >> this code could break that. I suggest you use {} to enclose the > >> >> variable that doesn't terminated with space, > >> > > >> > It can be a workaround but the bug is still here. The following > pieces > >> > of > >> > code fail: > >> > 1) echo $hello; > >> > 2) echo $hello > >> > > >> > >> Yeah, and there are other varieties as well, such as -. Perhaps it'd > >> be simpler to use your fix for now, but you should add some comment in > >> the source code to indicate its purpose. > > > > What about making it rely on order of rules? It should make it more > compact > > Hi, > > I'm sorry I don't quite follow, could you give an example ? > Something like this. Compile tested only > > -- > Bean > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > -- Regards Vladimir 'phcoder' Serbinenko --0015174c3ef0423d8504690205ba Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Sun, May 3, 2009 at 2:52 PM, Bean <bean123ch@gmail.com> wrote:
On Sun, May 3, 2009 at 8:39 PM, Vladimir 'phcoder' Serbinenko
<= phcoder@gmail.com> wrote:
>
>
> On Sun, May 3, 2009 at 2:37 PM, Bean <bean123ch@gmail.com> wrote:
>>
>> Hi,
>>
>> On Sun, May 3, 2009 at 5:12 PM, Vladimir 'phcoder' Serbine= nko
>> <phcoder@gmail.com>= wrote:
>> > Hello
>> >
>> > On Sat, May 2, 2009 at 4:08 PM, Bean <bean123ch@gmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >> I think there is problem with this patch. Consider ${aa},= the closing
>> >> character "}" would be left out.
>> >>
>> >> Although you can remedy this by swapping:
>> >>
>> >> =A0{ GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, &= #39; ', 1},
>> >> =A0{ GRUB_PARSER_STATE_VARNAME2, GRUB_PARSER_STATE_TEXT, = '}', 0},
>> >
>> > It's not the same starting state. However similar issue e= xists with ' '
>> > and
>> > '\"'
>>
>> Oh right, I copy the wrong sample.
>>
>> >>
>> >> so that '}' would be handled before ' ', = but it's still not a good
>> >> practice, as you have added a logic in code that would de= pend on the
>> >> order of state_transitions, which is not apparent for cas= ual code
>> >> viewer.
>> >
>> > Perhaps we should switch to just ordering the transition rule= s instead
>> > of
>> > separate code for default value
>> >>
>> >> Also, ' ' might be used for other transition in t= he future,
>> >> this code could break that. I suggest you use {} to enclo= se the
>> >> variable that doesn't terminated with space,
>> >
>> > It can be a workaround=A0 but the bug is still here. The foll= owing pieces
>> > of
>> > code fail:
>> > 1) echo $hello;
>> > 2) echo $hello
>> >
>>
>> Yeah, and there are other varieties as well, such as -. Perhaps it= 'd
>> be simpler to use your fix for now, but you should add some commen= t in
>> the source code to indicate its purpose.
>
> What about making it rely on order of rules? It should make it more co= mpact

Hi,

I'm sorry I don't quite follow, could you give an example ?
Something like this. Compi= le tested only
=A0

--
Bean


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel



--
Regards
= Vladimir 'phcoder' Serbinenko
--0015174c3ef0423d8504690205ba-- --0015174c3ef0423d9204690205bc Content-Type: text/x-diff; charset=US-ASCII; name="lex_bugfix.diff" Content-Disposition: attachment; filename="lex_bugfix.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fu9s2d330 ZGlmZiAtLWdpdCBhL2tlcm4vcGFyc2VyLmMgYi9rZXJuL3BhcnNlci5jCmluZGV4IDY4NWFiMjIu LmVlNmIxNjkgMTAwNjQ0Ci0tLSBhL2tlcm4vcGFyc2VyLmMKKysrIGIva2Vybi9wYXJzZXIuYwpA QCAtNDcsOCArNDcsOCBAQCBzdGF0aWMgc3RydWN0IGdydWJfcGFyc2VyX3N0YXRlX3RyYW5zaXRp b24gc3RhdGVfdHJhbnNpdGlvbnNbXSA9CiAKIC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