Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.bin/grep



On Thu, Feb 17, 2011 at 12:06:30PM +0900, enami tsugutomo wrote:
> 
> I just did `more fastgrep.c' and found following piece of code.  The
> usage of wflag is an obvious regression from OpenBSD code.
> 
> |     if (fg->len >= 14 &&
> |         strncmp(pat + (fg->bol ? 1 : 0), "[[:<:]]", 7) == 0 &&
> |         strncmp(pat + (fg->bol ? 1 : 0) + fg->len - 7, "[[:>:]]", 7) == 0) {
> |             fg->len -= 14;
> |             /* Word boundary is handled separately in util.c */
> |             wflag = true;
> |     }

It looks like that might transform:
    grep '[[:<:]]foo.*bar[[:>:]]'
to
    grep -w 'foo.*bar'

which isn't a valid transform.
(I presume something else translated the original '\<foo.*bar\>' ...)

I've known grep where searches for '\<word\>' were a lot faster than
using -w. Presumably because -w locates the words (start and end)
rather than just the start!

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index