]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Make the lexer use the correct error-printing mechanism
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 23 Aug 2012 17:20:50 +0000 (19:20 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 23 Aug 2012 17:20:50 +0000 (19:20 +0200)
lexer.c

diff --git a/lexer.c b/lexer.c
index 3d217abe3eb574cb252475d3e43fe0f71be1a041..b3243f071e0c2d316186034bbe5f2f8e68013e63 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -13,39 +13,31 @@ VECTOR_MAKE(char*, lex_filenames);
 
 void lexerror(lex_file *lex, const char *fmt, ...)
 {
-    va_list ap;
+       va_list ap;
 
-    if (lex)
-        printf("error %s:%lu: ", lex->name, (unsigned long)lex->sline);
-    else
-        printf("error: ");
-
-    va_start(ap, fmt);
-    vprintf(fmt, ap);
-    va_end(ap);
+       parser->errors++;
 
-    printf("\n");
+       va_start(ap, fmt);
+    vprintmsg(LVL_ERROR, lex->name, lex->sline, "parse error", fmt, ap);
+       va_end(ap);
 }
 
-bool lexwarn(lex_file *lex, int warn, const char *fmt, ...)
+bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
 {
-    va_list ap;
+       va_list ap;
+       int lvl = LVL_WARNING;
 
-    if (!OPTS_WARN(warn))
+    if (!OPTS_WARN(warntype))
         return false;
 
-    if (lex)
-        printf("warning %s:%lu: ", lex->name, (unsigned long)lex->sline);
-    else
-        printf("warning: ");
-
-    va_start(ap, fmt);
-    vprintf(fmt, ap);
-    va_end(ap);
+    if (opts_werror)
+           lvl = LVL_ERROR;
 
-    printf("\n");
+       va_start(ap, fmt);
+    vprintmsg(lvl, lex->name, lex->sline, "warning", fmt, ap);
+       va_end(ap);
 
-    return opts_werror;
+       return opts_werror;
 }
 
 token* token_new()