Rewrite code to avoid need to pass address of "mentioned" variable.
All checks were successful
Remind unit tests / tests (push) Successful in 30s

This commit is contained in:
Dianne Skoll
2024-08-27 11:33:41 -04:00
parent 8616236b3c
commit c397cc06da

View File

@@ -32,20 +32,19 @@ static int ParseUntil (ParsePtr s, Trigger *t, int type);
static int ShouldTriggerBasedOnWarn (Trigger *t, int dse, int *err);
static int ComputeTrigDuration(TimeTrig *t);
static void
ensure_satnode_mentions_trigdate_aux(expr_node *node, int *mentioned)
static int
ensure_satnode_mentions_trigdate_aux(expr_node *node)
{
char const *name;
expr_node *other;
if (!node || *mentioned) {
return;
if (!node) {
return 0;
}
if (node->type == N_BUILTIN_FUNC) {
name = node->u.builtin_func->name;
if (!strcmp(name, "trigdate") ||
!strcmp(name, "trigdatetime")) {
*mentioned = 1;
return;
return 1;
}
} else if (node->type == N_SHORT_SYSVAR || node->type == N_SYSVAR) {
if (node->type == N_SHORT_SYSVAR) {
@@ -57,31 +56,29 @@ ensure_satnode_mentions_trigdate_aux(expr_node *node, int *mentioned)
!StrCmpi(name, "Tm") ||
!StrCmpi(name, "Tw") ||
!StrCmpi(name, "Ty")) {
*mentioned = 1;
return;
return 1;
}
}
ensure_satnode_mentions_trigdate_aux(node->child, mentioned);
if (*mentioned) {
return;
if (ensure_satnode_mentions_trigdate_aux(node->child)) {
return 1;
}
other = node->sibling;
while (other) {
ensure_satnode_mentions_trigdate_aux(other, mentioned);
if (*mentioned) {
return;
if (ensure_satnode_mentions_trigdate_aux(other)) {
return 1;
}
other = other->sibling;
}
return 0;
}
static void ensure_satnode_mentions_trigdate(expr_node *node)
{
int mentioned = 0;
int mentioned;
if (node->type == N_CONSTANT) {
return;
}
ensure_satnode_mentions_trigdate_aux(node, &mentioned);
mentioned = ensure_satnode_mentions_trigdate_aux(node);
if (!mentioned) {
Wprint("SATISFY: expression has no reference to trigdate() or $T...");
}