[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] Use 'file join' to concatenate directory and filename
From: |
Andrew Burgess |
Subject: |
[PATCH 1/2] Use 'file join' to concatenate directory and filename |
Date: |
Thu, 7 Mar 2019 14:01:56 +0000 |
In search_and_load_file in once place 'file join' is used to
concatenate a directory and a filename, while elsewhere in the
function the concatenate is hard coded as a string "$dir/$initfile",
assuming that '/' is used to join components.
Presumably this is fine for all the targets dejagnu supports, but its
probably better to stick to one approach or the other.
This patch makes use of 'file join' for building paths.
ChangeLog:
* runtest.exp (search_and_load_file): Join the directory and
filename once using 'file join'.
---
ChangeLog | 5 +++++
runtest.exp | 13 +++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/runtest.exp b/runtest.exp
index bea8f29..c4dd207 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -328,18 +328,19 @@ proc search_and_load_file { type filelist dirlist } {
foreach dir $dirlist {
foreach initfile $filelist {
- verbose "Looking for $type $dir/$initfile" 2
- if {[file exists [file join $dir $initfile]]} {
+ set filename [file join $dir $initfile]
+ verbose "Looking for $type $filename" 2
+ if {[file exists $filename]} {
set found 1
set error ""
if { $type ne "library file" } {
- send_user "Using $dir/$initfile as $type.\n"
+ send_user "Using $filename as $type.\n"
} else {
- verbose "Loading $dir/$initfile"
+ verbose "Loading $filename"
}
- if {[catch "uplevel #0 source $dir/$initfile" error] == 1} {
+ if {[catch "uplevel #0 source $filename" error] == 1} {
global errorInfo
- send_error "ERROR: tcl error sourcing $type
$dir/$initfile.\n$error\n"
+ send_error "ERROR: tcl error sourcing $type
$filename.\n$error\n"
if {[info exists errorInfo]} {
send_error "$errorInfo\n"
}
--
2.14.5