summaryrefslogtreecommitdiff
path: root/src/pcresearch.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2020-10-04 09:39:39 -0700
committerJim Meyering <meyering@fb.com>2020-10-11 20:30:30 -0700
commitdf33ff807de40b131ba835ee4b0d27a0577a17ab (patch)
tree877177afbfe2d6c5b2805074d7a488fdac22a26a /src/pcresearch.c
parentf31abf786f61f4bdd7134559a5f155fc9c8c2513 (diff)
downloadgrep-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 'src/pcresearch.c')
-rw-r--r--src/pcresearch.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 67989675..df91ee9d 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -303,25 +303,29 @@ Pexecute (void *vcp, char const *buf, size_t size, size_t *match_size,
break;
case PCRE_ERROR_NOMEMORY:
- die (EXIT_TROUBLE, 0, _("memory exhausted"));
+ die (EXIT_TROUBLE, 0, _("%s: memory exhausted"), input_filename ());
#if PCRE_STUDY_JIT_COMPILE
case PCRE_ERROR_JIT_STACKLIMIT:
- die (EXIT_TROUBLE, 0, _("exhausted PCRE JIT stack"));
+ die (EXIT_TROUBLE, 0, _("%s: exhausted PCRE JIT stack"),
+ input_filename ());
#endif
case PCRE_ERROR_MATCHLIMIT:
- die (EXIT_TROUBLE, 0, _("exceeded PCRE's backtracking limit"));
+ die (EXIT_TROUBLE, 0, _("%s: exceeded PCRE's backtracking limit"),
+ input_filename ());
case PCRE_ERROR_RECURSIONLIMIT:
- die (EXIT_TROUBLE, 0, _("exceeded PCRE's recursion limit"));
+ die (EXIT_TROUBLE, 0, _("%s: exceeded PCRE's recursion limit"),
+ input_filename ());
default:
/* For now, we lump all remaining PCRE failures into this basket.
If anyone cares to provide sample grep usage that can trigger
particular PCRE errors, we can add to the list (above) of more
detailed diagnostics. */
- die (EXIT_TROUBLE, 0, _("internal PCRE error: %d"), e);
+ die (EXIT_TROUBLE, 0, _("%s: internal PCRE error: %d"),
+ input_filename (), e);
}
return -1;