m4 include() broken?

From: Tim Kientzle <kientzle_at_freebsd.org>
Date: Tue, 28 Feb 2006 20:42:05 -0800
I'm still a little new to M4, so I may have gotten this wrong,
but it looks like the BSD M4 implementation bombs on include():

$ echo AAA > input
$ m4
define(`SYM',include(`input'))
m4: unexpected end of input, unclosed parenthesis:
    stdin at line 1

I tried this on MacOS 10.4.4 and it reports no errors (GNU M4 1.4.2).
On FreeBSD-CURRENT and 5.3, it bombs with the above error.
Tracing through main.c, it looks like the scanner is explicitly
forbidding include() as an argument to another macro by
requiring that any include() close all parens:

usr.bin/m4/main.c, around line 380:

   } else if (t == EOF) {
	if (sp > -1) {
		warnx( "unexpected end of input, unclosed parenthesis:");
		dump_stack(paren, PARLEV);
		exit(1);
	}
	if (ilevel <= 0)
		break;			/* all done thanks.. */

To verify this, note that the following does not generate an error:

$ echo 'AAA)' > input
$ m4
define(`SYM',include(`input')


SYM()
AAA


Can anyone who knows M4 better than me confirm that the current
handling of include() is wrong?

Tim
Received on Wed Mar 01 2006 - 03:42:09 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:52 UTC