PATCH: reduce syntactic sugar
Ben Elliston <[email protected]>
| Newsgroups | gmane.comp.sysutils.dejagnu.general |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
* 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
_______________________________________________
DejaGnu mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/dejagnu
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEFS8+rdM1/2KWERKFZ9rcPj90NkkFAlwK83YACgkQZ9rcPj90 Nkk5qA/+KoR32MzkbBu+3O6hOMKr5i9KWZlWN/vPV7gnjAfbFoS54IDW32ALEPB6 vKLTaITS889Cl4plUsnW0hgtaogtDfvYL06vSmsYi1KOxuk11cjJUnyAoXwfCCGb TwbuuespuC8wDOLB4FUaZHpJu+qQsEEY6DrYRDvzON8QBY7vWlV1HHVBECsRgXsI pVbVgErdNjyW1RRN1pfilXUYyqk87GRZ0lzUqsL+RePgPj1Pps/OMftlvtZPQpX3 /MPmK0uPsO6b3ItrOifZ3/EzssBnIUKSaEZqFPsLtPd2R1Eoo6j0jNHbeNEnsTEz mZdh9d7ovSLBhJB5BJxvuFLMt2du7661bxbVKfFMM/Rq+//4nj7NDUL9WxEqnI96 URFICfmRMHqIzCpx4V6cwAqV2t2SLr3t/x5jLgt9mw/r2OFjv3oCgG7MPlVBmq41 krcmxtNOtoXrbc7+5RsmJ5wsHPrnij/+naZyuG8bQZywJsNJIDGFlSpOhHwV/QBA STxJdU2w/d9BN5gYecQAIE5phf5ZJXM6ltk1DA1UXJ+YDdkEGhohH0f8CaLMHPCa ao6xd5PrewM1vHPBHjw/5jrk2ZSkiICQQlPzJ+gKXig+Ep2/oZBRllcI4tmKK9ei PvYtv9VPAo2uRo6n/c9gR9ATF7Bh/xGUF/PlAlRkIRrvI3cSGes= =FkPp -----END PGP SIGNATURE-----