mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 12:00:38 +00:00
vcompile_error, vcompile_warning; fixed: removed opts_ globals from con.c; made the lexer use vcompile_warning
This commit is contained in:
parent
6fa30fdaf4
commit
fe344cb5b2
3 changed files with 31 additions and 23 deletions
33
con.c
33
con.c
|
@ -22,9 +22,6 @@
|
||||||
*/
|
*/
|
||||||
#include "gmqcc.h"
|
#include "gmqcc.h"
|
||||||
|
|
||||||
uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)];
|
|
||||||
bool opts_werror = false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* isatty/STDERR_FILENO/STDOUT_FILNO
|
* isatty/STDERR_FILENO/STDOUT_FILNO
|
||||||
* + some other things likewise.
|
* + some other things likewise.
|
||||||
|
@ -368,33 +365,45 @@ void con_cprintmsg (void *ctx, int lvl, const char *msgtype, const char *msg, ..
|
||||||
size_t compile_errors = 0;
|
size_t compile_errors = 0;
|
||||||
size_t compile_warnings = 0;
|
size_t compile_warnings = 0;
|
||||||
|
|
||||||
|
void vcompile_error(lex_ctx ctx, const char *msg, va_list ap)
|
||||||
|
{
|
||||||
|
++compile_errors;
|
||||||
|
con_cvprintmsg((void*)&ctx, LVL_ERROR, "error", msg, ap);
|
||||||
|
}
|
||||||
|
|
||||||
void compile_error(lex_ctx ctx, const char *msg, ...)
|
void compile_error(lex_ctx ctx, const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
++compile_errors;
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
con_cvprintmsg((void*)&ctx, LVL_ERROR, "error", msg, ap);
|
vcompile_error(ctx, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...)
|
bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
va_list ap;
|
|
||||||
int lvl = LVL_WARNING;
|
int lvl = LVL_WARNING;
|
||||||
|
|
||||||
if (!OPTS_WARN(warntype))
|
if (!OPTS_WARN(warntype))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (opts_werror) {
|
if (opts.werror) {
|
||||||
++compile_errors;
|
++compile_errors;
|
||||||
lvl = LVL_ERROR;
|
lvl = LVL_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++compile_warnings;
|
++compile_warnings;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
con_vprintmsg(lvl, ctx.file, ctx.line, (opts.werror ? "error" : "warning"), fmt, ap);
|
||||||
con_vprintmsg(lvl, ctx.file, ctx.line, (opts_werror ? "error" : "warning"), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return opts_werror;
|
return opts.werror;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
bool r;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
r = vcompile_warning(ctx, warntype, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
6
gmqcc.h
6
gmqcc.h
|
@ -623,8 +623,10 @@ int con_out (const char *, ...);
|
||||||
extern size_t compile_errors;
|
extern size_t compile_errors;
|
||||||
extern size_t compile_warnings;
|
extern size_t compile_warnings;
|
||||||
|
|
||||||
void /********/ compile_error (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, ...);
|
void /********/ compile_error (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, ...);
|
||||||
bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...);
|
bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...);
|
||||||
|
void /********/ vcompile_error (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, va_list);
|
||||||
|
bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_list);
|
||||||
|
|
||||||
/*===================================================================*/
|
/*===================================================================*/
|
||||||
/*========================= assembler.c =============================*/
|
/*========================= assembler.c =============================*/
|
||||||
|
|
15
lexer.c
15
lexer.c
|
@ -74,20 +74,17 @@ void lexerror(lex_file *lex, const char *fmt, ...)
|
||||||
|
|
||||||
bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
|
bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
bool r;
|
||||||
|
lex_ctx ctx;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int lvl = LVL_WARNING;
|
|
||||||
|
|
||||||
if (!OPTS_WARN(warntype))
|
ctx.file = lex->name;
|
||||||
return false;
|
ctx.line = lex->sline;
|
||||||
|
|
||||||
if (opts.werror)
|
|
||||||
lvl = LVL_ERROR;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
con_vprintmsg(lvl, lex->name, lex->sline, (opts.werror ? "error" : "warning"), fmt, ap);
|
r = vcompile_warning(ctx, warntype, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
return r;
|
||||||
return opts.werror;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue