Commit bf77e1c1 bf77e1c15d4a4356d1f8a0ffbcaeb42ca6903203 by Sergey Poznyakoff

(sieve_value_create): Bugfix.

(sieve_error): Prepend action or test identifier to the diagnostic
message.
(sieve_arg_error): New function.
1 parent 7a53eb35
...@@ -159,6 +159,7 @@ sieve_value_create (sieve_data_type type, void *data) ...@@ -159,6 +159,7 @@ sieve_value_create (sieve_data_type type, void *data)
159 case SVT_VALUE_LIST: 159 case SVT_VALUE_LIST:
160 case SVT_STRING_LIST: 160 case SVT_STRING_LIST:
161 val->v.list = data; 161 val->v.list = data;
162 break;
162 163
163 case SVT_TAG: 164 case SVT_TAG:
164 case SVT_IDENT: 165 case SVT_IDENT:
...@@ -201,13 +202,35 @@ void ...@@ -201,13 +202,35 @@ void
201 sieve_error (sieve_machine_t mach, const char *fmt, ...) 202 sieve_error (sieve_machine_t mach, const char *fmt, ...)
202 { 203 {
203 va_list ap; 204 va_list ap;
204 205
205 va_start (ap, fmt); 206 va_start (ap, fmt);
206 mach->error_printer (mach->data, fmt, ap); 207 if (mach->identifier)
208 {
209 char *new_fmt = malloc (strlen (mach->identifier) + 2 +
210 strlen (fmt) + 1);
211 if (new_fmt)
212 {
213 strcpy (new_fmt, mach->identifier);
214 strcat (new_fmt, ": ");
215 strcat (new_fmt, fmt);
216 mach->error_printer (mach->data, new_fmt, ap);
217 free (new_fmt);
218 }
219 else
220 mach->error_printer (mach->data, fmt, ap);
221 }
222 else
223 mach->error_printer (mach->data, fmt, ap);
207 va_end (ap); 224 va_end (ap);
208 } 225 }
209 226
210 void 227 void
228 sieve_arg_error (sieve_machine_t mach, int n)
229 {
230 sieve_error (mach, _("cannot retrieve argument %d"), n);
231 }
232
233 void
211 sieve_debug_internal (sieve_printf_t printer, void *data, const char *fmt, ...) 234 sieve_debug_internal (sieve_printf_t printer, void *data, const char *fmt, ...)
212 { 235 {
213 va_list ap; 236 va_list ap;
......