<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[25789] trunk/base/src/port/port.tcl</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/macports/changeset/25789">25789</a></dd>
<dt>Author</dt> <dd>jberry@macports.org</dd>
<dt>Date</dt> <dd>2007-06-01 22:07:27 -0700 (Fri, 01 Jun 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix bug #10674.

port installed, active, list, and search all behaved poorly if given
a pseudo port that evaluated to nothing. The root problem was that the
argument parsing code could not tell the difference between no arguments
and arguments that evaluated to a null set.

The change puts a hack in that sets a global option if there are indeed
no arguments to an action, to allow us to distinguish this case.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbasesrcportporttcl">trunk/base/src/port/port.tcl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbasesrcportporttcl"></a>
<div class="modfile"><h4>Modified: trunk/base/src/port/port.tcl (25788 => 25789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/base/src/port/port.tcl        2007-06-02 04:00:10 UTC (rev 25788)
+++ trunk/base/src/port/port.tcl        2007-06-02 05:07:27 UTC (rev 25789)
</span><span class="lines">@@ -912,10 +912,6 @@
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         # Walk through each item in a, matching against b
</span><del>-        #
-        # Note: -regexp may not be present in all versions of Tcl we need to work
-        #                 against, in which case we may have to fall back to a slower alternative
-        #                for those cases. I'm not worrying about that for now, however. -jdb
</del><span class="cx">         foreach aitem $a {
</span><span class="cx">                 array set port $aitem
</span><span class="cx">                 
</span><span class="lines">@@ -1509,7 +1505,8 @@
</span><span class="cx">         set status 0
</span><span class="cx">         set restrictedList 0
</span><span class="cx">         set ilist {}
</span><del>-        if { [llength $portlist] } {
</del><ins>+        
+        if { [llength $portlist] || ![global_option_isset ports_no_args]} {
</ins><span class="cx">                 set restrictedList 1
</span><span class="cx">                 foreachport $portlist {
</span><span class="cx">                         set composite_version [composite_version $portversion [array get variations]]
</span><span class="lines">@@ -1561,10 +1558,10 @@
</span><span class="cx"> 
</span><span class="cx">         set status 0
</span><span class="cx"> 
</span><del>-        # If port names were supplied, limit ourselves to those port, else check all installed ports
</del><ins>+        # If port names were supplied, limit ourselves to those ports, else check all installed ports
</ins><span class="cx">         set ilist {}
</span><span class="cx">         set restrictedList 0
</span><del>-        if { [llength $portlist] } {
</del><ins>+        if { [llength $portlist] || ![global_option_isset ports_no_args]} {
</ins><span class="cx">                 set restrictedList 1
</span><span class="cx">                 foreach portspec $portlist {
</span><span class="cx">                         array set port $portspec
</span><span class="lines">@@ -1793,7 +1790,7 @@
</span><span class="cx"> 
</span><span class="cx"> proc action_search { action portlist opts } {
</span><span class="cx">         set status 0
</span><del>-        if {![llength portlist]} {
</del><ins>+        if {![llength $portlist] &amp;&amp; [global_option_isset ports_no_args]} {
</ins><span class="cx">                 ui_error &quot;You must specify a search pattern&quot;
</span><span class="cx">                 return 1
</span><span class="cx">         }
</span><span class="lines">@@ -1841,9 +1838,9 @@
</span><span class="cx"> 
</span><span class="cx"> proc action_list { action portlist opts } {
</span><span class="cx">         set status 0
</span><del>-
</del><ins>+        
</ins><span class="cx">         # Default to list all ports if no portnames are supplied
</span><del>-        if {![llength $portlist]} {
</del><ins>+        if {![llength $portlist] &amp;&amp; [global_option_isset ports_no_args]} {
</ins><span class="cx">                 add_to_portlist portlist [list name &quot;-all-&quot;]
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="lines">@@ -2340,14 +2337,23 @@
</span><span class="cx">                 # used to terminate option processing, or the pseudo-port current must be specified).
</span><span class="cx">                 parse_options $action ui_options global_options
</span><span class="cx">                 
</span><del>-                # Parse port specifications into portlist
</del><ins>+                # Parse action arguments, setting a special flag if there were none
+                # We otherwise can't tell the difference between arguments that evaluate
+                # to the empty set, and the empty set itself.
</ins><span class="cx">                 set portlist {}
</span><del>-                if {![portExpr portlist]} {
-                        ui_error &quot;Improper expression syntax while processing parameters&quot;
-                        set action_status 1
-                        break
</del><ins>+                switch -- [lookahead] {
+                                        -
+                        _EOF_        { set global_options(ports_no_args) yes }
+                        default {
+                                # Parse port specifications into portlist
+                                if {![portExpr portlist]} {
+                                        ui_error &quot;Improper expression syntax while processing parameters&quot;
+                                        set action_status 1
+                                        break
+                                }
+                        }
</ins><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 # Find an action to execute
</span><span class="cx">                 set action_proc [find_action_proc $action]
</span><span class="cx">                 if { $action_proc != &quot;&quot; } {
</span></span></pre>
</div>
</div>

</body>
</html>