[Toybox] New toy: grep

Andre Renaud andre at bluewatersys.com
Mon Feb 27 13:08:25 PST 2012


Hi Tim,

On 28/02/12 09:45, Tim Elliott wrote:
> On Mon, Feb 27, 2012 at 12:35 PM, Andre Renaud <andre at bluewatersys.com> wrote:
>> Regarding the greps over binaries, and arbitrary length buffers. I'm
>> curious what kind of implementation you'd do there to avoid having
>> issues with expressions that sit on block boundaries, or regular
>> expressions that have a possible infinite length match, such as 'a.*b'.
>> Is it realistic to expect the entire file to be in memory for such a
>> regexp? I suppose mmap could be used, but isn't that a bit heavy-handed?
> 
> This post has some pointers non-regex string searching and mmap in grep:
> http://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html
> 
> Since toybox prioritizes simplicity over performance, it may or may
> not end up being useful.

I'm curious about this as well - the mailing post you point to talks
about a lot of optimisations, all geared towards making grep as fast as
possible. However for toybox, I would assume that the preference would
be for the smallest complete implementation, rather than a larger,
faster one. So would that mean that a simplistic mmap + regexp + line
counter be sufficient, even though its pretty hideous for the
fixed-string common case?

Regards,
Andre

 1330376905.0


More information about the Toybox mailing list