diff options
author | Jim Meyering <meyering@fb.com> | 2020-10-04 09:39:39 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2020-10-11 20:30:30 -0700 |
commit | df33ff807de40b131ba835ee4b0d27a0577a17ab (patch) | |
tree | 877177afbfe2d6c5b2805074d7a488fdac22a26a /tests/filename-lineno.pl | |
parent | f31abf786f61f4bdd7134559a5f155fc9c8c2513 (diff) | |
download | grep-df33ff807de40b131ba835ee4b0d27a0577a17ab.tar.gz |
grep: -P: report input filename upon PCRE execution failure
Without this, it could be tedious to determine which input
file evokes a PCRE-execution-time failure.
* src/pcresearch.c (Pexecute): When failing, include the
error-provoking file name in the diagnostic.
* src/grep.c (input_filename): Make extern, since used above.
* src/search.h (input_filename): Declare.
* tests/filename-lineno.pl: Test for this.
($no_pcre): Factor out.
* NEWS (Bug fixes): Mention this.
Diffstat (limited to 'tests/filename-lineno.pl')
-rwxr-xr-x | tests/filename-lineno.pl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/filename-lineno.pl b/tests/filename-lineno.pl index d44dd7b7..42d1b046 100755 --- a/tests/filename-lineno.pl +++ b/tests/filename-lineno.pl @@ -37,6 +37,8 @@ $prog = $full_prog_name if $full_prog_name; # Transform each to this: "Unmatched [..." my $err_subst = {ERR_SUBST => 's/(: Unmatched \[).*/$1.../'}; +my $no_pcre = "$prog: Perl matching not supported in a --disable-perl-regexp build\n"; + my @Tests = ( # Show that grep now includes filename:lineno in the diagnostic: @@ -100,13 +102,22 @@ my @Tests = ['invalid-re-P-paren', '-P ")"', {EXIT=>2}, {ERR => $ENV{PCRE_WORKS} == 1 ? "$prog: unmatched parentheses\n" - : "$prog: Perl matching not supported in a --disable-perl-regexp build\n" + : $no_pcre }, ], ['invalid-re-P-star-paren', '-P "a.*)"', {EXIT=>2}, {ERR => $ENV{PCRE_WORKS} == 1 ? "$prog: unmatched parentheses\n" - : "$prog: Perl matching not supported in a --disable-perl-regexp build\n" + : $no_pcre + }, + ], + + # Prior to grep-3.6, the name of the offending file was not printed. + ['backtracking-with-file', '-P "((a+)*)+$"', {EXIT=>2}, + {IN=>{f=>"a"x20 ."b"}}, + {ERR => $ENV{PCRE_WORKS} == 1 + ? "$prog: f: exceeded PCRE's backtracking limit\n" + : $no_pcre }, ], |