[146745] trunk/base/src/port/port.tcl

ijackson at macports.org ijackson at macports.org
Wed Mar 16 14:47:18 PDT 2016


Revision: 146745
          https://trac.macports.org/changeset/146745
Author:   ijackson at macports.org
Date:     2016-03-16 14:47:18 -0700 (Wed, 16 Mar 2016)
Log Message:
-----------
Add range support to ui_ask_multichoice API.

Modified Paths:
--------------
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2016-03-16 21:37:08 UTC (rev 146744)
+++ trunk/base/src/port/port.tcl	2016-03-16 21:47:18 UTC (rev 146745)
@@ -5508,15 +5508,31 @@
 
             set selected_opt []
 
+            set err_flag 1
             foreach num $input {
-                if {([string is integer -strict $num] && $num <= [llength $ports] && $num > 0)} {
+                if {[string is integer -strict $num] && $num <= [llength $ports] && $num > 0} {
                     lappend selected_opt [expr {$num -1}]
+                } elseif {[regexp {(\d+)-(\d+)} $input _ start end]
+                          && $start <= [llength $ports]
+                          && $start > 0
+                          && $end <= [llength $ports]
+                          && $end > 0
+                } then {
+                    if {$start > $end} {
+                        set tmp $start
+                        set start $end
+                        set end $tmp
+                    }
+                    for {set x $start} {$x <= $end} {incr x} {
+                        lappend selected_opt [expr {$x -1}]
+                    }
                 } else {
                     puts "Please enter numbers separated by a space which are indices from the above list."
+                    set err_flag 0
                     break
                 }
             }
-            if {[llength $input] == [llength $selected_opt]} {
+            if {$err_flag == 1} {
                 return $selected_opt
             }
         }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160316/241ef39b/attachment.html>


More information about the macports-changes mailing list