Commit 56217f1e 56217f1e53ebd0527b0fa1457c0b214d0ea76fd6 by Sergey Poznyakoff

Minor fixes

* libmu_sieve/sieve-priv.h (sieve_op_t) <unum>: New field.
* libmu_sieve/sieve.l: Leave one string interpreter slot.
1 parent f5a1ff9b
gint @ 42f47120
1 Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1 1 Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
......
...@@ -35,6 +35,7 @@ typedef union ...@@ -35,6 +35,7 @@ typedef union
35 size_t line; 35 size_t line;
36 int inum; 36 int inum;
37 char *string; 37 char *string;
38 unsigned unum;
38 } sieve_op_t; 39 } sieve_op_t;
39 40
40 struct mu_locus_range 41 struct mu_locus_range
......
...@@ -642,46 +642,32 @@ str_unescape (char *text, size_t len) ...@@ -642,46 +642,32 @@ str_unescape (char *text, size_t len)
642 return str; 642 return str;
643 } 643 }
644 644
645 enum 645 static mu_i_sv_interp_t string_interpreter;
646 {
647 interp_encoded_character,
648 interp_variable
649 };
650
651 #define MAXINTERP (interp_variable+1)
652 mu_i_sv_interp_t interpreter[MAXINTERP];
653 646
654 static void 647 static void
655 line_finish (void) 648 line_finish (void)
656 { 649 {
657 int i;
658 char *str; 650 char *str;
659 651
660 mu_opool_append_char (mu_sieve_machine->string_pool, 0); 652 mu_opool_append_char (mu_sieve_machine->string_pool, 0);
661 str = mu_opool_finish (mu_sieve_machine->string_pool, NULL); 653 str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
662 for (i = 0; i < MAXINTERP; i++) 654 if (string_interpreter)
663 { 655 {
664 if (interpreter[i]) 656 char *exp;
657 int rc = mu_i_sv_string_expand (str, string_interpreter, NULL, &exp);
658 if (rc == 0)
659 {
660 mu_opool_free (mu_sieve_machine->string_pool, str);
661 mu_opool_appendz (mu_sieve_machine->string_pool, exp);
662 mu_opool_append_char (mu_sieve_machine->string_pool, 0);
663 free (exp);
664 str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
665 }
666 else if (rc != MU_ERR_CANCELED)
665 { 667 {
666 char *exp; 668 mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
667 int rc = mu_i_sv_string_expand (str, interpreter[i], NULL, &exp); 669 _("error expandind string: %s"),
668 if (rc == 0) 670 mu_strerror (rc));
669 {
670 mu_opool_free (mu_sieve_machine->string_pool, str);
671 mu_opool_appendz (mu_sieve_machine->string_pool, exp);
672 mu_opool_append_char (mu_sieve_machine->string_pool, 0);
673 free (exp);
674 str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
675 }
676 else if (rc == MU_ERR_CANCELED)
677 continue;
678 else
679 {
680 mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
681 _("error expandind string: %s"),
682 mu_strerror (rc));
683 break;
684 }
685 } 671 }
686 } 672 }
687 yylval.string = str; 673 yylval.string = str;
...@@ -691,6 +677,6 @@ int ...@@ -691,6 +677,6 @@ int
691 mu_sieve_require_encoded_character (mu_sieve_machine_t mach, 677 mu_sieve_require_encoded_character (mu_sieve_machine_t mach,
692 const char *name) 678 const char *name)
693 { 679 {
694 interpreter[interp_encoded_character] = mu_i_sv_expand_encoded_char; 680 string_interpreter = mu_i_sv_expand_encoded_char;
695 return 0; 681 return 0;
696 } 682 }
......