From: Wolfgang (Blub) Bumiller Date: Thu, 23 Aug 2012 17:20:50 +0000 (+0200) Subject: Make the lexer use the correct error-printing mechanism X-Git-Tag: 0.1-rc1~66 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d23fc5f5f196ba6669497f0411b324dbd4b6808;p=xonotic%2Fgmqcc.git Make the lexer use the correct error-printing mechanism --- diff --git a/lexer.c b/lexer.c index 3d217ab..b3243f0 100644 --- 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()