summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-01-17 16:29:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-17 18:43:24 (GMT)
commitbf82940dbf12f066ba42a2a03a5bb626ba22c067 (patch)
tree641c90caf5c9810fdb009d9ffa25be36c94e9adb /diff.c
parent2b6a5417d750d086d1da906e46de2b3ad8df6753 (diff)
downloadgit-bf82940dbf12f066ba42a2a03a5bb626ba22c067.zip
git-bf82940dbf12f066ba42a2a03a5bb626ba22c067.tar.gz
git-bf82940dbf12f066ba42a2a03a5bb626ba22c067.tar.bz2
color-words: enable REG_NEWLINE to help user
We silently truncate a match at the newline, which may lead to unexpected behaviour, e.g., when matching "<[^>]*>" against <foo bar> since then "<foo" becomes a word (and "bar>" doesn't!) even though the regex said only angle-bracket-delimited things can be words. To alleviate the problem slightly, use REG_NEWLINE so that negated classes can't match a newline. Of course newlines can still be matched explicitly. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 9fb3d0d..00c661f 100644
--- a/diff.c
+++ b/diff.c
@@ -1544,7 +1544,8 @@ static void builtin_diff(const char *name_a,
ecbdata.diff_words->word_regex = (regex_t *)
xmalloc(sizeof(regex_t));
if (regcomp(ecbdata.diff_words->word_regex,
- o->word_regex, REG_EXTENDED))
+ o->word_regex,
+ REG_EXTENDED | REG_NEWLINE))
die ("Invalid regular expression: %s",
o->word_regex);
}