[89839] trunk/base/src/port1.0/portutil.tcl
jeremyhu at macports.org
jeremyhu at macports.org
Sun Feb 12 16:18:32 PST 2012
Revision: 89839
http://trac.macports.org/changeset/89839
Author: jeremyhu at macports.org
Date: 2012-02-12 16:18:30 -0800 (Sun, 12 Feb 2012)
Log Message:
-----------
Add an option to reinplace that will allow choosing a specific locale for sed to operate under.
Modified Paths:
--------------
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2012-02-13 00:07:39 UTC (rev 89838)
+++ trunk/base/src/port1.0/portutil.tcl 2012-02-13 00:18:30 UTC (rev 89839)
@@ -916,13 +916,25 @@
# Provides "sed in place" functionality
proc reinplace {args} {
+ global env
set extended 0
set suppress 0
+ set oldlocale_exists 0
+ set oldlocale ""
+ set locale ""
while 1 {
set arg [lindex $args 0]
if {[string index $arg 0] eq "-"} {
set args [lrange $args 1 end]
switch -- [string range $arg 1 end] {
+ locale {
+ set oldlocale_exists [info exists env(LC_CTYPE)]
+ if {$oldlocale_exists} {
+ set oldlocale $env(LC_CTYPE)
+ }
+ set locale [lindex $args 0]
+ set args [lrange $args 1 end]
+ }
E {
set extended 1
}
@@ -971,15 +983,32 @@
lappend cmdline -n
}
set cmdline [concat $cmdline [list $pattern < $file >@ $tmpfd]]
+ if {$locale != ""} {
+ set env(LC_CTYPE) $locale
+ }
if {[catch {eval exec $cmdline} error]} {
global errorInfo
ui_debug "$errorInfo"
ui_error "reinplace: $error"
file delete "$tmpfile"
+ if {$locale != ""} {
+ if {$oldlocale_exists} {
+ set env(LC_CTYPE) $oldlocale
+ } else {
+ unset env(LC_CTYPE)
+ }
+ }
close $tmpfd
return -code error "reinplace sed(1) failed"
}
+ if {$locale != ""} {
+ if {$oldlocale_exists} {
+ set env(LC_CTYPE) $oldlocale
+ } else {
+ unset env(LC_CTYPE)
+ }
+ }
close $tmpfd
set attributes [file attributes $file]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120212/e4a33a41/attachment.html>
More information about the macports-changes
mailing list