This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] sanitize paths used in regular expression


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]