From c4806cc6f1a53f8a85f381d1afdd1db58426dba9 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sun, 16 Sep 2001 21:12:09 +0000 Subject: special-case MACRO (without parens) recognition, so that $# is set to 0 as it should. --- usr.bin/m4/main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 6f3ee902b90..c0687e9c5f7 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.40 2001/07/28 05:36:18 pvalchev Exp $ */ +/* $OpenBSD: main.c,v 1.41 2001/09/16 21:12:08 espie Exp $ */ /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.40 2001/07/28 05:36:18 pvalchev Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.41 2001/09/16 21:12:08 espie Exp $"; #endif #endif /* not lint */ @@ -328,13 +328,23 @@ macro() pushs1(p->name); /* macro name */ pushs(ep); /* start next..*/ - if (l != LPAREN) { /* add bracks */ - putback(RPAREN); - putback(LPAREN); + if (l != LPAREN && PARLEV == 0) { + /* no bracks */ + chrsave(EOS); + + if (sp == STACKMAX) + errx(1, "internal stack overflow"); + if (CALTYP == MACRTYPE) + expand((const char **) mstack+fp+1, 2); + else + eval((const char **) mstack+fp+1, 2, CALTYP); + + ep = PREVEP; /* flush strspace */ + sp = PREVSP; /* previous sp.. */ + fp = PREVFP; /* rewind stack...*/ } } - } - else if (t == EOF) { + } else if (t == EOF) { if (sp > -1) { warnx( "unexpected end of input, unclosed parenthesis:"); dump_stack(paren, PARLEV); -- cgit v1.2.3