[103055] users/cal/base-sqlite-portindex/src/port1.0/portutil.tcl

cal at macports.org cal at macports.org
Tue Feb 12 10:22:07 PST 2013


Revision: 103055
          https://trac.macports.org/changeset/103055
Author:   cal at macports.org
Date:     2013-02-12 10:22:07 -0800 (Tue, 12 Feb 2013)
Log Message:
-----------
make options sets rather than lists (which means no duplicate values allowed), drop support for calling -replace with one option, which was deprecated for a while

Modified Paths:
--------------
    users/cal/base-sqlite-portindex/src/port1.0/portutil.tcl

Modified: users/cal/base-sqlite-portindex/src/port1.0/portutil.tcl
===================================================================
--- users/cal/base-sqlite-portindex/src/port1.0/portutil.tcl	2013-02-12 18:20:31 UTC (rev 103054)
+++ users/cal/base-sqlite-portindex/src/port1.0/portutil.tcl	2013-02-12 18:22:07 UTC (rev 103055)
@@ -65,8 +65,9 @@
     # the Portfile's interpreter and the target's interpreters.
     global $option
     if {[llength $args] > 0} {
-        ui_debug "setting option $option to $args"
-        set $option [lindex $args 0]
+        ui_debug "setting option $option to [lindex $args 0]"
+        set $option {}
+        set_union $option [lindex $args 0]
     }
     return [set $option]
 }
@@ -84,6 +85,24 @@
     return [info exists $option]
 }
 
+proc set_union {option args} {
+    global $option
+
+    foreach val $args {
+        if {[lsearch -exact [set $option] $val] == -1} {
+            lappend $option $val
+        }
+    }
+}
+
+proc set_difference {option args} {
+    global $option
+
+    foreach val $args {
+        set $option [lsearch -all -inline -not -exact [set $option] $val]
+    }
+}
+
 ##
 # Handle an option
 #
@@ -93,7 +112,8 @@
     global $option user_options option_procs
 
     if {![info exists user_options($option)]} {
-        set $option $args
+        set $option {}
+        set_union $option $args
     }
 }
 
@@ -106,11 +126,10 @@
     global $option user_options option_procs
 
     if {![info exists user_options($option)]} {
-        if {[info exists $option]} {
-            set $option [concat [set $option] $args]
-        } else {
-            set $option $args
+        if {![info exists $option]} {
+            set $option {}
         }
+        set_union $option $args
     }
 }
 
@@ -123,11 +142,7 @@
     global $option user_options option_procs
 
     if {![info exists user_options($option)] && [info exists $option]} {
-        set temp [set $option]
-        foreach val $args {
-            set temp [ldelete $temp $val]
-        }
-        set $option $temp
+        set_difference $option $args
     }
 }
 
@@ -144,7 +159,7 @@
         foreach val $args {
             set temp [strsed $temp $val]
         }
-        set $option $temp
+        set $option [lsort -unique $temp]
     }
 }
 
@@ -156,24 +171,18 @@
 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]
-        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]
+            # only add the replacement if it isn't in the list yet
+            if {[lsearch -exact [set $option] $new] != -1} {
+                set $option [lreplace [set $option] $index $index $new]
+            } else {
+                set $option [lreplace [set $option] $index $index]
+            }
         }
     }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130212/d748e8bb/attachment.html>


More information about the macports-changes mailing list