This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] sanitize paths used in regular expression
- From: Zachary T Welch <zwelch at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: Zachary T Welch <zwelch at codesourcery dot com>
- Date: Thu, 14 Jan 2016 16:54:18 -0800
- Subject: [PATCH] sanitize paths used in regular expression
- Authentication-results: sourceware.org; auth=none
This patch fixes a small problem when running 'make check' from a path
that includes "++". When such paths get used as a regular expression,
that sequence would cause a runtime error. That is prevented here by
escaping that character.
gcc/testsuite/lib/
* prune.exp (prune_file_path): Sanitize path used in regex.
Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
---
gcc/testsuite/lib/prune.exp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 8e4c203..3bb477c 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -76,9 +76,12 @@ proc prune_gcc_output { text } {
proc prune_file_path { text } {
global srcdir
+ # escape '+' characters when using path as regex pattern
+ set safedir {[regsub -all {\+} "$srcdir" "\\+"]}
+ regsub -all "$safedir\/" $text "" text
+
# Truncate absolute file path into relative path.
- set topdir "[file dirname [file dirname [file dirname $srcdir]]]"
- regsub -all "$srcdir\/" $text "" text
+ set topdir "[file dirname [file dirname [file dirname $safedir]]]"
regsub -all "$topdir\/" $text "" text
return $text
--
1.8.1.1