[Toybox] New toy: grep
Andre Renaud
andre at bluewatersys.com
Mon Feb 27 12:35:41 PST 2012
Hi Rob,
On 28/02/12 07:01, Rob Landley wrote:
> On 02/26/2012 10:01 PM, Andre Renaud wrote:
>> Attached is a simplistic starter implementation of the grep command.
[snip]
> It might be best if I take over this one since I'm doing sed anyway
> (which is fiddly and evil, and requires me to do the xregcmp()
> infrastructure in lib/ and the compile time test for it).
>
> (I also note that I wrote my own regex/glob engine back in the 90's
> under OS/2, so if bionic turns out not to have usable regexes and I have
> to write my own, I'm prepared to do that...)
That's fair enough - I'm mostly just playing with these in my spare
time, so I'm not to precious about whether they're accepted or not.
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?
Regards,
Andre
1330374941.0
More information about the Toybox
mailing list