* git-grep colouring bug with -w option.
@ 2009-05-20 18:38 Dmitry Gryazin
2009-05-20 21:31 ` [PATCH] grep: fix word-regexp colouring René Scharfe
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Gryazin @ 2009-05-20 18:38 UTC (permalink / raw)
To: git; +Cc: rene.scharfe
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
I've found that "git-grep --color -w VirtualKeybord" works not correct
for string like:
vkbd = RVirtualKeyboard(main_window, "VirtualKeyboard")
My script in attachment reproduces this bug.
[-- Attachment #2: git_grep_colouring_bug.sh --]
[-- Type: application/x-sh, Size: 513 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] grep: fix word-regexp colouring
2009-05-20 18:38 git-grep colouring bug with -w option Dmitry Gryazin
@ 2009-05-20 21:31 ` René Scharfe
2009-05-21 4:29 ` Dmitry Gryazin
0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2009-05-20 21:31 UTC (permalink / raw)
To: Dmitry Gryazin; +Cc: git
As noticed by Dmitry Gryazin: When a pattern is found but it doesn't
start and end at word boundaries, bol is forwarded to after the match and
the pattern is searched again. When a pattern is finally found between
word boundaries, the match offsets are off by the number of characters
that have been skipped.
This patch corrects the offsets to be relative to the value of bol as
passed to match_one_pattern() by its caller.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
grep.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/grep.c b/grep.c
index 04c777a..a649f06 100644
--- a/grep.c
+++ b/grep.c
@@ -305,6 +305,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
{
int hit = 0;
int saved_ch = 0;
+ const char *start = bol;
if ((p->token != GREP_PATTERN) &&
((p->token == GREP_PATTERN_HEAD) != (ctx == GREP_CONTEXT_HEAD)))
@@ -365,6 +366,10 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
}
if (p->token == GREP_PATTERN_HEAD && saved_ch)
*eol = saved_ch;
+ if (hit) {
+ pmatch[0].rm_so += bol - start;
+ pmatch[0].rm_eo += bol - start;
+ }
return hit;
}
--
1.6.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] grep: fix word-regexp colouring
2009-05-20 21:31 ` [PATCH] grep: fix word-regexp colouring René Scharfe
@ 2009-05-21 4:29 ` Dmitry Gryazin
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Gryazin @ 2009-05-21 4:29 UTC (permalink / raw)
To: René Scharfe; +Cc: git
René Scharfe wrote:
> As noticed by Dmitry Gryazin: When a pattern is found but it doesn't
> start and end at word boundaries, bol is forwarded to after the match and
> the pattern is searched again. When a pattern is finally found between
> word boundaries, the match offsets are off by the number of characters
> that have been skipped.
>
> This patch corrects the offsets to be relative to the value of bol as
> passed to match_one_pattern() by its caller.
>
> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
> ---
> grep.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index 04c777a..a649f06 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -305,6 +305,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
> {
> int hit = 0;
> int saved_ch = 0;
> + const char *start = bol;
>
> if ((p->token != GREP_PATTERN) &&
> ((p->token == GREP_PATTERN_HEAD) != (ctx == GREP_CONTEXT_HEAD)))
> @@ -365,6 +366,10 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
> }
> if (p->token == GREP_PATTERN_HEAD && saved_ch)
> *eol = saved_ch;
> + if (hit) {
> + pmatch[0].rm_so += bol - start;
> + pmatch[0].rm_eo += bol - start;
> + }
> return hit;
> }
>
>
Thanks.
ACK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-21 4:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 18:38 git-grep colouring bug with -w option Dmitry Gryazin
2009-05-20 21:31 ` [PATCH] grep: fix word-regexp colouring René Scharfe
2009-05-21 4:29 ` Dmitry Gryazin
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).