From 423a7c48994fc9430960f83955d6697d484e342a Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Wed, 30 Sep 2020 01:13:07 +0200 Subject: [PATCH] Handle \\r better Translate it to \\n regardless of the lexer mode --- src/asm/lexer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/asm/lexer.c b/src/asm/lexer.c index c54f854d..62904e29 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -1611,9 +1611,7 @@ static int yylex_NORMAL(void) /* Handle newlines and EOF */ case '\r': - if (peek(0) == '\n') - shiftChars(1); /* Shift that EOL */ - /* fallthrough */ + return '\r'; case '\n': return '\n'; @@ -1905,6 +1903,10 @@ restart: return 0; } } + } else if (token == '\r') { /* Handle CR and CRLF line endings */ + token = '\n'; /* We universally use '\n' as the value for line ending tokens */ + if (peek(0) == '\n') + shiftChars(1); /* Shift the CRLF's LF */ } lexerState->lastToken = token;