]> git.sur5r.net Git - cc65/commitdiff
Bug fixed: The preprocessor # operator did not work correctly with string arguments
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 6 Mar 2002 07:35:20 +0000 (07:35 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 6 Mar 2002 07:35:20 +0000 (07:35 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1167 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/preproc.c

index f1135acb23df277611e23f5ea6650d4ccb472e1c..92042c041526cab2a3a836b95644b0f0d21c732c 100644 (file)
@@ -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 ('#');