Use "is_constant" attribute for Var to be consistent with UserFunc.

This commit is contained in:
Dianne Skoll
2025-05-24 10:10:44 -04:00
parent c5bc459dd9
commit af2daa7a87
3 changed files with 7 additions and 7 deletions

View File

@@ -426,7 +426,7 @@ get_var(expr_node *node, Value *ans, int *nonconst)
return E_NOSUCH_VAR;
}
v->used_since_set = 1;
if (v->nonconstant) {
if (!v->is_constant) {
nonconst_debug(*nonconst, tr("Global variable `%s' makes expression non-constant"), str);
*nonconst = 1;
}

View File

@@ -105,7 +105,7 @@ typedef struct var {
struct hash_link link;
char name[VAR_NAME_LEN+1];
char preserve;
char nonconstant;
char is_constant;
char used_since_set;
Value v;
} Var;

View File

@@ -599,7 +599,7 @@ int SetVar(char const *str, Value const *val, int nonconst_expr)
DestroyValue(v->v);
v->v = *val;
v->nonconstant = nonconst_expr;
v->is_constant = ! nonconst_expr;
v->used_since_set = 0;
return OK;
}
@@ -653,8 +653,8 @@ int DoSet (Parser *p)
}
var = FindVar(DBufValue(&buf), 0);
if (var) {
nonconst_debug(var->nonconstant, tr("Potential variable assignment considered non-constant because of context"));
var->nonconstant = 1;
nonconst_debug(!var->is_constant, tr("Potential variable assignment considered non-constant because of context"));
var->is_constant = 0;
}
DBufFree(&buf);
return OK;
@@ -787,7 +787,7 @@ int DoDump(ParsePtr p)
fprintf(ErrFp, "%s ", v->name);
PrintValue(&(v->v), ErrFp);
if (dump_constness) {
if (!v->nonconstant) {
if (v->is_constant) {
fprintf(ErrFp, " <const>");
}
}
@@ -822,7 +822,7 @@ void DumpVarTable(int dump_constness)
fprintf(ErrFp, "%s ", v->name);
PrintValue(&(v->v), ErrFp);
if (dump_constness) {
if (!v->nonconstant) {
if (v->is_constant) {
fprintf(ErrFp, " <const>");
}
}