From 707d81158628cddd1fc192a78032ef62e8e4f2c5 Mon Sep 17 00:00:00 2001 From: eck Date: Thu, 13 Sep 1990 15:14:52 +0000 Subject: [PATCH] fixed error with # && ##-operators in non function-like macro's --- lang/cem/cpp.ansi/replace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 7585d266b..de9b44c0e 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -536,6 +536,7 @@ macro2buffer(repl, idf, args) */ register char *ptr = idf->id_macro->mc_text; int err = 0; + int func = idf->id_macro->mc_nps != -1; char *stringify(); assert(ptr[idf->id_macro->mc_length] == '\0'); @@ -554,7 +555,7 @@ macro2buffer(repl, idf, args) ptr++; } while (*ptr != delim || *ptr == '\0'); add2repl(repl, *ptr++); - } else if (*ptr == '#') { + } else if (func && *ptr == '#') { if (*++ptr == '#') { register int tmpindex; /* ## - paste operator */ @@ -619,8 +620,9 @@ macro2buffer(repl, idf, args) repl->r_text[tmpindex] = TOKSEP; } } - } else /* # operator */ - ptr = stringify(repl, ptr, args); + } else { /* # operator */ + ptr = stringify(repl, ptr, args); + } } else if (*ptr & FORMALP) { /* insert actual parameter */ register int n = *ptr++ & 0177; @@ -646,8 +648,9 @@ macro2buffer(repl, idf, args) if (*(repl->r_ptr-1) != TOKSEP) add2repl(repl, TOKSEP); - } else + } else { add2repl(repl, *ptr++); + } } if (err) error("illegal use of ## operator"); -- 2.34.1