From 775b09cb001aae11f753654ae22365f295f56fe8 Mon Sep 17 00:00:00 2001 From: oehhar Date: Wed, 21 Oct 2015 20:30:49 +0000 Subject: Change "clock format -format %x -locale current" output on msgcat locale change [4a0c163d24] --- library/clock.tcl | 36 ++++++++++++++++++++++++++++++++++++ tests/clock.test | 13 +++++++++++++ 2 files changed, 49 insertions(+) diff --git a/library/clock.tcl b/library/clock.tcl index bfdf832..8e4b657 100755 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -111,6 +111,7 @@ proc ::tcl::clock::Initialize {} { mcpackagelocale set {} ::msgcat::mcpackageconfig set mcfolder [file join $LibDir msgs] ::msgcat::mcpackageconfig set unknowncmd "" + ::msgcat::mcpackageconfig set changecmd ChangeCurrentLocale # Define the message catalog for the root locale. @@ -4475,6 +4476,41 @@ proc ::tcl::clock::AddDays { days clockval timezone changeover } { #---------------------------------------------------------------------- # +# ChangeCurrentLocale -- +# +# The global locale was changed within msgcat. +# Clears the buffered parse functions of the current locale. +# +# Parameters: +# loclist (ignored) +# +# Results: +# None. +# +# Side effects: +# Buffered parse functions are cleared. +# +#---------------------------------------------------------------------- + +proc ::tcl::clock::ChangeCurrentLocale {args} { + variable FormatProc + variable LocaleNumeralCache + variable CachedSystemTimeZone + variable TimeZoneBad + + foreach p [info procs [namespace current]::scanproc'*'current] { + rename $p {} + } + foreach p [info procs [namespace current]::formatproc'*'current] { + rename $p {} + } + + catch {array unset FormatProc *'current} + set LocaleNumeralCache {} +} + +#---------------------------------------------------------------------- +# # ClearCaches -- # # Clears all caches to reclaim the memory used in [clock] diff --git a/tests/clock.test b/tests/clock.test index 2abeab9..4f69ed3 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -36931,6 +36931,19 @@ test clock-67.2 {Bug d19a30db57} -body { # error, not segfault tcl::clock::GetJulianDayFromEraYearMonthDay {} 2361222 } -returnCodes error -match glob -result * + +test clock-67.3 {Change %x output on global locale change [Bug 4a0c163d24]} -setup { + package require msgcat + set current [msgcat::mclocale] +} -body { + msgcat::mclocale de_de + set res [clock format 1 -locale current -format %x] + msgcat::mclocale en_uk + lappend res [clock format 1 -locale current -format %x] +} -cleanup { + msgcat::mclocale $current +} -result {01.01.1970 01/01/1970} + test clock-67.3 {Bug d19a30db57} -body { # error, not segfault tcl::clock::GetJulianDayFromEraYearWeekDay {} 2361222 -- cgit v0.12 From 4479e16df25d9fad8636372be8e5010eb70df2c9 Mon Sep 17 00:00:00 2001 From: oehhar Date: Fri, 23 Oct 2015 08:08:09 +0000 Subject: New test for clock scan, test numbering corrected --- tests/clock.test | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) mode change 100644 => 100755 tests/clock.test diff --git a/tests/clock.test b/tests/clock.test old mode 100644 new mode 100755 index 4f69ed3..d4f0bc9 --- a/tests/clock.test +++ b/tests/clock.test @@ -36932,22 +36932,35 @@ test clock-67.2 {Bug d19a30db57} -body { tcl::clock::GetJulianDayFromEraYearMonthDay {} 2361222 } -returnCodes error -match glob -result * -test clock-67.3 {Change %x output on global locale change [Bug 4a0c163d24]} -setup { +test clock-67.3 {Bug d19a30db57} -body { + # error, not segfault + tcl::clock::GetJulianDayFromEraYearWeekDay {} 2361222 +} -returnCodes error -match glob -result * + +test clock-67.4 {Change format %x output on global locale change [Bug 4a0c163d24]} -setup { package require msgcat set current [msgcat::mclocale] } -body { msgcat::mclocale de_de - set res [clock format 1 -locale current -format %x] + set res [list [clock format 1 -locale current -format %x]] msgcat::mclocale en_uk lappend res [clock format 1 -locale current -format %x] } -cleanup { msgcat::mclocale $current } -result {01.01.1970 01/01/1970} -test clock-67.3 {Bug d19a30db57} -body { - # error, not segfault - tcl::clock::GetJulianDayFromEraYearWeekDay {} 2361222 -} -returnCodes error -match glob -result * +test clock-67.5 {Change scan %x output on global locale change [Bug 4a0c163d24]} -setup { + package require msgcat + set current [msgcat::mclocale] +} -body { + msgcat::mclocale de_de + set res [clock scan "01.01.1970" -locale current -format %x] + msgcat::mclocale en_uk + # This will fail without the bug fix, as still de_de is active + expr {$res == [clock scan "01/01/1970" -locale current -format %x]} +} -cleanup { + msgcat::mclocale $current +} -result {1} # cleanup -- cgit v0.12