From 5c8b2773469e1bab02368f8854b922da2855c1fc Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Tue, 21 Jul 2009 16:32:11 +0200 Subject: [PATCH] do not die on syntax errors, save email to default mailbox instead --- cond.y | 4 +++- umpf.c | 11 ++++++++--- umpf.h | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cond.y b/cond.y index 4c1d3d2..5e2cf40 100644 --- a/cond.y +++ b/cond.y @@ -273,5 +273,7 @@ get_var_type(char* var) void yyerror (char const *s) { - fprintf (stderr, "Line %d: %s\n", line, s); + fprintf (stderr, "Line %d: %s\n Saving your e-mail to default mailbox %s\n", + line, s, default_mailbox); + longjmp(env, 1); } diff --git a/umpf.c b/umpf.c index b8c2cd9..e97da9e 100644 --- a/umpf.c +++ b/umpf.c @@ -32,9 +32,14 @@ main(int argc, char** argv) default_mailbox = argv[2]; save_gids(); - read_conf(argv[1]); + init(); -// yydebug=1; + + /* returning from longjump? save the mail and exit */ + if (setjmp(env)) + goto skip_conf; + + read_conf(argv[1]); res = yyparse (); if (res) @@ -43,13 +48,13 @@ main(int argc, char** argv) temp_varcode_start = current_varcode; compile(input_tree, NULL); +skip_conf: var_tab = xmalloc((max_varcode + 1) * sizeof(char*)); for (i = 0; i <= max_varcode; i++) { var_tab[i] = empty; } current_headers = make_hlist(0); -// print_headers(current_headers); current_body = get_body(0); save_current_headers(var_hash); set_cur_mail_length_var(curr_email_len, var_hash); diff --git a/umpf.h b/umpf.h index cff01db..41cea0c 100644 --- a/umpf.h +++ b/umpf.h @@ -1,3 +1,4 @@ +#include #include "lists.h" /* definitions of internal variables */ @@ -5,6 +6,9 @@ #define INT_VAR_LAST_EXIT "LAST_EXIT_CODE" #define INT_VAR_PIPE_RES "LAST_OUTPUT" +/* umpf.c */ +jmp_buf env; + /* cond.h */ int yylex (void); void yyerror (char const *); -- 2.39.2