Index: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	(revision 957)
+++ trunk/base/src/port1.0/portutil.tcl	(revision 960)
@@ -65,5 +65,5 @@
 		\} \n\
 	\}"
-
+	
 	eval "proc ${option}-delete {args} \{ \n\
 	    global ${option} user_options \n\
@@ -112,6 +112,6 @@
 
 proc option_proc {option args} {
-	global option_procs
-	eval "lappend option_procs($option) $args"
+    global option_procs
+    eval "lappend option_procs($option) $args"
 }
 
@@ -130,19 +130,19 @@
 proc command {command} {
     global ${command}.dir ${command}.pre_args ${command}.args ${command}.post_args ${command}.env ${command}.type ${command}.cmd
-
+    
     set cmdstring ""
     if [info exists ${command}.dir] {
 	set cmdstring "cd [set ${command}.dir] &&"
     }
-
+    
     if [info exists ${command}.env] {
 	foreach string [set ${command}.env] {
-		set cmdstring "$cmdstring $string"
-	}
-    }
-
+	    set cmdstring "$cmdstring $string"
+	}
+    }
+    
     if [info exists ${command}.cmd] {
 	foreach string [set ${command}.cmd] {
-		set cmdstring "$cmdstring $string"
+	    set cmdstring "$cmdstring $string"
 	}
     } else {
@@ -151,7 +151,7 @@
     foreach var "${command}.pre_args ${command}.args ${command}.post_args" {
 	if [info exists $var] {
-	foreach string [set ${var}] {
+	    foreach string [set ${var}] {
 		set cmdstring "$cmdstring $string"
-	}
+	    }
 	}
     }
@@ -166,16 +166,16 @@
 proc default {option val} {
     global $option option_defaults
-	if {[info exists option_defaults($option)]} {
-		ui_debug "Re-registering default for $option"
-	} else {
-		# If option is already set and we did not set it
-		# do not reset the value
-		if {[info exists $option]} {
-			return
-		}
-	}
-	set option_defaults($option) $val
-	set $option $val
-	trace variable $option rwu default_check
+    if {[info exists option_defaults($option)]} {
+	ui_debug "Re-registering default for $option"
+    } else {
+	# If option is already set and we did not set it
+	# do not reset the value
+	if {[info exists $option]} {
+	    return
+	}
+    }
+    set option_defaults($option) $val
+    set $option $val
+    trace variable $option rwu default_check
 }
 
@@ -184,22 +184,22 @@
 # for default variable values
 proc default_check {optionName index op} {
-	global option_defaults $optionName
-	switch $op {
-		w {
-			unset option_defaults($optionName)
-			trace vdelete $optionName rwu default_check
-			return
-		}
-		r {
-			upvar $optionName option
-			uplevel #0 set $optionName $option_defaults($optionName)
-			return
-		}
-		u {
-			unset option_defaults($optionName)
-			trace vdelete $optionName rwu default_check
-			return
-		}
-	}
+    global option_defaults $optionName
+    switch $op {
+	w {
+	    unset option_defaults($optionName)
+	    trace vdelete $optionName rwu default_check
+	    return
+	}
+	r {
+	    upvar $optionName option
+	    uplevel #0 set $optionName $option_defaults($optionName)
+	    return
+	}
+	u {
+	    unset option_defaults($optionName)
+	    trace vdelete $optionName rwu default_check
+	    return
+	}
+    }
 }
 
@@ -236,6 +236,6 @@
     $obj append requires $requires
     $obj set code $code
-	lappend variants $obj
-
+    lappend variants $obj
+    
     # Export provided variant to PortInfo
     lappend PortInfo(variants) $provides
@@ -246,5 +246,5 @@
 proc variant_isset {name} {
     global variations
-
+    
     if {[info exists variations($name)] && $variations($name) == "+"} {
 	return 1
@@ -257,5 +257,5 @@
 proc variant_set {name} {
     global variations
-
+    
     set variations($name) +
 }
@@ -399,10 +399,10 @@
     global targets target_uniqid
     
-	set obj [dlist_get_by_name $targets $name]
-	if {$obj == ""} {
-		set obj [target_new $name]
-		lappend targets $obj
-	}
-
+    set obj [dlist_get_by_name $targets $name]
+    if {$obj == ""} {
+	set obj [target_new $name]
+	lappend targets $obj
+    }
+    
     if {$mode == "target"} {
         set procedure [lindex $args 0]
@@ -411,29 +411,29 @@
         }
         $obj set procedure $procedure
-		
-		# Set runtype {always,once} if available
-		if {[llength $args] >= 2} {
-			$obj set runtype [lindex $args 1]
-		}
+	
+	# Set runtype {always,once} if available
+	if {[llength $args] >= 2} {
+	    $obj set runtype [lindex $args 1]
+	}
     } elseif {$mode == "init"} {
-		set init [lindex $args 0]
-		if {[$obj has init]} {
-			ui_debug "Warning: target '$name' re-registered init procedure (new procedure: '$init')"
-		}
-		$obj set init $init
+	set init [lindex $args 0]
+	if {[$obj has init]} {
+	    ui_debug "Warning: target '$name' re-registered init procedure (new procedure: '$init')"
+	}
+	$obj set init $init
     } elseif {$mode == "prerun"} {
-		set prerun [lindex $args 0]
-		if {[$obj has prerun]} {
-			ui_debug "Warning: target '$name' re-registered pre-run procedure (new procedure: '$prerun')"
-		}
-		$obj prerun $prerun
+	set prerun [lindex $args 0]
+	if {[$obj has prerun]} {
+	    ui_debug "Warning: target '$name' re-registered pre-run procedure (new procedure: '$prerun')"
+	}
+	$obj prerun $prerun
     } elseif {$mode == "postrun"} {
-		set postrun [lindex $args 0]
-		if {[$obj has postrun]} {
-			ui_debug "Warning: target '$name' re-registered post-run procedure (new procedure: '$postrun')"
-		}
-		$obj set postrun $postrun
+	set postrun [lindex $args 0]
+	if {[$obj has postrun]} {
+	    ui_debug "Warning: target '$name' re-registered post-run procedure (new procedure: '$postrun')"
+	}
+	$obj set postrun $postrun
     } elseif {$mode == "requires" || $mode == "uses" || $mode == "provides"} {
-		$obj append $mode $args
+	$obj append $mode $args
         
         if {$mode == "provides"} {
@@ -443,11 +443,11 @@
             # Thus if the user code breaks, dependent targets will not execute.
             foreach target $args {
-				if {[info commands $target] != ""} {
-					ui_error "$name attempted to register provide \'$target\' which is a pre-existing procedure. Ignoring register."
-					continue;
-				}
+		if {[info commands $target] != ""} {
+		    ui_error "$name attempted to register provide \'$target\' which is a pre-existing procedure. Ignoring register."
+		    continue;
+		}
                 set ident [lindex [depspec_get_matches $targets provides $args] 0]
                 set origproc [$ident get procedure]
-				set ident [$ident get name]
+		set ident [$ident get name]
                 eval "proc $target {args} \{ \n\
 					global target_uniqid \n\
@@ -492,20 +492,20 @@
             }
         }
-
-	} elseif {$mode == "deplist"} {
-		$obj append $mode $args
+	
+    } elseif {$mode == "deplist"} {
+	$obj append $mode $args
 	
     } elseif {$mode == "preflight"} {
-		# Find target which provides the specified name, and add a preflight.
-		# XXX: this only returns the first match, is this what we want?
-		set obj [lindex [depspec_get_matches $targets provides $name] 0]
-		$obj append pre $args
-		
+	# Find target which provides the specified name, and add a preflight.
+	# XXX: this only returns the first match, is this what we want?
+	set obj [lindex [depspec_get_matches $targets provides $name] 0]
+	$obj append pre $args
+	
     } elseif {$mode == "postflight"} {
-		# Find target which provides the specified name, and add a preflight.
-		# XXX: this only returns the first match, is this what we want?
-		set obj [lindex [depspec_get_matches $targets provides $name] 0]
-		$obj append post $args
-	}
+	# Find target which provides the specified name, and add a preflight.
+	# XXX: this only returns the first match, is this what we want?
+	set obj [lindex [depspec_get_matches $targets provides $name] 0]
+	$obj append post $args
+    }
 }
 
