Re: more m4p bugs
Nikolaos Chatzikonstantinou <[email protected]> Mon, 19 May 2025 14:05:28 -0400
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <CAAQmekcbTU=aYgBzHOECV4zA-Z8CrU7enX1UsrFbGuHREEhO+A@mail.gmail.com> |
--000000000000c23603063580faa6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 19, 2025, 1:27=E2=80=AFPM Eric Blake <[email protected]> wrote: > On Mon, May 19, 2025 at 10:46:10AM -0500, Eric Blake wrote: > > On Fri, May 16, 2025 at 08:16:24AM -0500, Eric Blake wrote: > > > Since you continue to patch things as fast as I report them (now > > > testing with commit a4cc0f3c): > > > > Now testing with b686ed, you have a problem with redefining a macro as > > empty if it has been undefined in the meantime: > > > > $ echo 'changequote([,])define(a)undefine([a])define(a)' | m4p > > Traceback (most recent call last): > > File "/home/eblake/m4p/.venv/bin/m4p", line 8, in <module> > > sys.exit(main()) > > ~~~~^^ > > ... > > File "/home/eblake/m4p/m4p/parser.py", line 279, in add_define > > self.macros[ident][-1] =3D defn > > ~~~~~~~~~~~~~~~~~~^^^^ > > IndexError: list assignment index out of range > > This appears to fix it for me: > > diff --git i/m4p/parser.py w/m4p/parser.py > index 4793c8a..83c69df 100644 > --- i/m4p/parser.py > +++ w/m4p/parser.py > @@ -272,7 +272,7 @@ class Parser: > > def add_define(self, ident: bytes, defn: bytes | Builtin): > """Equivalent to m4_define(ident, defn).""" > - if self.macros.get(ident) is None: > + if not self.macros.get(ident, []): > self.macros[ident] =3D [defn] > else: > # GNU ext define: replace top. Others: replace all with 1. > That looks good, I hoped something of the sort would have fixed it. I can commit it when I'm back home. Regards, Nikolaos Chatzikonstantinou > --000000000000c23603063580faa6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div><br><br><div class=3D"gmail_quote gmail_quote_contai= ner"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, May 19, 2025, 1:27=E2=80= =AFPM Eric Blake <<a href=3D"mailto:[email protected]">[email protected]= </a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:= 0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, May 19, 202= 5 at 10:46:10AM -0500, Eric Blake wrote:<br> > On Fri, May 16, 2025 at 08:16:24AM -0500, Eric Blake wrote:<br> > > Since you continue to patch things as fast as I report them (now<= br> > > testing with commit a4cc0f3c):<br> > <br> > Now testing with b686ed, you have a problem with redefining a macro as= <br> > empty if it has been undefined in the meantime:<br> > <br> > $ echo 'changequote([,])define(a)undefine([a])define(a)' | m4p= <br> > Traceback (most recent call last):<br> >=C2=A0 =C2=A0File "/home/eblake/m4p/.venv/bin/m4p", line 8, i= n <module><br> >=C2=A0 =C2=A0 =C2=A0sys.exit(main())<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ~~~~^^<br> > ...<br> >=C2=A0 =C2=A0File "/home/eblake/m4p/m4p/parser.py", line 279,= in add_define<br> >=C2=A0 =C2=A0 =C2=A0self.macros[ident][-1] =3D defn<br> >=C2=A0 =C2=A0 =C2=A0~~~~~~~~~~~~~~~~~~^^^^<br> > IndexError: list assignment index out of range<br> <br> This appears to fix it for me:<br> <br> diff --git i/m4p/parser.py w/m4p/parser.py<br> index 4793c8a..83c69df 100644<br> --- i/m4p/parser.py<br> +++ w/m4p/parser.py<br> @@ -272,7 +272,7 @@ class Parser:<br> <br> =C2=A0 =C2=A0 =C2=A0def add_define(self, ident: bytes, defn: bytes | Builti= n):<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"""Equivalent to m4_define= (ident, defn)."""<br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if self.macros.get(ident) is None:<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if not self.macros.get(ident, []):<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.macros[ident] =3D [def= n]<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# GNU ext define: replace t= op. Others: replace all with 1.<br></blockquote></div></div><div dir=3D"aut= o"><br></div><div dir=3D"auto">That looks good, I hoped something of the so= rt would have fixed it. I can commit it when I'm back home.</div><div d= ir=3D"auto"><br></div><div dir=3D"auto">Regards,</div><div dir=3D"auto">Nik= olaos Chatzikonstantinou=C2=A0</div><div dir=3D"auto"><div class=3D"gmail_q= uote gmail_quote_container"><blockquote class=3D"gmail_quote" style=3D"marg= in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote></div></div></div> --000000000000c23603063580faa6--