Skip to content

Commit 21723e9

Browse files
committed
Merge branch 'bug-5137b43870--clock-test-singleproc'
fixes [5137b4387019d0e1](https://core.tcl-lang.org/tcl/info/5137b4387019d0e1): ensure cache of base is correct for :localtime (system TZ) if TZ-env changing, especially if there is no registry; clock.test: several tests rewritten as locale, timezone, environment (TZ, TCL_TZ) and also registry independent, also improved several setups/cleanups and usage of test-own registry - there are also no test failures by `-singleproc 1` anymore in clock.test
2 parents 0677389 + b15c0cb commit 21723e9

File tree

3 files changed

+138
-220
lines changed

3 files changed

+138
-220
lines changed

generic/tclClock.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,11 @@ ClockConfigureObjCmd(
10351035
Tcl_SetObjRef(dataPtr->systemTimeZone, objv[i]);
10361036
Tcl_UnsetObjRef(dataPtr->systemSetupTZData);
10371037
}
1038-
dataPtr->lastTZEpoch = lastTZEpoch;
1038+
if (dataPtr->lastTZEpoch != lastTZEpoch) {
1039+
dataPtr->lastTZEpoch = lastTZEpoch;
1040+
/* TZ epoch changed - invalidate base-cache */
1041+
Tcl_UnsetObjRef(dataPtr->lastBase.timezoneObj);
1042+
}
10391043
}
10401044
if (i+1 >= objc && dataPtr->systemTimeZone != NULL
10411045
&& dataPtr->lastTZEpoch == lastTZEpoch) {

lib/clock.tcl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,14 +668,17 @@ proc ::tcl::clock::EnterLocale { locale } {
668668

669669
#----------------------------------------------------------------------
670670
#
671+
# _registryExists --
671672
# _hasRegistry --
672673
#
673-
# Helper that checks whether registry module is available (Windows only)
674+
# Helpers that checks whether registry module is available (Windows only)
674675
# and loads it on demand.
675676
#
677+
# Side effects:
678+
# _hasRegistry does it only once, and hereafter simply returns 1 or 0.
679+
#
676680
#----------------------------------------------------------------------
677-
proc ::tcl::clock::_hasRegistry {} {
678-
set res 0
681+
proc ::tcl::clock::_registryExists {} {
679682
if { $::tcl_platform(platform) eq {windows} } {
680683
if { [catch { package require registry 1.1 }] } {
681684
# try to load registry directly from root (if uninstalled / development env):
@@ -687,9 +690,13 @@ proc ::tcl::clock::_hasRegistry {} {
687690
}}
688691
}
689692
if { [namespace which -command ::registry] ne "" } {
690-
set res 1
693+
return 1
691694
}
692695
}
696+
return 0
697+
}
698+
proc ::tcl::clock::_hasRegistry {} {
699+
set res [_registryExists]
693700
proc ::tcl::clock::_hasRegistry {} [list return $res]
694701
return $res
695702
}

0 commit comments

Comments
 (0)