From e68e8b910b85a97d8b4804c4b193bd92372855a8 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 16 Dec 2009 09:26:05 +0000 Subject: [Bug 2913616]: Make msgcat package work in safe interpreters. --- ChangeLog | 5 +++++ library/msgcat/msgcat.tcl | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a34d12..dbea089 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-16 Donal K. Fellows + + * library/msgcat/msgcat.tcl (Init): [Bug 2913616]: Do not use platform + tests that are not needed and which don't work in safe interpreters. + 2009-12-14 Donal K. Fellows * doc/file.n (file tempfile): [Bug 2388866]: Note that this only ever diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 660d435..f3e79d8 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: msgcat.tcl,v 1.27 2009/11/18 21:45:36 nijtmans Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.28 2009/12/16 09:26:24 dkf Exp $ package require Tcl 8.5 # When the version number changes, be sure to update the pkgIndex.tcl file, @@ -442,13 +442,15 @@ proc msgcat::ConvertLocale {value} { # Initialize the default locale proc msgcat::Init {} { + global env tcl_platform + # # set default locale, try to get from environment # foreach varName {LC_ALL LC_MESSAGES LANG} { - if {[info exists ::env($varName)] && ("" ne $::env($varName))} { + if {[info exists env($varName)] && ("" ne $env($varName))} { if {![catch { - mclocale [ConvertLocale $::env($varName)] + mclocale [ConvertLocale $env($varName)] }]} { return } @@ -457,8 +459,7 @@ proc msgcat::Init {} { # # On Darwin, fallback to current CFLocale identifier if available. # - if {$::tcl_platform(os) eq "Darwin" && $::tcl_platform(platform) eq "unix" - && [info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} { + if {[info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} { if {![catch { mclocale [ConvertLocale $::tcl::mac::locale] }]} { @@ -469,7 +470,7 @@ proc msgcat::Init {} { # The rest of this routine is special processing for Windows; # all other platforms, get out now. # - if { $::tcl_platform(platform) ne "windows" } { + if {$tcl_platform(platform) ne "windows"} { mclocale C return } @@ -477,9 +478,11 @@ proc msgcat::Init {} { # On Windows, try to set locale depending on registry settings, # or fall back on locale of "C". # - set key {HKEY_CURRENT_USER\Control Panel\International} - if {[catch {package require registry}] \ - || [catch {registry get $key "locale"} locale]} { + if {[catch { + package require registry + set key {HKEY_CURRENT_USER\Control Panel\International} + set locale [registry get $key "locale"] + }]} { mclocale C return } @@ -496,7 +499,7 @@ proc msgcat::Init {} { set locale [string tolower $locale] while {[string length $locale]} { if {![catch { - mclocale [ConvertLocale [dict get $WinRegToISO639 $locale]] + mclocale [ConvertLocale [dict get $WinRegToISO639 $locale]] }]} { return } -- cgit v0.12