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
Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
......
......@@ -35,6 +35,7 @@ typedef union
size_t line;
int inum;
char *string;
unsigned unum;
} sieve_op_t;
struct mu_locus_range
......
......@@ -642,29 +642,19 @@ 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 (interpreter[i])
if (string_interpreter)
{
char *exp;
int rc = mu_i_sv_string_expand (str, interpreter[i], NULL, &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);
......@@ -673,15 +663,11 @@ line_finish (void)
free (exp);
str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
}
else if (rc == MU_ERR_CANCELED)
continue;
else
else if (rc != MU_ERR_CANCELED)
{
mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
_("error expandind string: %s"),
mu_strerror (rc));
break;
}
}
}
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;
}
......