mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 14:59:20 +02:00
Add warning if we SET a variable that has already been set, but not used (if -du debug flag is set)
This commit is contained in:
14
src/var.c
14
src/var.c
@@ -560,6 +560,8 @@ Var *FindVar(char const *str, int create)
|
||||
v->v.type = INT_TYPE;
|
||||
v->v.v.val = 0;
|
||||
v->preserve = 0;
|
||||
v->filename = GetCurrentFilename();
|
||||
v->lineno = LineNo;
|
||||
StrnCpy(v->name, str, VAR_NAME_LEN);
|
||||
|
||||
hash_table_insert(&VHashTbl, v);
|
||||
@@ -593,8 +595,18 @@ int DeleteVar(char const *str)
|
||||
/***************************************************************/
|
||||
int SetVar(char const *str, Value const *val, int nonconst_expr)
|
||||
{
|
||||
Var *v = FindVar(str, 1);
|
||||
Var *v = NULL;
|
||||
|
||||
if (DebugFlag & DB_UNUSED_VARS) {
|
||||
v = FindVar(str, 0);
|
||||
if (v && !(v->used_since_set)) {
|
||||
Eprint(tr("Variable %s re-SET without being used (original SET was at %s:%d)"), str, v->filename, v->lineno);
|
||||
}
|
||||
}
|
||||
|
||||
if (!v) {
|
||||
v = FindVar(str, 1);
|
||||
}
|
||||
if (!v) return E_NO_MEM; /* Only way FindVar can fail */
|
||||
|
||||
DestroyValue(v->v);
|
||||
|
||||
@@ -24978,6 +24978,7 @@ TRANSLATE "Undefined %s function: `%s'" ""
|
||||
TRANSLATE "Unmatched PUSH-OMIT-CONTEXT at %s(%d)" ""
|
||||
TRANSLATE "Unrecognized command; interpreting as REM" ""
|
||||
TRANSLATE "User function `%s' defined in non-constant context makes expression non-constant" ""
|
||||
TRANSLATE "Variable %s re-SET without being used (original SET was at %s:%d)" ""
|
||||
TRANSLATE "Variable assignment considered non-constant because of context" ""
|
||||
TRANSLATE "Warning: Function name `%s...' truncated to `%s'" ""
|
||||
TRANSLATE "Warning: OMIT is ignored if you use OMITFUNC" ""
|
||||
|
||||
Reference in New Issue
Block a user