]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeseg.c
Fixed a bug that caused problems locating the last parameter of a function
[cc65] / src / cc65 / codeseg.c
index 06260ff3a30c71488968d6afb10057237ab69c7c..fede7ae6215b12c694a0afd8668e9a77a752aefa 100644 (file)
@@ -39,6 +39,7 @@
 /* common */
 #include "chartype.h"
 #include "check.h"
+#include "debugflag.h"
 #include "global.h"
 #include "hashstr.h"
 #include "strutil.h"
@@ -1281,9 +1282,21 @@ void CS_Output (const CodeSeg* S, FILE* F)
            /* Line info has changed, remember the new line info */
            LI = E->LI;
 
-           /* Add the source line as a comment */
+           /* Add the source line as a comment. Beware: When line continuation
+             * was used, the line may contain newlines.
+             */
            if (AddSource) {
-               fprintf (F, ";\n; %s\n;\n", LI->Line);
+                const char* L = LI->Line;
+                fputs (";\n; ", F);
+                while (*L) {
+                    if (*L == '\n') {
+                        fputs ("\n; ", F);
+                    } else {
+                        fputc (*L, F);
+                    }
+                    ++L;
+                }
+                fputs ("\n;\n", F);
            }
 
            /* Add line debug info */