Boost logo

Boost-Build :

From: Rene Rivera (grafik.list_at_[hidden])
Date: 2005-09-03 11:22:56


João Abecasis wrote:
> Alexey Pakhunov wrote:
>
>>I think the limit will not solve all problems. I think some kind of
>>streaming support should be implemented instead. For example each time
>>'CAT' is called it will read only a single block/line/block of lines.

That seems like the best approach.

> I also thought of implementing a grep-like rule that'd use streaming and
> avoid mapping entire files to memory:
>
> rule GREP ( regexp : files * : recursive ? )

The problem with a GREP solution is that it limits what one can do with
the results. For example it would not help in the implementation of the
current doc support as it changes what it greps for contextually. So it
would end up doing what it currently does of "reading" in the files with
an initial grep of "^(.*)$" and doing further greps internally.

What is the "recursive" argument?

>>- Support of line-by-line reading.

How about something like:

rule READ ( file : first-and-last-line * : regexp ? )
# file, path to file
# first-and-last-line, range of lines to read, default ( 0 1 )
# regexp, optional regex to apply to each line before it is returned
#
# returns: ( first-line-read last-line-read strings * )

That allows for considerable flexibility in how much and how one reads
in a file. For example reading in a line at a time:

local r = [ READ "somefile.txt" ] ;
while $(r[1]) < $(r[2])
{
ECHO Line #$(r[1]) - $(r[3-]) ;
r = [ READ "somefile.txt"
: [ CALC $(r[1]) + 1 ] [ CALC $(r[2]) + 1 ] ] ;
}

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - Grafik/jabber.org
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk