path: root/grep.c
diff options
authorÆvar Arnfjörð Bjarmason <>2017-06-29 22:22:22 (GMT)
committerJunio C Hamano <>2017-06-30 17:06:24 (GMT)
commit1ceababc4c1817f86094dab1771e23da1ddaf443 (patch)
treec59abd45fc8643dbb5a2aa43ff787ed5f98a930c /grep.c
parent07a3d4117390841ed6884a9eac836918491df0a9 (diff)
grep: remove redundant REG_NEWLINE when compiling fixed regex
Remove the redundant REG_NEWLINE regcomp() flag from the code that compiles a fixed-string regular-expression. The REG_NEWLINE causes metacharacters such as "." to match a newline, since the basic_regex_quote_buf() function being called here escapes all metacharacters using REG_NEWLINE is confusing and redundant. The use of this flag was introduced as an unintended emergent property of 793dc676e0 ("grep/icase: avoid kwsset when -F is specified", 2016-06-25). That change amended the existing regflags, which were initialized to REG_NEWLINE in init_grep_defaults() assuming a subsequent non-fixed regcomp(). Manual testing reveals that this was always redundant, since no flags of any use were inherited from opt->regflags even back then. 793dc676e0 passes all tests with this on top: diff --git a/grep.c b/grep.c index 627ae3e3e8..89e84ed7fd 100644 --- a/grep.c +++ b/grep.c @@ -407,3 +407,3 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt) basic_regex_quote_buf(&sb, p->pattern); - regflags = opt->regflags & ~REG_EXTENDED; + regflags = 0; if (opt->ignore_case) Since this isn't used for anything and never was, remove it to reduce confusion when reading this code. Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'grep.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/grep.c b/grep.c
index 11a8654..2efec0e 100644
--- a/grep.c
+++ b/grep.c
@@ -593,7 +593,7 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)
struct strbuf sb = STRBUF_INIT;
int err;
- int regflags = REG_NEWLINE;
+ int regflags = 0;
basic_regex_quote_buf(&sb, p->pattern);
if (opt->ignore_case)