]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
skipwhite bugfix
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index 258fb97a9605eac6efc9ad11103f47b4dc75cb67..4d283f464ddb2ff1bec50ec20dc294fb08f200e5 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -441,7 +441,7 @@ static bool lex_try_pragma(lex_file *lex)
         goto unroll;
     }
 
-    for (ch = lex_getch(lex); vec_size(param) < 32 && ch != ')' && ch != '\n'; ch = lex_getch(lex))
+    for (ch = lex_getch(lex); vec_size(param) < 1024 && ch != ')' && ch != '\n'; ch = lex_getch(lex))
         vec_push(param, ch);
     vec_push(param, 0);
 
@@ -547,10 +547,10 @@ printf(   "line one\n"
  *    here is to store the line of the first character after skipping
  *    the initial whitespace in lex->sline, this happens in lex_do.
  */
-static int lex_skipwhite(lex_file *lex)
+static int lex_skipwhite(lex_file *lex, bool hadwhite)
 {
     int ch = 0;
-    bool haswhite = false;
+    bool haswhite = hadwhite;
 
     do
     {
@@ -930,6 +930,7 @@ static int GMQCC_WARN lex_finish_digit(lex_file *lex, int lastch)
 int lex_do(lex_file *lex)
 {
     int ch, nextch, thirdch;
+    bool hadwhite = false;
 
     lex_token_new(lex);
 #if 0
@@ -938,7 +939,8 @@ int lex_do(lex_file *lex)
 #endif
 
     while (true) {
-        ch = lex_skipwhite(lex);
+        ch = lex_skipwhite(lex, hadwhite);
+        hadwhite = true;
         if (!lex->flags.mergelines || ch != '\\')
             break;
         ch = lex_getch(lex);
@@ -969,7 +971,7 @@ int lex_do(lex_file *lex)
     }
 
     /* modelgen / spiritgen commands */
-    if (ch == '$') {
+    if (ch == '$' && !lex->flags.preprocessing) {
         const char *v;
         size_t frame;
 
@@ -1322,7 +1324,7 @@ int lex_do(lex_file *lex)
         while (!lex->flags.preprocessing && lex->tok.ttype == TOKEN_STRINGCONST)
         {
             /* Allow c style "string" "continuation" */
-            ch = lex_skipwhite(lex);
+            ch = lex_skipwhite(lex, false);
             if (ch != '"') {
                 lex_ungetch(lex, ch);
                 break;