git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: "Morten Welinder" <mwelinder@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC/PATCH] Fix "grep -w"
Date: Sat, 05 Aug 2006 14:08:28 -0700	[thread overview]
Message-ID: <7vlkq2dh6b.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <118833cc0608051219q7e19800alc05870058973c2e@mail.gmail.com> (Morten Welinder's message of "Sat, 5 Aug 2006 15:19:02 -0400")

"Morten Welinder" <mwelinder@gmail.com> 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.

  reply	other threads:[~2006-08-05 21:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-05  5:16 [RFC/PATCH] Fix "grep -w" Junio C Hamano
2006-08-05 19:19 ` Morten Welinder
2006-08-05 21:08   ` Junio C Hamano [this message]
2006-08-06  8:39     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vlkq2dh6b.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mwelinder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).