Index | Thread | Search

From:
Marc Espie <marc.espie.openbsd@gmail.com>
Subject:
m4: better error messages for define/pushdef
To:
tech@openbsd.org
Date:
Mon, 9 Feb 2026 16:40:46 +0100

Download raw body.

Thread
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);
 }