From 2645c7c322e609d8c5ca99ae8718d29b2f8a3b4c Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 16 Dec 2009 09:31:08 +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 3e0c650..c39b173 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-12 Donal K. Fellows * generic/tclTest.c (TestconcatobjCmd): [Bug 2895367]: Stop memory diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index ccf4054..486c106 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.26 2006/11/03 00:34:52 hobbs Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.26.4.1 2009/12/16 09:31:08 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 } @@ -478,9 +479,11 @@ proc msgcat::Init {} { # 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]} { - mclocale C + if {[catch { + package require registry + 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