[146658] trunk/base/src

g5pw at macports.org g5pw at macports.org
Mon Mar 14 19:06:07 PDT 2016


Revision: 146658
          https://trac.macports.org/changeset/146658
Author:   g5pw at macports.org
Date:     2016-03-14 19:06:07 -0700 (Mon, 14 Mar 2016)
Log Message:
-----------
base: ui_ask_multichoice returns 0-based index instead of 1-based one

- Return 0-based index: since you pass a list to the proc, it makes sense for it
  to return a list of 0-based indexes the user selected.
- Add a check for extra indices
- Update portuninstall.tcl to use the new 0-based indexed ui_ask_multichoice

Modified Paths:
--------------
    trunk/base/src/port/port.tcl
    trunk/base/src/registry2.0/portuninstall.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2016-03-15 01:13:42 UTC (rev 146657)
+++ trunk/base/src/port/port.tcl	2016-03-15 02:06:07 UTC (rev 146658)
@@ -5512,21 +5512,28 @@
                 return -code error "Ctrl-C"
             }
             signal -restart error {TERM INT}
-            set count 0
             # check if input is non-empty and otherwise fine
             if {$input == ""} {
                 continue
             }
+
+            if {[llength $input] > [llength $ports]} {
+                puts "Extra indices present. Please enter option(s) only once."
+                continue
+            }
+
+            set selected_opt []
+
             foreach num $input {
-                if {($num <= [llength $ports] && [string is integer -strict $num])} {
-                    incr count
+                if {([string is integer -strict $num] && $num <= [llength $ports] && $num > 0)} {
+                    lappend selected_opt [expr {$num -1}]
                 } else {
                     puts "Please enter numbers separated by a space which are indices from the above list."
                     break
                 }
             }
-            if {$count == [llength $input]} {
-                return $input
+            if {[llength $input] == [llength $selected_opt]} {
+                return $selected_opt
             }
         }
     }

Modified: trunk/base/src/registry2.0/portuninstall.tcl
===================================================================
--- trunk/base/src/registry2.0/portuninstall.tcl	2016-03-15 01:13:42 UTC (rev 146657)
+++ trunk/base/src/registry2.0/portuninstall.tcl	2016-03-15 02:06:07 UTC (rev 146658)
@@ -174,7 +174,7 @@
         if {[info exists macports::ui_options(questions_multichoice)]} {
             set retstring [$macports::ui_options(questions_multichoice) $msg "Choice_Q2" $portilist]
             foreach index $retstring {
-                set uport [lindex $sortedlist [expr { $index - 1 }]]
+                set uport [lindex $sortedlist $index]
                 uninstall [$uport name] [$uport version] [$uport revision] [$uport variants]
             }
             return 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160314/bd8d68e0/attachment.html>


More information about the macports-changes mailing list