summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-11-13 13:35:55 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-11-13 13:35:55 +0000
commitae09a5a6b1893087a8b2fa6285f4439dcb484bb0 (patch)
tree37c396cdd5d672b6b118554ba245367fc7378f73
parent91aa105c038a290f9fe4e1fe22a4a2c4b2c020a3 (diff)
downloadmailutils-ae09a5a6b1893087a8b2fa6285f4439dcb484bb0.tar.gz
mailutils-ae09a5a6b1893087a8b2fa6285f4439dcb484bb0.tar.bz2
Use sieve_compile_error() to report parse errors.
-rw-r--r--libsieve/require.c9
-rw-r--r--libsieve/sieve.l23
-rw-r--r--libsieve/util.c32
3 files changed, 41 insertions, 23 deletions
diff --git a/libsieve/require.c b/libsieve/require.c
index 4512eb74c..44a192dbd 100644
--- a/libsieve/require.c
+++ b/libsieve/require.c
@@ -34,8 +34,8 @@ sieve_require (list_t slist)
status = iterator_create (&itr, slist);
if (status)
{
- sieve_error ("%s:%d: cannot create iterator: %s",
- sieve_filename, sieve_line_num,
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "cannot create iterator: %s",
mu_errstring (status));
return;
}
@@ -51,8 +51,9 @@ sieve_require (list_t slist)
reg = sieve_action_lookup (s);
if (!reg)
{
- sieve_error ("%s:%d: source for the required action %s is not available",
- sieve_filename, sieve_line_num, s);
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "source for the required action %s is not available",
+ s);
break;
}
reg->required = 1;
diff --git a/libsieve/sieve.l b/libsieve/sieve.l
index 65bd2997d..a541a1c5f 100644
--- a/libsieve/sieve.l
+++ b/libsieve/sieve.l
@@ -117,7 +117,7 @@ lex_set_buffer (FILE *fp)
if (!buf)
{
- sieve_error ("not enough memory");
+ sieve_compile_error (sieve_filename, sieve_line_num, "not enough memory");
abort ();
}
@@ -218,8 +218,8 @@ push_source (const char *name)
if (stat (name, &st))
{
- sieve_error ("can't stat `%s': %s", name, strerror (errno));
- yyerror ("can't include file");
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "can't stat `%s': %s", name, strerror (errno));
return 1;
}
@@ -232,19 +232,21 @@ push_source (const char *name)
{
yyerror ("recursive inclusion");
if (ctx->prev)
- sieve_error ("%s:%d: `%s' already included here",
- ctx->prev->filename, ctx->prev->line, name);
+ sieve_compile_error (ctx->prev->filename, ctx->prev->line,
+ "`%s' already included here",
+ name);
else
- sieve_error ("`%s' already included at top level",
- name);
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "`%s' already included at top level",
+ name);
return 1;
}
fp = fopen (name, "r");
if (!fp)
{
- sieve_error ("can't open `%s': %s", name, strerror (errno));
- yyerror ("can't include file");
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "can't open `%s': %s", name, strerror (errno));
return 1;
}
@@ -470,7 +472,8 @@ multiline_begin ()
status = list_create (&string_list);
if (status)
{
- sieve_error ("list_create: %s", mu_errstring (status));
+ sieve_compile_error (sieve_filename, sieve_line_num,
+ "list_create: %s", mu_errstring (status));
exit (1);
}
}
diff --git a/libsieve/util.c b/libsieve/util.c
index 2fadeeb55..b8b23a55c 100644
--- a/libsieve/util.c
+++ b/libsieve/util.c
@@ -144,20 +144,31 @@ sieve_value_create (sieve_data_type type, void *data)
break;
default:
- sieve_error ("Invalid data type");
+ sieve_compile_error (sieve_filename, sieve_line_num, "Invalid data type");
abort ();
}
return val;
}
void
-sieve_error (const char *fmt, ...)
+sieve_compile_error (const char *filename, int linenum, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
sieve_error_count++;
- sieve_machine->error_printer (sieve_machine->data, fmt, ap);
+ sieve_machine->parse_error_printer (sieve_machine->data, filename, linenum,
+ fmt, ap);
+ va_end (ap);
+}
+
+void
+sieve_error (sieve_machine_t *mach, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ mach->error_printer (mach->data, fmt, ap);
va_end (ap);
}
@@ -187,6 +198,15 @@ _sieve_default_error_printer (void *unused, const char *fmt, va_list ap)
return mu_verror (fmt, ap);
}
+int
+_sieve_default_parse_error (void *unused, const char *filename, int lineno,
+ const char *fmt, va_list ap)
+{
+ fprintf (stderr, "%s:%d: ", filename, lineno);
+ vfprintf (stderr, fmt, ap);
+ return 0;
+}
+
char *
sieve_type_str (sieve_data_type type)
{
@@ -304,10 +324,4 @@ sieve_print_tag_list (list_t list, sieve_printf_t printer, void *data)
list_do (list, (list_action_t*) tag_printer, &dbg);
}
-void
-sieve_set_debug (sieve_machine_t *mach, sieve_printf_t debug, int level)
-{
- mach->debug_printer = debug;
- mach->debug_level = level;
-}

Return to:

Send suggestions and report system problems to the System administrator.