diff --git a/src/ca65/macro.c b/src/ca65/macro.c index 4b9f1370b..f8c9b81e6 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -705,6 +705,7 @@ ExpandParam: if (new_expand_line) { StrBuf mac_line = MakeLineFromTokens (Mac->Exp); NewListingLine (&mac_line, 0, 0); + InitListingLine (); SB_Done (&mac_line); new_expand_line = 0; } @@ -1107,17 +1108,12 @@ static StrBuf MakeLineFromTokens (TokNode* first) /* is it a string of some sort?*/ unsigned len = SB_GetLen (&token->SVal); if (len > 0) { - token_string = xmalloc (len + 1); - memcpy (token_string, SB_GetBuf (&token->SVal), len); - token_string[len] = 0; - SB_AppendStr (&T, token_string); - xfree (token_string); + SB_Append (&T, &token->SVal); } else if (token->Tok == TOK_INTCON) { char ival[12]; // max size a long can be snprintf (ival, sizeof(ival), "%ld", token->IVal); SB_AppendStr (&T, ival); - } else if ((token_string = GetTokenString (token)) != NULL) - { + } else if ((token_string = GetTokenString (token)) != NULL) { SB_AppendStr (&T, token_string); } SB_Append (&S, &T); diff --git a/src/ca65/main.c b/src/ca65/main.c index cc5f99786..bbb82736f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -702,9 +702,11 @@ static void OneLine (void) int Instr = -1; /* Initialize the new listing line if we are actually reading from file - ** and not from internally pushed input, unless expanding macros + ** and not from internally pushed input */ - if (!HavePushedInput () || ExpandMacros) { + + + if (!HavePushedInput () ) { InitListingLine (); }