1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Despite not technically needed, it seems to be desirable to remove all trailing whitespace from inline assembly

This commit is contained in:
mrdudz 2022-08-28 03:43:02 +02:00
parent 6096a24f1d
commit d371046ae4

View File

@ -4921,5 +4921,25 @@ void g_switch (Collection* Nodes, unsigned DefaultLabel, unsigned Depth)
void g_asmcode (struct StrBuf* B)
/* Output one line of assembler code. */
{
AddCodeLine ("%.*s", (int) SB_GetLen (B), SB_GetConstBuf (B));
int len = (int) SB_GetLen(B);
const char *buf = SB_GetConstBuf(B);
/* remove whitespace at end of line */
/* NOTE: This masks problems in ParseInsn(), which in some cases seems to
rely on no whitespace being present at the end of a line in generated
code (see issue #1252). However, it generally seems to be a good
idea to remove trailing whitespace from (inline) assembly, so we
do it anyway. */
while (len) {
switch (buf[len - 1]) {
case '\n':
case ' ':
case '\t':
--len;
continue;
}
break;
}
AddCodeLine ("%.*s", len, buf);
}