OSDN Git Service

* lib/compat.exp (compat-execute): Fix processing of file names.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / compat.exp
index 79f6f15..6e15f91 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 # This file was written by Janis Johnson, <janis187@us.ibm.com>
 
@@ -62,7 +62,8 @@ if ![info exists COMPAT_SKIPS] {
     set COMPAT_SKIPS [list {}]
 }
 
-set skip_list $COMPAT_SKIPS
+global compat_skip_list
+set compat_skip_list $COMPAT_SKIPS
 
 load_lib dg.exp
 load_lib gcc-dg.exp
@@ -81,10 +82,10 @@ proc compat-obj { source dest optall optfile optstr xfaildata } {
     global testcase
     global tool
     global compiler_conditional_xfail_data
-    global skip_list
+    global compat_skip_list
 
     # Add the skip specifiers.
-    foreach skip $skip_list {
+    foreach skip $compat_skip_list {
        if { ![string match $skip ""] } {
            lappend optall "-DSKIP_$skip"
        }
@@ -258,10 +259,13 @@ proc compat-execute { src1 sid use_alt } {
     }
 
     # Set up the names of the other source files.
-    regsub "_main.*" $src1 "" base
-    regsub ".*/" $base "" base
-    regsub "_main" $src1 "_x" src2
-    regsub "_main" $src1 "_y" src3
+    set dir [file dirname $src1]
+    set ext [file extension $src1]
+    set base [file rootname $src1]
+    set base [string range $base [string length $dir] end]
+    regsub "_main" $base "" base
+    set src2 "${dir}/${base}_x${ext}"
+    set src3 "${dir}/${base}_y${ext}"
 
     # Use the dg-options mechanism to specify extra flags for this test. 
     # The extra flags in each file are used to compile that file, and the
@@ -279,8 +283,18 @@ 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/" "$testcase"] == 0} {
+       set testcase [string range "$testcase" [string length "$tmpdir/"] end]
+       set testcase "tmpdir-$testcase"
+    }
     regsub "_main.*" $testcase "" testcase
     # Set up the base name of executable files so they'll be unique.
     regsub -all "\[./\]" $testcase "-" execbase