[cvs] bogofilter lexer.h,1.23.2.2,1.23.2.3 lexer.l,1.50.2.6,1.50.2.7 token.c,1.6.2.2,1.6.2.3 charset
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2002-12-29 15:59:05
|
Update of /cvsroot/bogofilter/bogofilter In directory sc8-pr-cvs1:/tmp/cvs-serv9022 Modified Files: Tag: mime lexer.h lexer.l token.c charset.c Log Message: Move processing of "charset=name" out of token.c to lexer.l. Have lexer.l pass charset string to charset.c Index: lexer.h =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/lexer.h,v retrieving revision 1.23.2.2 retrieving revision 1.23.2.3 diff -u -d -r1.23.2.2 -r1.23.2.3 --- lexer.h 29 Dec 2002 04:01:39 -0000 1.23.2.2 +++ lexer.h 29 Dec 2002 15:59:02 -0000 1.23.2.3 @@ -27,8 +27,7 @@ TOKEN, /* regular token */ FROM, /* mbox message delimiter */ BOUNDARY, /* MIME multipart boundary line */ - IPADDR, /* ip address */ - CHARSET /* charset="..." */ + IPADDR /* ip address */ } token_t; extern token_t yylex(void); Index: lexer.l =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/lexer.l,v retrieving revision 1.50.2.6 retrieving revision 1.50.2.7 diff -u -d -r1.50.2.6 -r1.50.2.7 --- lexer.l 29 Dec 2002 15:23:53 -0000 1.50.2.6 +++ lexer.l 29 Dec 2002 15:59:02 -0000 1.50.2.7 @@ -108,7 +108,7 @@ center ; char ; charoff ; -charset {return(CHARSET);} +charset=\"?{ID}\"? { got_charset(yytext); yyredo('='); } circle ; cite ; colspan ; Index: token.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/token.c,v retrieving revision 1.6.2.2 retrieving revision 1.6.2.3 diff -u -d -r1.6.2.2 -r1.6.2.3 --- token.c 29 Dec 2002 03:52:48 -0000 1.6.2.2 +++ token.c 29 Dec 2002 15:59:02 -0000 1.6.2.3 @@ -64,12 +64,6 @@ return (class); } - if (class == CHARSET) /* charset=name */ - { /* Get name; call got_charset(); return name. */ - get_token(); - got_charset(yytext); - } - /* eat all long words */ if (yyleng <= MAXTOKENLEN) break; Index: charset.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/charset.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -d -r1.6.2.1 -r1.6.2.2 --- charset.c 29 Dec 2002 15:23:25 -0000 1.6.2.1 +++ charset.c 29 Dec 2002 15:59:02 -0000 1.6.2.2 @@ -382,24 +382,25 @@ void got_charset( const char *charset ) { - char *lcl; - char *tmp = strchr( charset, '=' ); + char *t = strchr( charset, '=' ); + bool q = *t == '"'; char *s, *d; - lcl = xstrdup( tmp ? tmp+1 : charset); - for (s = d = lcl; *s != '\0'; s++) + t = xstrdup( t + q); + for (s = d = t; *s != '\0'; s++) { - if (*s == '"') /* skip quotes */ - continue; - if (*s == '_') /* map underscore to dash */ - *s = '-'; - *d++ = tolower(*s); /* map upper case to lower */ - if (*s == '-' && /* map "iso-" to "iso" */ - memcmp(lcl, "iso-", 4) == 0) + char c = *s; + if (c == '_') /* map underscore to dash */ + c = '-'; + *d++ = tolower(c); /* map upper case to lower */ + if (c == '-' && /* map "iso-" to "iso" */ + memcmp(t, "iso-", 4) == 0) d -= 1; + if (q && c == '"') + break; } *d++ = '\0'; if (DEBUG_CONFIG(0)) - fprintf( stderr, "got_charset( '%s' )\n", lcl ); - init_charset_table( lcl, false ); - xfree(lcl); + fprintf( stderr, "got_charset( '%s' )\n", t ); + init_charset_table( t, false ); + xfree(t); } |