make(1): clean up VarParseErrors, for proper error handling
Having a pure bitset was wrong. Instead, there are several alternatives (parse error, eval error, undef error), and each of them can either have an error message printed (good) or not (bad). In addition, there are VPE_OK for successful expression evaluation and VPE_UNKNOWN (only used during migration to the correct error handling scheme).
This commit is contained in:
parent
cc07d45207
commit
69ef6fbe0d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nonints.h,v 1.122 2020/09/13 20:38:47 rillig Exp $ */
|
||||
/* $NetBSD: nonints.h,v 1.123 2020/09/21 05:28:26 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -218,47 +218,45 @@ typedef enum {
|
||||
/* Both parsing and evaluation succeeded. */
|
||||
VPE_OK = 0x0000,
|
||||
|
||||
/* Parsing failed.
|
||||
* An error message has already been printed. */
|
||||
VPE_PARSE_MSG = 0x0001,
|
||||
/* See if a message has already been printed for this error. */
|
||||
VPE_ANY_MSG = 0x0001,
|
||||
|
||||
/* Parsing failed.
|
||||
* No error message has been printed yet.
|
||||
*
|
||||
* This should never happen since it is impossible to say where
|
||||
* the parsing error occurred. */
|
||||
* Deprecated, migrate to VPE_PARSE_MSG instead. */
|
||||
VPE_PARSE_SILENT = 0x0002,
|
||||
|
||||
/* Parsing succeeded.
|
||||
* During evaluation, VARE_UNDEFERR was set and there was an undefined
|
||||
* variable.
|
||||
/* Parsing failed.
|
||||
* An error message has already been printed. */
|
||||
VPE_UNDEF_MSG = 0x0010,
|
||||
VPE_PARSE_MSG = VPE_PARSE_SILENT | VPE_ANY_MSG,
|
||||
|
||||
/* Parsing succeeded.
|
||||
* During evaluation, VARE_UNDEFERR was set and there was an undefined
|
||||
* variable.
|
||||
* No error message has been printed yet.
|
||||
*
|
||||
* This should never happen since it is impossible to say which of
|
||||
* the variables was undefined. */
|
||||
VPE_UNDEF_SILENT = 0x0020,
|
||||
* Deprecated, migrate to VPE_UNDEF_MSG instead. */
|
||||
VPE_UNDEF_SILENT = 0x0004,
|
||||
|
||||
/* Parsing succeeded.
|
||||
* Evaluation failed.
|
||||
* During evaluation, VARE_UNDEFERR was set and there was an undefined
|
||||
* variable.
|
||||
* An error message has already been printed. */
|
||||
VPE_EVAL_MSG = 0x0100,
|
||||
VPE_UNDEF_MSG = VPE_UNDEF_SILENT | VPE_ANY_MSG,
|
||||
|
||||
/* Parsing succeeded.
|
||||
* Evaluation failed.
|
||||
* No error message has been printed yet.
|
||||
*
|
||||
* This should never happen since it is impossible to say where
|
||||
* exactly the evaluation error occurred. */
|
||||
VPE_EVAL_SILENT = 0x0200,
|
||||
* Deprecated, migrate to VPE_EVAL_MSG instead. */
|
||||
VPE_EVAL_SILENT = 0x0006,
|
||||
|
||||
/* See if a message has already been printed for this error. */
|
||||
VPE_ANY_MSG = VPE_PARSE_MSG | VPE_UNDEF_MSG | VPE_EVAL_MSG
|
||||
/* Parsing succeeded.
|
||||
* Evaluation failed.
|
||||
* An error message has already been printed. */
|
||||
VPE_EVAL_MSG = VPE_EVAL_SILENT | VPE_ANY_MSG,
|
||||
|
||||
/* The exact error handling status is not known yet.
|
||||
* Deprecated, migrate to VPE_OK or any VPE_*_MSG instead. */
|
||||
VPE_UNKNOWN = 0x0008
|
||||
} VarParseErrors;
|
||||
|
||||
void Var_Delete(const char *, GNode *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $ */
|
||||
/* $NetBSD: var.c,v 1.523 2020/09/21 05:28:26 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -121,7 +121,7 @@
|
||||
#include "metachar.h"
|
||||
|
||||
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.523 2020/09/21 05:28:26 rillig Exp $");
|
||||
|
||||
#define VAR_DEBUG_IF(cond, fmt, ...) \
|
||||
if (!(DEBUG(VAR) && (cond))) \
|
||||
@ -3368,7 +3368,7 @@ ValidShortVarname(char varname, const char *start)
|
||||
case '}':
|
||||
case ':':
|
||||
case '$':
|
||||
break;
|
||||
break; /* and continue below */
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
@ -3683,7 +3683,7 @@ Var_Parse(const char **pp, GNode *ctxt, VarEvalFlags eflags,
|
||||
free(v);
|
||||
}
|
||||
*out_val = nstr;
|
||||
return VPE_OK; /* TODO: may also be errors */
|
||||
return VPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Substitute for all variables in the given string in the given context.
|
||||
|
Loading…
Reference in New Issue
Block a user