On Mon, May 12, 2025 at 09:54:54AM -0500, Nikolaos Chatzikonstantinou wrote:
> > $ echo 'eval(1 || (1/0))' | m4-1.4.20
> > 1
> > $ echo 'eval(1 || (1/0))' | m4p
> > m4:stdin:1: divide by zero in eval: 1 || (1/0)
> > 1
> >
> 
> I have a file where I noted some of these here:
> https://codeberg.org/annoyingusername/m4p/src/branch/main/tests/resources/eval_bugs.txt

Useful.  The '1 || (0 / 0)' bug was indeed fixed in 1.4.20.  '1 || 2
&= 3' still complains about invalid operator, but that's intentional:
&= is not a supported operator.  But the complaint about '1 || (2 &=
3)') complaining about a missing right parenthesis (instead of a bad
operator) is something I hadn't noticed before today, and something still
present in 1.4.20.  The parser is correctly detecting that the
expression is not valid at the point it hits the invalid operator; but
perhaps the error message could be improved (by stating that it
expects ')' instead of '&=', for example).

Writing a parser that handles only good expressions is easy.  Writing
a parser that provides sane error messages with useful suggestions
when the parse fails is hard.  Yours may be the first (indirect) bug
report against 1.4.20!

> PS. I'm tracking feature progress here,
> https://codeberg.org/annoyingusername/m4p/wiki/Features and I will note
> some of the things you mentioned when I get back home.

Another one that is hopefully easy:

$ printf 'divert(2)2\ndivert(1)1\n' | m4
1
2
$ printf 'divert(2)2\ndivert(1)1\n' | m4p
$

Non-negative diversions are not being dumped automatically at end of input.

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


Reply via email to