diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2019-07-01 23:20:58 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-01 23:33:14 +0200 |
commit | 45d1f37ccc16ad53303910e150f7fbe36213aad8 (patch) | |
tree | 84605f63ecfa24eb9a0bff3cd70aed2efa1b06cd /grep.c | |
parent | grep: make the behavior for NUL-byte in patterns sane (diff) | |
download | git-45d1f37ccc16ad53303910e150f7fbe36213aad8.tar.xz git-45d1f37ccc16ad53303910e150f7fbe36213aad8.zip |
grep: drop support for \0 in --fixed-strings <pattern>
Change "-f <file>" to not support patterns with a NUL-byte in them
under --fixed-strings. We'll now only support these under
"--perl-regexp" with PCRE v2.
A previous change to grep's documentation changed the description of
"-f <file>" to be vague enough as to not promise that this would work.
By dropping support for this we make it a whole lot easier to move
away from the kwset backend, which we'll do in a subsequent change.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -644,6 +644,9 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) p->word_regexp = opt->word_regexp; p->ignore_case = opt->ignore_case; + if (memchr(p->pattern, 0, p->patternlen) && !opt->pcre2) + die(_("given pattern contains NULL byte (via -f <file>). This is only supported with -P under PCRE v2")); + /* * Even when -F (fixed) asks us to do a non-regexp search, we * may not be able to correctly case-fold when -i @@ -666,9 +669,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) return; } - if (memchr(p->pattern, 0, p->patternlen) && !opt->pcre2) - die(_("given pattern contains NULL byte (via -f <file>). This is only supported with -P under PCRE v2")); - if (opt->fixed) { /* * We come here when the pattern has the non-ascii |