Index: bogofilter.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/bogofilter.c,v retrieving revision 1.19 diff -u -r1.19 bogofilter.c --- bogofilter.c 28 Aug 2003 13:22:50 -0000 1.19 +++ bogofilter.c 4 Sep 2003 14:08:27 -0000 @@ -40,6 +40,10 @@ #include "rstats.h" #include "wordlists.h" +/* Define longjmp environment for use by YY_FATAL_ERROR in lexer_v3.l */ +#include +jmp_buf lexer_abort_jmp_buf; + /* ** case B_NORMAL: ** case B_STDIN: * '-b' - streaming (stdin) mode * @@ -118,7 +122,8 @@ passthrough_setup(); - token_type = collect_words(w); + if (setjmp(lexer_abort_jmp_buf) == 0) + token_type = collect_words(w); msgcount += 1; if (register_opt && DEBUG_REGISTER(1)) Index: bogolexer.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/bogolexer.c,v retrieving revision 1.39 diff -u -r1.39 bogolexer.c --- bogolexer.c 29 Aug 2003 16:31:43 -0000 1.39 +++ bogolexer.c 4 Sep 2003 14:08:27 -0000 @@ -27,6 +27,10 @@ #include "token.h" #include "mime.h" +/* Define longjmp environment for use by YY_FATAL_ERROR in lexer_v3.l */ +#include +jmp_buf lexer_abort_jmp_buf; + #define PROGNAME "bogolexer" const char *progname = PROGNAME; @@ -265,6 +269,10 @@ while (reader_more()) { initialize(); + + if (setjmp(lexer_abort_jmp_buf) != 0) + continue; + while ((t = get_token()) != NONE) { count += 1; Index: lexer_v3.l =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/lexer_v3.l,v retrieving revision 1.73 diff -u -r1.73 lexer_v3.l --- lexer_v3.l 2 Sep 2003 20:14:23 -0000 1.73 +++ lexer_v3.l 4 Sep 2003 14:08:28 -0000 @@ -82,6 +82,9 @@ #define YY_INPUT(buf,result,max_size) result = yyinput((byte *)buf, max_size) #define YY_EXIT_FAILURE EX_ERROR +#include +extern jmp_buf lexer_abort_jmp_buf; + #undef stderr #define stderr dbgout /* for debug & -D options */ @@ -102,6 +105,17 @@ yyt.text = (byte *)yytext; yyt.leng = yyleng; return &yyt; +} + +#define YY_FATAL_ERROR(msg) bogo_lexer_error(msg) + +static void bogo_lexer_error(const char *msg) +{ + void *fe = yy_fatal_error; /* suppress compiler warning */ + (void) fe; /* suppress compiler warning */ + + (void) fprintf( stderr, "%s\n", msg ); + longjmp( lexer_abort_jmp_buf, EX_ERROR ) ; } %}