Ticket #51706: patch-platform-command.diff

File patch-platform-command.diff, 1.5 KB (added by RJVB (René Bertin), 8 years ago)
  • src/port1.0/portutil.tcl

    diff --git src/port1.0/portutil.tcl src/port1.0/portutil.tcl
    index 362b3ea..4122b9f 100644
    proc variant_desc {porturl variant} { 
    767773# Portfile level procedure to provide support for declaring platform-specifics
    768774# Basically, just a fancy 'if', so that Portfiles' platform declarations can
    769775# be more readable, and support arch and version specifics
    770 proc platform {args} {
     776proc platform {os args} {
    771777    global os.platform os.subplatform os.arch os.major
    772778
    773779    set len [llength $args]
    774     if {$len < 2} {
     780    if {$len < 1} {
    775781        return -code error "Malformed platform specification"
    776782    }
    777     set code [lindex $args end]
    778     set os [lindex $args 0]
    779     set args [lrange $args 1 [expr {$len - 2}]]
     783    if {[lindex $args end-1] eq "else"} {
     784        set code [lindex $args end-2]
     785        set altcode [lindex $args end]
     786        set consumed 3
     787    } else {
     788        set code [lindex $args end]
     789        set altcode ""
     790        set consumed 1
     791    }
    780792
    781     foreach arg $args {
     793    foreach arg [lrange $args 0 end-$consumed] {
    782794        if {[regexp {(^[0-9]+$)} $arg match result]} {
    783795            set release $result
    784796        } elseif {[regexp {([a-zA-Z0-9]*)} $arg match result]} {
    proc platform {args} { 
    799811    # Execute the code if this platform matches the platform we're on
    800812    if {$match} {
    801813        uplevel 1 $code
     814    } elseif {${altcode} ne ""} {
     815        uplevel 1 $altcode
    802816    }
    803817}
    804818