From 6ea22d950fd7246c9159a3601819ae23d03e8dcd Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 20 May 2020 12:22:30 -0700 Subject: fix: truncate infinite recursion caused by self referential macros --- sys/cmd/cc/lex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/cmd/cc/lex.c') diff --git a/sys/cmd/cc/lex.c b/sys/cmd/cc/lex.c index 8ce4e79..4cc1259 100644 --- a/sys/cmd/cc/lex.c +++ b/sys/cmd/cc/lex.c @@ -635,8 +635,8 @@ Dispatch: } sym = lookup(&lx->sym, tok.val.s); - if (sym) { - io = makeio(); + if (sym && ((uintptr)sym->name != (uintptr)lx->io->path)) { + io = makeio(sym->name); printf("EXPANDING MACRO %s\n", sym->name); io->buf.end += expandmacro(lx, sym, io->b); *io->buf.end++ = EOF; -- cgit v1.2.1