I started working through lib/target.exp to reduce unnecessary syntactic sugar around variable expansions. I find that removing excessive quoting and braces makes the code more reacable. It seems some of these were introduced by a lack of understanding of the Tcl syntax. The rest are due to DejaGnu contributors just copying what they see. :-)
(1) Unlike the shell, it is not necessary to protect against empty strings like so: call_to_proc "$x" foo In this case, the proc will always see two arguments even if $x is empty. If $x is undefined, you will get an error whether it is quoted or not. (2) Tcl variable names may contain an underscore. Therefore, there is no need to brace variable names like so: ${foo} ${foo_bar} In this case, $foo and $foo_bar work just fine. There are cases where it is needed, though, such as ${tool}_init. Comments? Cheers, Ben 2018-12-08 Ben Elliston <b...@gnu.org> * lib/target.exp: Remove excessive syntactic sugar in variable expansions such as: "$foo", ${foo}, "${foo}", ${foo_bar}. diff --git a/lib/target.exp b/lib/target.exp index dbb50f6..b818d92 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -639,7 +639,7 @@ proc default_target_compile {source destfile type options} { if {[isremote host]} { if {[host_info exists use_at]} { set fid [open "atfile" "w"] - puts $fid "$opts" + puts $fid $opts close $fid set opts "@[remote_download host atfile]" remote_file build delete atfile @@ -673,7 +673,7 @@ proc default_target_compile {source destfile type options} { if { [lindex $status 1] ne "" } { verbose "output is:\n[lindex $status 1]" 2 } - if { [lindex $status 0] != 0 && "${comp_output}" eq "" } { + if { [lindex $status 0] != 0 && $comp_output eq "" } { set comp_output "exit status is [lindex $status 0]" } return ${comp_output} @@ -698,7 +698,7 @@ proc default_target_assemble { source destfile flags } { global ASFLAGS_FOR_TARGET if {[info exists AS_FOR_TARGET]} { - set AS "$AS_FOR_TARGET" + set AS $AS_FOR_TARGET } else { if {![board_info target exists assembler]} { set AS [find_gas] @@ -737,7 +737,7 @@ proc default_target_assemble { source destfile flags } { # linker. # proc target_link { objects destfile flags } { - return [default_link target "$objects" "$destfile" $flags] + return [default_link target $objects $destfile $flags] } proc default_link { board objects destfile flags } { @@ -770,7 +770,7 @@ proc default_link { board objects destfile flags } { } if {[info exists LD_FOR_TARGET]} { - set LD "$LD_FOR_TARGET" + set LD $LD_FOR_TARGET } else { if {![board_info target exists linker]} { set LD [find_ld] @@ -804,7 +804,7 @@ proc default_link { board objects destfile flags } { foreach x $objects { set nobjects "$nobjects [remote_download host $x]" } - set objects "$nobjects" + set objects $nobjects set dest "a.out" } else { set dest $destfile
signature.asc
Description: PGP signature
_______________________________________________ DejaGnu mailing list DejaGnu@gnu.org https://lists.gnu.org/mailman/listinfo/dejagnu