m4 include() broken?
Tim Kientzle
kientzle at freebsd.org
Tue Feb 28 20:42:09 PST 2006
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
More information about the freebsd-current
mailing list