On Sat, May 17, 2025 at 01:03:21PM -0400, Nikolaos Chatzikonstantinou wrote:
> On Sat, May 17, 2025 at 12:07 PM Nikolaos Chatzikonstantinou
> <nchatz...@gmail.com> wrote:
> >
> > On Fri, May 16, 2025 at 11:28 AM Eric Blake <ebl...@redhat.com> wrote:
> > > ...
> > I fixed all the bugs that you've mentioned.
> 
> I should say, except the diversion issue and the arithmetic. I will
> work on these too soon.

Here's another one (tested with 13f9957):

* m4 gives comments higher precedence than macros (ie. if there is an
  ambiguity between a macro and a comment, then the comment wins).
  But this true even when changecom happens in the middle of parsing a
  macro's arguments (and alas, this means that you CAN'T reliably peek
  ahead to see where a macro's closing ) is, because actions taken by
  argument collection may change syntax on the fly and thus change
  where the closing ) comes from).
$ m4
define(a, b changecom(`((', `))') (( ) ) )
)) c)

a
b  (( ) ) )
)) c
$ m4p
define(a, b changecom(`((', `))') (( ) ) )
)) c)
Traceback (most recent call last):
  File "/home/eblake/m4p/.venv/bin/m4p", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/eblake/m4p/m4p/main.py", line 40, in main
    _main()
    ~~~~~^^
  File "/home/eblake/m4p/m4p/main.py", line 161, in _main
    parser.parse()
    ~~~~~~~~~~~~^^
  File "/home/eblake/m4p/m4p/parser.py", line 573, in parse
    self.call_builtin(
    ~~~~~~~~~~~~~~~~~^
        pathname, line, macro, [word] + args, self.traced_macros[word]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/eblake/m4p/m4p/parser.py", line 643, in call_builtin
    result = self.call_builtin_aux(pathname, line, macro, args)
  File "/home/eblake/m4p/m4p/parser.py", line 653, in call_builtin_aux
    return self.m4_define(pathname, line, args)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eblake/m4p/m4p/parser.py", line 755, in m4_define
    self.add_define(ident, defn)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/eblake/m4p/m4p/parser.py", line 272, in add_define
    self.macros[ident][-1] = defn
    ~~~~~~~~~~~~~~~~~~^^^^
IndexError: list assignment index out of range

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply via email to