]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Lexer fixes
authorDale Weiler <killfieldengine@gmail.com>
Sat, 28 Apr 2012 20:25:43 +0000 (16:25 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Sat, 28 Apr 2012 20:25:43 +0000 (16:25 -0400)
gmqcc.h
lex.c

diff --git a/gmqcc.h b/gmqcc.h
index 6da465b42e741533fb18ce58509c16ef75114582..d8697120f4193a9a9208d6f7dbb0505effb82683 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -271,8 +271,6 @@ uint32_t util_crc32(const char *, int, register const short);
 #define VECTOR_MAKE(T,N) \
     VECTOR_TYPE(T,N);    \
     VECTOR_CORE(T,N)
-/* Builds a vector add function pointer for inside structures */
-#define VECTOR_IMPL(T,N) int (*N##_add)(T)
 
 //===================================================================
 //=========================== code.c ================================
diff --git a/lex.c b/lex.c
index eb18ee1e30776676db6718b3c596f135c76735b2..671d7a53220305070218624dff2f14fdee7d9931 100644 (file)
--- a/lex.c
+++ b/lex.c
@@ -139,22 +139,10 @@ static int lex_digraph(lex_file *file, int first) {
 
 static int lex_getch(lex_file *file) {
     int ch = lex_inget(file);
-
-    static int str = 0;
-    switch (ch) {
-        case '?' :
-            return lex_trigraph(file);
-        case '<' :
-        case ':' :
-        case '%' :
-        case '"' : str = !str; if (str) { file->line ++; }
-            return lex_digraph(file, ch);
-            
-        case '\n':
-            if (!str)
-                file->line++;
-    }
-        
+    if (ch == '?')
+        return lex_trigraph(file);
+    if (ch == '<' || ch == ':' || ch == '%')
+        return lex_digraph(file, ch);
     return ch;
 }
 
@@ -283,13 +271,7 @@ int lex_token(lex_file *file) {
     if (ch > 0 && (ch == '_' || isalpha(ch))) {
         lex_clear(file);
         
-        /*
-         * Yes this is dirty, but there is no other _sane_ easy
-         * way to do it, this is what I call defensive programming
-         * if something breaks, add more defense :-)
-         */
-        while (ch >   0   && ch != ' ' && ch != '(' &&
-               ch != '\n' && ch != ';' && ch != ')') {
+        while (ch > 0 && (ch == '_' || isalpha(ch))) {
             lex_addch(ch, file);
             ch = lex_getsource(file);
         }