Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

Changeset 37238

Show
Ignore:
Timestamp:
05/31/08 13:03:34 (6 months ago)
Author:
raimue@…
Message:

port/port.tcl:
Only expand portlist when needed

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port/port.tcl

    r37233 r37238  
    19511951     
    19521952    set separator "" 
    1953     foreachport $portlist { 
     1953    foreach portname $portlist { 
    19541954        puts -nonewline $separator 
    19551955 
     
    23422342} 
    23432343 
    2344  
     2344# action_array specifies which action to run on the given command 
     2345# and if the action wants an expanded portlist. 
     2346# The value is a list of the form {action expand}, 
     2347# where action is a string and expand a value (0, 1, 2) 
     2348#   0   Does not expect any text argument 
     2349#   1   Expects some strings as text argument 
     2350#   2   Wants an expanded list of ports as text argument 
    23452351global action_array 
    23462352array set action_array { 
    2347     usage       action_usage 
    2348     help        action_help 
    2349  
    2350     echo        action_echo 
    2351      
    2352     info        action_info 
    2353     location    action_location 
    2354     provides    action_provides 
    2355      
    2356     activate    action_activate 
    2357     deactivate  action_deactivate 
    2358      
    2359     sync        action_sync 
    2360     selfupdate  action_selfupdate 
    2361      
    2362     upgrade     action_upgrade 
    2363      
    2364     version     action_version 
    2365     platform    action_platform 
    2366     compact     action_compact 
    2367     uncompact   action_uncompact 
    2368      
    2369     uninstall   action_uninstall 
    2370      
    2371     installed   action_installed 
    2372     outdated    action_outdated 
    2373     contents    action_contents 
    2374     dependents  action_dependents 
    2375     deps        action_deps 
    2376     variants    action_variants 
    2377      
    2378     search      action_search 
    2379     list        action_list 
    2380      
    2381     ed          action_portcmds 
    2382     edit        action_portcmds 
    2383     cat         action_portcmds 
    2384     dir         action_portcmds 
    2385     work        action_portcmds 
    2386     cd          action_portcmds 
    2387     url         action_portcmds 
    2388     file        action_portcmds 
    2389     gohome      action_portcmds 
    2390      
    2391     fetch       action_target 
    2392     checksum    action_target 
    2393     extract     action_target 
    2394     patch       action_target 
    2395     configure   action_target 
    2396     build       action_target 
    2397     destroot    action_target 
    2398     install     action_target 
    2399     clean       action_target 
    2400     test        action_target 
    2401     lint        action_target 
    2402     submit      action_target 
    2403     trace       action_target 
    2404     livecheck   action_target 
    2405     distcheck   action_target 
    2406     mirror      action_target 
    2407     load        action_target 
    2408     unload      action_target 
    2409     distfiles   action_target 
    2410  
    2411     archive     action_target 
    2412     unarchive   action_target 
    2413     dmg         action_target 
    2414     mdmg        action_target 
    2415     dpkg        action_target 
    2416     mpkg        action_target 
    2417     pkg         action_target 
    2418     rpm         action_target 
    2419     srpm        action_target 
    2420  
    2421     quit        action_exit 
    2422     exit        action_exit 
     2353    usage       {action_usage 0} 
     2354    help        {action_help 1} 
     2355 
     2356    echo        {action_echo 2} 
     2357     
     2358    info        {action_info 2} 
     2359    location    {action_location 2} 
     2360    provides    {action_provides 1} 
     2361     
     2362    activate    {action_activate 2} 
     2363    deactivate  {action_deactivate 2} 
     2364     
     2365    sync        {action_sync 0} 
     2366    selfupdate  {action_selfupdate 0} 
     2367     
     2368    upgrade     {action_upgrade 2} 
     2369     
     2370    version     {action_version 0} 
     2371    platform    {action_platform 0} 
     2372    compact     {action_compact 2} 
     2373    uncompact   {action_uncompact 2} 
     2374     
     2375    uninstall   {action_uninstall 2} 
     2376     
     2377    installed   {action_installed 2} 
     2378    outdated    {action_outdated 2} 
     2379    contents    {action_contents 2} 
     2380    dependents  {action_dependents 2} 
     2381    deps        {action_deps 2} 
     2382    variants    {action_variants 2} 
     2383     
     2384    search      {action_search 1} 
     2385    list        {action_list 2} 
     2386     
     2387    ed          {action_portcmds 2} 
     2388    edit        {action_portcmds 2} 
     2389    cat         {action_portcmds 2} 
     2390    dir         {action_portcmds 2} 
     2391    work        {action_portcmds 2} 
     2392    cd          {action_portcmds 2} 
     2393    url         {action_portcmds 2} 
     2394    file        {action_portcmds 2} 
     2395    gohome      {action_portcmds 2} 
     2396     
     2397    fetch       {action_target 2} 
     2398    checksum    {action_target 2} 
     2399    extract     {action_target 2} 
     2400    patch       {action_target 2} 
     2401    configure   {action_target 2} 
     2402    build       {action_target 2} 
     2403    destroot    {action_target 2} 
     2404    install     {action_target 2} 
     2405    clean       {action_target 2} 
     2406    test        {action_target 2} 
     2407    lint        {action_target 2} 
     2408    submit      {action_target 2} 
     2409    trace       {action_target 2} 
     2410    livecheck   {action_target 2} 
     2411    distcheck   {action_target 2} 
     2412    mirror      {action_target 2} 
     2413    load        {action_target 2} 
     2414    unload      {action_target 2} 
     2415    distfiles   {action_target 2} 
     2416     
     2417    archive     {action_target 2} 
     2418    unarchive   {action_target 2} 
     2419    dmg         {action_target 2} 
     2420    mdmg        {action_target 2} 
     2421    dpkg        {action_target 2} 
     2422    mpkg        {action_target 2} 
     2423    pkg         {action_target 2} 
     2424    rpm         {action_target 2} 
     2425    srpm        {action_target 2} 
     2426     
     2427    quit        {action_exit 0} 
     2428    exit        {action_exit 0} 
    24232429} 
    24242430 
     
    24292435    set action_proc "" 
    24302436    if { [info exists action_array($action)] } { 
    2431         set action_proc $action_array($action) 
     2437        set action_proc [lindex $action_array($action) 0] 
    24322438    } 
    24332439     
    24342440    return $action_proc 
     2441} 
     2442 
     2443# Returns whether an action expects text arguments at all, 
     2444# expects text arguments or wants an expanded list of ports 
     2445# Return value: 
     2446#   0   Does not expect any text argument 
     2447#   1   Expects some strings as text argument 
     2448#   2   Wants an expanded list of ports as text argument 
     2449proc action_needs_portlist { action } { 
     2450    global action_array 
     2451 
     2452    set ret 0 
     2453    if {[info exists action_array($action)]} { 
     2454        set ret [lindex $action_array($action) 1] 
     2455    } 
     2456 
     2457    return [expr $ret > 2 ? 2 : $ret] 
    24352458} 
    24362459 
     
    26152638            break 
    26162639        } 
    2617          
     2640 
     2641        # Does the port need text arguments? 
     2642        set expand [action_needs_portlist $action] 
     2643 
    26182644        # Parse action arguments, setting a special flag if there were none 
    26192645        # We otherwise can't tell the difference between arguments that evaluate 
     
    26262652            } 
    26272653            default { 
    2628                 # Parse port specifications into portlist 
    2629                 if {![portExpr portlist]} { 
    2630                     ui_error "Improper expression syntax while processing parameters" 
    2631                     set action_status 1 
    2632                     break 
     2654                switch -- $expand { 
     2655                    0 { 
     2656                        ui_error "$action does not accept string arguments" 
     2657                        set action_status 1 
     2658                        break 
     2659                    } 
     2660                    1 { 
     2661                        while { [moreargs] && ![match ";"] } { 
     2662                            lappend portlist [lookahead] 
     2663                            advance 
     2664                        } 
     2665                    } 
     2666                    2 { 
     2667                        # Parse port specifications into portlist 
     2668                        if {![portExpr portlist]} { 
     2669                            ui_error "Improper expression syntax while processing parameters" 
     2670                            set action_status 1 
     2671                            break 
     2672                        } 
     2673                    } 
    26332674                } 
    26342675            }