Keep namespace clean
* libsieve/comparator.c, libsieve/prog.c, libsieve/require.c, libsieve/runtime.c, libsieve/sieve.h, libsieve/sieve.l, libsieve/sieve.y, libsieve/util.c: Prefix instr_ functions with mu_. (sieve_filename, sieve_line_num): Removed. Use new global mu_sieve_locus instead.
Showing
9 changed files
with
153 additions
and
138 deletions
1 | 2008-07-19 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | Keep namespace clean | ||
4 | |||
5 | * libsieve/comparator.c, libsieve/prog.c, libsieve/require.c, | ||
6 | libsieve/runtime.c, libsieve/sieve.h, libsieve/sieve.l, | ||
7 | libsieve/sieve.y, libsieve/util.c: Prefix instr_ functions with | ||
8 | mu_. | ||
9 | (sieve_filename, sieve_line_num): Removed. Use new global | ||
10 | mu_sieve_locus instead. | ||
11 | |||
1 | 2008-07-04 Sergey Poznyakoff <gray@gnu.org.ua> | 12 | 2008-07-04 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 13 | ||
3 | Fix converting RFC822 streams to messages. | 14 | Fix converting RFC822 streams to messages. | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, |
3 | 2005, 2007 Free Software Foundation, Inc. | 3 | 2005, 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -169,13 +169,11 @@ _regex_compile (void *item, void *data) | ... | @@ -169,13 +169,11 @@ _regex_compile (void *item, void *data) |
169 | if (errbuf) | 169 | if (errbuf) |
170 | { | 170 | { |
171 | regerror (rc, preg, errbuf, size); | 171 | regerror (rc, preg, errbuf, size); |
172 | sieve_compile_error (sieve_filename, sieve_line_num, | 172 | sieve_compile_error (&mu_sieve_locus, _("Regex error: %s"), errbuf); |
173 | _("Regex error: %s"), errbuf); | ||
174 | free (errbuf); | 173 | free (errbuf); |
175 | } | 174 | } |
176 | else | 175 | else |
177 | sieve_compile_error (sieve_filename, sieve_line_num, | 176 | sieve_compile_error (&mu_sieve_locus, _("Regex error")); |
178 | _("Regex error")); | ||
179 | return rc; | 177 | return rc; |
180 | } | 178 | } |
181 | 179 | ||
... | @@ -236,7 +234,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -236,7 +234,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
236 | { | 234 | { |
237 | if (match) | 235 | if (match) |
238 | { | 236 | { |
239 | sieve_compile_error (sieve_filename, sieve_line_num, | 237 | sieve_compile_error (&mu_sieve_locus, |
240 | _("match type specified twice in call to `%s'"), | 238 | _("match type specified twice in call to `%s'"), |
241 | name); | 239 | name); |
242 | err = 1; | 240 | err = 1; |
... | @@ -272,9 +270,11 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -272,9 +270,11 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
272 | 270 | ||
273 | if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric")) | 271 | if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric")) |
274 | { | 272 | { |
275 | sieve_compile_error (sieve_filename, sieve_line_num, | 273 | sieve_compile_error (&mu_sieve_locus, |
276 | /* TRANSLATORS: Do not translate ':count'. It is the name of a Sieve tag */ | 274 | /* TRANSLATORS: Do not translate ':count'. |
277 | _("comparator %s is incompatible with :count in call to `%s'"), | 275 | It is the name of a Sieve tag */ |
276 | _("comparator %s is incompatible with " | ||
277 | ":count in call to `%s'"), | ||
278 | comp->arg->v.string, | 278 | comp->arg->v.string, |
279 | name); | 279 | name); |
280 | return 1; | 280 | return 1; |
... | @@ -289,7 +289,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -289,7 +289,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
289 | mu_list_count (val->v.list, &count); | 289 | mu_list_count (val->v.list, &count); |
290 | if (count > 1) | 290 | if (count > 1) |
291 | { | 291 | { |
292 | sieve_compile_error (sieve_filename, sieve_line_num, | 292 | sieve_compile_error (&mu_sieve_locus, |
293 | _("second argument must be a list of one element")); | 293 | _("second argument must be a list of one element")); |
294 | return 1; | 294 | return 1; |
295 | } | 295 | } |
... | @@ -297,7 +297,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -297,7 +297,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
297 | count = strtoul (str, &str, 10); | 297 | count = strtoul (str, &str, 10); |
298 | if (*str) | 298 | if (*str) |
299 | { | 299 | { |
300 | sieve_compile_error (sieve_filename, sieve_line_num, | 300 | sieve_compile_error (&mu_sieve_locus, |
301 | _("second argument cannot be converted to number")); | 301 | _("second argument cannot be converted to number")); |
302 | return 1; | 302 | return 1; |
303 | } | 303 | } |
... | @@ -307,7 +307,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -307,7 +307,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
307 | 307 | ||
308 | if (mu_sieve_str_to_relcmp (str, NULL, NULL)) | 308 | if (mu_sieve_str_to_relcmp (str, NULL, NULL)) |
309 | { | 309 | { |
310 | sieve_compile_error (sieve_filename, sieve_line_num, | 310 | sieve_compile_error (&mu_sieve_locus, |
311 | _("invalid relational match `%s' in call to `%s'"), | 311 | _("invalid relational match `%s' in call to `%s'"), |
312 | str, name); | 312 | str, name); |
313 | return 1; | 313 | return 1; |
... | @@ -320,7 +320,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) | ... | @@ -320,7 +320,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) |
320 | compfun = mu_sieve_comparator_lookup (sieve_machine, compname, matchtype); | 320 | compfun = mu_sieve_comparator_lookup (sieve_machine, compname, matchtype); |
321 | if (!compfun) | 321 | if (!compfun) |
322 | { | 322 | { |
323 | sieve_compile_error (sieve_filename, sieve_line_num, | 323 | sieve_compile_error (&mu_sieve_locus, |
324 | _("comparator `%s' is incompatible with match type `%s' in call to `%s'"), | 324 | _("comparator `%s' is incompatible with match type `%s' in call to `%s'"), |
325 | compname, match ? match->tag : "is", name); | 325 | compname, match ? match->tag : "is", name); |
326 | return 1; | 326 | return 1; | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, |
3 | 2005, 2006, 2007 Free Software Foundation, Inc. | 3 | 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -36,8 +36,7 @@ sieve_code (sieve_op_t *op) | ... | @@ -36,8 +36,7 @@ sieve_code (sieve_op_t *op) |
36 | sizeof sieve_machine->prog[0]); | 36 | sizeof sieve_machine->prog[0]); |
37 | if (!newprog) | 37 | if (!newprog) |
38 | { | 38 | { |
39 | sieve_compile_error (sieve_filename, sieve_line_num, | 39 | sieve_compile_error (&mu_sieve_locus, _("out of memory!")); |
40 | _("out of memory!")); | ||
41 | return 1; | 40 | return 1; |
42 | } | 41 | } |
43 | sieve_machine->prog = newprog; | 42 | sieve_machine->prog = newprog; |
... | @@ -155,7 +154,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -155,7 +154,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
155 | 154 | ||
156 | if (rc) | 155 | if (rc) |
157 | { | 156 | { |
158 | sieve_compile_error (sieve_filename, sieve_line_num, | 157 | sieve_compile_error (&mu_sieve_locus, |
159 | _("cannot create iterator: %s"), | 158 | _("cannot create iterator: %s"), |
160 | mu_strerror (rc)); | 159 | mu_strerror (rc)); |
161 | return 1; | 160 | return 1; |
... | @@ -174,7 +173,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -174,7 +173,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
174 | mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf); | 173 | mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf); |
175 | if (!tag) | 174 | if (!tag) |
176 | { | 175 | { |
177 | sieve_compile_error (sieve_filename, sieve_line_num, | 176 | sieve_compile_error (&mu_sieve_locus, |
178 | _("invalid tag name `%s' for `%s'"), | 177 | _("invalid tag name `%s' for `%s'"), |
179 | val->v.string, reg->name); | 178 | val->v.string, reg->name); |
180 | err = 1; | 179 | err = 1; |
... | @@ -183,7 +182,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -183,7 +182,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
183 | 182 | ||
184 | if (!tag_list && (rc = mu_list_create (&tag_list))) | 183 | if (!tag_list && (rc = mu_list_create (&tag_list))) |
185 | { | 184 | { |
186 | sieve_compile_error (sieve_filename, sieve_line_num, | 185 | sieve_compile_error (&mu_sieve_locus, |
187 | _("cannot create tag list: %s"), | 186 | _("cannot create tag list: %s"), |
188 | mu_strerror (rc)); | 187 | mu_strerror (rc)); |
189 | err = 1; | 188 | err = 1; |
... | @@ -196,7 +195,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -196,7 +195,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
196 | mu_iterator_next (itr); | 195 | mu_iterator_next (itr); |
197 | if (mu_iterator_is_done (itr)) | 196 | if (mu_iterator_is_done (itr)) |
198 | { | 197 | { |
199 | sieve_compile_error (sieve_filename, sieve_line_num, | 198 | sieve_compile_error (&mu_sieve_locus, |
200 | _("required argument for tag %s is missing"), | 199 | _("required argument for tag %s is missing"), |
201 | tag->name); | 200 | tag->name); |
202 | err = 1; | 201 | err = 1; |
... | @@ -215,7 +214,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -215,7 +214,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
215 | { | 214 | { |
216 | if (!chk_list && (rc = mu_list_create (&chk_list))) | 215 | if (!chk_list && (rc = mu_list_create (&chk_list))) |
217 | { | 216 | { |
218 | sieve_compile_error (sieve_filename, sieve_line_num, | 217 | sieve_compile_error (&mu_sieve_locus, |
219 | _("cannot create check list: %s"), | 218 | _("cannot create check list: %s"), |
220 | mu_strerror (rc)); | 219 | mu_strerror (rc)); |
221 | err = 1; | 220 | err = 1; |
... | @@ -227,7 +226,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -227,7 +226,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
227 | } | 226 | } |
228 | else if (*exp_arg == SVT_VOID) | 227 | else if (*exp_arg == SVT_VOID) |
229 | { | 228 | { |
230 | sieve_compile_error (sieve_filename, sieve_line_num, | 229 | sieve_compile_error (&mu_sieve_locus, |
231 | _("too many arguments in call to `%s'"), | 230 | _("too many arguments in call to `%s'"), |
232 | reg->name); | 231 | reg->name); |
233 | err = 1; | 232 | err = 1; |
... | @@ -248,11 +247,11 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -248,11 +247,11 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
248 | } | 247 | } |
249 | else | 248 | else |
250 | { | 249 | { |
251 | sieve_compile_error (sieve_filename, sieve_line_num, | 250 | sieve_compile_error (&mu_sieve_locus, |
252 | _("type mismatch in argument %d to `%s'"), | 251 | _("type mismatch in argument %d to `%s'"), |
253 | exp_arg - reg->req_args + 1, | 252 | exp_arg - reg->req_args + 1, |
254 | reg->name); | 253 | reg->name); |
255 | sieve_compile_error (sieve_filename, sieve_line_num, | 254 | sieve_compile_error (&mu_sieve_locus, |
256 | _("expected %s but passed %s"), | 255 | _("expected %s but passed %s"), |
257 | mu_sieve_type_str (*exp_arg), | 256 | mu_sieve_type_str (*exp_arg), |
258 | mu_sieve_type_str (val->type)); | 257 | mu_sieve_type_str (val->type)); |
... | @@ -263,7 +262,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -263,7 +262,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
263 | 262 | ||
264 | if (!arg_list && (rc = mu_list_create (&arg_list))) | 263 | if (!arg_list && (rc = mu_list_create (&arg_list))) |
265 | { | 264 | { |
266 | sieve_compile_error (sieve_filename, sieve_line_num, | 265 | sieve_compile_error (&mu_sieve_locus, |
267 | _("cannot create arg list: %s"), | 266 | _("cannot create arg list: %s"), |
268 | mu_strerror (rc)); | 267 | mu_strerror (rc)); |
269 | err = 1; | 268 | err = 1; |
... | @@ -281,7 +280,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) | ... | @@ -281,7 +280,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) |
281 | { | 280 | { |
282 | if (*exp_arg != SVT_VOID) | 281 | if (*exp_arg != SVT_VOID) |
283 | { | 282 | { |
284 | sieve_compile_error (sieve_filename, sieve_line_num, | 283 | sieve_compile_error (&mu_sieve_locus, |
285 | _("too few arguments in call to `%s'"), | 284 | _("too few arguments in call to `%s'"), |
286 | reg->name); | 285 | reg->name); |
287 | err = 1; | 286 | err = 1; |
... | @@ -324,7 +323,7 @@ sieve_code_source (const char *name) | ... | @@ -324,7 +323,7 @@ sieve_code_source (const char *name) |
324 | mu_list_append (sieve_machine->source_list, s); | 323 | mu_list_append (sieve_machine->source_list, s); |
325 | } | 324 | } |
326 | 325 | ||
327 | return sieve_code_instr (instr_source) | 326 | return sieve_code_instr (_mu_sv_instr_source) |
328 | || sieve_code_string (s); | 327 | || sieve_code_string (s); |
329 | } | 328 | } |
330 | 329 | ||
... | @@ -334,7 +333,7 @@ sieve_code_line (size_t line) | ... | @@ -334,7 +333,7 @@ sieve_code_line (size_t line) |
334 | sieve_op_t op; | 333 | sieve_op_t op; |
335 | 334 | ||
336 | op.line = line; | 335 | op.line = line; |
337 | return sieve_code_instr (instr_line) | 336 | return sieve_code_instr (_mu_sv_instr_line) |
338 | || sieve_code (&op); | 337 | || sieve_code (&op); |
339 | } | 338 | } |
340 | 339 | ||
... | @@ -352,7 +351,7 @@ sieve_check_source_changed () | ... | @@ -352,7 +351,7 @@ sieve_check_source_changed () |
352 | if (sieve_source_changed) | 351 | if (sieve_source_changed) |
353 | { | 352 | { |
354 | sieve_source_changed = 0; | 353 | sieve_source_changed = 0; |
355 | return sieve_code_source (sieve_filename); | 354 | return sieve_code_source (mu_sieve_locus.source_file); |
356 | } | 355 | } |
357 | return 0; | 356 | return 0; |
358 | } | 357 | } |
... | @@ -361,8 +360,8 @@ int | ... | @@ -361,8 +360,8 @@ int |
361 | sieve_code_action (mu_sieve_register_t *reg, mu_list_t arglist) | 360 | sieve_code_action (mu_sieve_register_t *reg, mu_list_t arglist) |
362 | { | 361 | { |
363 | return sieve_check_source_changed () | 362 | return sieve_check_source_changed () |
364 | || sieve_code_line (sieve_line_num) | 363 | || sieve_code_line (mu_sieve_locus.source_line) |
365 | || sieve_code_instr (instr_action) | 364 | || sieve_code_instr (_mu_sv_instr_action) |
366 | || sieve_code_command (reg, arglist); | 365 | || sieve_code_command (reg, arglist); |
367 | } | 366 | } |
368 | 367 | ||
... | @@ -370,8 +369,8 @@ int | ... | @@ -370,8 +369,8 @@ int |
370 | sieve_code_test (mu_sieve_register_t *reg, mu_list_t arglist) | 369 | sieve_code_test (mu_sieve_register_t *reg, mu_list_t arglist) |
371 | { | 370 | { |
372 | return sieve_check_source_changed () | 371 | return sieve_check_source_changed () |
373 | || sieve_code_line (sieve_line_num) | 372 | || sieve_code_line (mu_sieve_locus.source_line) |
374 | || sieve_code_instr (instr_test) | 373 | || sieve_code_instr (_mu_sv_instr_test) |
375 | || sieve_code_command (reg, arglist); | 374 | || sieve_code_command (reg, arglist); |
376 | } | 375 | } |
377 | 376 | ||
... | @@ -382,12 +381,12 @@ sieve_code_anyof (size_t start) | ... | @@ -382,12 +381,12 @@ sieve_code_anyof (size_t start) |
382 | while (sieve_machine->prog[start+1].pc != 0) | 381 | while (sieve_machine->prog[start+1].pc != 0) |
383 | { | 382 | { |
384 | size_t next = sieve_machine->prog[start+1].pc; | 383 | size_t next = sieve_machine->prog[start+1].pc; |
385 | sieve_machine->prog[start].instr = instr_brnz; | 384 | sieve_machine->prog[start].instr = _mu_sv_instr_brnz; |
386 | sieve_machine->prog[start+1].pc = end - start - 2; | 385 | sieve_machine->prog[start+1].pc = end - start - 2; |
387 | start = next; | 386 | start = next; |
388 | } | 387 | } |
389 | sieve_machine->prog[start].instr = instr_nop; | 388 | sieve_machine->prog[start].instr = _mu_sv_instr_nop; |
390 | sieve_machine->prog[start+1].instr = instr_nop; | 389 | sieve_machine->prog[start+1].instr = _mu_sv_instr_nop; |
391 | } | 390 | } |
392 | 391 | ||
393 | void | 392 | void |
... | @@ -401,7 +400,7 @@ sieve_code_allof (size_t start) | ... | @@ -401,7 +400,7 @@ sieve_code_allof (size_t start) |
401 | sieve_machine->prog[start+1].pc = end - start - 2; | 400 | sieve_machine->prog[start+1].pc = end - start - 2; |
402 | start = next; | 401 | start = next; |
403 | } | 402 | } |
404 | sieve_machine->prog[start].instr = instr_nop; | 403 | sieve_machine->prog[start].instr = _mu_sv_instr_nop; |
405 | sieve_machine->prog[start+1].instr = instr_nop; | 404 | sieve_machine->prog[start+1].instr = _mu_sv_instr_nop; |
406 | } | 405 | } |
407 | 406 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, |
3 | 2005, 2006, 2007 Free Software Foundation, Inc. | 3 | 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -36,7 +36,7 @@ mu_sieve_require (mu_list_t slist) | ... | @@ -36,7 +36,7 @@ mu_sieve_require (mu_list_t slist) |
36 | status = mu_list_get_iterator (slist, &itr); | 36 | status = mu_list_get_iterator (slist, &itr); |
37 | if (status) | 37 | if (status) |
38 | { | 38 | { |
39 | sieve_compile_error (sieve_filename, sieve_line_num, | 39 | sieve_compile_error (&mu_sieve_locus, |
40 | _("cannot create iterator: %s"), | 40 | _("cannot create iterator: %s"), |
41 | mu_strerror (status)); | 41 | mu_strerror (status)); |
42 | return; | 42 | return; |
... | @@ -76,7 +76,7 @@ mu_sieve_require (mu_list_t slist) | ... | @@ -76,7 +76,7 @@ mu_sieve_require (mu_list_t slist) |
76 | 76 | ||
77 | if (reqfn (sieve_machine, name)) | 77 | if (reqfn (sieve_machine, name)) |
78 | { | 78 | { |
79 | sieve_compile_error (sieve_filename, sieve_line_num, | 79 | sieve_compile_error (&mu_sieve_locus, |
80 | _("source for the %s %s is not available"), | 80 | _("source for the %s %s is not available"), |
81 | text, | 81 | text, |
82 | name); | 82 | name); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, |
3 | 2007 Free Software Foundation, Inc. | 3 | 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -34,7 +34,7 @@ | ... | @@ -34,7 +34,7 @@ |
34 | #define INSTR_DISASS(m) ((m)->debug_level & MU_SIEVE_DEBUG_DISAS) | 34 | #define INSTR_DISASS(m) ((m)->debug_level & MU_SIEVE_DEBUG_DISAS) |
35 | 35 | ||
36 | void | 36 | void |
37 | instr_nop (mu_sieve_machine_t mach) | 37 | _mu_sv_instr_nop (mu_sieve_machine_t mach) |
38 | { | 38 | { |
39 | if (INSTR_DEBUG (mach)) | 39 | if (INSTR_DEBUG (mach)) |
40 | mu_sieve_debug (mach, "%4lu: NOP\n", | 40 | mu_sieve_debug (mach, "%4lu: NOP\n", |
... | @@ -42,7 +42,7 @@ instr_nop (mu_sieve_machine_t mach) | ... | @@ -42,7 +42,7 @@ instr_nop (mu_sieve_machine_t mach) |
42 | } | 42 | } |
43 | 43 | ||
44 | void | 44 | void |
45 | instr_source (mu_sieve_machine_t mach) | 45 | _mu_sv_instr_source (mu_sieve_machine_t mach) |
46 | { | 46 | { |
47 | mach->locus.source_file = SIEVE_ARG (mach, 0, string); | 47 | mach->locus.source_file = SIEVE_ARG (mach, 0, string); |
48 | if (INSTR_DEBUG (mach)) | 48 | if (INSTR_DEBUG (mach)) |
... | @@ -53,7 +53,7 @@ instr_source (mu_sieve_machine_t mach) | ... | @@ -53,7 +53,7 @@ instr_source (mu_sieve_machine_t mach) |
53 | } | 53 | } |
54 | 54 | ||
55 | void | 55 | void |
56 | instr_line (mu_sieve_machine_t mach) | 56 | _mu_sv_instr_line (mu_sieve_machine_t mach) |
57 | { | 57 | { |
58 | mach->locus.source_line = SIEVE_ARG (mach, 0, line); | 58 | mach->locus.source_line = SIEVE_ARG (mach, 0, line); |
59 | if (INSTR_DEBUG (mach)) | 59 | if (INSTR_DEBUG (mach)) |
... | @@ -88,7 +88,7 @@ instr_run (mu_sieve_machine_t mach) | ... | @@ -88,7 +88,7 @@ instr_run (mu_sieve_machine_t mach) |
88 | } | 88 | } |
89 | 89 | ||
90 | void | 90 | void |
91 | instr_action (mu_sieve_machine_t mach) | 91 | _mu_sv_instr_action (mu_sieve_machine_t mach) |
92 | { | 92 | { |
93 | mach->identifier = SIEVE_ARG (mach, 3, string); | 93 | mach->identifier = SIEVE_ARG (mach, 3, string); |
94 | if (INSTR_DEBUG (mach)) | 94 | if (INSTR_DEBUG (mach)) |
... | @@ -101,7 +101,7 @@ instr_action (mu_sieve_machine_t mach) | ... | @@ -101,7 +101,7 @@ instr_action (mu_sieve_machine_t mach) |
101 | } | 101 | } |
102 | 102 | ||
103 | void | 103 | void |
104 | instr_test (mu_sieve_machine_t mach) | 104 | _mu_sv_instr_test (mu_sieve_machine_t mach) |
105 | { | 105 | { |
106 | mach->identifier = SIEVE_ARG (mach, 3, string); | 106 | mach->identifier = SIEVE_ARG (mach, 3, string); |
107 | if (INSTR_DEBUG (mach)) | 107 | if (INSTR_DEBUG (mach)) |
... | @@ -113,7 +113,7 @@ instr_test (mu_sieve_machine_t mach) | ... | @@ -113,7 +113,7 @@ instr_test (mu_sieve_machine_t mach) |
113 | } | 113 | } |
114 | 114 | ||
115 | void | 115 | void |
116 | instr_push (mu_sieve_machine_t mach) | 116 | _mu_sv_instr_push (mu_sieve_machine_t mach) |
117 | { | 117 | { |
118 | if (INSTR_DEBUG (mach)) | 118 | if (INSTR_DEBUG (mach)) |
119 | { | 119 | { |
... | @@ -131,7 +131,7 @@ instr_push (mu_sieve_machine_t mach) | ... | @@ -131,7 +131,7 @@ instr_push (mu_sieve_machine_t mach) |
131 | } | 131 | } |
132 | 132 | ||
133 | void | 133 | void |
134 | instr_pop (mu_sieve_machine_t mach) | 134 | _mu_sv_instr_pop (mu_sieve_machine_t mach) |
135 | { | 135 | { |
136 | if (INSTR_DEBUG (mach)) | 136 | if (INSTR_DEBUG (mach)) |
137 | { | 137 | { |
... | @@ -150,7 +150,7 @@ instr_pop (mu_sieve_machine_t mach) | ... | @@ -150,7 +150,7 @@ instr_pop (mu_sieve_machine_t mach) |
150 | } | 150 | } |
151 | 151 | ||
152 | void | 152 | void |
153 | instr_not (mu_sieve_machine_t mach) | 153 | _mu_sv_instr_not (mu_sieve_machine_t mach) |
154 | { | 154 | { |
155 | if (INSTR_DEBUG (mach)) | 155 | if (INSTR_DEBUG (mach)) |
156 | { | 156 | { |
... | @@ -162,7 +162,7 @@ instr_not (mu_sieve_machine_t mach) | ... | @@ -162,7 +162,7 @@ instr_not (mu_sieve_machine_t mach) |
162 | } | 162 | } |
163 | 163 | ||
164 | void | 164 | void |
165 | instr_branch (mu_sieve_machine_t mach) | 165 | _mu_sv_instr_branch (mu_sieve_machine_t mach) |
166 | { | 166 | { |
167 | long num = SIEVE_ARG (mach, 0, number); | 167 | long num = SIEVE_ARG (mach, 0, number); |
168 | 168 | ||
... | @@ -180,7 +180,7 @@ instr_branch (mu_sieve_machine_t mach) | ... | @@ -180,7 +180,7 @@ instr_branch (mu_sieve_machine_t mach) |
180 | } | 180 | } |
181 | 181 | ||
182 | void | 182 | void |
183 | instr_brz (mu_sieve_machine_t mach) | 183 | _mu_sv_instr_brz (mu_sieve_machine_t mach) |
184 | { | 184 | { |
185 | long num = SIEVE_ARG (mach, 0, number); | 185 | long num = SIEVE_ARG (mach, 0, number); |
186 | SIEVE_ADJUST (mach, 1); | 186 | SIEVE_ADJUST (mach, 1); |
... | @@ -199,7 +199,7 @@ instr_brz (mu_sieve_machine_t mach) | ... | @@ -199,7 +199,7 @@ instr_brz (mu_sieve_machine_t mach) |
199 | } | 199 | } |
200 | 200 | ||
201 | void | 201 | void |
202 | instr_brnz (mu_sieve_machine_t mach) | 202 | _mu_sv_instr_brnz (mu_sieve_machine_t mach) |
203 | { | 203 | { |
204 | long num = SIEVE_ARG (mach, 0, number); | 204 | long num = SIEVE_ARG (mach, 0, number); |
205 | SIEVE_ADJUST (mach, 1); | 205 | SIEVE_ADJUST (mach, 1); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006, |
3 | 2007 Free Software Foundation, Inc. | 3 | 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -80,29 +80,32 @@ struct sieve_machine { | ... | @@ -80,29 +80,32 @@ struct sieve_machine { |
80 | void *data; | 80 | void *data; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | extern char *sieve_filename; | 83 | extern mu_sieve_locus_t mu_sieve_locus; |
84 | extern int sieve_line_num; | ||
85 | extern mu_sieve_machine_t sieve_machine; | 84 | extern mu_sieve_machine_t sieve_machine; |
86 | extern int sieve_error_count; | 85 | extern int sieve_error_count; |
87 | 86 | ||
88 | #define TAG_COMPFUN "__compfun__" | 87 | #define TAG_COMPFUN "__compfun__" |
89 | #define TAG_RELFUN "__relfun__" | 88 | #define TAG_RELFUN "__relfun__" |
90 | 89 | ||
91 | void sieve_compile_error (const char *filename, int linenum, | 90 | void sieve_compile_error (mu_sieve_locus_t *locus, |
92 | const char *fmt, ...) MU_PRINTFLIKE(3,4); | 91 | const char *fmt, ...) MU_PRINTFLIKE(2,3); |
93 | void sieve_debug_internal (mu_sieve_printf_t printer, void *data, | 92 | void sieve_debug_internal (mu_sieve_printf_t printer, void *data, |
94 | const char *fmt, ...) MU_PRINTFLIKE(3,4); | 93 | const char *fmt, ...) MU_PRINTFLIKE(3,4); |
95 | void sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer, | 94 | void sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer, |
96 | void *data); | 95 | void *data); |
97 | void sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer, void *data); | 96 | void sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer, |
98 | void sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, void *data); | 97 | void *data); |
98 | void sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, | ||
99 | void *data); | ||
99 | 100 | ||
100 | int _sieve_default_error_printer (void *data, const char *fmt, va_list ap); | 101 | int _sieve_default_error_printer (void *data, const char *fmt, va_list ap); |
101 | int _sieve_default_parse_error (void *unused, const char *filename, int lineno, | 102 | int _sieve_default_parse_error (void *unused, |
103 | const char *filename, int lineno, | ||
102 | const char *fmt, va_list ap); | 104 | const char *fmt, va_list ap); |
103 | 105 | ||
104 | int sieve_lex_begin (const char *name); | 106 | int sieve_lex_begin (const char *name); |
105 | int sieve_lex_begin_string (const char *buf, int bufsize, const char *fname, int line); | 107 | int sieve_lex_begin_string (const char *buf, int bufsize, |
108 | const char *fname, int line); | ||
106 | void sieve_lex_finish (void); | 109 | void sieve_lex_finish (void); |
107 | int mu_sieve_yyerror (char *s); | 110 | int mu_sieve_yyerror (char *s); |
108 | int mu_sieve_yylex (); | 111 | int mu_sieve_yylex (); |
... | @@ -124,17 +127,17 @@ int sieve_code_source (const char *name); | ... | @@ -124,17 +127,17 @@ int sieve_code_source (const char *name); |
124 | int sieve_code_line (size_t line); | 127 | int sieve_code_line (size_t line); |
125 | void sieve_change_source (void); | 128 | void sieve_change_source (void); |
126 | 129 | ||
127 | void instr_action (mu_sieve_machine_t mach); | 130 | void _mu_sv_instr_action (mu_sieve_machine_t mach); |
128 | void instr_test (mu_sieve_machine_t mach); | 131 | void _mu_sv_instr_test (mu_sieve_machine_t mach); |
129 | void instr_push (mu_sieve_machine_t mach); | 132 | void _mu_sv_instr_push (mu_sieve_machine_t mach); |
130 | void instr_pop (mu_sieve_machine_t mach); | 133 | void _mu_sv_instr_pop (mu_sieve_machine_t mach); |
131 | void instr_not (mu_sieve_machine_t mach); | 134 | void _mu_sv_instr_not (mu_sieve_machine_t mach); |
132 | void instr_branch (mu_sieve_machine_t mach); | 135 | void _mu_sv_instr_branch (mu_sieve_machine_t mach); |
133 | void instr_brz (mu_sieve_machine_t mach); | 136 | void _mu_sv_instr_brz (mu_sieve_machine_t mach); |
134 | void instr_brnz (mu_sieve_machine_t mach); | 137 | void _mu_sv_instr_brnz (mu_sieve_machine_t mach); |
135 | void instr_nop (mu_sieve_machine_t mach); | 138 | void _mu_sv_instr_nop (mu_sieve_machine_t mach); |
136 | void instr_source (mu_sieve_machine_t mach); | 139 | void _mu_sv_instr_source (mu_sieve_machine_t mach); |
137 | void instr_line (mu_sieve_machine_t mach); | 140 | void _mu_sv_instr_line (mu_sieve_machine_t mach); |
138 | 141 | ||
139 | int sieve_mark_deleted (mu_message_t msg, int deleted); | 142 | int sieve_mark_deleted (mu_message_t msg, int deleted); |
140 | 143 | ... | ... |
1 | %{ | 1 | %{ |
2 | /* GNU Mailutils -- a suite of utilities for electronic mail | 2 | /* GNU Mailutils -- a suite of utilities for electronic mail |
3 | Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, | 3 | Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, |
4 | 2007 Free Software Foundation, Inc. | 4 | 2007, 2008 Free Software Foundation, Inc. |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Lesser General Public | 7 | modify it under the terms of the GNU Lesser General Public |
... | @@ -34,8 +34,7 @@ | ... | @@ -34,8 +34,7 @@ |
34 | #include <sieve.h> | 34 | #include <sieve.h> |
35 | #include <sieve-gram.h> | 35 | #include <sieve-gram.h> |
36 | 36 | ||
37 | char *sieve_filename; | 37 | mu_sieve_locus_t mu_sieve_locus; |
38 | int sieve_line_num; | ||
39 | ino_t sieve_source_inode; | 38 | ino_t sieve_source_inode; |
40 | 39 | ||
41 | static mu_list_t string_list; | 40 | static mu_list_t string_list; |
... | @@ -93,8 +92,7 @@ fillbuf(char *buf, int max_size) | ... | @@ -93,8 +92,7 @@ fillbuf(char *buf, int max_size) |
93 | 92 | ||
94 | struct buffer_ctx { | 93 | struct buffer_ctx { |
95 | struct buffer_ctx *prev; | 94 | struct buffer_ctx *prev; |
96 | char *filename; | 95 | mu_sieve_locus_t locus; |
97 | int line; | ||
98 | ino_t i_node; | 96 | ino_t i_node; |
99 | FILE *yyin; | 97 | FILE *yyin; |
100 | LEX_BUFFER_STATE state; | 98 | LEX_BUFFER_STATE state; |
... | @@ -126,12 +124,12 @@ push_source (const char *name) | ... | @@ -126,12 +124,12 @@ push_source (const char *name) |
126 | 124 | ||
127 | if (stat (name, &st)) | 125 | if (stat (name, &st)) |
128 | { | 126 | { |
129 | sieve_compile_error (sieve_filename, sieve_line_num, | 127 | sieve_compile_error (&mu_sieve_locus, |
130 | _("cannot stat `%s': %s"), name, strerror (errno)); | 128 | _("cannot stat `%s': %s"), name, strerror (errno)); |
131 | return 1; | 129 | return 1; |
132 | } | 130 | } |
133 | 131 | ||
134 | if (sieve_filename && st.st_ino == sieve_source_inode) | 132 | if (mu_sieve_locus.source_file && st.st_ino == sieve_source_inode) |
135 | { | 133 | { |
136 | yyerror (_("recursive inclusion")); | 134 | yyerror (_("recursive inclusion")); |
137 | return 1; | 135 | return 1; |
... | @@ -140,11 +138,11 @@ push_source (const char *name) | ... | @@ -140,11 +138,11 @@ push_source (const char *name) |
140 | { | 138 | { |
141 | yyerror (_("recursive inclusion")); | 139 | yyerror (_("recursive inclusion")); |
142 | if (ctx->prev) | 140 | if (ctx->prev) |
143 | sieve_compile_error (ctx->prev->filename, ctx->prev->line, | 141 | sieve_compile_error (&ctx->prev->locus, |
144 | _("`%s' already included here"), | 142 | _("`%s' already included here"), |
145 | name); | 143 | name); |
146 | else | 144 | else |
147 | sieve_compile_error (sieve_filename, sieve_line_num, | 145 | sieve_compile_error (&mu_sieve_locus, |
148 | _("`%s' already included at top level"), | 146 | _("`%s' already included at top level"), |
149 | name); | 147 | name); |
150 | return 1; | 148 | return 1; |
... | @@ -153,17 +151,16 @@ push_source (const char *name) | ... | @@ -153,17 +151,16 @@ push_source (const char *name) |
153 | fp = fopen (name, "r"); | 151 | fp = fopen (name, "r"); |
154 | if (!fp) | 152 | if (!fp) |
155 | { | 153 | { |
156 | sieve_compile_error (sieve_filename, sieve_line_num, | 154 | sieve_compile_error (&mu_sieve_locus, |
157 | _("cannot open `%s': %s"), name, strerror (errno)); | 155 | _("cannot open `%s': %s"), name, strerror (errno)); |
158 | return 1; | 156 | return 1; |
159 | } | 157 | } |
160 | 158 | ||
161 | /* Push current context */ | 159 | /* Push current context */ |
162 | if (sieve_filename) | 160 | if (mu_sieve_locus.source_file) |
163 | { | 161 | { |
164 | ctx = mu_sieve_alloc (sizeof (*ctx)); | 162 | ctx = mu_sieve_alloc (sizeof (*ctx)); |
165 | ctx->filename = sieve_filename; | 163 | ctx->locus = mu_sieve_locus; |
166 | ctx->line = sieve_line_num; | ||
167 | ctx->i_node = sieve_source_inode; | 164 | ctx->i_node = sieve_source_inode; |
168 | ctx->yyin = yyin; | 165 | ctx->yyin = yyin; |
169 | ctx->prev = context_stack; | 166 | ctx->prev = context_stack; |
... | @@ -176,8 +173,8 @@ push_source (const char *name) | ... | @@ -176,8 +173,8 @@ push_source (const char *name) |
176 | else | 173 | else |
177 | yyrestart (fp); | 174 | yyrestart (fp); |
178 | 175 | ||
179 | sieve_filename = strdup (name); | 176 | mu_sieve_locus.source_file = strdup (name); |
180 | sieve_line_num = 1; | 177 | mu_sieve_locus.source_line = 1; |
181 | sieve_source_inode = st.st_ino; | 178 | sieve_source_inode = st.st_ino; |
182 | 179 | ||
183 | sieve_change_source (); | 180 | sieve_change_source (); |
... | @@ -193,18 +190,17 @@ pop_source () | ... | @@ -193,18 +190,17 @@ pop_source () |
193 | if (yyin) | 190 | if (yyin) |
194 | fclose (yyin); | 191 | fclose (yyin); |
195 | 192 | ||
196 | if (sieve_filename) | 193 | if (mu_sieve_locus.source_file) |
197 | free (sieve_filename); | 194 | free (mu_sieve_locus.source_file); |
198 | if (!context_stack) | 195 | if (!context_stack) |
199 | { | 196 | { |
200 | yyin = NULL; | 197 | yyin = NULL; |
201 | sieve_filename = NULL; | 198 | mu_sieve_locus.source_file = NULL; |
202 | return 1; | 199 | return 1; |
203 | } | 200 | } |
204 | /* Restore previous context */ | 201 | /* Restore previous context */ |
205 | sieve_filename = context_stack->filename; | 202 | mu_sieve_locus = context_stack->locus; |
206 | sieve_line_num = context_stack->line + 1; /* #include rule did not increment | 203 | mu_sieve_locus.source_line++; /* #include rule did not increment it */ |
207 | it */ | ||
208 | sieve_source_inode = context_stack->i_node; | 204 | sieve_source_inode = context_stack->i_node; |
209 | RESTORE_BUFFER_STATE (context_stack->state); | 205 | RESTORE_BUFFER_STATE (context_stack->state); |
210 | ctx = context_stack->prev; | 206 | ctx = context_stack->prev; |
... | @@ -227,13 +223,13 @@ SIZESUF [kKmMgG] | ... | @@ -227,13 +223,13 @@ SIZESUF [kKmMgG] |
227 | "/*" BEGIN(COMMENT); | 223 | "/*" BEGIN(COMMENT); |
228 | <COMMENT>[^*\n]* /* eat anything that's not a '*' */ | 224 | <COMMENT>[^*\n]* /* eat anything that's not a '*' */ |
229 | <COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ | 225 | <COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ |
230 | <COMMENT>\n ++sieve_line_num; | 226 | <COMMENT>\n ++mu_sieve_locus.source_line; |
231 | <COMMENT>"*"+"/" BEGIN(INITIAL); | 227 | <COMMENT>"*"+"/" BEGIN(INITIAL); |
232 | /* Preprocessor directives (an extension) */ | 228 | /* Preprocessor directives (an extension) */ |
233 | #[ \t]*include.*\n { sieve_include (); } | 229 | #[ \t]*include.*\n { sieve_include (); } |
234 | #[ \t]*searchpath.*\n { sieve_searchpath (); } | 230 | #[ \t]*searchpath.*\n { sieve_searchpath (); } |
235 | /* End-of-line comments */ | 231 | /* End-of-line comments */ |
236 | #.*\n { sieve_line_num++; } | 232 | #.*\n { mu_sieve_locus.source_line++; } |
237 | #.* /* end-of-file comment */; | 233 | #.* /* end-of-file comment */; |
238 | /* Reserved words */ | 234 | /* Reserved words */ |
239 | require return REQUIRE; | 235 | require return REQUIRE; |
... | @@ -262,21 +258,25 @@ not return NOT; | ... | @@ -262,21 +258,25 @@ not return NOT; |
262 | line_finish (); | 258 | line_finish (); |
263 | return STRING; } | 259 | return STRING; } |
264 | /* Multiline strings */ | 260 | /* Multiline strings */ |
265 | text:-?[ \t]*#.*\n { BEGIN(ML); multiline_begin (); sieve_line_num++; } | 261 | text:-?[ \t]*#.*\n { BEGIN(ML); |
266 | text:-?[ \t]*\n { BEGIN(ML); multiline_begin (); sieve_line_num++; } | 262 | multiline_begin (); |
263 | mu_sieve_locus.source_line++; } | ||
264 | text:-?[ \t]*\n { BEGIN(ML); | ||
265 | multiline_begin (); | ||
266 | mu_sieve_locus.source_line++; } | ||
267 | text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML); multiline_begin (); | 267 | text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML); multiline_begin (); |
268 | sieve_line_num++; } | 268 | mu_sieve_locus.source_line++; } |
269 | text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin (); | 269 | text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin (); |
270 | sieve_line_num++; } | 270 | mu_sieve_locus.source_line++; } |
271 | <ML>#[ \t]*include.*\n { if (multiline_delimiter[0] == '\\') | 271 | <ML>#[ \t]*include.*\n { if (multiline_delimiter[0] == '\\') |
272 | { | 272 | { |
273 | sieve_line_num++; | 273 | mu_sieve_locus.source_line++; |
274 | multiline_add (NULL); | 274 | multiline_add (NULL); |
275 | } | 275 | } |
276 | else | 276 | else |
277 | sieve_include (); } | 277 | sieve_include (); } |
278 | <ML>.*\n { char *p = multiline_strip_tabs (yytext); | 278 | <ML>.*\n { char *p = multiline_strip_tabs (yytext); |
279 | sieve_line_num++; | 279 | mu_sieve_locus.source_line++; |
280 | 280 | ||
281 | if (strncmp (p, multiline_delimiter, strlen (multiline_delimiter)) | 281 | if (strncmp (p, multiline_delimiter, strlen (multiline_delimiter)) |
282 | == 0 | 282 | == 0 |
... | @@ -291,7 +291,7 @@ text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin (); | ... | @@ -291,7 +291,7 @@ text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin (); |
291 | multiline_add (NULL); } | 291 | multiline_add (NULL); } |
292 | {WS} ; | 292 | {WS} ; |
293 | /* Other tokens */ | 293 | /* Other tokens */ |
294 | \n { sieve_line_num++; } | 294 | \n { mu_sieve_locus.source_line++; } |
295 | . return yytext[0]; | 295 | . return yytext[0]; |
296 | 296 | ||
297 | %% | 297 | %% |
... | @@ -361,7 +361,7 @@ _try_include (void *item, void *data) | ... | @@ -361,7 +361,7 @@ _try_include (void *item, void *data) |
361 | return 0; | 361 | return 0; |
362 | } | 362 | } |
363 | 363 | ||
364 | void | 364 | static void |
365 | sieve_include () | 365 | sieve_include () |
366 | { | 366 | { |
367 | char *p, *endp = yytext + yyleng, *name; | 367 | char *p, *endp = yytext + yyleng, *name; |
... | @@ -392,7 +392,7 @@ sieve_include () | ... | @@ -392,7 +392,7 @@ sieve_include () |
392 | free (name); | 392 | free (name); |
393 | } | 393 | } |
394 | 394 | ||
395 | void | 395 | static void |
396 | sieve_searchpath () | 396 | sieve_searchpath () |
397 | { | 397 | { |
398 | int append = 0; | 398 | int append = 0; |
... | @@ -431,8 +431,8 @@ sieve_lex_begin_string (const char *buf, int bufsize, | ... | @@ -431,8 +431,8 @@ sieve_lex_begin_string (const char *buf, int bufsize, |
431 | 431 | ||
432 | input_string_ptr = buf; | 432 | input_string_ptr = buf; |
433 | input_string_level = bufsize; | 433 | input_string_level = bufsize; |
434 | sieve_filename = strdup (fname); | 434 | mu_sieve_locus.source_file = strdup (fname); |
435 | sieve_line_num = line; | 435 | mu_sieve_locus.source_line = line; |
436 | sieve_source_inode = 0; | 436 | sieve_source_inode = 0; |
437 | 437 | ||
438 | sieve_change_source (); | 438 | sieve_change_source (); |
... | @@ -446,7 +446,7 @@ sieve_lex_finish () | ... | @@ -446,7 +446,7 @@ sieve_lex_finish () |
446 | ; | 446 | ; |
447 | } | 447 | } |
448 | 448 | ||
449 | int | 449 | static int |
450 | number () | 450 | number () |
451 | { | 451 | { |
452 | char *p; | 452 | char *p; |
... | @@ -470,7 +470,7 @@ number () | ... | @@ -470,7 +470,7 @@ number () |
470 | return NUMBER; | 470 | return NUMBER; |
471 | } | 471 | } |
472 | 472 | ||
473 | int | 473 | static int |
474 | string () | 474 | string () |
475 | { | 475 | { |
476 | yylval.string = mu_sieve_malloc (sieve_machine, yyleng - 1); | 476 | yylval.string = mu_sieve_malloc (sieve_machine, yyleng - 1); |
... | @@ -479,7 +479,7 @@ string () | ... | @@ -479,7 +479,7 @@ string () |
479 | return STRING; | 479 | return STRING; |
480 | } | 480 | } |
481 | 481 | ||
482 | int | 482 | static int |
483 | isemptystr (char *text) | 483 | isemptystr (char *text) |
484 | { | 484 | { |
485 | for (; *text && isspace (*text); text++) | 485 | for (; *text && isspace (*text); text++) |
... | @@ -487,7 +487,7 @@ isemptystr (char *text) | ... | @@ -487,7 +487,7 @@ isemptystr (char *text) |
487 | return *text == 0; | 487 | return *text == 0; |
488 | } | 488 | } |
489 | 489 | ||
490 | char * | 490 | static char * |
491 | multiline_strip_tabs (char *text) | 491 | multiline_strip_tabs (char *text) |
492 | { | 492 | { |
493 | if (strip_tabs) | 493 | if (strip_tabs) |
... | @@ -496,7 +496,7 @@ multiline_strip_tabs (char *text) | ... | @@ -496,7 +496,7 @@ multiline_strip_tabs (char *text) |
496 | return text; | 496 | return text; |
497 | } | 497 | } |
498 | 498 | ||
499 | void | 499 | static void |
500 | line_add (char *text, size_t len) | 500 | line_add (char *text, size_t len) |
501 | { | 501 | { |
502 | char *s; | 502 | char *s; |
... | @@ -514,7 +514,7 @@ line_add (char *text, size_t len) | ... | @@ -514,7 +514,7 @@ line_add (char *text, size_t len) |
514 | mu_list_append (string_list, s); | 514 | mu_list_append (string_list, s); |
515 | } | 515 | } |
516 | 516 | ||
517 | void | 517 | static void |
518 | multiline_add (char *s) | 518 | multiline_add (char *s) |
519 | { | 519 | { |
520 | if (!s) | 520 | if (!s) |
... | @@ -522,7 +522,7 @@ multiline_add (char *s) | ... | @@ -522,7 +522,7 @@ multiline_add (char *s) |
522 | line_add (s, 0); | 522 | line_add (s, 0); |
523 | } | 523 | } |
524 | 524 | ||
525 | void | 525 | static void |
526 | line_begin () | 526 | line_begin () |
527 | { | 527 | { |
528 | int status; | 528 | int status; |
... | @@ -532,13 +532,13 @@ line_begin () | ... | @@ -532,13 +532,13 @@ line_begin () |
532 | status = mu_list_create (&string_list); | 532 | status = mu_list_create (&string_list); |
533 | if (status) | 533 | if (status) |
534 | { | 534 | { |
535 | sieve_compile_error (sieve_filename, sieve_line_num, | 535 | sieve_compile_error (&mu_sieve_locus, |
536 | "mu_list_create: %s", mu_strerror (status)); | 536 | "mu_list_create: %s", mu_strerror (status)); |
537 | exit (1); | 537 | exit (1); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | void | 541 | static void |
542 | multiline_begin () | 542 | multiline_begin () |
543 | { | 543 | { |
544 | char *p = yytext + 5; /* past the text: keyword */ | 544 | char *p = yytext + 5; /* past the text: keyword */ |
... | @@ -578,7 +578,7 @@ multiline_begin () | ... | @@ -578,7 +578,7 @@ multiline_begin () |
578 | line_begin (); | 578 | line_begin (); |
579 | } | 579 | } |
580 | 580 | ||
581 | void | 581 | static void |
582 | line_finish () | 582 | line_finish () |
583 | { | 583 | { |
584 | mu_iterator_t itr; | 584 | mu_iterator_t itr; |
... | @@ -612,13 +612,13 @@ line_finish () | ... | @@ -612,13 +612,13 @@ line_finish () |
612 | mu_list_destroy (&string_list); | 612 | mu_list_destroy (&string_list); |
613 | } | 613 | } |
614 | 614 | ||
615 | void | 615 | static void |
616 | multiline_finish () | 616 | multiline_finish () |
617 | { | 617 | { |
618 | line_finish (); | 618 | line_finish (); |
619 | } | 619 | } |
620 | 620 | ||
621 | void | 621 | static void |
622 | ident (const char *text) | 622 | ident (const char *text) |
623 | { | 623 | { |
624 | yylval.string = strdup (text); | 624 | yylval.string = strdup (text); |
... | @@ -630,7 +630,7 @@ ident (const char *text) | ... | @@ -630,7 +630,7 @@ ident (const char *text) |
630 | } | 630 | } |
631 | 631 | ||
632 | /* Escapes the last character from yytext */ | 632 | /* Escapes the last character from yytext */ |
633 | char * | 633 | static char * |
634 | str_unescape (char *text, size_t len) | 634 | str_unescape (char *text, size_t len) |
635 | { | 635 | { |
636 | char *str = mu_sieve_alloc (len); | 636 | char *str = mu_sieve_alloc (len); | ... | ... |
1 | %{ | 1 | %{ |
2 | /* GNU Mailutils -- a suite of utilities for electronic mail | 2 | /* GNU Mailutils -- a suite of utilities for electronic mail |
3 | Copyright (C) 1999, 2000, 2001, 2002, 2005, | 3 | Copyright (C) 1999, 2000, 2001, 2002, 2005, |
4 | 2006, 2007 Free Software Foundation, Inc. | 4 | 2006, 2007, 2008 Free Software Foundation, Inc. |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Lesser General Public | 7 | modify it under the terms of the GNU Lesser General Public |
... | @@ -154,7 +154,7 @@ elsif_branch : elsif begin cond block | ... | @@ -154,7 +154,7 @@ elsif_branch : elsif begin cond block |
154 | 154 | ||
155 | elsif : ELSIF | 155 | elsif : ELSIF |
156 | { | 156 | { |
157 | sieve_code_instr (instr_branch); | 157 | sieve_code_instr (_mu_sv_instr_branch); |
158 | $$ = sieve_machine->pc; | 158 | $$ = sieve_machine->pc; |
159 | sieve_code_number (0); | 159 | sieve_code_number (0); |
160 | } | 160 | } |
... | @@ -162,7 +162,7 @@ elsif : ELSIF | ... | @@ -162,7 +162,7 @@ elsif : ELSIF |
162 | 162 | ||
163 | else : ELSE | 163 | else : ELSE |
164 | { | 164 | { |
165 | sieve_code_instr (instr_branch); | 165 | sieve_code_instr (_mu_sv_instr_branch); |
166 | $$ = sieve_machine->pc; | 166 | $$ = sieve_machine->pc; |
167 | sieve_code_number (0); | 167 | sieve_code_number (0); |
168 | } | 168 | } |
... | @@ -177,7 +177,7 @@ block : '{' list '}' | ... | @@ -177,7 +177,7 @@ block : '{' list '}' |
177 | testlist : cond_expr | 177 | testlist : cond_expr |
178 | { | 178 | { |
179 | $$.start = $$.end = sieve_machine->pc; | 179 | $$.start = $$.end = sieve_machine->pc; |
180 | if (sieve_code_instr (instr_brz) | 180 | if (sieve_code_instr (_mu_sv_instr_brz) |
181 | || sieve_code_number (0)) | 181 | || sieve_code_number (0)) |
182 | YYERROR; | 182 | YYERROR; |
183 | } | 183 | } |
... | @@ -185,7 +185,7 @@ testlist : cond_expr | ... | @@ -185,7 +185,7 @@ testlist : cond_expr |
185 | { | 185 | { |
186 | sieve_machine->prog[$1.end+1].pc = sieve_machine->pc; | 186 | sieve_machine->prog[$1.end+1].pc = sieve_machine->pc; |
187 | $1.end = sieve_machine->pc; | 187 | $1.end = sieve_machine->pc; |
188 | if (sieve_code_instr (instr_brz) | 188 | if (sieve_code_instr (_mu_sv_instr_brz) |
189 | || sieve_code_number (0)) | 189 | || sieve_code_number (0)) |
190 | YYERROR; | 190 | YYERROR; |
191 | $$ = $1; | 191 | $$ = $1; |
... | @@ -194,7 +194,7 @@ testlist : cond_expr | ... | @@ -194,7 +194,7 @@ testlist : cond_expr |
194 | 194 | ||
195 | cond : cond_expr | 195 | cond : cond_expr |
196 | { | 196 | { |
197 | sieve_code_instr (instr_brz); | 197 | sieve_code_instr (_mu_sv_instr_brz); |
198 | $$ = sieve_machine->pc; | 198 | $$ = sieve_machine->pc; |
199 | sieve_code_number (0); | 199 | sieve_code_number (0); |
200 | } | 200 | } |
... | @@ -212,7 +212,7 @@ cond_expr : test | ... | @@ -212,7 +212,7 @@ cond_expr : test |
212 | } | 212 | } |
213 | | NOT cond_expr | 213 | | NOT cond_expr |
214 | { | 214 | { |
215 | if (sieve_code_instr (instr_not)) | 215 | if (sieve_code_instr (_mu_sv_instr_not)) |
216 | YYERROR; | 216 | YYERROR; |
217 | } | 217 | } |
218 | ; | 218 | ; |
... | @@ -230,11 +230,11 @@ test : command | ... | @@ -230,11 +230,11 @@ test : command |
230 | $$ = sieve_machine->pc; | 230 | $$ = sieve_machine->pc; |
231 | 231 | ||
232 | if (!reg) | 232 | if (!reg) |
233 | sieve_compile_error (sieve_filename, sieve_line_num, | 233 | sieve_compile_error (&mu_sieve_locus, |
234 | _("unknown test: %s"), | 234 | _("unknown test: %s"), |
235 | $1.ident); | 235 | $1.ident); |
236 | else if (!reg->required) | 236 | else if (!reg->required) |
237 | sieve_compile_error (sieve_filename, sieve_line_num, | 237 | sieve_compile_error (&mu_sieve_locus, |
238 | _("test `%s' has not been required"), | 238 | _("test `%s' has not been required"), |
239 | $1.ident); | 239 | $1.ident); |
240 | else if (sieve_code_test (reg, $1.args)) | 240 | else if (sieve_code_test (reg, $1.args)) |
... | @@ -256,11 +256,11 @@ action : command | ... | @@ -256,11 +256,11 @@ action : command |
256 | 256 | ||
257 | $$ = sieve_machine->pc; | 257 | $$ = sieve_machine->pc; |
258 | if (!reg) | 258 | if (!reg) |
259 | sieve_compile_error (sieve_filename, sieve_line_num, | 259 | sieve_compile_error (&mu_sieve_locus, |
260 | _("unknown action: %s"), | 260 | _("unknown action: %s"), |
261 | $1.ident); | 261 | $1.ident); |
262 | else if (!reg->required) | 262 | else if (!reg->required) |
263 | sieve_compile_error (sieve_filename, sieve_line_num, | 263 | sieve_compile_error (&mu_sieve_locus, |
264 | _("action `%s' has not been required"), | 264 | _("action `%s' has not been required"), |
265 | $1.ident); | 265 | $1.ident); |
266 | else if (sieve_code_action (reg, $1.args)) | 266 | else if (sieve_code_action (reg, $1.args)) |
... | @@ -340,7 +340,7 @@ slist : STRING | ... | @@ -340,7 +340,7 @@ slist : STRING |
340 | int | 340 | int |
341 | yyerror (char *s) | 341 | yyerror (char *s) |
342 | { | 342 | { |
343 | sieve_compile_error (sieve_filename, sieve_line_num, "%s", s); | 343 | sieve_compile_error (&mu_sieve_locus, "%s", s); |
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
346 | 346 | ||
... | @@ -630,7 +630,8 @@ mu_sieve_compile (mu_sieve_machine_t mach, const char *name) | ... | @@ -630,7 +630,8 @@ mu_sieve_compile (mu_sieve_machine_t mach, const char *name) |
630 | 630 | ||
631 | int | 631 | int |
632 | mu_sieve_compile_buffer (mu_sieve_machine_t mach, | 632 | mu_sieve_compile_buffer (mu_sieve_machine_t mach, |
633 | const char *buf, int bufsize, const char *fname, int line) | 633 | const char *buf, int bufsize, |
634 | const char *fname, int line) | ||
634 | { | 635 | { |
635 | int rc; | 636 | int rc; |
636 | 637 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, |
3 | 2006, 2007 Free Software Foundation, Inc. | 3 | 2006, 2007, 2008 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -173,8 +173,7 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data) | ... | @@ -173,8 +173,7 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data) |
173 | break; | 173 | break; |
174 | 174 | ||
175 | default: | 175 | default: |
176 | sieve_compile_error (sieve_filename, sieve_line_num, | 176 | sieve_compile_error (&mu_sieve_locus, _("invalid data type")); |
177 | _("invalid data type")); | ||
178 | abort (); | 177 | abort (); |
179 | } | 178 | } |
180 | return val; | 179 | return val; |
... | @@ -189,13 +188,15 @@ mu_sieve_value_get (mu_list_t vlist, size_t index) | ... | @@ -189,13 +188,15 @@ mu_sieve_value_get (mu_list_t vlist, size_t index) |
189 | } | 188 | } |
190 | 189 | ||
191 | void | 190 | void |
192 | sieve_compile_error (const char *filename, int linenum, const char *fmt, ...) | 191 | sieve_compile_error (mu_sieve_locus_t *ploc, const char *fmt, ...) |
193 | { | 192 | { |
194 | va_list ap; | 193 | va_list ap; |
195 | 194 | ||
196 | va_start (ap, fmt); | 195 | va_start (ap, fmt); |
197 | sieve_error_count++; | 196 | sieve_error_count++; |
198 | sieve_machine->parse_error_printer (sieve_machine->data, filename, linenum, | 197 | sieve_machine->parse_error_printer (sieve_machine->data, |
198 | ploc->source_file, | ||
199 | ploc->source_line, | ||
199 | fmt, ap); | 200 | fmt, ap); |
200 | va_end (ap); | 201 | va_end (ap); |
201 | } | 202 | } | ... | ... |
-
Please register or sign in to post a comment