]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
fixup line counting in #pragmas
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 18 Nov 2012 14:23:00 +0000 (15:23 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 18 Nov 2012 14:23:00 +0000 (15:23 +0100)
lexer.c

diff --git a/lexer.c b/lexer.c
index c28ad8815e49edfde9d5b3d204c938ef49faa37e..40756c0a4e3d0c93a7f2822ebfa2aa83df1c7b81 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -353,10 +353,13 @@ static bool lex_try_pragma(lex_file *lex)
     char *pragma  = NULL;
     char *command = NULL;
     char *param   = NULL;
+    size_t line;
 
     if (lex->flags.preprocessing)
         return false;
 
+    line = lex->line;
+
     ch = lex_getch(lex);
     if (ch != '#') {
         lex_ungetch(lex, ch);
@@ -393,7 +396,7 @@ static bool lex_try_pragma(lex_file *lex)
     if (!strcmp(command, "push")) {
         if (!strcmp(param, "line")) {
             lex->push_line++;
-            lex->line--;
+            --line;
         }
         else
             goto unroll;
@@ -402,7 +405,6 @@ static bool lex_try_pragma(lex_file *lex)
         if (!strcmp(param, "line")) {
             if (lex->push_line)
                 lex->push_line--;
-            lex->line--;
         }
         else
             goto unroll;
@@ -412,6 +414,7 @@ static bool lex_try_pragma(lex_file *lex)
 
     while (ch != '\n')
         ch = lex_getch(lex);
+    lex->line = line;
     return true;
 
 unroll:
@@ -440,6 +443,8 @@ unroll:
         vec_free(pragma);
     }
     lex_ungetch(lex, '#');
+
+    lex->line = line;
     return false;
 }