summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-11 10:18:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-11 10:18:03 (GMT)
commitae04607901c12a74a8fc87f174e461640a4004d6 (patch)
treec3a767cb7310c9c469cce09775f95bf06fc885e7 /generic/tclClock.c
parentd2fb846f98f47e4199b988b558b8bde42e7b1923 (diff)
parent003b3000368a5f8752fcee1444cf4ec1cee6fe62 (diff)
downloadtcl-ae04607901c12a74a8fc87f174e461640a4004d6.zip
tcl-ae04607901c12a74a8fc87f174e461640a4004d6.tar.gz
tcl-ae04607901c12a74a8fc87f174e461640a4004d6.tar.bz2
Fix [c9eb6b0ac01bb8ef96a616c71426a3db4a279bec|c9eb6b0ac0]: ConvertLocalToUTCUsingC fails the first time if TZ is not set
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 9d4bcd6..949cb1c 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -2005,22 +2005,23 @@ ClockSecondsObjCmd(
static void
TzsetIfNecessary(void)
{
- static char *tzWas = NULL; /* Previous value of TZ, protected by
+ static char* tzWas = INT2PTR(-1); /* Previous value of TZ, protected by
* clockMutex. */
const char *tzIsNow; /* Current value of TZ */
Tcl_MutexLock(&clockMutex);
tzIsNow = getenv("TZ");
- if (tzIsNow != NULL && (tzWas == NULL || strcmp(tzIsNow, tzWas) != 0)) {
+ if (tzIsNow != NULL && (tzWas == NULL || tzWas == INT2PTR(-1)
+ || strcmp(tzIsNow, tzWas) != 0)) {
tzset();
- if (tzWas != NULL) {
+ if (tzWas != NULL && tzWas != INT2PTR(-1)) {
ckfree(tzWas);
}
tzWas = ckalloc(strlen(tzIsNow) + 1);
strcpy(tzWas, tzIsNow);
} else if (tzIsNow == NULL && tzWas != NULL) {
tzset();
- ckfree(tzWas);
+ if (tzWas != INT2PTR(-1)) ckfree(tzWas);
tzWas = NULL;
}
Tcl_MutexUnlock(&clockMutex);