From e25f4f2080867bc7e60c18ccf60030976144a3e3 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Thu, 6 Dec 2018 14:44:43 +1100 Subject: * runtest.exp: Replace '==' with 'eq' for string compares. Likewise, replace '!=' with 'ne'. Replace a few instances of [string length $str] == 0 with $str eq "". * config/gdb-comm.exp: Likewise. * lib/dg.exp: Likewise. * lib/framework.exp: Likewise. * lib/libgloss.exp: Likewise. * lib/remote.exp: Likewise. * lib/target.exp: Likewise. * lib/utils.exp: Likewise. --- ChangeLog | 13 +++++++++++++ config/gdb-comm.exp | 2 +- lib/dg.exp | 8 ++++---- lib/framework.exp | 4 ++-- lib/libgloss.exp | 2 +- lib/remote.exp | 16 ++++++++-------- lib/target.exp | 4 ++-- lib/utils.exp | 2 +- runtest.exp | 10 +++++----- 9 files changed, 37 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0aa76a..a60d2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2018-12-06 Ben Elliston + + * runtest.exp: Replace '==' with 'eq' for string compares. + Likewise, replace '!=' with 'ne'. Replace a few instances of + [string length $str] == 0 with $str eq "". + * config/gdb-comm.exp: Likewise. + * lib/dg.exp: Likewise. + * lib/framework.exp: Likewise. + * lib/libgloss.exp: Likewise. + * lib/remote.exp: Likewise. + * lib/target.exp: Likewise. + * lib/utils.exp: Likewise. + 2018-12-06 Jacob Bachmeyer * runtest.exp: Replace archaic use of [string match] with "eq". diff --git a/config/gdb-comm.exp b/config/gdb-comm.exp index fc25b9b..07ba25e 100644 --- a/config/gdb-comm.exp +++ b/config/gdb-comm.exp @@ -219,7 +219,7 @@ proc quit_gdb { } { set spawn_id [board_info host fileid] if { $spawn_id != "" && $spawn_id > -1 } { - if { [remote_send host "quit\n"] == "" } { + if { [remote_send host "quit\n"] eq "" } { remote_expect host 10 { -re ".*y or n.*$" { remote_send host "y\n" diff --git a/lib/dg.exp b/lib/dg.exp index 7a894cb..23f9512 100644 --- a/lib/dg.exp +++ b/lib/dg.exp @@ -592,14 +592,14 @@ proc dg-test { args } { set keep 0 set i 0 - if { [string index [lindex $args 0] 0] == "-" } { + if { [string index [lindex $args 0] 0] eq "-" } { for { set i 0 } { $i < [llength $args] } { incr i } { if { [lindex $args $i] == "--" } { incr i break } elseif { [lindex $args $i] == "-keep-output" } { set keep 1 - } elseif { [string index [lindex $args $i] 0] == "-" } { + } elseif { [string index [lindex $args $i] 0] eq "-" } { clone_output "ERROR: dg-test: illegal argument: [lindex $args $i]" return } else { @@ -805,7 +805,7 @@ proc dg-test { args } { if { [lindex ${dg-do-what} 2] == "F" } { setup_xfail "*-*-*" } - if { "$status" == "pass" } { + if { "$status" eq "pass" } { pass "$name execution test" verbose "Exec succeeded." 3 if { [llength ${dg-output-text}] > 1 } { @@ -823,7 +823,7 @@ proc dg-test { args } { } unset texttmp } - } elseif { "$status" == "fail" } { + } elseif { "$status" eq "fail" } { # It would be nice to get some info out of errorCode. if {[info exists errorCode]} { verbose "Exec failed, errorCode: $errorCode" 3 diff --git a/lib/framework.exp b/lib/framework.exp index 70b91c8..a635a03 100644 --- a/lib/framework.exp +++ b/lib/framework.exp @@ -142,7 +142,7 @@ proc is_remote { board } { # We're on the "build". The check for the empty string is just for # paranoia's sake--we shouldn't ever get one. "unix" is a magic # string that should really go away someday. - if { $board == "build" || $board == "unix" || $board == "" } { + if { $board eq "build" || $board eq "unix" || $board eq "" } { verbose "board is $board, not remote" 3 return 0 } @@ -186,7 +186,7 @@ proc is3way {} { set build_triplet ${host_triplet} } verbose "Checking $host_triplet against $build_triplet" 2 - if { "$build_triplet" == "$host_triplet" } { + if { "$build_triplet" eq "$host_triplet" } { return 0 } return 1 diff --git a/lib/libgloss.exp b/lib/libgloss.exp index c36630c..6a4fb0e 100644 --- a/lib/libgloss.exp +++ b/lib/libgloss.exp @@ -524,7 +524,7 @@ proc get_multilibs { args } { set multimatches "" set lines [split [exec $compiler -dumpspecs] "\n"] for {set i 0} {$i <= [llength $lines] - 1} {incr i 1} { - if {"*multilib_matches:" == "[lindex $lines $i]"} { + if {"*multilib_matches:" eq "[lindex $lines $i]"} { set multimatches [lindex $lines [expr {$i + 1}]] break } diff --git a/lib/remote.exp b/lib/remote.exp index d8b60a3..3761a7d 100644 --- a/lib/remote.exp +++ b/lib/remote.exp @@ -156,7 +156,7 @@ proc local_exec { commandline inp outp timeout } { # cause it to exit before it can exit normally. The child should # ignore SIGHUP. global errorInfo - if { "$inp" == "" && "$outp" == "" } { + if { "$inp" eq "" && "$outp" eq "" } { set id -1 set result [catch "eval spawn -ignore SIGHUP \{${commandline}\}" pid] if { $result == 0 } { @@ -265,7 +265,7 @@ proc local_exec { commandline inp outp timeout } { set status 0 } verbose "output is $output status $status" - if { $outp == "" || $outp == "|& cat" } { + if { $outp eq "" || $outp eq "|& cat" } { return [list $status $output] } else { return [list $status ""] @@ -613,7 +613,7 @@ proc call_remote { type proc dest args } { verbose "call_remote $type $proc $dest $args " 3 # Close has to be handled specially. - if { $proc == "close" || $proc == "open" } { + if { $proc eq "close" || $proc eq "open" } { foreach try "$high_prot [board_info $dest connect] telnet standard" { if { $try != "" } { if { [info procs "${try}_${proc}"] != "" } { @@ -819,7 +819,7 @@ proc unix_clean_filename { dest file } { } set result "" foreach x [split $file "/"] { - if { $x == "." || $x == "" } { + if { $x eq "." || $x eq "" } { continue } if { $x == ".." } { @@ -906,7 +906,7 @@ proc remote_spawn { dest commandline args } { } # Seems to me there should be a cleaner way to do this. - if { "$args" == "" } { + if { $args eq "" } { return [call_remote "" spawn "$dest" "$commandline"] } else { return [call_remote "" spawn "$dest" "$commandline" $args] @@ -1273,14 +1273,14 @@ proc remote_expect { board timeout args } { set x "[lrange $args $i $i]" regsub "^\n*\[ \t\]*" "$x" "" x - if { $x == "-i" || $x == "-timeout" || $x == "-ex" } { + if { $x eq "-i" || $x eq "-timeout" || $x eq "-ex" } { append res "$x " set next [expr {$i + 1}] append res "[lrange $args $next $next]" incr i continue } - if { $x == "-n" || $x == "-notransfer" || $x == "-nocase" || $x == "-indices" } { + if { $x eq "-n" || $x eq "-notransfer" || $x eq "-nocase" || $x eq "-indices" } { append res "${x} " continue } @@ -1304,7 +1304,7 @@ proc remote_expect { board timeout args } { } else { if { ${x} == "eof" } { set save_next 1 - } elseif { ${x} == "default" || ${x} == "timeout" } { + } elseif { ${x} eq "default" || ${x} eq "timeout" } { if { $error_sect == "" } { set save_next 1 } diff --git a/lib/target.exp b/lib/target.exp index ba6253f..9268f4e 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -673,7 +673,7 @@ proc default_target_compile {source destfile type options} { if { [lindex $status 1] != "" } { verbose "output is:\n[lindex $status 1]" 2 } - if { [lindex $status 0] != 0 && "${comp_output}" == "" } { + if { [lindex $status 0] != 0 && "${comp_output}" eq "" } { set comp_output "exit status is [lindex $status 0]" } return ${comp_output} @@ -756,7 +756,7 @@ proc default_link { board objects destfile flags } { regsub "^-Wl," $arg "" arg if {[regexp "^-L" $arg]} { # Is the directory in the next arg, or part of this one? - if { "$arg" == "-L" } { + if { $arg eq "-L" } { if { $i + 1 < $len } { append result " -L [lindex $ldflags $i+1]" incr i diff --git a/lib/utils.exp b/lib/utils.exp index 30f61fa..eb9865a 100644 --- a/lib/utils.exp +++ b/lib/utils.exp @@ -131,7 +131,7 @@ proc relative_filename { base destination } { # proc find { rootdir pattern } { set files [list] - if { [string length $rootdir] == 0 || [string length $pattern] == 0 } { + if { $rootdir eq "" || $pattern eq "" } { return $files } diff --git a/runtest.exp b/runtest.exp index b6e5c64..4657bd7 100644 --- a/runtest.exp +++ b/runtest.exp @@ -141,7 +141,7 @@ proc verbose { args } { set logfile 0 set i 0 - if { [string index [lindex $args 0] 0] == "-" } { + if { [string index [lindex $args 0] 0] eq "-" } { for { set i 0 } { $i < [llength $args] } { incr i } { if { [lindex $args $i] == "--" } { incr i @@ -152,7 +152,7 @@ proc verbose { args } { set logfile 1 } elseif { [lindex $args $i] == "-x" } { set xml 1 - } elseif { [string index [lindex $args $i] 0] == "-" } { + } elseif { [string index [lindex $args $i] 0] eq "-" } { clone_output "ERROR: verbose: illegal argument: [lindex $args $i]" return } else { @@ -665,11 +665,11 @@ if { $arg_build_triplet != "" } { # If we only specify --host, then that must be the build machine too, # and we're stuck using the old functionality of a simple cross test. -if {[expr { $build_triplet == "" && $host_triplet != "" } ]} { +if {[expr { $build_triplet eq "" && $host_triplet ne "" } ]} { set build_triplet $host_triplet } # If we only specify --build, then we'll use that as the host too. -if {[expr { $build_triplet != "" && $host_triplet == "" } ]} { +if {[expr { $build_triplet ne "" && $host_triplet eq "" } ]} { set host_triplet $build_triplet } unset arg_host_triplet arg_build_triplet @@ -678,7 +678,7 @@ unset arg_host_triplet arg_build_triplet # If the build machine type hasn't been specified by now, use config.guess. # -if {[expr {$build_triplet == "" && $host_triplet == ""}]} { +if {[expr {$build_triplet eq "" && $host_triplet eq ""}]} { # find config.guess foreach dir "$libdir $libdir/libexec $libdir/.. $execpath $srcdir $srcdir/.. $srcdir/../.." { verbose "Looking for ${dir}/config.guess" 2 -- cgit v1.1