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; ...@@ -32,7 +32,6 @@ static struct mu_sieve_node *sieve_tree;
32 32
33 static struct mu_sieve_node *node_alloc (enum mu_sieve_node_type, 33 static struct mu_sieve_node *node_alloc (enum mu_sieve_node_type,
34 struct mu_locus_range *); 34 struct mu_locus_range *);
35 static void cond_join (struct mu_sieve_node *node);
36 35
37 #define YYLLOC_DEFAULT(Current, Rhs, N) \ 36 #define YYLLOC_DEFAULT(Current, Rhs, N) \
38 do \ 37 do \
...@@ -158,17 +157,13 @@ statement : REQUIRE stringorlist ';' ...@@ -158,17 +157,13 @@ statement : REQUIRE stringorlist ';'
158 157
159 else_part : maybe_elsif 158 else_part : maybe_elsif
160 { 159 {
161 cond_join ($1.head);
162 $$ = $1.head; 160 $$ = $1.head;
163 } 161 }
164 | maybe_elsif ELSE block 162 | maybe_elsif ELSE block
165 { 163 {
166 $3->prev = $1.tail; 164 if ($1.tail)
167 if ($1.head)
168 { 165 {
169 $1.tail->next = $3; 166 $1.tail->v.cond.iffalse = $3;
170 $1.tail = $3;
171 cond_join ($1.head);
172 $$ = $1.head; 167 $$ = $1.head;
173 } 168 }
174 else 169 else
...@@ -183,6 +178,8 @@ maybe_elsif : /* empty */ ...@@ -183,6 +178,8 @@ maybe_elsif : /* empty */
183 | elsif_branch 178 | elsif_branch
184 ; 179 ;
185 180
181 /* elsif branches form a singly-linked version of node_list. Nodes in
182 this list are linked by v.cond.iffalse pointer */
186 elsif_branch : ELSIF cond block 183 elsif_branch : ELSIF cond block
187 { 184 {
188 struct mu_sieve_node *node = 185 struct mu_sieve_node *node =
...@@ -199,10 +196,10 @@ elsif_branch : ELSIF cond block ...@@ -199,10 +196,10 @@ elsif_branch : ELSIF cond block
199 node->v.cond.expr = $3; 196 node->v.cond.expr = $3;
200 node->v.cond.iftrue = $4; 197 node->v.cond.iftrue = $4;
201 node->v.cond.iffalse = NULL; 198 node->v.cond.iffalse = NULL;
202 199
203 node->prev = $1.tail; 200 $1.tail->v.cond.iffalse = node;
204 $1.tail->next = node;
205 $1.tail = node; 201 $1.tail = node;
202
206 $$ = $1; 203 $$ = $1;
207 } 204 }
208 ; 205 ;
...@@ -405,18 +402,6 @@ yyerror (const char *s) ...@@ -405,18 +402,6 @@ yyerror (const char *s)
405 mu_i_sv_error (mu_sieve_machine); 402 mu_i_sv_error (mu_sieve_machine);
406 return 0; 403 return 0;
407 } 404 }
408
409 static void
410 cond_join (struct mu_sieve_node *node)
411 {
412 while (node && node->type == mu_sieve_node_cond)
413 {
414 struct mu_sieve_node *next = node->next;
415 node->prev = node->next = NULL;
416 node->v.cond.iffalse = next;
417 node = next;
418 }
419 }
420 405
421 static struct mu_sieve_node * 406 static struct mu_sieve_node *
422 node_alloc (enum mu_sieve_node_type type, struct mu_locus_range *lr) 407 node_alloc (enum mu_sieve_node_type type, struct mu_locus_range *lr)
......
...@@ -485,6 +485,7 @@ main (int argc, char *argv[]) ...@@ -485,6 +485,7 @@ main (int argc, char *argv[])
485 return EX_SOFTWARE; 485 return EX_SOFTWARE;
486 } 486 }
487 487
488 sieve_setenv ("location=MS", mach);
488 sieve_setenv ("phase=post", mach); 489 sieve_setenv ("phase=post", mach);
489 mu_list_foreach (env_list, sieve_setenv, mach); 490 mu_list_foreach (env_list, sieve_setenv, mach);
490 mu_list_destroy (&env_list); 491 mu_list_destroy (&env_list);
......