From b8b3054bba43c7e44465b05888e635da90326257 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 1 Mar 1994 15:04:52 +0000 Subject: [PATCH] Fix: prevent unintentional token pasting --- lang/cem/cemcom.ansi/replace.c | 5 +++++ lang/cem/cpp.ansi/replace.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lang/cem/cemcom.ansi/replace.c b/lang/cem/cemcom.ansi/replace.c index 86826575b..298eab952 100644 --- a/lang/cem/cemcom.ansi/replace.c +++ b/lang/cem/cemcom.ansi/replace.c @@ -350,6 +350,7 @@ actual(repl) ch = GetChar(); } while (in_idf(ch)); *p++ = '\0'; + ch = '\0'; /* It could be an unstashed TOKSEP */ UnGetChar(); /* When the identifier has an associated macro @@ -376,6 +377,7 @@ actual(repl) if (ch == '.') { ch = GetChar(); if (class(ch) != STNUM) { + ch = '\0'; /* It could be an unstashed TOKSEP */ UnGetChar(); continue; } @@ -393,6 +395,7 @@ actual(repl) } } } + ch = '\0'; /* It could be an unstashed TOKSEP */ UnGetChar(); } else if (ch == '(') { /* a comma may occur between parentheses */ @@ -455,6 +458,7 @@ a_new_line: ch = GetChar(); } if (ch != '/') { UnGetChar(); + ch = ' '; stash(repl, ' ', !nostashraw); } } else if (ch == '/') { @@ -464,6 +468,7 @@ a_new_line: ch = GetChar(); stash(repl, ' ', !nostashraw); } else { UnGetChar(); + ch = '/'; stash(repl, '/', !nostashraw); } } else if (ch == '\'' || ch == '"') { diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index f2470f96f..a4a16247b 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -344,6 +344,7 @@ actual(repl) ch = GetChar(); } while (in_idf(ch)); *p++ = '\0'; + ch = '\0'; /* Could be a non-stashed TOKSEP */ UnGetChar(); /* When the identifier has an associated macro @@ -370,6 +371,7 @@ actual(repl) if (ch == '.') { ch = GetChar(); if (class(ch) != STNUM) { + ch = '\0'; /* Could be a non-stashed TOKSEP */ UnGetChar(); continue; } @@ -387,6 +389,7 @@ actual(repl) } } } + ch = '\0'; /* Could be a non-stashed TOKSEP */ UnGetChar(); } else if (ch == '(') { /* a comma may occur within parentheses */ @@ -445,6 +448,7 @@ a_new_line: ch = GetChar(); } if (ch != '/') { UnGetChar(); + ch = ' '; stash(repl, ' ', !nostashraw); } } else if (ch == '/') { @@ -454,6 +458,7 @@ a_new_line: ch = GetChar(); stash(repl, ' ', !nostashraw); } else { UnGetChar(); + ch = '/'; stash(repl, '/', !nostashraw); } } else if (ch == '\'' || ch == '"') {