shithub: rgbds

Download patch

ref: 1f579deaffe0d3d1035d46ac3bb2cbbf0002c9a4
parent: fad48326f833b7b282d76d1b79f0dc3b3ecc8d04
author: Rangi <[email protected]>
date: Wed Feb 17 13:28:45 EST 2021

Trim right whitespace from macro args before warning about length

--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -2118,7 +2118,7 @@
 	/* 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);
 
@@ -2139,13 +2139,13 @@
 		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.