From e9b0009f97f0bbd4459ebc21d0b24eedd6c8fc70 Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 6 Mar 2002 07:35:20 +0000 Subject: [PATCH] Bug fixed: The preprocessor # operator did not work correctly with string arguments git-svn-id: svn://svn.cc65.org/cc65/trunk@1167 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/preproc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index f1135acb2..92042c041 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -309,7 +309,22 @@ static void ExpandMacroArgs (Macro* M) Replacement = FindMacroArg (M, Ident); if (Replacement) { keepch ('\"'); - keepstr (Replacement); + /* We have to escape any characters inside replacement that + * may not be part of a string unescaped. + */ + while (*Replacement) { + switch (*Replacement) { + case '\"': + case '\\': + case '\'': + keepch ('\\'); + /* FALLTHROUGH */ + default: + keepch (*Replacement); + break; + } + ++Replacement; + } keepch ('\"'); } else { keepch ('#'); -- 2.39.5