New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 82760


Ignore:
Timestamp:
08/19/11 14:41:40 (4 years ago)
Author:
raimue@…
Message:

port1.0/portutil.tcl:
Implement new option-replace using lsearch/lreplace instead of strsed. The old
syntax is still supported as option-strsed. Using option-replace with just one
argument still works but issues a deprecation warning in 'port lint'.

http://lists.macosforge.org/pipermail/macports-dev/2010-September/012739.html

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r82291 r82760  
    133133 
    134134## 
     135# Handle option-strsed 
     136# 
     137# @param option name of the option 
     138# @param args arguments 
     139proc handle_option-strsed {option args} { 
     140    global $option user_options option_procs 
     141 
     142    if {![info exists user_options($option)] && [info exists $option]} { 
     143        set temp [set $option] 
     144        foreach val $args { 
     145            set temp [strsed $temp $val] 
     146        } 
     147        set $option $temp 
     148    } 
     149} 
     150 
     151## 
    135152# Handle option-replace 
    136153# 
     
    138155# @param args arguments 
    139156proc handle_option-replace {option args} { 
    140     global $option user_options option_procs 
     157    global $option user_options option_procs deprecated_options 
     158 
     159    # Deprecate -replace with only one argument, for backwards compatibility call -strsed 
     160    # XXX: Remove this in 2.2.0 
     161    if {[llength $args] == 1} { 
     162        if {![info exists deprecated_options(${option}-replace)]} { 
     163            set deprecated_options(${option}-replace) [list ${option}-strsed 0] 
     164        } 
     165        set refcount [lindex $deprecated_options(${option}-replace) 1] 
     166        lset deprecated_options(${option}-replace) 1 [expr $refcount + 1] 
     167        ui_msg "LOL" 
     168        return [eval handle_option-strsed $option $args] 
     169    } 
    141170 
    142171    if {![info exists user_options($option)] && [info exists $option]} { 
    143         set temp [set $option] 
    144         foreach val $args { 
    145             set temp [strsed $temp $val] 
    146         } 
    147         set $option $temp 
     172        foreach {old new} $args { 
     173            set index [lsearch -exact [set $option] $old] 
     174            if {$index == -1} { 
     175                continue 
     176            } 
     177            set $option [lreplace [set $option] $index $index $new] 
     178        } 
    148179    } 
    149180} 
     
    161192        interp alias {} $option-append {} handle_option-append $option 
    162193        interp alias {} $option-delete {} handle_option-delete $option 
     194        interp alias {} $option-strsed {} handle_option-strsed $option 
    163195        interp alias {} $option-replace {} handle_option-replace $option 
    164196    } 
Note: See TracChangeset for help on using the changeset viewer.