[82760] trunk/base/src/port1.0/portutil.tcl

raimue at macports.org raimue at macports.org
Fri Aug 19 14:41:41 PDT 2011


Revision: 82760
          http://trac.macports.org/changeset/82760
Author:   raimue at macports.org
Date:     2011-08-19 14:41:40 -0700 (Fri, 19 Aug 2011)
Log 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

Modified Paths:
--------------
    trunk/base/src/port1.0/portutil.tcl

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2011-08-19 21:07:57 UTC (rev 82759)
+++ trunk/base/src/port1.0/portutil.tcl	2011-08-19 21:41:40 UTC (rev 82760)
@@ -132,11 +132,11 @@
 }
 
 ##
-# Handle option-replace
+# Handle option-strsed
 #
 # @param option name of the option
 # @param args arguments
-proc handle_option-replace {option args} {
+proc handle_option-strsed {option args} {
     global $option user_options option_procs
 
     if {![info exists user_options($option)] && [info exists $option]} {
@@ -148,6 +148,37 @@
     }
 }
 
+##
+# Handle option-replace
+#
+# @param option name of the option
+# @param args arguments
+proc handle_option-replace {option args} {
+    global $option user_options option_procs deprecated_options
+
+    # Deprecate -replace with only one argument, for backwards compatibility call -strsed
+    # XXX: Remove this in 2.2.0
+    if {[llength $args] == 1} {
+        if {![info exists deprecated_options(${option}-replace)]} {
+            set deprecated_options(${option}-replace) [list ${option}-strsed 0]
+        }
+        set refcount [lindex $deprecated_options(${option}-replace) 1]
+        lset deprecated_options(${option}-replace) 1 [expr $refcount + 1]
+        ui_msg "LOL"
+        return [eval handle_option-strsed $option $args]
+    }
+
+    if {![info exists user_options($option)] && [info exists $option]} {
+        foreach {old new} $args {
+            set index [lsearch -exact [set $option] $old]
+            if {$index == -1} {
+                continue
+            }
+            set $option [lreplace [set $option] $index $index $new]
+        }
+    }
+}
+
 # options
 # Exports options in an array as externally callable procedures
 # Thus, "options name date" would create procedures named "name"
@@ -160,6 +191,7 @@
         interp alias {} $option {} handle_option $option
         interp alias {} $option-append {} handle_option-append $option
         interp alias {} $option-delete {} handle_option-delete $option
+        interp alias {} $option-strsed {} handle_option-strsed $option
         interp alias {} $option-replace {} handle_option-replace $option
     }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110819/e32c6a0b/attachment.html>


More information about the macports-changes mailing list