Commit 1d15947e 1d15947e4ba98beb52065c9601896bb24a0ddb86 by Sergey Poznyakoff

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.
1 parent 347deef4
2008-07-19 Sergey Poznyakoff <gray@gnu.org.ua>
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.
2008-07-04 Sergey Poznyakoff <gray@gnu.org.ua>
Fix converting RFC822 streams to messages.
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2007 Free Software Foundation, Inc.
2005, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -169,13 +169,11 @@ _regex_compile (void *item, void *data)
if (errbuf)
{
regerror (rc, preg, errbuf, size);
sieve_compile_error (sieve_filename, sieve_line_num,
_("Regex error: %s"), errbuf);
sieve_compile_error (&mu_sieve_locus, _("Regex error: %s"), errbuf);
free (errbuf);
}
else
sieve_compile_error (sieve_filename, sieve_line_num,
_("Regex error"));
sieve_compile_error (&mu_sieve_locus, _("Regex error"));
return rc;
}
......@@ -236,7 +234,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
{
if (match)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("match type specified twice in call to `%s'"),
name);
err = 1;
......@@ -272,9 +270,11 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric"))
{
sieve_compile_error (sieve_filename, sieve_line_num,
/* TRANSLATORS: Do not translate ':count'. It is the name of a Sieve tag */
_("comparator %s is incompatible with :count in call to `%s'"),
sieve_compile_error (&mu_sieve_locus,
/* TRANSLATORS: Do not translate ':count'.
It is the name of a Sieve tag */
_("comparator %s is incompatible with "
":count in call to `%s'"),
comp->arg->v.string,
name);
return 1;
......@@ -289,7 +289,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
mu_list_count (val->v.list, &count);
if (count > 1)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("second argument must be a list of one element"));
return 1;
}
......@@ -297,7 +297,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
count = strtoul (str, &str, 10);
if (*str)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("second argument cannot be converted to number"));
return 1;
}
......@@ -307,7 +307,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
if (mu_sieve_str_to_relcmp (str, NULL, NULL))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("invalid relational match `%s' in call to `%s'"),
str, name);
return 1;
......@@ -320,7 +320,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
compfun = mu_sieve_comparator_lookup (sieve_machine, compname, matchtype);
if (!compfun)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("comparator `%s' is incompatible with match type `%s' in call to `%s'"),
compname, match ? match->tag : "is", name);
return 1;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2006, 2007 Free Software Foundation, Inc.
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -36,8 +36,7 @@ sieve_code (sieve_op_t *op)
sizeof sieve_machine->prog[0]);
if (!newprog)
{
sieve_compile_error (sieve_filename, sieve_line_num,
_("out of memory!"));
sieve_compile_error (&mu_sieve_locus, _("out of memory!"));
return 1;
}
sieve_machine->prog = newprog;
......@@ -155,7 +154,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
if (rc)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot create iterator: %s"),
mu_strerror (rc));
return 1;
......@@ -174,7 +173,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf);
if (!tag)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("invalid tag name `%s' for `%s'"),
val->v.string, reg->name);
err = 1;
......@@ -183,7 +182,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
if (!tag_list && (rc = mu_list_create (&tag_list)))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot create tag list: %s"),
mu_strerror (rc));
err = 1;
......@@ -196,7 +195,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
mu_iterator_next (itr);
if (mu_iterator_is_done (itr))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("required argument for tag %s is missing"),
tag->name);
err = 1;
......@@ -215,7 +214,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
{
if (!chk_list && (rc = mu_list_create (&chk_list)))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot create check list: %s"),
mu_strerror (rc));
err = 1;
......@@ -227,7 +226,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
}
else if (*exp_arg == SVT_VOID)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("too many arguments in call to `%s'"),
reg->name);
err = 1;
......@@ -248,11 +247,11 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
}
else
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("type mismatch in argument %d to `%s'"),
exp_arg - reg->req_args + 1,
reg->name);
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("expected %s but passed %s"),
mu_sieve_type_str (*exp_arg),
mu_sieve_type_str (val->type));
......@@ -263,7 +262,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
if (!arg_list && (rc = mu_list_create (&arg_list)))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot create arg list: %s"),
mu_strerror (rc));
err = 1;
......@@ -281,7 +280,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
{
if (*exp_arg != SVT_VOID)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("too few arguments in call to `%s'"),
reg->name);
err = 1;
......@@ -324,7 +323,7 @@ sieve_code_source (const char *name)
mu_list_append (sieve_machine->source_list, s);
}
return sieve_code_instr (instr_source)
return sieve_code_instr (_mu_sv_instr_source)
|| sieve_code_string (s);
}
......@@ -334,7 +333,7 @@ sieve_code_line (size_t line)
sieve_op_t op;
op.line = line;
return sieve_code_instr (instr_line)
return sieve_code_instr (_mu_sv_instr_line)
|| sieve_code (&op);
}
......@@ -352,7 +351,7 @@ sieve_check_source_changed ()
if (sieve_source_changed)
{
sieve_source_changed = 0;
return sieve_code_source (sieve_filename);
return sieve_code_source (mu_sieve_locus.source_file);
}
return 0;
}
......@@ -361,8 +360,8 @@ int
sieve_code_action (mu_sieve_register_t *reg, mu_list_t arglist)
{
return sieve_check_source_changed ()
|| sieve_code_line (sieve_line_num)
|| sieve_code_instr (instr_action)
|| sieve_code_line (mu_sieve_locus.source_line)
|| sieve_code_instr (_mu_sv_instr_action)
|| sieve_code_command (reg, arglist);
}
......@@ -370,8 +369,8 @@ int
sieve_code_test (mu_sieve_register_t *reg, mu_list_t arglist)
{
return sieve_check_source_changed ()
|| sieve_code_line (sieve_line_num)
|| sieve_code_instr (instr_test)
|| sieve_code_line (mu_sieve_locus.source_line)
|| sieve_code_instr (_mu_sv_instr_test)
|| sieve_code_command (reg, arglist);
}
......@@ -382,12 +381,12 @@ sieve_code_anyof (size_t start)
while (sieve_machine->prog[start+1].pc != 0)
{
size_t next = sieve_machine->prog[start+1].pc;
sieve_machine->prog[start].instr = instr_brnz;
sieve_machine->prog[start].instr = _mu_sv_instr_brnz;
sieve_machine->prog[start+1].pc = end - start - 2;
start = next;
}
sieve_machine->prog[start].instr = instr_nop;
sieve_machine->prog[start+1].instr = instr_nop;
sieve_machine->prog[start].instr = _mu_sv_instr_nop;
sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
}
void
......@@ -401,7 +400,7 @@ sieve_code_allof (size_t start)
sieve_machine->prog[start+1].pc = end - start - 2;
start = next;
}
sieve_machine->prog[start].instr = instr_nop;
sieve_machine->prog[start+1].instr = instr_nop;
sieve_machine->prog[start].instr = _mu_sv_instr_nop;
sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2006, 2007 Free Software Foundation, Inc.
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -36,7 +36,7 @@ mu_sieve_require (mu_list_t slist)
status = mu_list_get_iterator (slist, &itr);
if (status)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot create iterator: %s"),
mu_strerror (status));
return;
......@@ -76,7 +76,7 @@ mu_sieve_require (mu_list_t slist)
if (reqfn (sieve_machine, name))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("source for the %s %s is not available"),
text,
name);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007 Free Software Foundation, Inc.
2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -34,7 +34,7 @@
#define INSTR_DISASS(m) ((m)->debug_level & MU_SIEVE_DEBUG_DISAS)
void
instr_nop (mu_sieve_machine_t mach)
_mu_sv_instr_nop (mu_sieve_machine_t mach)
{
if (INSTR_DEBUG (mach))
mu_sieve_debug (mach, "%4lu: NOP\n",
......@@ -42,7 +42,7 @@ instr_nop (mu_sieve_machine_t mach)
}
void
instr_source (mu_sieve_machine_t mach)
_mu_sv_instr_source (mu_sieve_machine_t mach)
{
mach->locus.source_file = SIEVE_ARG (mach, 0, string);
if (INSTR_DEBUG (mach))
......@@ -53,7 +53,7 @@ instr_source (mu_sieve_machine_t mach)
}
void
instr_line (mu_sieve_machine_t mach)
_mu_sv_instr_line (mu_sieve_machine_t mach)
{
mach->locus.source_line = SIEVE_ARG (mach, 0, line);
if (INSTR_DEBUG (mach))
......@@ -88,7 +88,7 @@ instr_run (mu_sieve_machine_t mach)
}
void
instr_action (mu_sieve_machine_t mach)
_mu_sv_instr_action (mu_sieve_machine_t mach)
{
mach->identifier = SIEVE_ARG (mach, 3, string);
if (INSTR_DEBUG (mach))
......@@ -101,7 +101,7 @@ instr_action (mu_sieve_machine_t mach)
}
void
instr_test (mu_sieve_machine_t mach)
_mu_sv_instr_test (mu_sieve_machine_t mach)
{
mach->identifier = SIEVE_ARG (mach, 3, string);
if (INSTR_DEBUG (mach))
......@@ -113,7 +113,7 @@ instr_test (mu_sieve_machine_t mach)
}
void
instr_push (mu_sieve_machine_t mach)
_mu_sv_instr_push (mu_sieve_machine_t mach)
{
if (INSTR_DEBUG (mach))
{
......@@ -131,7 +131,7 @@ instr_push (mu_sieve_machine_t mach)
}
void
instr_pop (mu_sieve_machine_t mach)
_mu_sv_instr_pop (mu_sieve_machine_t mach)
{
if (INSTR_DEBUG (mach))
{
......@@ -150,7 +150,7 @@ instr_pop (mu_sieve_machine_t mach)
}
void
instr_not (mu_sieve_machine_t mach)
_mu_sv_instr_not (mu_sieve_machine_t mach)
{
if (INSTR_DEBUG (mach))
{
......@@ -162,7 +162,7 @@ instr_not (mu_sieve_machine_t mach)
}
void
instr_branch (mu_sieve_machine_t mach)
_mu_sv_instr_branch (mu_sieve_machine_t mach)
{
long num = SIEVE_ARG (mach, 0, number);
......@@ -180,7 +180,7 @@ instr_branch (mu_sieve_machine_t mach)
}
void
instr_brz (mu_sieve_machine_t mach)
_mu_sv_instr_brz (mu_sieve_machine_t mach)
{
long num = SIEVE_ARG (mach, 0, number);
SIEVE_ADJUST (mach, 1);
......@@ -199,7 +199,7 @@ instr_brz (mu_sieve_machine_t mach)
}
void
instr_brnz (mu_sieve_machine_t mach)
_mu_sv_instr_brnz (mu_sieve_machine_t mach)
{
long num = SIEVE_ARG (mach, 0, number);
SIEVE_ADJUST (mach, 1);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006,
2007 Free Software Foundation, Inc.
2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -80,29 +80,32 @@ struct sieve_machine {
void *data;
};
extern char *sieve_filename;
extern int sieve_line_num;
extern mu_sieve_locus_t mu_sieve_locus;
extern mu_sieve_machine_t sieve_machine;
extern int sieve_error_count;
#define TAG_COMPFUN "__compfun__"
#define TAG_RELFUN "__relfun__"
void sieve_compile_error (const char *filename, int linenum,
const char *fmt, ...) MU_PRINTFLIKE(3,4);
void sieve_compile_error (mu_sieve_locus_t *locus,
const char *fmt, ...) MU_PRINTFLIKE(2,3);
void sieve_debug_internal (mu_sieve_printf_t printer, void *data,
const char *fmt, ...) MU_PRINTFLIKE(3,4);
void sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer,
void *data);
void sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer, void *data);
void sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, void *data);
void sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer,
void *data);
void sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer,
void *data);
int _sieve_default_error_printer (void *data, const char *fmt, va_list ap);
int _sieve_default_parse_error (void *unused, const char *filename, int lineno,
int _sieve_default_parse_error (void *unused,
const char *filename, int lineno,
const char *fmt, va_list ap);
int sieve_lex_begin (const char *name);
int sieve_lex_begin_string (const char *buf, int bufsize, const char *fname, int line);
int sieve_lex_begin_string (const char *buf, int bufsize,
const char *fname, int line);
void sieve_lex_finish (void);
int mu_sieve_yyerror (char *s);
int mu_sieve_yylex ();
......@@ -124,17 +127,17 @@ int sieve_code_source (const char *name);
int sieve_code_line (size_t line);
void sieve_change_source (void);
void instr_action (mu_sieve_machine_t mach);
void instr_test (mu_sieve_machine_t mach);
void instr_push (mu_sieve_machine_t mach);
void instr_pop (mu_sieve_machine_t mach);
void instr_not (mu_sieve_machine_t mach);
void instr_branch (mu_sieve_machine_t mach);
void instr_brz (mu_sieve_machine_t mach);
void instr_brnz (mu_sieve_machine_t mach);
void instr_nop (mu_sieve_machine_t mach);
void instr_source (mu_sieve_machine_t mach);
void instr_line (mu_sieve_machine_t mach);
void _mu_sv_instr_action (mu_sieve_machine_t mach);
void _mu_sv_instr_test (mu_sieve_machine_t mach);
void _mu_sv_instr_push (mu_sieve_machine_t mach);
void _mu_sv_instr_pop (mu_sieve_machine_t mach);
void _mu_sv_instr_not (mu_sieve_machine_t mach);
void _mu_sv_instr_branch (mu_sieve_machine_t mach);
void _mu_sv_instr_brz (mu_sieve_machine_t mach);
void _mu_sv_instr_brnz (mu_sieve_machine_t mach);
void _mu_sv_instr_nop (mu_sieve_machine_t mach);
void _mu_sv_instr_source (mu_sieve_machine_t mach);
void _mu_sv_instr_line (mu_sieve_machine_t mach);
int sieve_mark_deleted (mu_message_t msg, int deleted);
......
%{
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005,
2007 Free Software Foundation, Inc.
2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -34,8 +34,7 @@
#include <sieve.h>
#include <sieve-gram.h>
char *sieve_filename;
int sieve_line_num;
mu_sieve_locus_t mu_sieve_locus;
ino_t sieve_source_inode;
static mu_list_t string_list;
......@@ -93,8 +92,7 @@ fillbuf(char *buf, int max_size)
struct buffer_ctx {
struct buffer_ctx *prev;
char *filename;
int line;
mu_sieve_locus_t locus;
ino_t i_node;
FILE *yyin;
LEX_BUFFER_STATE state;
......@@ -126,12 +124,12 @@ push_source (const char *name)
if (stat (name, &st))
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot stat `%s': %s"), name, strerror (errno));
return 1;
}
if (sieve_filename && st.st_ino == sieve_source_inode)
if (mu_sieve_locus.source_file && st.st_ino == sieve_source_inode)
{
yyerror (_("recursive inclusion"));
return 1;
......@@ -140,11 +138,11 @@ push_source (const char *name)
{
yyerror (_("recursive inclusion"));
if (ctx->prev)
sieve_compile_error (ctx->prev->filename, ctx->prev->line,
sieve_compile_error (&ctx->prev->locus,
_("`%s' already included here"),
name);
else
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("`%s' already included at top level"),
name);
return 1;
......@@ -153,17 +151,16 @@ push_source (const char *name)
fp = fopen (name, "r");
if (!fp)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
_("cannot open `%s': %s"), name, strerror (errno));
return 1;
}
/* Push current context */
if (sieve_filename)
if (mu_sieve_locus.source_file)
{
ctx = mu_sieve_alloc (sizeof (*ctx));
ctx->filename = sieve_filename;
ctx->line = sieve_line_num;
ctx->locus = mu_sieve_locus;
ctx->i_node = sieve_source_inode;
ctx->yyin = yyin;
ctx->prev = context_stack;
......@@ -176,8 +173,8 @@ push_source (const char *name)
else
yyrestart (fp);
sieve_filename = strdup (name);
sieve_line_num = 1;
mu_sieve_locus.source_file = strdup (name);
mu_sieve_locus.source_line = 1;
sieve_source_inode = st.st_ino;
sieve_change_source ();
......@@ -193,18 +190,17 @@ pop_source ()
if (yyin)
fclose (yyin);
if (sieve_filename)
free (sieve_filename);
if (mu_sieve_locus.source_file)
free (mu_sieve_locus.source_file);
if (!context_stack)
{
yyin = NULL;
sieve_filename = NULL;
mu_sieve_locus.source_file = NULL;
return 1;
}
/* Restore previous context */
sieve_filename = context_stack->filename;
sieve_line_num = context_stack->line + 1; /* #include rule did not increment
it */
mu_sieve_locus = context_stack->locus;
mu_sieve_locus.source_line++; /* #include rule did not increment it */
sieve_source_inode = context_stack->i_node;
RESTORE_BUFFER_STATE (context_stack->state);
ctx = context_stack->prev;
......@@ -227,13 +223,13 @@ SIZESUF [kKmMgG]
"/*" BEGIN(COMMENT);
<COMMENT>[^*\n]* /* eat anything that's not a '*' */
<COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
<COMMENT>\n ++sieve_line_num;
<COMMENT>\n ++mu_sieve_locus.source_line;
<COMMENT>"*"+"/" BEGIN(INITIAL);
/* Preprocessor directives (an extension) */
#[ \t]*include.*\n { sieve_include (); }
#[ \t]*searchpath.*\n { sieve_searchpath (); }
/* End-of-line comments */
#.*\n { sieve_line_num++; }
#.*\n { mu_sieve_locus.source_line++; }
#.* /* end-of-file comment */;
/* Reserved words */
require return REQUIRE;
......@@ -262,21 +258,25 @@ not return NOT;
line_finish ();
return STRING; }
/* Multiline strings */
text:-?[ \t]*#.*\n { BEGIN(ML); multiline_begin (); sieve_line_num++; }
text:-?[ \t]*\n { BEGIN(ML); multiline_begin (); sieve_line_num++; }
text:-?[ \t]*#.*\n { BEGIN(ML);
multiline_begin ();
mu_sieve_locus.source_line++; }
text:-?[ \t]*\n { BEGIN(ML);
multiline_begin ();
mu_sieve_locus.source_line++; }
text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML); multiline_begin ();
sieve_line_num++; }
mu_sieve_locus.source_line++; }
text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin ();
sieve_line_num++; }
mu_sieve_locus.source_line++; }
<ML>#[ \t]*include.*\n { if (multiline_delimiter[0] == '\\')
{
sieve_line_num++;
mu_sieve_locus.source_line++;
multiline_add (NULL);
}
else
sieve_include (); }
<ML>.*\n { char *p = multiline_strip_tabs (yytext);
sieve_line_num++;
mu_sieve_locus.source_line++;
if (strncmp (p, multiline_delimiter, strlen (multiline_delimiter))
== 0
......@@ -291,7 +291,7 @@ text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin ();
multiline_add (NULL); }
{WS} ;
/* Other tokens */
\n { sieve_line_num++; }
\n { mu_sieve_locus.source_line++; }
. return yytext[0];
%%
......@@ -361,7 +361,7 @@ _try_include (void *item, void *data)
return 0;
}
void
static void
sieve_include ()
{
char *p, *endp = yytext + yyleng, *name;
......@@ -392,7 +392,7 @@ sieve_include ()
free (name);
}
void
static void
sieve_searchpath ()
{
int append = 0;
......@@ -431,8 +431,8 @@ sieve_lex_begin_string (const char *buf, int bufsize,
input_string_ptr = buf;
input_string_level = bufsize;
sieve_filename = strdup (fname);
sieve_line_num = line;
mu_sieve_locus.source_file = strdup (fname);
mu_sieve_locus.source_line = line;
sieve_source_inode = 0;
sieve_change_source ();
......@@ -446,7 +446,7 @@ sieve_lex_finish ()
;
}
int
static int
number ()
{
char *p;
......@@ -470,7 +470,7 @@ number ()
return NUMBER;
}
int
static int
string ()
{
yylval.string = mu_sieve_malloc (sieve_machine, yyleng - 1);
......@@ -479,7 +479,7 @@ string ()
return STRING;
}
int
static int
isemptystr (char *text)
{
for (; *text && isspace (*text); text++)
......@@ -487,7 +487,7 @@ isemptystr (char *text)
return *text == 0;
}
char *
static char *
multiline_strip_tabs (char *text)
{
if (strip_tabs)
......@@ -496,7 +496,7 @@ multiline_strip_tabs (char *text)
return text;
}
void
static void
line_add (char *text, size_t len)
{
char *s;
......@@ -514,7 +514,7 @@ line_add (char *text, size_t len)
mu_list_append (string_list, s);
}
void
static void
multiline_add (char *s)
{
if (!s)
......@@ -522,7 +522,7 @@ multiline_add (char *s)
line_add (s, 0);
}
void
static void
line_begin ()
{
int status;
......@@ -532,13 +532,13 @@ line_begin ()
status = mu_list_create (&string_list);
if (status)
{
sieve_compile_error (sieve_filename, sieve_line_num,
sieve_compile_error (&mu_sieve_locus,
"mu_list_create: %s", mu_strerror (status));
exit (1);
}
}
void
static void
multiline_begin ()
{
char *p = yytext + 5; /* past the text: keyword */
......@@ -578,7 +578,7 @@ multiline_begin ()
line_begin ();
}
void
static void
line_finish ()
{
mu_iterator_t itr;
......@@ -612,13 +612,13 @@ line_finish ()
mu_list_destroy (&string_list);
}
void
static void
multiline_finish ()
{
line_finish ();
}
void
static void
ident (const char *text)
{
yylval.string = strdup (text);
......@@ -630,7 +630,7 @@ ident (const char *text)
}
/* Escapes the last character from yytext */
char *
static char *
str_unescape (char *text, size_t len)
{
char *str = mu_sieve_alloc (len);
......
%{
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2006, 2007 Free Software Foundation, Inc.
2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -154,7 +154,7 @@ elsif_branch : elsif begin cond block
elsif : ELSIF
{
sieve_code_instr (instr_branch);
sieve_code_instr (_mu_sv_instr_branch);
$$ = sieve_machine->pc;
sieve_code_number (0);
}
......@@ -162,7 +162,7 @@ elsif : ELSIF
else : ELSE
{
sieve_code_instr (instr_branch);
sieve_code_instr (_mu_sv_instr_branch);
$$ = sieve_machine->pc;
sieve_code_number (0);
}
......@@ -177,7 +177,7 @@ block : '{' list '}'
testlist : cond_expr
{
$$.start = $$.end = sieve_machine->pc;
if (sieve_code_instr (instr_brz)
if (sieve_code_instr (_mu_sv_instr_brz)
|| sieve_code_number (0))
YYERROR;
}
......@@ -185,7 +185,7 @@ testlist : cond_expr
{
sieve_machine->prog[$1.end+1].pc = sieve_machine->pc;
$1.end = sieve_machine->pc;
if (sieve_code_instr (instr_brz)
if (sieve_code_instr (_mu_sv_instr_brz)
|| sieve_code_number (0))
YYERROR;
$$ = $1;
......@@ -194,7 +194,7 @@ testlist : cond_expr
cond : cond_expr
{
sieve_code_instr (instr_brz);
sieve_code_instr (_mu_sv_instr_brz);
$$ = sieve_machine->pc;
sieve_code_number (0);
}
......@@ -212,7 +212,7 @@ cond_expr : test
}
| NOT cond_expr
{
if (sieve_code_instr (instr_not))
if (sieve_code_instr (_mu_sv_instr_not))
YYERROR;
}
;
......@@ -230,13 +230,13 @@ test : command
$$ = sieve_machine->pc;
if (!reg)
sieve_compile_error (sieve_filename, sieve_line_num,
_("unknown test: %s"),
$1.ident);
sieve_compile_error (&mu_sieve_locus,
_("unknown test: %s"),
$1.ident);
else if (!reg->required)
sieve_compile_error (sieve_filename, sieve_line_num,
_("test `%s' has not been required"),
$1.ident);
sieve_compile_error (&mu_sieve_locus,
_("test `%s' has not been required"),
$1.ident);
else if (sieve_code_test (reg, $1.args))
YYERROR;
}
......@@ -256,13 +256,13 @@ action : command
$$ = sieve_machine->pc;
if (!reg)
sieve_compile_error (sieve_filename, sieve_line_num,
_("unknown action: %s"),
$1.ident);
sieve_compile_error (&mu_sieve_locus,
_("unknown action: %s"),
$1.ident);
else if (!reg->required)
sieve_compile_error (sieve_filename, sieve_line_num,
_("action `%s' has not been required"),
$1.ident);
sieve_compile_error (&mu_sieve_locus,
_("action `%s' has not been required"),
$1.ident);
else if (sieve_code_action (reg, $1.args))
YYERROR;
}
......@@ -340,7 +340,7 @@ slist : STRING
int
yyerror (char *s)
{
sieve_compile_error (sieve_filename, sieve_line_num, "%s", s);
sieve_compile_error (&mu_sieve_locus, "%s", s);
return 0;
}
......@@ -630,7 +630,8 @@ mu_sieve_compile (mu_sieve_machine_t mach, const char *name)
int
mu_sieve_compile_buffer (mu_sieve_machine_t mach,
const char *buf, int bufsize, const char *fname, int line)
const char *buf, int bufsize,
const char *fname, int line)
{
int rc;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2006, 2007 Free Software Foundation, Inc.
2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
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)
break;
default:
sieve_compile_error (sieve_filename, sieve_line_num,
_("invalid data type"));
sieve_compile_error (&mu_sieve_locus, _("invalid data type"));
abort ();
}
return val;
......@@ -189,13 +188,15 @@ mu_sieve_value_get (mu_list_t vlist, size_t index)
}
void
sieve_compile_error (const char *filename, int linenum, const char *fmt, ...)
sieve_compile_error (mu_sieve_locus_t *ploc, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
sieve_error_count++;
sieve_machine->parse_error_printer (sieve_machine->data, filename, linenum,
sieve_machine->parse_error_printer (sieve_machine->data,
ploc->source_file,
ploc->source_line,
fmt, ap);
va_end (ap);
}
......