mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Rewrite code to avoid need to pass address of "mentioned" variable.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
All checks were successful
Remind unit tests / tests (push) Successful in 30s
This commit is contained in:
29
src/dorem.c
29
src/dorem.c
@@ -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...");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user