mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add "n" debugging flag to diagnose non-constant expressions.
This commit is contained in:
@@ -638,6 +638,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
|
||||
strtolower(trig->omitfunc);
|
||||
/* An OMITFUNC counts as a nonconst_expr! */
|
||||
s->expr_happened = 1;
|
||||
nonconst_debug(s->nonconst_expr, "OMITFUNC counts as a non-constant expression");
|
||||
s->nonconst_expr = 1;
|
||||
DBufFree(&buf);
|
||||
break;
|
||||
@@ -1059,6 +1060,7 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
|
||||
FromDSE(DSEToday - tok.val, &y, &m, &d);
|
||||
/* Don't purge reminders with a relative scanfrom */
|
||||
s->expr_happened = 1;
|
||||
nonconst_debug(s->nonconst_expr, "Relative SCANFROM counts as a non-constant expression");
|
||||
s->nonconst_expr = 1;
|
||||
break;
|
||||
|
||||
|
||||
@@ -854,6 +854,7 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
|
||||
case N_SHORT_VAR:
|
||||
/* Global var? Return it and note non-constant expression */
|
||||
nonconst_debug(*nonconst, "Global variable `%s' makes expression non-constant", node->u.name);
|
||||
*nonconst = 1;
|
||||
r = get_var(node, ans);
|
||||
DBG(debug_evaluation(ans, r, "%s", node->u.name));
|
||||
@@ -861,6 +862,7 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
|
||||
case N_VARIABLE:
|
||||
/* Global var? Return it and note non-constant expression */
|
||||
nonconst_debug(*nonconst, "Global variable `%s' makes expression non-constant", node->u.value.v.str);
|
||||
*nonconst = 1;
|
||||
r = get_var(node, ans);
|
||||
DBG(debug_evaluation(ans, r, "%s", node->u.value.v.str));
|
||||
@@ -874,6 +876,7 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
|
||||
case N_SHORT_SYSVAR:
|
||||
/* System var? Return it and note non-constant expression */
|
||||
nonconst_debug(*nonconst, "System variable `$%s' makes expression non-constant", node->u.name);
|
||||
*nonconst = 1;
|
||||
r = get_sysvar(node, ans);
|
||||
DBG(debug_evaluation(ans, r, "$%s", node->u.name));
|
||||
@@ -881,6 +884,7 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
|
||||
case N_SYSVAR:
|
||||
/* System var? Return it and note non-constant expression */
|
||||
nonconst_debug(*nonconst, "System variable `$%s' makes expression non-constant", node->u.value.v.str);
|
||||
*nonconst = 1;
|
||||
r = get_sysvar(node, ans);
|
||||
DBG(debug_evaluation(ans, r, "$%s", node->u.value.v.str));
|
||||
@@ -889,8 +893,9 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
case N_BUILTIN_FUNC:
|
||||
/* Built-in function? Evaluate and note non-constant where applicable */
|
||||
if (!node->u.builtin_func->is_constant) {
|
||||
*nonconst = 1;
|
||||
nonconst_debug(*nonconst, "Non-constant builtin function `%s' makes expression non-constnat", node->u.builtin_func->name);
|
||||
}
|
||||
*nonconst = 1;
|
||||
return eval_builtin(node, locals, ans, nonconst);
|
||||
|
||||
case N_USER_FUNC:
|
||||
|
||||
@@ -635,7 +635,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
while (*arg) {
|
||||
switch(*arg++) {
|
||||
case 's': case 'S': DebugFlag |= DB_PARSE_EXPR; break;
|
||||
case 'h': case 'H': DebugFlag |= DB_HASHSTATS; break;
|
||||
case 'h': case 'H': DebugFlag |= DB_HASHSTATS; break;
|
||||
case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break;
|
||||
case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break;
|
||||
case 't': case 'T': DebugFlag |= DB_PRTTRIG; break;
|
||||
@@ -643,6 +643,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
case 'l': case 'L': DebugFlag |= DB_PRTLINE; break;
|
||||
case 'f': case 'F': DebugFlag |= DB_TRACE_FILES; break;
|
||||
case 'q': case 'Q': DebugFlag |= DB_TRANSLATE; break;
|
||||
case 'n': case 'N': DebugFlag |= DB_NONCONST; break;
|
||||
default:
|
||||
fprintf(ErrFp, GetErr(M_BAD_DB_FLAG), *(arg-1));
|
||||
fprintf(ErrFp, "\n");
|
||||
|
||||
@@ -1380,6 +1380,12 @@ int DoDebug(ParsePtr p)
|
||||
if (val) DebugFlag |= DB_TRACE_FILES;
|
||||
else DebugFlag &= ~DB_TRACE_FILES;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
if (val) DebugFlag |= DB_NONCONST;
|
||||
else DebugFlag &= ~DB_NONCONST;
|
||||
break;
|
||||
default:
|
||||
Wprint(GetErr(M_BAD_DB_FLAG), ch);
|
||||
break;
|
||||
|
||||
@@ -290,3 +290,5 @@ int GetMoonrise(int dse);
|
||||
int GetMoonset(int dse);
|
||||
int GetMoonrise_angle(int dse);
|
||||
int GetMoonset_angle(int dse);
|
||||
#define nonconst_debug(nc, ...) do { if ((DebugFlag & DB_NONCONST) && !nc) { Wprint(__VA_ARGS__); } } while(0)
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
|
||||
#define DB_PARSE_EXPR 0x040
|
||||
#define DB_HASHSTATS 0x080
|
||||
#define DB_TRANSLATE 0x100
|
||||
#define DB_NONCONST 0x200
|
||||
|
||||
/* Enumeration of the tokens */
|
||||
enum TokTypes
|
||||
|
||||
Reference in New Issue
Block a user