@@ -521,12 +521,12 @@
 # returns a depspec by name
 proc dlist_get_by_name {dlist name} {
-	set result ""
-	foreach d $dlist {
-		if {[$d get name] == $name} {
-			set result $d
-			break
-		}
-	}
-	return $result
+    set result ""
+    foreach d $dlist {
+	if {[$d get name] == $name} {
+	    set result $d
+	    break
+	}
+    }
+    return $result
 }
 
@@ -535,9 +535,9 @@
     set result [list]
     foreach d $dlist {
-		foreach val [$d get $key] {
-			if {$val == $value} {
-				lappend result $d
-			}
-		}
+	foreach val [$d get $key] {
+	    if {$val == $value} {
+		lappend result $d
+	    }
+	}
     }
     return $result
@@ -549,10 +549,10 @@
     set unmet 0
     foreach name $names {
-		# Service was provided, check next.
-		if {[info exists upstatusdict($name)] && $upstatusdict($name) == 1} {
-			continue
-		} else {
-			incr unmet
-		}
+	# Service was provided, check next.
+	if {[info exists upstatusdict($name)] && $upstatusdict($name) == 1} {
+	    continue
+	} else {
+	    incr unmet
+	}
     }
     return $unmet
@@ -562,7 +562,7 @@
 proc dlist_has_pending {dlist uses} {
     foreach name $uses {
-		if {[llength [depspec_get_matches $dlist provides $name]] > 0} {
-			return 1
-		}
+	if {[llength [depspec_get_matches $dlist provides $name]] > 0} {
+	    return 1
+	}
     }
     return 0
@@ -577,21 +577,21 @@
     
     foreach obj $dlist {		
-		# skip if unsatisfied hard dependencies
-		if {[dlist_count_unmet $dlist upstatusdict [$obj get requires]]} { continue }
-		
-		# favor item with fewest unment soft dependencies
-		set unmet [dlist_count_unmet $dlist upstatusdict [$obj get uses]]
-
-		# delay items with unmet soft dependencies that can be filled
-		if {$unmet > 0 && [dlist_has_pending $dlist [$obj get uses]]} { continue }
-		
-		if {$unmet >= $minfailed} {
-			# not better than our last pick
-			continue
-		} else {
-			# better than our last pick
-			set minfailed $unmet
-			set nextitem $obj
-		}
+	# skip if unsatisfied hard dependencies
+	if {[dlist_count_unmet $dlist upstatusdict [$obj get requires]]} { continue }
+	
+	# favor item with fewest unment soft dependencies
+	set unmet [dlist_count_unmet $dlist upstatusdict [$obj get uses]]
+	
+	# delay items with unmet soft dependencies that can be filled
+	if {$unmet > 0 && [dlist_has_pending $dlist [$obj get uses]]} { continue }
+	
+	if {$unmet >= $minfailed} {
+	    # not better than our last pick
+	    continue
+	} else {
+	    # better than our last pick
+	    set minfailed $unmet
+	    set nextitem $obj
+	}
     }
     return $nextitem
@@ -603,129 +603,129 @@
 # get_next_proc is used to determine the best item to run
 proc dlist_evaluate {dlist get_next_proc} {
-	global portname
+    global portname
 	
     # status - keys will be node names, values will be {-1, 0, 1}.
     array set statusdict [list]
 	
-	# XXX: Do we want to evaluate this dynamically instead of statically? 
-	foreach obj $dlist {
-		if {[$obj test] == 1} {
-			foreach name [$obj get provides] {
-				set statusdict($name) 1
-			}
-			ldelete dlist $obj
-		}
-	}
+    # XXX: Do we want to evaluate this dynamically instead of statically? 
+    foreach obj $dlist {
+	if {[$obj test] == 1} {
+	    foreach name [$obj get provides] {
+		set statusdict($name) 1
+	    }
+	    ldelete dlist $obj
+	}
+    }
     
     # loop for as long as there are nodes in the dlist.
     while (1) {
-		set obj [$get_next_proc $dlist statusdict]
-
-		if {$obj == ""} { 
-			break
-		} else {
-			set result [$obj run]
-			# depspec->run returns an error code, so 0 == success.
-			# translate this to the statusdict notation where 1 == success.
-			foreach name [$obj get provides] {
-				set statusdict($name) [expr $result == 0]
-			}
-			
-			# Delete the item from the waiting list.
-			ldelete dlist $obj
+	set obj [$get_next_proc $dlist statusdict]
+	
+	if {$obj == ""} { 
+	    break
+	} else {
+	    set result [$obj run]
+	    # depspec->run returns an error code, so 0 == success.
+	    # translate this to the statusdict notation where 1 == success.
+	    foreach name [$obj get provides] {
+		set statusdict($name) [expr $result == 0]
+	    }
+	    
+	    # Delete the item from the waiting list.
+	    ldelete dlist $obj
+	}
+    }
+    
+    if {[llength $dlist] > 0} {
+	# somebody broke!
+	ui_info "Warning: the following items did not execute (for $portname): "
+	foreach obj $dlist {
+	    ui_info "[$obj get name] " -nonewline
+	}
+	ui_info ""
+	return 1
+    }
+    return 0
+}
+
+proc target_run {this} {
+    global target_state_fd portname
+    set result 0
+    set procedure [$this get procedure]
+    if {$procedure != ""} {
+	set name [$this get name]
+	
+	if {[$this has init]} {
+	    set result [catch {[$this get init] $name} errstr]
+	}
+	
+	if {[check_statefile $name $target_state_fd]} {
+	    set result 0
+	    ui_debug "Skipping completed $name ($portname)"
+	} else {
+	    # Execute pre-run procedure
+	    if {[$this has prerun]} {
+		set result [catch {[$this get prerun] $name} errstr]
+	    }
+	    
+	    if {$result == 0} {
+		foreach pre [$this get pre] {
+		    ui_debug "Executing $pre"
+		    set result [catch {$pre $name} errstr]
+		    if {$result != 0} { break }
 		}
-    }
-    
-	if {[llength $dlist] > 0} {
-		# somebody broke!
-		ui_info "Warning: the following items did not execute (for $portname): "
-		foreach obj $dlist {
-			ui_info "[$obj get name] " -nonewline
+	    }
+	    
+	    if {$result == 0} {
+		ui_debug "Executing $name ($portname)"
+		set result [catch {$procedure $name} errstr]
+	    }
+	    
+	    if {$result == 0} {
+		foreach post [$this get post] {
+		    ui_debug "Executing $post"
+		    set result [catch {$post $name} errstr]
+		    if {$result != 0} { break }
 		}
-		ui_info ""
-		return 1
-    }
-	return 0
-}
-
-proc target_run {this} {
-	global target_state_fd portname
-	set result 0
-	set procedure [$this get procedure]
-    if {$procedure != ""} {
-		set name [$this get name]
-	
-		if {[$this has init]} {
-			set result [catch {[$this get init] $name} errstr]
-		}
-				
-		if {[check_statefile $name $target_state_fd]} {
-			set result 0
-			ui_debug "Skipping completed $name ($portname)"
-		} else {
-			# Execute pre-run procedure
-			if {[$this has prerun]} {
-				set result [catch {[$this get prerun] $name} errstr]
-			}
-
-			if {$result == 0} {
-				foreach pre [$this get pre] {
-					ui_debug "Executing $pre"
-					set result [catch {$pre $name} errstr]
-					if {$result != 0} { break }
-				}
-			}
-
-			if {$result == 0} {
-				ui_debug "Executing $name ($portname)"
-				set result [catch {$procedure $name} errstr]
-			}
-			
-			if {$result == 0} {
-				foreach post [$this get post] {
-					ui_debug "Executing $post"
-					set result [catch {$post $name} errstr]
-					if {$result != 0} { break }
-				}
-			}
-			# Execute post-run procedure
-			if {[$this has postrun] && $result == 0} {
-				set postrun [$this get postrun]
-				ui_debug "Executing $postrun"
-				set result [catch {$postrun $name} errstr]
-			}
-		}
-		if {$result == 0} {
-			if {[$this get runtype] != "always"} {
-				write_statefile $name $target_state_fd
-			}
-		} else {
-			ui_error "Target error: $name returned: $errstr"
-			set result 1
-		}
-		
+	    }
+	    # Execute post-run procedure
+	    if {[$this has postrun] && $result == 0} {
+		set postrun [$this get postrun]
+		ui_debug "Executing $postrun"
+		set result [catch {$postrun $name} errstr]
+	    }
+	}
+	if {$result == 0} {
+	    if {[$this get runtype] != "always"} {
+		write_statefile $name $target_state_fd
+	    }
+	} else {
+	    ui_error "Target error: $name returned: $errstr"
+	    set result 1
+	}
+	
     } else {
-		ui_info "Warning: $name does not have a registered procedure"
-		set result 1
-    }
-
+	ui_info "Warning: $name does not have a registered procedure"
+	set result 1
+    }
+    
     return $result
 }
 
 proc eval_targets {target} {
-	global targets target_state_fd
-	set dlist $targets
-
+    global targets target_state_fd
+    set dlist $targets
+    
     # Select the subset of targets under $target
     if {$target != ""} {
-		# XXX munge target. install really means registry, then install
-		# If more than one target ever needs this, make this a generic interface
-		if {$target == "install"} {
-			set target registry
-		}
+	# XXX munge target. install really means registry, then install
+	# If more than one target ever needs this, make this a generic interface
+	if {$target == "install"} {
+	    set target registry
+	}
         set matches [depspec_get_matches $dlist provides $target]
         if {[llength $matches] > 0} {
-			set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
-		# Special-case 'all'
+	    set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
+	    # Special-case 'all'
         } elseif {$target != "all"} {
             ui_info "unknown target: $target"
@@ -733,30 +733,30 @@
         }
     }
-        
+    
     # Restore the state from a previous run.
     set target_state_fd [open_statefile]
     
     set ret [dlist_evaluate $dlist generic_get_next]
-
+    
     close $target_state_fd
-	return $ret
+    return $ret
 }
 
 # returns the names of dependents of <name> from the <itemlist>
 proc dlist_append_dependents {dlist obj result} {
-
-	# Append the item to the list, avoiding duplicates
-	if {[lsearch $result $obj] == -1} {
-		lappend result $obj
-	}
-    	
+    
+    # Append the item to the list, avoiding duplicates
+    if {[lsearch $result $obj] == -1} {
+	lappend result $obj
+    }
+    
     # Recursively append any hard dependencies
-	foreach dep [$obj get requires] {
-		foreach provider [depspec_get_matches $dlist provides $dep] {
-			set result [dlist_append_dependents $dlist $provider $result]
+    foreach dep [$obj get requires] {
+	foreach provider [depspec_get_matches $dlist provides $dep] {
+	    set result [dlist_append_dependents $dlist $provider $result]
         }
     }
     # XXX: add soft-dependencies?
-	return $result
+    return $result
 }
 
@@ -765,5 +765,5 @@
 proc open_statefile {args} {
     global portpath workdir
-
+    
     if ![file isdirectory $portpath/$workdir] {
 	file mkdir $portpath/$workdir
@@ -793,5 +793,5 @@
 proc check_statefile {name fd} {
     global portpath workdir
-
+    
     seek $fd 0
     while {[gets $fd line] >= 0} {
@@ -844,61 +844,61 @@
 proc choose_variants {dlist variations} {
     upvar $variations upvariations
-
+    
     set selected [list]
     
     foreach obj $dlist {
-		# Enumerate through the provides, tallying the pros and cons.
-		set pros 0
-		set cons 0
-		set ignored 0
-		foreach flavor [$obj get provides] {
-			if {[info exists upvariations($flavor)]} {
-				if {$upvariations($flavor) == "+"} {
-					incr pros
-				} elseif {$upvariations($flavor) == "-"} {
-					incr cons
-				}
-			} else {
-				incr ignored
-			}
+	# Enumerate through the provides, tallying the pros and cons.
+	set pros 0
+	set cons 0
+	set ignored 0
+	foreach flavor [$obj get provides] {
+	    if {[info exists upvariations($flavor)]} {
+		if {$upvariations($flavor) == "+"} {
+		    incr pros
+		} elseif {$upvariations($flavor) == "-"} {
+		    incr cons
 		}
-		
-		if {$cons > 0} { continue }
-		
-		if {$pros > 0 && $ignored == 0} {
-			lappend selected $obj
-		}
-	}
+	    } else {
+		incr ignored
+	    }
+	}
+	
+	if {$cons > 0} { continue }
+	
+	if {$pros > 0 && $ignored == 0} {
+	    lappend selected $obj
+	}
+    }
     return $selected
 }
 
 proc variant_run {this} {
-	set name [$this get name]
+    set name [$this get name]
     ui_debug "Executing $name provides [$this get provides]"
     makeuserproc $name-code "\{[$this get code]\}"
     if ([catch $name-code result]) {
-		ui_error "Error executing $name: $result"
-		return 1
-	}
+	ui_error "Error executing $name: $result"
+	return 1
+    }
     return 0
 }
 
 proc eval_variants {variations} {
-	global variants
-	set dlist $variants
-	upvar $variations upvariations
-	set chosen [choose_variants $dlist upvariations]
-    
-	# now that we've selected variants, change all provides [a b c] to [a-b-c]
+    global variants
+    set dlist $variants
+    upvar $variations upvariations
+    set chosen [choose_variants $dlist upvariations]
+    
+    # now that we've selected variants, change all provides [a b c] to [a-b-c]
     # this will eliminate ambiguity between item a, b, and a-b while fulfilling requirments.
     #foreach obj $dlist {
     #    $obj set provides [list [join [$obj get provides] -]]
     #}
-	
-	set newlist [list]
+    
+    set newlist [list]
     foreach variant $chosen {
         set newlist [dlist_append_dependents $dlist $variant $newlist]
     }
-
+    
     dlist_evaluate $newlist generic_get_next
 }
@@ -934,21 +934,21 @@
 # constructor for abstract depspec class
 proc depspec_new {name} {
-	global depspec_uniqid
-	set id [incr depspec_uniqid]
-	
-	# declare the array of data
-	set data dpspc_data_${id}
-	set disp dpspc_disp_${id}
-	
-	global $data 
-	set ${data}(name) $name
-	set ${data}(_vtbl) depspec_vtbl
-	
-	eval "proc $disp {method args} { \n \
+    global depspec_uniqid
+    set id [incr depspec_uniqid]
+    
+    # declare the array of data
+    set data dpspc_data_${id}
+    set disp dpspc_disp_${id}
+    
+    global $data 
+    set ${data}(name) $name
+    set ${data}(_vtbl) depspec_vtbl
+    
+    eval "proc $disp {method args} { \n \
 			global $data \n \
 			eval return \\\[depspec_dispatch $disp $data \$method \$args\\\] \n \
 		}"
-	
-	return $disp
+    
+    return $disp
 }
 
@@ -957,47 +957,47 @@
 # the virtual members get a real "this" object.
 proc depspec_dispatch {this data method args} {
-	global $data
-	switch $method {
-		get {
-			set prop [lindex $args 0]
-			if {[eval info exists ${data}($prop)]} {
-				eval return $${data}($prop)
-			} else {
-				return ""
-			}
-		}
-		set {
-			set prop [lindex $args 0]
-			eval "set ${data}($prop) [lrange $args 1 end]"
-		}
-		has {
-			set prop [lindex $args 0]
-			return [info exists ${data}($prop)]
-		}
-		append {
-			set prop [lindex $args 0]
-			set vals [join [lrange $args 1 end] " "]
-			eval "lappend ${data}($prop) $vals"
-		}
-		default {
-			eval set vtbl $${data}(_vtbl)
-			global $vtbl
-			if {[info exists ${vtbl}($method)]} {
-				eval set function $${vtbl}($method)
-				eval "return \[$function $this $args\]"
-			} else {
-				ui_error "unknown method: $method"
-			}
-		}
-	}
-	return ""
+    global $data
+    switch $method {
+	get {
+	    set prop [lindex $args 0]
+	    if {[eval info exists ${data}($prop)]} {
+		eval return $${data}($prop)
+	    } else {
+		return ""
+	    }
+	}
+	set {
+	    set prop [lindex $args 0]
+	    eval "set ${data}($prop) [lrange $args 1 end]"
+	}
+	has {
+	    set prop [lindex $args 0]
+	    return [info exists ${data}($prop)]
+	}
+	append {
+	    set prop [lindex $args 0]
+	    set vals [join [lrange $args 1 end] " "]
+	    eval "lappend ${data}($prop) $vals"
+	}
+	default {
+	    eval set vtbl $${data}(_vtbl)
+	    global $vtbl
+	    if {[info exists ${vtbl}($method)]} {
+		eval set function $${vtbl}($method)
+		eval "return \[$function $this $args\]"
+	    } else {
+		ui_error "unknown method: $method"
+	    }
+	}
+    }
+    return ""
 }
 
 proc depspec_test {this} {
-	return 0
+    return 0
 }
 
 proc depspec_run {this} {
-	return 0
+    return 0
 }
 
@@ -1011,9 +1011,9 @@
 # constructor for target depspec class
 proc target_new {name} {
-	set obj [depspec_new $name]
-	
-	$obj set _vtbl target_vtbl
-
-	return $obj
+    set obj [depspec_new $name]
+    
+    $obj set _vtbl target_vtbl
+    
+    return $obj
 }
 
@@ -1027,9 +1027,9 @@
 # constructor for target depspec class
 proc variant_new {name} {
-	set obj [depspec_new $name]
-	
-	$obj set _vtbl variant_vtbl
-
-	return $obj
+    set obj [depspec_new $name]
+    
+    $obj set _vtbl variant_vtbl
+    
+    return $obj
 }
 
@@ -1043,15 +1043,15 @@
 
 proc portfile_new {name} {
-	set obj [depspec_new $name]
-	
-	$obj set _vtbl portfile_vtbl
-	
-	return $obj
+    set obj [depspec_new $name]
+    
+    $obj set _vtbl portfile_vtbl
+    
+    return $obj
 }
 
 # build the specified portfile
 proc portfile_run {this} {
-	set portname [$this get name]
-	
+    set portname [$this get name]
+    
     ui_debug "Building $portname"
     array set options [list]
@@ -1063,49 +1063,49 @@
     }
     set porturl $portinfo(porturl)
-
+    
     set worker [dportopen $porturl options variations]
-	if {[catch {dportexec $worker clean} result] || $result != 0} {
-		ui_error "Clean of $portname before build failed: $result"
-		dportclose $worker
-		return -1
-    }
-	if {[catch {dportexec $worker install} result] || $result != 0} {
-		ui_error "Build of $portname failed: $result"
-		dportclose $worker
-		return -1
-	}
-	if {[catch {dportexec $worker clean} result] || $result != 0} {
-		ui_error "Clean of $portname after build failed: $result"
+    if {[catch {dportexec $worker clean} result] || $result != 0} {
+	ui_error "Clean of $portname before build failed: $result"
+	dportclose $worker
+	return -1
+    }
+    if {[catch {dportexec $worker install} result] || $result != 0} {
+	ui_error "Build of $portname failed: $result"
+	dportclose $worker
+	return -1
+    }
+    if {[catch {dportexec $worker clean} result] || $result != 0} {
+	ui_error "Clean of $portname after build failed: $result"
     }
     dportclose $worker
-	
+    
+    return 0
+}
+
+proc portfile_test {this} {
+    set receipt [registry_exists [$this get name]]
+    if {$receipt != ""} {
+	ui_debug "Found Dependency: receipt: $receipt"
+	return 1
+    } else {
 	return 0
-}
-
-proc portfile_test {this} {
-	set receipt [registry_exists [$this get name]]
-	if {$receipt != ""} {
-		ui_debug "Found Dependency: receipt: $receipt"
-		return 1
-	} else {
-		return 0
-	}
+    }
 }
 
 proc portfile_search_path {depregex search_path} {
-	set found 0
+    set found 0
     foreach path $search_path {
-		if {![file isdirectory $path]} {
-			continue
-		}
-		foreach filename [readdir $path] {
-			if {[regexp $depregex $filename] == 1} {
-				ui_debug "Found Dependency: path: $path filename: $filename regex: $depregex"
-				set found 1
-				break
-			}
-		}
-	}
-	return $found
+	if {![file isdirectory $path]} {
+	    continue
+	}
+	foreach filename [readdir $path] {
+	    if {[regexp $depregex $filename] == 1} {
+		ui_debug "Found Dependency: path: $path filename: $filename regex: $depregex"
+		set found 1
+		break
+	    }
+	}
+    }
+    return $found
 }
 
@@ -1118,10 +1118,10 @@
 
 proc libportfile_new {name match} {
-	set obj [portfile_new $name]
-	
-	$obj set _vtbl libportfile_vtbl
-	$obj set depregex $match
-	
-	return $obj
+    set obj [portfile_new $name]
+    
+    $obj set _vtbl libportfile_vtbl
+    $obj set depregex $match
+    
+    return $obj
 }
 
@@ -1135,35 +1135,35 @@
 
 proc libportfile_test {this} {
-	global env prefix 
-
-	# Check the registry first
-	set result [portfile_test $this]
-	if {$result == 1} {
-		return $result
+    global env prefix 
+    
+    # Check the registry first
+    set result [portfile_test $this]
+    if {$result == 1} {
+	return $result
+    } else {
+	# Not in the registry, check the library path.
+	set depregex [$this get depregex]
+	
+	if {[info exists env(DYLD_FRAMEWORK_PATH)]} {
+	    lappend search_path $env(DYLD_FRAMEWORK_PATH)
 	} else {
-		# Not in the registry, check the library path.
-		set depregex [$this get depregex]
-		
-		if {[info exists env(DYLD_FRAMEWORK_PATH)]} {
-		lappend search_path $env(DYLD_FRAMEWORK_PATH)
-		} else {
-		lappend search_path /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks
-		}
-		if {[info exists env(DYLD_FALLBACK_FRAMEWORK_PATH)]} {
-		lappend search_path $env(DYLD_FALLBACK_FRAMEWORK_PATH)
-		}
-		if {[info exists env(DYLD_LIBRARY_PATH)]} {
-		lappend search_path $env(DYLD_LIBRARY_PATH)
-		} else {
-		lappend search_path /lib /usr/local/lib /lib /usr/lib /op/local/lib /usr/X11R6/lib ${prefix}/lib
-		}
-		if {[info exists env(DYLD_FALLBACK_LIBRARY_PATH)]} {
-		lappend search_path $env(DYLD_LIBRARY_PATH)
-		}
-		regsub {\.} $depregex {\.} depregex
-		set depregex \^$depregex.*\\.dylib\$
-
-		return [portfile_search_path $depregex $search_path]
-	}
+	    lappend search_path /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks
+	}
+	if {[info exists env(DYLD_FALLBACK_FRAMEWORK_PATH)]} {
+	    lappend search_path $env(DYLD_FALLBACK_FRAMEWORK_PATH)
+	}
+	if {[info exists env(DYLD_LIBRARY_PATH)]} {
+	    lappend search_path $env(DYLD_LIBRARY_PATH)
+	} else {
+	    lappend search_path /lib /usr/local/lib /lib /usr/lib /op/local/lib /usr/X11R6/lib ${prefix}/lib
+	}
+	if {[info exists env(DYLD_FALLBACK_LIBRARY_PATH)]} {
+	    lappend search_path $env(DYLD_LIBRARY_PATH)
+	}
+	regsub {\.} $depregex {\.} depregex
+	set depregex \^$depregex.*\\.dylib\$
+	
+	return [portfile_search_path $depregex $search_path]
+    }
 }
 
@@ -1174,28 +1174,28 @@
 
 proc binportfile_new {name match} {
-	set obj [portfile_new $name]
-	
-	$obj set _vtbl binportfile_vtbl
-	$obj set depregex $match
-
-	return $obj
+    set obj [portfile_new $name]
+    
+    $obj set _vtbl binportfile_vtbl
+    $obj set depregex $match
+    
+    return $obj
 }
 
 proc binportfile_test {this} {
-	global env prefix 
-
-	# Check the registry first
-	set result [portfile_test $this]
-	if {$result == 1} {
-		return $result
-	} else {
-		# Not in the registry, check the binary path.
-		set depregex [$this get depregex]
-
-		set search_path [split $env(PATH) :]
-		
-		set depregex \^$depregex\$
-
-		return [portfile_search_path $depregex $search_path]
-	}
-}
+    global env prefix 
+    
+    # Check the registry first
+    set result [portfile_test $this]
+    if {$result == 1} {
+	return $result
+    } else {
+	# Not in the registry, check the binary path.
+	set depregex [$this get depregex]
+	
+	set search_path [split $env(PATH) :]
+	
+	set depregex \^$depregex\$
+	
+	return [portfile_search_path $depregex $search_path]
+    }
+}
