From 4f5027bfc2c665cb17314808d10faae85d2ffe38 Mon Sep 17 00:00:00 2001 From: ike709 Date: Tue, 26 Nov 2024 20:16:05 -0600 Subject: [PATCH] more robust checking --- DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs b/DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs index 154b9cb3b1..bde1ab358b 100644 --- a/DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs +++ b/DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs @@ -344,8 +344,11 @@ public Token NextToken(bool ignoreWhitespace = false) { var delimIdx = 0; do { TokenTextBuilder.Append(c); + if (GetCurrent() == complexDelimiter[delimIdx]) delimIdx++; - if (delimIdx + 1 == complexDelimiter.Length) { + else delimIdx = 0; + + if (delimIdx + 1 == complexDelimiter.Length && c == complexDelimiter[^1]) { // latter check ensures a 1-char delimiter actually matches TokenTextBuilder.Remove(TokenTextBuilder.Length - delimIdx, complexDelimiter.Length - 1); break; }