* lib/compat.exp (compat-execute): Do not use regsub unsafely.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 15 May 2005 22:31:35 +0000 (22:31 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 15 May 2005 22:31:35 +0000 (22:31 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99747 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/lib/compat.exp

index 9e23938..9f9458e 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-15  Mark Mitchell  <mark@codesourcery.com>
+
+       * lib/compat.exp (compat-execute): Do not use regsub unsafely.
+
 2005-05-15  Jerry DeLisle <jvdelisle@verizon.net>
 
        PR fortran/17432
index 79f6f15..def6f26 100644 (file)
@@ -279,8 +279,17 @@ proc compat-execute { src1 sid use_alt } {
     regsub "sid" "sid_y_alt.o" $sid obj3_alt
 
     # Get the base name of this test, for use in messages.
-    regsub "^$srcdir/?" $src1 "" testcase
-    regsub "^$tmpdir/?" $testcase "tmpdir-" testcase
+    set testcase "$src1"
+    # Remove the $srcdir and $tmpdir prefixes from $src1.  (It would
+    # be possible to use "regsub" here, if we were careful to escape
+    # all regular expression characters in $srcdir and $tmpdir, but
+    # that would be more complicated that this approach.) 
+    if {[string first "$srcdir/" "$src1"] == 0} {
+       set testcase [string range "$src1" [string length "$srcdir/"] end]
+    }
+    if {[string first "$tmpdir/" "$src1"] == 0} {
+       set testcase [string range "$src1" [string length "$tmpdir/"] end]
+    }
     regsub "_main.*" $testcase "" testcase
     # Set up the base name of executable files so they'll be unique.
     regsub -all "\[./\]" $testcase "-" execbase