]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
Merge branch 'master' into cooking
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index feea8a2eb49cf5ce14873df7067d25cb4526e274..7642d261b89b4b3b9eae3e8fa6c4c1ec0751b96e 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -352,14 +352,18 @@ static int lex_getch(lex_file *lex)
 
     if (lex->peekpos) {
         lex->peekpos--;
-        if (!lex->push_line && lex->peek[lex->peekpos] == '\n')
+        if (!lex->push_line && lex->peek[lex->peekpos] == '\n') {
             lex->line++;
+            lex->column = 0;
+        }
         return lex->peek[lex->peekpos];
     }
 
     ch = lex_fgetc(lex);
-    if (!lex->push_line && ch == '\n')
+    if (!lex->push_line && ch == '\n') {
         lex->line++;
+        lex->column = 0;
+    }
     else if (ch == '?')
         return lex_try_trigraph(lex, ch);
     else if (!lex->flags.nodigraphs && (ch == '<' || ch == ':' || ch == '%'))
@@ -1302,7 +1306,7 @@ int lex_do(lex_file *lex)
     }
 
     if (ch == '+' || ch == '-' || /* ++, --, +=, -=  and -> as well! */
-        ch == '>' || ch == '<' || /* <<, >>, <=, >=                  */
+        ch == '>' || ch == '<' || /* <<, >>, <=, >=  and >< as well! */
         ch == '=' || ch == '!' || /* <=>, ==, !=                     */
         ch == '&' || ch == '|' || /* &&, ||, &=, |=                  */
         ch == '~' || ch == '^'    /* ~=, ~, ^                        */
@@ -1310,7 +1314,9 @@ int lex_do(lex_file *lex)
         lex_tokench(lex, ch);
 
         nextch = lex_getch(lex);
-        if ((nextch == '=' && ch != '<') || (nextch == ch && ch != '!')) {
+        if ((nextch == '=' && ch != '<') ||
+            (nextch == ch  && ch != '!') ||
+            (nextch == '<' && ch == '>')) {
             lex_tokench(lex, nextch);
         } else if (ch == '<' && nextch == '=') {
             lex_tokench(lex, nextch);
@@ -1513,6 +1519,6 @@ int lex_do(lex_file *lex)
         return (lex->tok.ttype = ch);
     }
 
-    lexerror(lex, "unknown token: `%s`", lex->tok.value);
+    lexerror(lex, "unknown token: `%c`", ch);
     return (lex->tok.ttype = TOKEN_ERROR);
 }