[108078] trunk/base/src/port1.0/portconfigure.tcl

Lawrence Velázquez larryv at macports.org
Fri Jul 12 13:22:16 PDT 2013


On Jul 12, 2013, at 3:45 PM, Ryan Schmidt <ryandesign at macports.org> wrote:

> On Jul 12, 2013, at 13:38, larryv at macports.org wrote:
> 
>> Revision: 108078
>>         https://trac.macports.org/changeset/108078
>> Author:   larryv at macports.org
>> Date:     2013-07-12 11:38:30 -0700 (Fri, 12 Jul 2013)
>> Log Message:
>> -----------
>> portconfigure.tcl: Make "eval" uses robust.
> 
> Now I'm curious! Why is this more robust?

This probably explains it better than I can :)

http://wiki.tcl.tk/1017#pagetocdc3b9f30

>> Modified Paths:
>> --------------
>>   trunk/base/src/port1.0/portconfigure.tcl
>> 
>> Modified: trunk/base/src/port1.0/portconfigure.tcl
>> ===================================================================
>> --- trunk/base/src/port1.0/portconfigure.tcl	2013-07-12 18:17:04 UTC (rev 108077)
>> +++ trunk/base/src/port1.0/portconfigure.tcl	2013-07-12 18:38:30 UTC (rev 108078)
>> @@ -77,7 +77,7 @@
>>        ([info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == $option_defaults(${type}.cmd)) ||
>>        (![info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == "${type}")
>>        )} {
>> -            eval depends_build-append $dep
>> +            eval [linsert $dep 0 depends_build-append]
>>    }
>> }
>> 
>> @@ -97,14 +97,14 @@
>>            autoreconf.cmd  -
>>            automake.cmd    -
>>            autoconf.cmd {
>> -                eval depends_build-delete $configure_map(autoconf)
>> +                eval [linsert $configure_map(autoconf) 0 depends_build-delete]

These two changes are more about best practices than anything else, since we already control the possible values of $dep and $configure_map(autoconf).

>>            }
>>            xmkmf.cmd {
>> -                depends_build-delete $configure_map(xmkmf)
>> +                eval [linsert $configure_map(xmkmf) 0 depends_build-delete]
>>            }
>>            use_xmkmf {
>>                if {[tbool args]} {
>> -                    depends_build-append $configure_map(xmkmf)
>> +                    eval [linsert $configure_map(xmkmf) 0 depends_build-append]

These were for consistency with $configure_map(autoconf). Doesn't make a practical difference, since $configure_map(xmkmf) currently has only one value.

>>                }
>>            }
>>            default {
>> @@ -765,7 +765,7 @@
>>            append_list_to_environment_value configure "OBJCXXFLAGS" ${configure.universal_objcxxflags}
>>            append_list_to_environment_value configure "CPPFLAGS" ${configure.universal_cppflags}
>>            append_list_to_environment_value configure "LDFLAGS" ${configure.universal_ldflags}
>> -            eval configure.pre_args-append ${configure.universal_args}
>> +            eval [linsert ${configure.universal_args} 0 configure.pre_args-append]

This should make sure that any wonky ${configure.universal_args} values are escaped correctly, although this may already be done somewhere else.

These are undeniably ugly. For these uses, it would be preferable to dispense with eval entirely. If we didn't have to target Tcl 8.4, we could use these instead:

    depends_build-append {*}$dep
    depends_build-delete {*}$configure_map(autoconf)
    depends_build-delete {*}$configure_map(xmkmf)
    depends_build-append {*}$configure_map(xmkmf)
    configure.pre_args-append {*}${configure.universal_args}

http://wiki.tcl.tk/1017#pagetoc1f624d05

vq


More information about the macports-dev mailing list