challenge [was: unfolding header lines]

michael at optusnet.com.au michael at optusnet.com.au
Fri Sep 5 04:05:53 CEST 2003


David Relson <relson at osagesoftware.com> writes:
[..]
> The simple grammar does about 99% of what's needed for unfolding header
> lines.  Tests #1 and #2 work fine.  Test #3 is a couple of characters
> shorter than #2 (some whitespace and an 'x') and fails.
> 
> The challenge is to modify lexer.l so that all 3 tests pass :-)

Where's lexer.h ?? :)
 
> If I've setup the test properly, the modified lexer.l will merge easily
> into the official bogofilter lexer and bogofilter will handle unfolded
> header lines properly.  If I don't have it right, there will need to be
> a second challenge round.

Done. Get rid of the clr_tag() calls from main.c and use
a lexer like....

<INITIAL>\n[ \t]                        { lineno += 1; } /* unfold lines */
<INITIAL>^\n                                    { BEGIN TEXT;
                                                  printf("*** BEGIN TEXT***\n");;
                                                  return(EMPTY);
                                                }
{TOKEN}                                         { return TOKEN;}
boundary={MIME_BOUNDARY}                        { got_mime_boundary(); }
^--{MIME_BOUNDARY}(--)?$                        { mime_boundary_set(); BEGIN INITIAL; return BOUNDARY; }
.                                               ;                       /* ignore character */
\n                                              { lineno += 1; clr_tag(); }


Ta-dah!! :) Note the change to the '\n' pattern.

Michael.

PS. I know the whitespace isn't precisely right, but who cares. 




More information about the bogofilter-dev mailing list