[25157] trunk/base/src

source_changes at macosforge.org source_changes at macosforge.org
Mon May 14 23:05:13 PDT 2007


Revision: 25157
          http://trac.macosforge.org/projects/macports/changeset/25157
Author:   eridius at macports.org
Date:     2007-05-14 23:05:13 -0700 (Mon, 14 May 2007)

Log Message:
-----------
I don't think we have any ports that use non-ASCII charas in their description, but just to be safe explicitly declare open file descriptors to be utf-8.
Also remove some completely useless catch statements - why catch when you re-raise the error on the next line with no processing?

Modified Paths:
--------------
    trunk/base/src/darwinports1.0/darwinports.tcl
    trunk/base/src/port/portindex.tcl

Modified: trunk/base/src/darwinports1.0/darwinports.tcl
===================================================================
--- trunk/base/src/darwinports1.0/darwinports.tcl	2007-05-15 06:04:40 UTC (rev 25156)
+++ trunk/base/src/darwinports1.0/darwinports.tcl	2007-05-15 06:05:13 UTC (rev 25157)
@@ -291,6 +291,7 @@
 		if [file exists $file] {
 			set portconf $file
 			set fd [open $file r]
+			fconfigure $fd -encoding utf-8
 			while {[gets $fd line] >= 0} {
 				if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
 					if {[regexp {^"(.*)"[ \t]*$} $val match val2] == 1} {
@@ -312,6 +313,7 @@
 	set per_user "${macports_user_dir}/user.conf"
 	if [file exists $per_user] {
 		set fd [open $per_user r]
+		fconfigure $fd -encoding utf-8
 		while {[gets $fd line] >= 0} {
 			if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
 				if {[lsearch $user_options $option] >= 0} {
@@ -325,9 +327,8 @@
     if {![info exists sources_conf]} {
         return -code error "sources_conf must be set in $dports_conf_path/ports.conf or in $macports_user_dir/ports.conf"
     }
-    if {[catch {set fd [open $sources_conf r]} result]} {
-        return -code error "$result"
-    }
+    set fd [open $sources_conf r]
+    fconfigure $fd -encoding utf-8
     while {[gets $fd line] >= 0} {
         set line [string trimright $line]
         if {![regexp {[\ \t]*#.*|^$} $line]} {
@@ -344,9 +345,8 @@
 
 	if {[info exists variants_conf]} {
 		if {[file exist $variants_conf]} {
-			if {[catch {set fd [open $variants_conf r]} result]} {
-				return -code error "$result"
-			}
+			set fd [open $variants_conf r]
+			fconfigure $fd -encoding utf-8
 			while {[gets $fd line] >= 0} {
 				set line [string trimright $line]
 				if {![regexp {^[\ \t]*#.*$|^$} $line]} {
@@ -714,18 +714,14 @@
     global darwinports::portdbpath tcl_platform
     set fetchdir [file join $portdbpath portdirs]
     set fetchfile [file tail $url]
-    if {[catch {file mkdir $fetchdir} result]} {
-        return -code error $result
-    }
+    file mkdir $fetchdir
     if {![file writable $fetchdir]} {
     	return -code error "Port remote fetch failed: You do not have permission to write to $fetchdir"
     }
     if {[catch {exec curl -L -s -S -o [file join $fetchdir $fetchfile] $url} result]} {
         return -code error "Port remote fetch failed: $result"
     }
-    if {[catch {cd $fetchdir} result]} {
-	return -code error $result
-    }
+    cd $fetchdir
     if {[catch {exec tar -zxf $fetchfile} result]} {
 	return -code error "Port extract failed: $result"
     }
@@ -1216,9 +1212,7 @@
 				# Where to, boss?
 				set destdir [file dirname [darwinports::getindex $source]]
 
-				if {[catch {file mkdir $destdir} result]} {
-					return -code error $result
-				}
+				file mkdir $destdir
 
 				# Keep rsync happy with a trailing slash
 				if {[string index $source end] != "/"} {
@@ -1235,9 +1229,7 @@
 			}
 			{^https?$|^ftp$} {
 				set indexfile [darwinports::getindex $source]
-				if {[catch {file mkdir [file dirname $indexfile]} result]} {
-					return -code error $result
-				}
+				file mkdir [file dirname $indexfile]
 				exec curl -L -s -S -o $indexfile $source/PortIndex
 			}
 		}
@@ -1259,6 +1251,7 @@
 			if {[catch {set fd [open [darwinports::getindex $source] r]} result]} {
 				ui_warn "Can't open index file for source: $source"
 			} else {
+			    fconfigure $fd -encoding utf-8
 				incr found 1
 				while {[gets $fd line] >= 0} {
 					array unset portinfo

Modified: trunk/base/src/port/portindex.tcl
===================================================================
--- trunk/base/src/port/portindex.tcl	2007-05-15 06:04:40 UTC (rev 25156)
+++ trunk/base/src/port/portindex.tcl	2007-05-15 06:05:13 UTC (rev 25157)
@@ -202,6 +202,7 @@
 
 puts "Creating software index in $outdir"
 set fd [open [file join $outdir PortIndex] w]
+fconfigure $fd -encoding utf-8
 dporttraverse pindex $directory
 close $fd
 puts "\nTotal number of ports parsed:\t$stats(total)\

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070514/13432db6/attachment.html


More information about the macports-changes mailing list