No grep module?

Mo DeJong
Tue Feb 26 00:55:00 GMT 2002

On 22 Feb 2002 17:41:54 -0700
Tom Tromey <> wrote:

> >>>>> "Mo" == Mo DeJong <> writes:
> Mo> If we do want to add a grep module to support building under
> Mo> Windows, then perhaps we need to upgrade to a more recent version
> Mo> of GNU grep. I think we removed all the old custom grep hacks that
> Mo> we were using, so we should be able to upgrade.
> What about hacking S-N to load files and do its own regexp matching,
> thus avoiding the need for a separate grep executable?  I think in the
> past grep was used for better performance.  Is it really that
> significant?
> Tom

We looked into doing that for the last release but it just was not going
to work. This time around, we are using Tcl 8.3 so we have access to
the new regexp impl that supports the following:

% regexp -all -inline -indices {oy} {
a toy is not a boy
soy is a joy
{4 5} {17 18} {21 22} {30 31}

We can build up a buffer the size of the file and then run regexp to find all
the match indexes. The tricky part will be how we will count newlines so
that a match index can be mapped back to the file line number.

Then there is the code in greppane.tcl to worry about. It is kind of scary the
way we run multiple greps to get around OS command line limits. Also,
we currently run another regexp over each result line so that we can
highlight the match text. This all adds up to lots of time we could save
with a Tcl based grep impl. Then there is the really nasty hack that we
use to map the file names returned from grep back to files in the project.
Then there are the PATH problems that can cause the wrong version of
grep to be run. We could really fix a lot of problems with a Tcl only version
of grep.

That said, actually getting this code written and added might not be something
that is doable for the 5.1 release. Perhaps we should just punt on a grep module
and include a grep.exe in the Windows zip file for the binaries.


More information about the Sourcenav mailing list