Skip to content

Commit

Permalink
Trim right whitespace from macro args before warning about length
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Feb 28, 2021
1 parent fad4832 commit 1f579de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/asm/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ static int yylex_RAW(void)
/* This is essentially a modified `appendStringLiteral` */
size_t i = 0;

/* Trim left of string... */
/* Trim left whitespace (stops at a block comment or line continuation) */
while (isWhitespace(peek(0)))
shiftChars(1);

Expand All @@ -2139,13 +2139,13 @@ static int yylex_RAW(void)
case '\r':
case '\n':
case EOF:
/* Trim right whitespace */
while (i && isWhitespace(yylval.tzString[i - 1]))
i--;
if (i == sizeof(yylval.tzString)) {
i--;
warning(WARNING_LONG_STR, "Macro argument too long\n");
}
/* Trim whitespace */
while (i && isWhitespace(yylval.tzString[i - 1]))
i--;
/* Empty macro args break their expansion, so prevent that */
if (i == 0) {
// If at EOF, don't shift a non-existent char.
Expand Down

0 comments on commit 1f579de

Please sign in to comment.