diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-11-26 08:01:13 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-11-26 08:01:13 +0200 |
commit | 56217f1e53ebd0527b0fa1457c0b214d0ea76fd6 (patch) | |
tree | 477a9da1ab9f00c1a47cec6e5c1f17215fe98135 | |
parent | f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4 (diff) | |
download | mailutils-56217f1e53ebd0527b0fa1457c0b214d0ea76fd6.tar.gz mailutils-56217f1e53ebd0527b0fa1457c0b214d0ea76fd6.tar.bz2 |
Minor fixes
* libmu_sieve/sieve-priv.h (sieve_op_t) <unum>: New field.
* libmu_sieve/sieve.l: Leave one string interpreter slot.
m--------- | gint | 0 | ||||
-rw-r--r-- | libmu_sieve/sieve-priv.h | 1 | ||||
-rw-r--r-- | libmu_sieve/sieve.l | 48 |
3 files changed, 18 insertions, 31 deletions
diff --git a/gint b/gint -Subproject fd86bf7d44b0c970771830692ae7491447ebe8b +Subproject 42f4712085b40173eaea58e14b1a579291a6fe3 diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h index 8aa403098..6c622550c 100644 --- a/libmu_sieve/sieve-priv.h +++ b/libmu_sieve/sieve-priv.h @@ -35,6 +35,7 @@ typedef union size_t line; int inum; char *string; + unsigned unum; } sieve_op_t; struct mu_locus_range diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l index f04d219c9..43edd6a79 100644 --- a/libmu_sieve/sieve.l +++ b/libmu_sieve/sieve.l @@ -642,46 +642,32 @@ str_unescape (char *text, size_t len) return str; } -enum - { - interp_encoded_character, - interp_variable - }; - -#define MAXINTERP (interp_variable+1) -mu_i_sv_interp_t interpreter[MAXINTERP]; +static mu_i_sv_interp_t string_interpreter; static void line_finish (void) { - int i; char *str; mu_opool_append_char (mu_sieve_machine->string_pool, 0); str = mu_opool_finish (mu_sieve_machine->string_pool, NULL); - for (i = 0; i < MAXINTERP; i++) + if (string_interpreter) { - if (interpreter[i]) + char *exp; + int rc = mu_i_sv_string_expand (str, string_interpreter, NULL, &exp); + if (rc == 0) + { + mu_opool_free (mu_sieve_machine->string_pool, str); + mu_opool_appendz (mu_sieve_machine->string_pool, exp); + mu_opool_append_char (mu_sieve_machine->string_pool, 0); + free (exp); + str = mu_opool_finish (mu_sieve_machine->string_pool, NULL); + } + else if (rc != MU_ERR_CANCELED) { - char *exp; - int rc = mu_i_sv_string_expand (str, interpreter[i], NULL, &exp); - if (rc == 0) - { - mu_opool_free (mu_sieve_machine->string_pool, str); - mu_opool_appendz (mu_sieve_machine->string_pool, exp); - mu_opool_append_char (mu_sieve_machine->string_pool, 0); - free (exp); - str = mu_opool_finish (mu_sieve_machine->string_pool, NULL); - } - else if (rc == MU_ERR_CANCELED) - continue; - else - { - mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus, - _("error expandind string: %s"), - mu_strerror (rc)); - break; - } + mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus, + _("error expandind string: %s"), + mu_strerror (rc)); } } yylval.string = str; @@ -691,6 +677,6 @@ int mu_sieve_require_encoded_character (mu_sieve_machine_t mach, const char *name) { - interpreter[interp_encoded_character] = mu_i_sv_expand_encoded_char; + string_interpreter = mu_i_sv_expand_encoded_char; return 0; } |