]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
Importing a tiny README file
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index 40756c0a4e3d0c93a7f2822ebfa2aa83df1c7b81..25cf4e180a1aa4a842ba6affad71d3d5561937c4 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -405,16 +405,24 @@ static bool lex_try_pragma(lex_file *lex)
         if (!strcmp(param, "line")) {
             if (lex->push_line)
                 lex->push_line--;
+            --line;
         }
         else
             goto unroll;
     }
+    else if (!strcmp(command, "file")) {
+        lex->name = util_strdup(param);
+        vec_push(lex_filenames, lex->name);
+    }
+    else if (!strcmp(command, "line")) {
+        line = strtol(param, NULL, 0)-1;
+    }
     else
         goto unroll;
 
-    while (ch != '\n')
-        ch = lex_getch(lex);
     lex->line = line;
+    while (ch != '\n' && ch != EOF)
+        ch = lex_getch(lex);
     return true;
 
 unroll:
@@ -490,10 +498,8 @@ static int lex_skipwhite(lex_file *lex)
         ch = lex_getch(lex);
         while (ch != EOF && isspace(ch)) {
             if (ch == '\n') {
-                if (lex_try_pragma(lex)) {
-                    ch = lex_getch(lex);
+                if (lex_try_pragma(lex))
                     continue;
-                }
             }
             if (lex->flags.preprocessing) {
                 if (ch == '\n') {