]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
mergelines flag for the lexer to handle a backslash-newline
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index 96644c2623094d61ff54441bcebbbe66303dd1b8..1d1c42f3b61fc442a23b2b080aa23f180cf07605 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -675,7 +675,20 @@ int lex_do(lex_file *lex)
         return TOKEN_FATAL;
 #endif
 
-    ch = lex_skipwhite(lex);
+    while (true) {
+        ch = lex_skipwhite(lex);
+        if (!lex->flags.mergelines || ch != '\\')
+            break;
+        ch = lex_getch(lex);
+        if (ch != '\n') {
+            lex_ungetch(lex, ch);
+            ch = '\\';
+            break;
+        }
+        /* we reached a linemerge */
+        continue;
+    }
+
     lex->sline = lex->line;
     lex->tok.ctx.line = lex->sline;
     lex->tok.ctx.file = lex->name;