]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
Merge branch 'master' into test-suite
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index ecda7f7ebf0528b577e38a9b8a864ffa2b4df5d9..a71e50f6cfa9fcbdd19224f17c48a706ce06f6be 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -10,32 +10,32 @@ char* *lex_filenames;
 
 void lexerror(lex_file *lex, const char *fmt, ...)
 {
-       va_list ap;
+    va_list ap;
 
-       va_start(ap, fmt);
-       if (lex)
+    va_start(ap, fmt);
+    if (lex)
         con_vprintmsg(LVL_ERROR, lex->name, lex->sline, "parse error", fmt, ap);
     else
         con_vprintmsg(LVL_ERROR, "", 0, "parse error", fmt, ap);
-       va_end(ap);
+    va_end(ap);
 }
 
 bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
 {
-       va_list ap;
-       int lvl = LVL_WARNING;
+    va_list ap;
+    int lvl = LVL_WARNING;
 
     if (!OPTS_WARN(warntype))
         return false;
 
     if (opts_werror)
-           lvl = LVL_ERROR;
+        lvl = LVL_ERROR;
 
-       va_start(ap, fmt);
+    va_start(ap, fmt);
     con_vprintmsg(lvl, lex->name, lex->sline, "warning", fmt, ap);
-       va_end(ap);
+    va_end(ap);
 
-       return opts_werror;
+    return opts_werror;
 }
 
 
@@ -414,11 +414,14 @@ static bool lex_try_pragma(lex_file *lex)
         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;
 
     lex->line = line;
-    while (ch != '\n')
+    while (ch != '\n' && ch != EOF)
         ch = lex_getch(lex);
     return true;
 
@@ -495,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') {