]> mj.ucw.cz Git - umpf.git/commitdiff
do not die on syntax errors, save email to default mailbox instead
authorAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 14:32:11 +0000 (16:32 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 14:32:11 +0000 (16:32 +0200)
cond.y
umpf.c
umpf.h

diff --git a/cond.y b/cond.y
index 4c1d3d221d188a976ff7fd96d5b42e3e8c07a714..5e2cf400a2fe4bef664f82a0aea549a1153928de 100644 (file)
--- 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 b8c2cd9effe94c6a194ef68dc2451d29e6ece128..e97da9eadc89554a0346a57b707c13c294387664 100644 (file)
--- 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 cff01db6181c1389bd7d9b34b760df1674bf16d5..41cea0ca5a821c09104af5ba4cdca6174c53e080 100644 (file)
--- a/umpf.h
+++ b/umpf.h
@@ -1,3 +1,4 @@
+#include <setjmp.h>
 #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 *);