mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
[util] Propagate cexpr errors back to the caller
Not much point in error detection when it's ignored.
This commit is contained in:
parent
ac8206555e
commit
79f22ffebf
3 changed files with 7 additions and 4 deletions
|
@ -82,6 +82,7 @@ typedef struct exprctx_s {
|
|||
const struct plitem_s *item;
|
||||
struct plitem_s *messages;
|
||||
struct hashlink_s *hashlinks;
|
||||
int errors;
|
||||
} exprctx_t;
|
||||
|
||||
typedef struct exprenum_s {
|
||||
|
|
|
@ -82,6 +82,8 @@ cexpr_error(exprctx_t *ctx, const char *fmt, ...)
|
|||
va_list args;
|
||||
dstring_t *string;
|
||||
|
||||
ctx->errors++;
|
||||
|
||||
string = dstring_new ();
|
||||
|
||||
va_start (args, fmt);
|
||||
|
@ -211,6 +213,7 @@ cexpr_eval_string (const char *str, exprctx_t *context)
|
|||
yylex_init_extra (context, &scanner);
|
||||
yy_scan_string (str, scanner);
|
||||
|
||||
context->errors = 0;
|
||||
do {
|
||||
CEXPR_YYSTYPE lval;
|
||||
int token = yylex (&lval, scanner);
|
||||
|
@ -219,7 +222,7 @@ cexpr_eval_string (const char *str, exprctx_t *context)
|
|||
|
||||
yylex_destroy (scanner);
|
||||
cexpr_yypstate_delete (ps);
|
||||
return status;
|
||||
return status || context->errors;
|
||||
}
|
||||
|
||||
static exprval_t *parse_int (const char *str, exprctx_t *context)
|
||||
|
@ -271,7 +274,7 @@ parse_variable (const char *name, exprctx_t *context)
|
|||
if (sym) {
|
||||
val = cexpr_value_reference (sym->type, sym->value, context);
|
||||
} else {
|
||||
val = cexpr_cvar (name, context);
|
||||
//val = cexpr_cvar (name, context);
|
||||
}
|
||||
}
|
||||
if (!val) {
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "QF/cmem.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/hash.h"
|
||||
#include "QF/qfplist.h"
|
||||
|
||||
#include "libs/util/cexpr-parse.h"
|
||||
|
||||
|
@ -65,7 +64,7 @@ cvar_get (const exprval_t *a, const exprval_t *b, exprval_t *c, exprctx_t *ctx)
|
|||
__auto_type name = (const char *) b->value;
|
||||
exprval_t *var = cexpr_cvar (name, ctx);
|
||||
if (!var) {
|
||||
PL_Message (ctx->messages, ctx->item, "unknown cvar %s", name);
|
||||
cexpr_error (ctx, "unknown cvar %s", name);
|
||||
}
|
||||
*(exprval_t **) c->value = var;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue