summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-11 10:13:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-11 10:13:33 (GMT)
commit2e57446fb4328d096e1c2174b206489a11676cee (patch)
tree0d5d23c9f1098da91d17bc5f70e6d56ddc5f3d59
parent6c1d8b86caf3af77eb2b0c97134dc5f7584abc89 (diff)
downloadtcl-2e57446fb4328d096e1c2174b206489a11676cee.zip
tcl-2e57446fb4328d096e1c2174b206489a11676cee.tar.gz
tcl-2e57446fb4328d096e1c2174b206489a11676cee.tar.bz2
Fix [c9eb6b0ac01bb8ef96a616c71426a3db4a279bec|c9eb6b0ac0]: ConvertLocalToUTCUsingC fails the first time if TZ is not set
-rw-r--r--generic/tclClock.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 3ec94fb..32ba145 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -1994,22 +1994,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);