summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--compat/strftime.c17
-rw-r--r--generic/tclClock.c8
-rw-r--r--generic/tclInt.decls4
-rw-r--r--generic/tclIntDecls.h7
-rw-r--r--tests/clock.test15
-rw-r--r--unix/tclUnixTime.c8
7 files changed, 58 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cffea2..8effda2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-28 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tclThreadAlloc.c (TclpRealloc, TclpFree): protect
+ against the case when NULL is based.
+
+ * tests/clock.test: added clock-9.1
+ * compat/strftime.c:
+ * generic/tclClock.c:
+ * generic/tclInt.decls:
+ * generic/tclIntDecls.h:
+ * unix/tclUnixTime.c: fix for Windows msvcrt mem leak caused by
+ using an env(TZ) setting trick for in clock format -gmt 1. This
+ also makes %s seem to work correctly with -gmt 1 as well as
+ making it a lot faster by avoid the env(TZ) hack. TclpStrftime
+ now takes useGMT as an arg. [Bug #559376]
+
2002-05-28 Vince Darley <vincentdarley@users.sourceforge.net>
* generic/tclIOUtil.c: fixes to Tcl_FSLoadFile when called on
diff --git a/compat/strftime.c b/compat/strftime.c
index 52a7fa1..027e373 100644
--- a/compat/strftime.c
+++ b/compat/strftime.c
@@ -8,7 +8,9 @@
* source. See the copyright notice below for details on redistribution
* restrictions. The "license.terms" file does not apply to this file.
*
- * RCS: @(#) $Id: strftime.c,v 1.9 2002/04/22 22:41:46 hobbs Exp $
+ * Changes 2002 Copyright (c) 2002 ActiveState Corporation.
+ *
+ * RCS: @(#) $Id: strftime.c,v 1.10 2002/05/29 00:19:39 hobbs Exp $
*/
/*
@@ -45,7 +47,7 @@
*/
#if defined(LIBC_SCCS)
-static char *rcsid = "$Id: strftime.c,v 1.9 2002/04/22 22:41:46 hobbs Exp $";
+static char *rcsid = "$Id: strftime.c,v 1.10 2002/05/29 00:19:39 hobbs Exp $";
#endif /* LIBC_SCCS */
#include <time.h>
@@ -103,6 +105,7 @@ static const _TimeLocale _DefaultTimeLocale =
static const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;
+static int isGMT;
static size_t gsize;
static char *pt;
static int _add _ANSI_ARGS_((const char* str));
@@ -112,11 +115,12 @@ static size_t _fmt _ANSI_ARGS_((const char *format,
const struct tm *t));
size_t
-TclpStrftime(s, maxsize, format, t)
+TclpStrftime(s, maxsize, format, t, useGMT)
char *s;
size_t maxsize;
const char *format;
const struct tm *t;
+ int useGMT;
{
if (format[0] == '%' && format[1] == 'Q') {
/* Format as a stardate */
@@ -128,6 +132,11 @@ TclpStrftime(s, maxsize, format, t)
return(strlen(s));
}
+ isGMT = useGMT;
+ /*
+ * We may be able to skip this for useGMT, but it should be harmless.
+ * -- hobbs
+ */
tzset();
pt = s;
@@ -374,7 +383,7 @@ _fmt(format, t)
return(0);
continue;
case 'Z': {
- char *name = TclpGetTZName(t->tm_isdst);
+ char *name = (isGMT ? "GMT" : TclpGetTZName(t->tm_isdst));
if (name && !_add(name)) {
return 0;
}
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 5cfc675..9bf7ed0 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.14 2002/01/25 20:40:55 dgp Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.15 2002/05/29 00:19:40 hobbs Exp $
*/
#include "tcl.h"
@@ -289,7 +289,7 @@ FormatClock(interp, clockVal, useGMT, format)
return TCL_OK;
}
-#ifndef HAVE_TM_ZONE
+#if !defined(HAVE_TM_ZONE) && !defined(WIN32)
/*
* This is a kludge for systems not having the timezone string in
* struct tm. No matter what was specified, they use the local
@@ -332,10 +332,10 @@ FormatClock(interp, clockVal, useGMT, format)
Tcl_MutexLock(&clockMutex);
result = TclpStrftime(buffer.string, (unsigned int) bufSize, format,
- timeDataPtr);
+ timeDataPtr, useGMT);
Tcl_MutexUnlock(&clockMutex);
-#ifndef HAVE_TM_ZONE
+#if !defined(HAVE_TM_ZONE) && !defined(WIN32)
if (useGMT) {
if (savedTZEnv != NULL) {
Tcl_SetVar2(interp, "env", "TZ", savedTZEnv, TCL_GLOBAL_ONLY);
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index 4b6523c..b4d07fa 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tclInt.decls,v 1.48 2002/04/19 14:18:33 das Exp $
+# RCS: @(#) $Id: tclInt.decls,v 1.49 2002/05/29 00:19:40 hobbs Exp $
library tcl
@@ -518,7 +518,7 @@ declare 133 generic {
}
declare 134 generic {
size_t TclpStrftime(char *s, size_t maxsize, CONST char *format,
- CONST struct tm *t)
+ CONST struct tm *t, int useGMT)
}
declare 135 generic {
int TclpCheckStackSpace(void)
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index dd2bd0f..a16cc73 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIntDecls.h,v 1.39 2002/03/20 22:47:36 dgp Exp $
+ * RCS: @(#) $Id: tclIntDecls.h,v 1.40 2002/05/29 00:19:40 hobbs Exp $
*/
#ifndef _TCLINTDECLS
@@ -420,7 +420,8 @@ EXTERN int TclpHasSockets _ANSI_ARGS_((Tcl_Interp * interp));
EXTERN struct tm * TclpGetDate _ANSI_ARGS_((TclpTime_t time, int useGMT));
/* 134 */
EXTERN size_t TclpStrftime _ANSI_ARGS_((char * s, size_t maxsize,
- CONST char * format, CONST struct tm * t));
+ CONST char * format, CONST struct tm * t,
+ int useGMT));
/* 135 */
EXTERN int TclpCheckStackSpace _ANSI_ARGS_((void));
/* Slot 136 is reserved */
@@ -673,7 +674,7 @@ typedef struct TclIntStubs {
void (*tcl_SetNamespaceResolvers) _ANSI_ARGS_((Tcl_Namespace * namespacePtr, Tcl_ResolveCmdProc * cmdProc, Tcl_ResolveVarProc * varProc, Tcl_ResolveCompiledVarProc * compiledVarProc)); /* 131 */
int (*tclpHasSockets) _ANSI_ARGS_((Tcl_Interp * interp)); /* 132 */
struct tm * (*tclpGetDate) _ANSI_ARGS_((TclpTime_t time, int useGMT)); /* 133 */
- size_t (*tclpStrftime) _ANSI_ARGS_((char * s, size_t maxsize, CONST char * format, CONST struct tm * t)); /* 134 */
+ size_t (*tclpStrftime) _ANSI_ARGS_((char * s, size_t maxsize, CONST char * format, CONST struct tm * t, int useGMT)); /* 134 */
int (*tclpCheckStackSpace) _ANSI_ARGS_((void)); /* 135 */
void *reserved136;
void *reserved137;
diff --git a/tests/clock.test b/tests/clock.test
index c96c2e7..ac93cb6 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -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: clock.test,v 1.17 2001/10/18 20:20:28 hobbs Exp $
+# RCS: @(#) $Id: clock.test,v 1.18 2002/05/29 00:19:39 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -427,6 +427,19 @@ test clock-8.1 {clock scan midnight/gmt range bug 413397} {
[clock format [clock scan year -base $5amPST -gmt 1] -format $fmt]
} {12/31 12/31}
+set ::tcltest::testConstraints(needPST) \
+ [regexp {^(Pacific.*|P[DS]T)$} [clock format 1 -format %Z]]
+test clock-9.1 {%s gmt testing} {needPST} {
+ # We need PST to guarantee the difference value below.
+ set s 100000
+ set a [clock format $s -format %s -gmt 0]
+ set b [clock format $s -format %s -gmt 1]
+ # This should be the offset in seconds between current locale and GMT.
+ # This didn't seem to be correctly on Windows until the fix for
+ # Bug #559376, which fiddled with env(TZ) when -gmt 1 was used.
+ # It's hard-coded to check P[SD]T now. (8 hours)
+ set c [expr {$b-$a}]
+} {28800}
# cleanup
::tcltest::cleanupTests
diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c
index 8047858..5107062 100644
--- a/unix/tclUnixTime.c
+++ b/unix/tclUnixTime.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixTime.c,v 1.12 2001/11/21 02:36:21 hobbs Exp $
+ * RCS: @(#) $Id: tclUnixTime.c,v 1.13 2002/05/29 00:19:39 hobbs Exp $
*/
#include "tclInt.h"
@@ -303,7 +303,8 @@ TclpGetDate(time, useGMT)
*
* TclpStrftime --
*
- * On Unix, we can safely call the native strftime implementation.
+ * On Unix, we can safely call the native strftime implementation,
+ * and also ignore the useGMT parameter.
*
* Results:
* The normal strftime result.
@@ -315,11 +316,12 @@ TclpGetDate(time, useGMT)
*/
size_t
-TclpStrftime(s, maxsize, format, t)
+TclpStrftime(s, maxsize, format, t, useGMT)
char *s;
size_t maxsize;
CONST char *format;
CONST struct tm *t;
+ int useGMT;
{
if (format[0] == '%' && format[1] == 'Q') {
/* Format as a stardate */