Download raw body.
m4: better error messages for define/pushdef
On Mon, Feb 09, 2026 at 04:40:46PM +0100, Marc Espie wrote:
> Over the years, these lines have changed a bit, but the error message
> is still misleading
>
> "null definition" would refer to what you put in the macro (IMO) whereas
> in actuality, it's the macro NAME that's empty.
>
> Using two slightly different error messages will grow the executable slightly
> but it's still the right thing to do ?
>
> Index: eval.c
> ===================================================================
> RCS file: /vide/cvs/src/usr.bin/m4/eval.c,v
> diff -u -p -r1.79 eval.c
> --- eval.c 26 Dec 2022 19:16:01 -0000 1.79
> +++ eval.c 9 Feb 2026 15:35:15 -0000
> @@ -606,7 +606,7 @@ void
> dodefine(const char *name, const char *defn)
> {
> if (!*name && !mimic_gnu)
> - m4errx(1, "null definition.");
> + m4errx(1, "attempting to define macro with empty name.");
> else
> macro_define(name, defn);
> }
> @@ -643,7 +643,7 @@ static void
> dopushdef(const char *name, const char *defn)
> {
> if (!*name && !mimic_gnu)
> - m4errx(1, "null definition.");
> + m4errx(1, "attempting to pushdef macro with empty name.");
> else
> macro_pushdef(name, defn);
> }
I was feeling whimsical, so I went all the way into NetBSD's tree, those
obscure error messages have been with us since at least 4.4-lite.
I have a suspicion the code was in serv.c in 386bsd-0.1, but somehow I
can't seem to find a valid copy of serv.c anywhere.
m4: better error messages for define/pushdef