Re: [RFC/PATCH] Fix "grep -w"

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

 



"Morten Welinder" <mwelinder@xxxxxxxxx> writes:

> 1. Are you sure that going to the end of the first match is correct?
> It seems to me that this will skip matches.  Say you search
> for ".*" on a line that reads
>   " xxx".

It is fine for your example, I think.  .* matches the entire
line the first time, and BOL and EOL are defined to be word
boundaries.  But you are right.  If the pattern is "x xx* x" and
the line is "x x xx x", the first round would match the first 5
bytes, we find that 6th byte 'x' makes it not a word boundary,
and redoing the match starting at 6th is a wrong thing to do.
We should find "x xx x" starting at the 3rd byte.

> 2. What about "^"?

The pattern would not match the second time anyway, so I do not
think it is such a big deal.

But there is another bug I just spotted.  git grep -w -e '^x'
matches line "xxx" (when not cheating with external grep).

> 3. What about empty matches?  That could take a while...

True.  So we would need to make sure we advance at least one.

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]