[25980] trunk/base/src/darwinports1.0/darwinports.tcl
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 7 22:29:55 PDT 2007
Revision: 25980
http://trac.macosforge.org/projects/macports/changeset/25980
Author: eridius at macports.org
Date: 2007-06-07 22:29:55 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
Wrap dportsearch inner block in a try-finally clause to ensure PortIndex file is always closed even if an error occurs
Modified Paths:
--------------
trunk/base/src/darwinports1.0/darwinports.tcl
Modified: trunk/base/src/darwinports1.0/darwinports.tcl
===================================================================
--- trunk/base/src/darwinports1.0/darwinports.tcl 2007-06-08 05:27:14 UTC (rev 25979)
+++ trunk/base/src/darwinports1.0/darwinports.tcl 2007-06-08 05:29:55 UTC (rev 25980)
@@ -1290,57 +1290,60 @@
if {[catch {set fd [open [darwinports::getindex $source] r]} result]} {
ui_warn "Can't open index file for source: $source"
} else {
- incr found 1
- while {[gets $fd line] >= 0} {
- array unset portinfo
- set name [lindex $line 0]
- set len [lindex $line 1]
- set line [read $fd $len]
+ try {
+ incr found 1
+ while {[gets $fd line] >= 0} {
+ array unset portinfo
+ set name [lindex $line 0]
+ set len [lindex $line 1]
+ set line [read $fd $len]
- if {$easy} {
- set target $name
- } else {
- array set portinfo $line
- if {![info exists portinfo($field)]} continue
- set target $portinfo($field)
- }
-
- switch $matchstyle {
- exact { set matchres [expr 0 == ( {$case_sensitive == "yes"} ? [string compare $pattern $target] : [string compare -nocase $pattern $target] )] }
- glob { set matchres [expr {$case_sensitive == "yes"} ? [string match $pattern $target] : [string match -nocase $pattern $target]] }
- regexp -
- default { set matchres [expr {$case_sensitive == "yes"} ? [regexp -- $pattern $target] : [regexp -nocase -- $pattern $target]] }
- }
-
- if {$matchres == 1} {
if {$easy} {
+ set target $name
+ } else {
array set portinfo $line
+ if {![info exists portinfo($field)]} continue
+ set target $portinfo($field)
}
- switch -regexp -- [darwinports::getprotocol ${source}] {
- {^rsync$} {
- # Rsync files are local
- set source_url "file://[darwinports::getsourcepath $source]"
+
+ switch $matchstyle {
+ exact { set matchres [expr 0 == ( {$case_sensitive == "yes"} ? [string compare $pattern $target] : [string compare -nocase $pattern $target] )] }
+ glob { set matchres [expr {$case_sensitive == "yes"} ? [string match $pattern $target] : [string match -nocase $pattern $target]] }
+ regexp -
+ default { set matchres [expr {$case_sensitive == "yes"} ? [regexp -- $pattern $target] : [regexp -nocase -- $pattern $target]] }
+ }
+
+ if {$matchres == 1} {
+ if {$easy} {
+ array set portinfo $line
}
- default {
- set source_url $source
+ switch -regexp -- [darwinports::getprotocol ${source}] {
+ {^rsync$} {
+ # Rsync files are local
+ set source_url "file://[darwinports::getsourcepath $source]"
+ }
+ default {
+ set source_url $source
+ }
}
+ if {[info exists portinfo(portarchive)]} {
+ set porturl ${source_url}/$portinfo(portarchive)
+ } elseif {[info exists portinfo(portdir)]} {
+ set porturl ${source_url}/$portinfo(portdir)
+ }
+ if {[info exists porturl]} {
+ lappend line porturl $porturl
+ ui_debug "Found port in $porturl"
+ } else {
+ ui_debug "Found port info: $line"
+ }
+ lappend matches $name
+ lappend matches $line
}
- if {[info exists portinfo(portarchive)]} {
- set porturl ${source_url}/$portinfo(portarchive)
- } elseif {[info exists portinfo(portdir)]} {
- set porturl ${source_url}/$portinfo(portdir)
- }
- if {[info exists porturl]} {
- lappend line porturl $porturl
- ui_debug "Found port in $porturl"
- } else {
- ui_debug "Found port info: $line"
- }
- lappend matches $name
- lappend matches $line
}
+ } finally {
+ close $fd
}
- close $fd
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070607/e1816fbd/attachment.html
More information about the macports-changes
mailing list