Commit 5d4b76c5 5d4b76c56c558bfbd968e95ec57ff7055417d158 by Sergey Poznyakoff

Bugfixes

* libmu_sieve/sieve.y: Fix compilation of chained elsif conditions.
* sieve/sieve.c: Define the location environment item.
1 parent a1612b96
......@@ -32,7 +32,6 @@ static struct mu_sieve_node *sieve_tree;
static struct mu_sieve_node *node_alloc (enum mu_sieve_node_type,
struct mu_locus_range *);
static void cond_join (struct mu_sieve_node *node);
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
......@@ -158,17 +157,13 @@ statement : REQUIRE stringorlist ';'
else_part : maybe_elsif
{
cond_join ($1.head);
$$ = $1.head;
}
| maybe_elsif ELSE block
{
$3->prev = $1.tail;
if ($1.head)
if ($1.tail)
{
$1.tail->next = $3;
$1.tail = $3;
cond_join ($1.head);
$1.tail->v.cond.iffalse = $3;
$$ = $1.head;
}
else
......@@ -183,6 +178,8 @@ maybe_elsif : /* empty */
| elsif_branch
;
/* elsif branches form a singly-linked version of node_list. Nodes in
this list are linked by v.cond.iffalse pointer */
elsif_branch : ELSIF cond block
{
struct mu_sieve_node *node =
......@@ -200,9 +197,9 @@ elsif_branch : ELSIF cond block
node->v.cond.iftrue = $4;
node->v.cond.iffalse = NULL;
node->prev = $1.tail;
$1.tail->next = node;
$1.tail->v.cond.iffalse = node;
$1.tail = node;
$$ = $1;
}
;
......@@ -406,18 +403,6 @@ yyerror (const char *s)
return 0;
}
static void
cond_join (struct mu_sieve_node *node)
{
while (node && node->type == mu_sieve_node_cond)
{
struct mu_sieve_node *next = node->next;
node->prev = node->next = NULL;
node->v.cond.iffalse = next;
node = next;
}
}
static struct mu_sieve_node *
node_alloc (enum mu_sieve_node_type type, struct mu_locus_range *lr)
{
......
......@@ -485,6 +485,7 @@ main (int argc, char *argv[])
return EX_SOFTWARE;
}
sieve_setenv ("location=MS", mach);
sieve_setenv ("phase=post", mach);
mu_list_foreach (env_list, sieve_setenv, mach);
mu_list_destroy (&env_list);
......