[cvs] SF.net SVN: bogofilter:[6987] trunk/bogofilter
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <m-...@us...> - 2013-01-20 13:49:19
|
Revision: 6987 http://bogofilter.svn.sourceforge.net/bogofilter/?rev=6987&view=rev Author: m-a Date: 2013-01-20 13:49:12 +0000 (Sun, 20 Jan 2013) Log Message: ----------- Change lexer API/ABI a bit so as to work with flex 2.5.36 generated lexers (for instance, on Fedora 18 "Spherical Cow") that flip the type of yyleng from int to size_t. We use a signed long internally. Modified Paths: -------------- trunk/bogofilter/NEWS trunk/bogofilter/src/lexer.c trunk/bogofilter/src/lexer.h trunk/bogofilter/src/lexer_v3.l trunk/bogofilter/src/msgcounts.c trunk/bogofilter/src/msgcounts.h trunk/bogofilter/src/token.c Modified: trunk/bogofilter/NEWS =================================================================== --- trunk/bogofilter/NEWS 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/NEWS 2013-01-20 13:49:12 UTC (rev 6987) @@ -15,6 +15,11 @@ ------------------------------------------------------------------------------- + 2013-01-20 + * Change lexer API/ABI a bit so as to work with flex 2.5.36 generated + lexers (for instance, on Fedora 18 "Spherical Cow") that flip the + type of yyleng from int to size_t. We use a signed long internally. + 2012-12-03 * Add bogofilter-SA-2012-01 (CVE-2012-5468). * Fix XML form of Bulgarian FAQ so that it validates; Modified: trunk/bogofilter/src/lexer.c =================================================================== --- trunk/bogofilter/src/lexer.c 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/lexer.c 2013-01-20 13:49:12 UTC (rev 6987) @@ -43,14 +43,12 @@ static lexer_t v3_lexer = { yylex, - &yytext, - &yyleng + lexer_v3_get_token }; lexer_t msg_count_lexer = { read_msg_count_line, - &msg_count_text, - &msg_count_leng + msg_count_get_token }; /* Function Prototypes */ Modified: trunk/bogofilter/src/lexer.h =================================================================== --- trunk/bogofilter/src/lexer.h 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/lexer.h 2013-01-20 13:49:12 UTC (rev 6987) @@ -47,8 +47,7 @@ typedef struct lexer_s { yylex_t *yylex; - char **yytext; - int *yyleng; /* DO NOT EVEN CONSIDER MAKING THIS SIZE_T! */ + long (*get_parser_token)(byte **data); } lexer_t; extern lexer_t *lexer; @@ -56,9 +55,8 @@ /* in lexer_v3.l */ extern token_t yylex(void); -extern int yyleng; -extern char * yytext; extern void lexer_v3_init(FILE *fp); +extern long lexer_v3_get_token(byte **output); /* in lexer_v?.c */ extern char yy_get_state(void); Modified: trunk/bogofilter/src/lexer_v3.l =================================================================== --- trunk/bogofilter/src/lexer_v3.l 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/lexer_v3.l 2013-01-20 13:49:12 UTC (rev 6987) @@ -241,7 +241,7 @@ <INITIAL>^Content-(Transfer-Encoding|Type|Disposition):{MTYPE} { mime_content(yy_text()); skip_to(':'); header(); return TOKEN; } <INITIAL>^Message-ID:.* { /* save token for logging */ - int off = 11; + unsigned long off = 11; while(isspace((unsigned char)yytext[off]) && off < yyleng) off++; set_msg_id((unsigned char *)(yytext+off), yyleng-off); @@ -470,6 +470,12 @@ #endif } +long lexer_v3_get_token(byte **output) +{ + *output = (byte *)yytext; + return yyleng; +} + /* * The following sets edit modes for GNU EMACS * Local Variables: Modified: trunk/bogofilter/src/msgcounts.c =================================================================== --- trunk/bogofilter/src/msgcounts.c 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/msgcounts.c 2013-01-20 13:49:12 UTC (rev 6987) @@ -85,3 +85,9 @@ msg_count_header_len= strlen(msg_count_header); } + +long msg_count_get_token(byte **output) +{ + *output = (byte *)msg_count_text; + return msg_count_leng; +} Modified: trunk/bogofilter/src/msgcounts.h =================================================================== --- trunk/bogofilter/src/msgcounts.h 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/msgcounts.h 2013-01-20 13:49:12 UTC (rev 6987) @@ -30,4 +30,6 @@ void set_msg_counts(u_int32_t good, u_int32_t spam); void set_msg_counts_from_str(char *str); +long msg_count_get_token(byte **output); + #endif /* MSGCOUNTS_H */ Modified: trunk/bogofilter/src/token.c =================================================================== --- trunk/bogofilter/src/token.c 2012-12-07 21:34:05 UTC (rev 6986) +++ trunk/bogofilter/src/token.c 2013-01-20 13:49:12 UTC (rev 6987) @@ -205,8 +205,7 @@ cls = (*lexer->yylex)(); - token->leng = (uint) *lexer->yyleng; - token->u.text = (byte *) *lexer->yytext; + token->leng = lexer->get_parser_token(&token->u.text); Z(token->u.text[token->leng]); /* for easier debugging - removable */ leng = token->leng; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |