buff_t cleanup

David Relson relson at osagesoftware.com
Sat Mar 1 03:07:32 CET 2003


At 08:52 PM 2/28/03, Matthias Andree wrote:

>On Fri, 28 Feb 2003, David Relson wrote:
>
> > However, bogofilter does need to know about the most recently read line 
> (to
> > save it for passthrough and to print it for debugging), so buff_fgetsl()
> > savees the start position of the line in buff->read.
>
>OK. How do I use that buff->read, more precisely: when is buff->read
>cleared (reset to 0)?
>
> > These changes put more of the "bookkeeping code" for buff_t in buff.c and
> > simplify the use of the struct.  This should help maintain the code.
>
>Thanks.

Matthias,

It's set internally within buff.c when data is read into the buffer and is 
used for for identifying the contents of the most recently read line.  The 
two uses in the code are when creating a textblock_t (for passthrough mode) 
and when displaying the line (for debugging purposes).

A buff_t is created when flex calls yyinput() to ask for data.  At that 
point buff->read is zero because there's no previous data in the 
buffer.  It becomes non-zero only when data is added to a non-empty buff_t, 
which presently happens during the processing of long (multiline) html 
comments.  When the lexer rules start handling html comments, the C code 
for killing them will probably no longer be necessary.  At that time, 
likely all fgetsl() reads will be into buff_t structs created to 
encapsulate the parameters from flex and buff->read will be able to go 
away.  I'm not sure that this simplification will occur, but intuition make 
me think it's likely.

To answer your question, there's no need for you to "use" buff->read.

David





More information about the bogofilter-dev mailing list