diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2001-09-16 21:12:09 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2001-09-16 21:12:09 +0000 |
commit | c4806cc6f1a53f8a85f381d1afdd1db58426dba9 (patch) | |
tree | 2d1267a441156fe8825dfa94c6d579df44ba3ace /usr.bin | |
parent | c7800dbef245d85c1123d83f7fb335cbed026d0c (diff) |
special-case MACRO (without parens) recognition, so that $# is set to 0
as it should.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/m4/main.c | 24 |
1 files changed, 17 insertions, 7 deletions
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); |