mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +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;
|
const struct plitem_s *item;
|
||||||
struct plitem_s *messages;
|
struct plitem_s *messages;
|
||||||
struct hashlink_s *hashlinks;
|
struct hashlink_s *hashlinks;
|
||||||
|
int errors;
|
||||||
} exprctx_t;
|
} exprctx_t;
|
||||||
|
|
||||||
typedef struct exprenum_s {
|
typedef struct exprenum_s {
|
||||||
|
|
|
@ -82,6 +82,8 @@ cexpr_error(exprctx_t *ctx, const char *fmt, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
dstring_t *string;
|
dstring_t *string;
|
||||||
|
|
||||||
|
ctx->errors++;
|
||||||
|
|
||||||
string = dstring_new ();
|
string = dstring_new ();
|
||||||
|
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
|
@ -211,6 +213,7 @@ cexpr_eval_string (const char *str, exprctx_t *context)
|
||||||
yylex_init_extra (context, &scanner);
|
yylex_init_extra (context, &scanner);
|
||||||
yy_scan_string (str, scanner);
|
yy_scan_string (str, scanner);
|
||||||
|
|
||||||
|
context->errors = 0;
|
||||||
do {
|
do {
|
||||||
CEXPR_YYSTYPE lval;
|
CEXPR_YYSTYPE lval;
|
||||||
int token = yylex (&lval, scanner);
|
int token = yylex (&lval, scanner);
|
||||||
|
@ -219,7 +222,7 @@ cexpr_eval_string (const char *str, exprctx_t *context)
|
||||||
|
|
||||||
yylex_destroy (scanner);
|
yylex_destroy (scanner);
|
||||||
cexpr_yypstate_delete (ps);
|
cexpr_yypstate_delete (ps);
|
||||||
return status;
|
return status || context->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static exprval_t *parse_int (const char *str, exprctx_t *context)
|
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) {
|
if (sym) {
|
||||||
val = cexpr_value_reference (sym->type, sym->value, context);
|
val = cexpr_value_reference (sym->type, sym->value, context);
|
||||||
} else {
|
} else {
|
||||||
val = cexpr_cvar (name, context);
|
//val = cexpr_cvar (name, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "QF/cmem.h"
|
#include "QF/cmem.h"
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/qfplist.h"
|
|
||||||
|
|
||||||
#include "libs/util/cexpr-parse.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;
|
__auto_type name = (const char *) b->value;
|
||||||
exprval_t *var = cexpr_cvar (name, ctx);
|
exprval_t *var = cexpr_cvar (name, ctx);
|
||||||
if (!var) {
|
if (!var) {
|
||||||
PL_Message (ctx->messages, ctx->item, "unknown cvar %s", name);
|
cexpr_error (ctx, "unknown cvar %s", name);
|
||||||
}
|
}
|
||||||
*(exprval_t **) c->value = var;
|
*(exprval_t **) c->value = var;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue