aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.exp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.exp')
-rw-r--r--lib/utils.exp52
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/utils.exp b/lib/utils.exp
index abfbd1f..9c9575d 100644
--- a/lib/utils.exp
+++ b/lib/utils.exp
@@ -49,7 +49,7 @@ proc getdirs { args } {
catch "glob ${path}/${pattern}" tmp
if { ${tmp} != "" } {
foreach i ${tmp} {
- if [file isdirectory $i] {
+ if {[file isdirectory $i]} {
switch -- "[file tail $i]" {
"testsuite" -
"config" -
@@ -61,7 +61,7 @@ proc getdirs { args } {
continue
}
default {
- if [file readable $i] {
+ if {[file readable $i]} {
verbose "Found directory [file tail $i]" 3
lappend dirs $i
if { $alldirs } {
@@ -77,7 +77,7 @@ proc getdirs { args } {
return ""
}
- if ![info exists dirs] {
+ if {![info exists dirs]} {
return ""
} else {
return $dirs
@@ -103,7 +103,7 @@ proc find { rootdir pattern } {
foreach i $dirs {
verbose "Looking in $i" 3
foreach match [glob -nocomplain $i/$pattern] {
- if ![file isdirectory $match] {
+ if {![file isdirectory $match]} {
lappend files $match
verbose "Adding $match to file list" 3
}
@@ -127,10 +127,10 @@ proc which { file } {
# if it exists then the path must be OK
# ??? What if $file has no path and "." isn't in $PATH?
- if [file exists $file] {
+ if {[file exists $file]} {
return $file
}
- if [info exists env(PATH)] {
+ if {[info exists env(PATH)]} {
set path [split $env(PATH) ":"]
} else {
return 0
@@ -138,8 +138,8 @@ proc which { file } {
foreach i $path {
verbose "Checking against $i" 3
- if [file exists [file join $i $file]] {
- if [file executable [file join $i $file]] {
+ if {[file exists [file join $i $file]]} {
+ if {[file executable [file join $i $file]]} {
return [file join $i $file]
} else {
warning "[file join $i $file] exists but is not an executable"
@@ -178,8 +178,8 @@ proc grep { args } {
set fd [open $file r]
while { [gets $fd cur_line]>=0 } {
incr i
- if [regexp -- "$pattern" $cur_line match] {
- if ![string match "" $options] {
+ if {[regexp -- "$pattern" $cur_line match]} {
+ if {![string match "" $options]} {
foreach opt $options {
switch $opt {
"line" {
@@ -195,7 +195,7 @@ proc grep { args } {
close $fd
unset fd
unset i
- if ![info exists grep_out] {
+ if {![info exists grep_out]} {
set grep_out ""
}
return $grep_out
@@ -211,7 +211,7 @@ proc prune { list pattern } {
set tmp {}
foreach i $list {
verbose "Checking pattern \"$pattern\" against $i" 3
- if ![string match $pattern $i] {
+ if {![string match $pattern $i]} {
lappend tmp $i
} else {
verbose "Removing element $i from list" 3
@@ -226,8 +226,8 @@ proc prune { list pattern } {
proc slay { name } {
set in [open [concat "|ps"] r]
while {[gets $in line]>-1} {
- if ![string match "*expect*slay*" $line] {
- if [string match "*$name*" $line] {
+ if {![string match "*expect*slay*" $line]} {
+ if {[string match "*$name*" $line]} {
set pid [lindex $line 0]
catch "exec kill -9 $pid"
verbose "Killing $name, pid = $pid\n"
@@ -241,7 +241,7 @@ proc slay { name } {
# Convert a relative path to an absolute one on the local machine.
#
proc absolute { path } {
- if [string match "." $path] {
+ if {[string match "." $path]} {
return [pwd]
}
@@ -261,9 +261,9 @@ proc psource { file } {
global errorCode
unset errorInfo
- if [file exists $file] {
+ if {[file exists $file]} {
catch "source $file"
- if [info exists errorInfo] {
+ if {[info exists errorInfo]} {
send_error "ERROR: errors in $file\n"
send_error "$errorInfo"
return 1
@@ -285,12 +285,12 @@ proc psource { file } {
# Eg: RUNTESTFLAGS="bar.exp=foo1.c foo2.c foo3*.c bar/baz*.c"
#
proc runtest_file_p { runtests testcase } {
- if [string length [lindex $runtests 1]] {
+ if {[string length [lindex $runtests 1]]} {
foreach ptn [lindex $runtests 1] {
- if [string match "*/$ptn" $testcase] {
+ if {[string match "*/$ptn" $testcase]} {
return 1
}
- if [string match $ptn $testcase] {
+ if {[string match $ptn $testcase]} {
return 1
}
}
@@ -318,14 +318,14 @@ proc diff { file_1 file_2 } {
set eof -1
set differences 0
- if [file exists ${file_1}] {
+ if {[file exists ${file_1}]} {
set file_a [open ${file_1} r]
} else {
warning "${file_1} doesn't exist"
return 0
}
- if [file exists ${file_2}] {
+ if {[file exists ${file_2}]} {
set file_b [open ${file_2} r]
} else {
warning "${file_2} doesn't exist"
@@ -336,7 +336,7 @@ proc diff { file_1 file_2 } {
set list_a ""
while { [gets ${file_a} line] != ${eof} } {
- if [regexp "^#.*$" ${line}] {
+ if {[regexp "^#.*$" ${line}]} {
continue
} else {
lappend list_a ${line}
@@ -346,7 +346,7 @@ proc diff { file_1 file_2 } {
set list_b ""
while { [gets ${file_b} line] != ${eof} } {
- if [regexp "^#.*$" ${line}] {
+ if {[regexp "^#.*$" ${line}]} {
continue
} else {
lappend list_b ${line}
@@ -359,7 +359,7 @@ proc diff { file_1 file_2 } {
# verbose "\t${file_1}: ${i}: ${line_a}\n" 3
# verbose "\t${file_2}: ${i}: ${line_b}\n" 3
- if [string compare ${line_a} ${line_b}] {
+ if {[string compare ${line_a} ${line_b}]} {
verbose "line #${i}\n" 2
verbose "\< ${line_a}\n" 2
verbose "\> ${line_b}\n" 2
@@ -405,7 +405,7 @@ proc unsetenv { var } {
proc getenv { var } {
global env
- if [info exists env($var)] {
+ if {[info exists env($var)]} {
return $env($var)
} else {
return ""