shithub: rgbds

Download patch

ref: 89eda89838755902482a0e6619dea77c06fd64a9
parent: 2e6f5ac679b6fec430023a1527fb4d4f9a8bfc82
author: dbrotz <[email protected]>
date: Mon Sep 9 08:25:26 EDT 2019

Handle tabs after backslash at end of file
Commit 6fbb25c added support for tabs between a \ and the newline it escapes,
but yy_create_buffer() was not updated to handle tabs.

--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -325,8 +325,9 @@
 	if (pBuffer->nBufferSize >= 2) {
 		size_t pos = pBuffer->nBufferSize - 2;
 
-		/* Skip spaces */
-		while (pos > 0 && pBuffer->pBufferStart[pos] == ' ')
+		/* Skip spaces and tabs */
+		while (pos > 0 && (pBuffer->pBufferStart[pos] == ' '
+				|| pBuffer->pBufferStart[pos] == '\t'))
 			pos--;
 
 		if (pBuffer->pBufferStart[pos] == '\\')
--- /dev/null
+++ b/test/asm/line-continuation-whitespace.asm
@@ -1,0 +1,7 @@
+; Test that \ followed by whitespace after a macro invocation at the end of the
+; file doesn't cause a segfault.
+
+bar: MACRO
+ENDM
+
+foo bar baz\