From 1b5d2f150dd9b073cb98891d4ce9395a4318304e Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Jul 2015 21:38:05 +0000 Subject: Spell out [info exists] in example code for [exit] command. --- doc/exit.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/exit.n b/doc/exit.n index ab5c87d..9b4ad20 100644 --- a/doc/exit.n +++ b/doc/exit.n @@ -35,7 +35,7 @@ proc main {} { if {[catch {main} msg options]} { puts stderr "unexpected script error: $msg" - if {[info exist env(DEBUG)]} { + if {[info exists env(DEBUG)]} { puts stderr "---- BEGIN TRACE ----" puts stderr [dict get $options -errorinfo] puts stderr "---- END TRACE ----" -- cgit v0.12 From 5500c15d8aa92235040ff3c6d6eeba3b64c86e58 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jul 2015 08:36:46 +0000 Subject: Eliminate the definition of L_tmpnam. It isn't used anywhere within Tcl any more. (backported from androwish) --- unix/tclUnixPort.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 123abec..2728957 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -443,16 +443,6 @@ extern int gettimeofday(struct timeval *tp, /* *--------------------------------------------------------------------------- - * Make sure that L_tmpnam is defined. - *--------------------------------------------------------------------------- - */ - -#ifndef L_tmpnam -# define L_tmpnam 100 -#endif - -/* - *--------------------------------------------------------------------------- * The following macro defines the type of the mask arguments to select: *--------------------------------------------------------------------------- */ -- cgit v0.12 From 7b49d1632e55010e4cc776e0bc02e934d6cfbd3e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jul 2015 14:47:32 +0000 Subject: Increase some counter sizes related to filesystem epoch from int to size_t. And prevent them ever becoming 0 due to an overflow. (backported with variation from androwish) --- generic/tclFileSystem.h | 4 ++-- generic/tclIOUtil.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/generic/tclFileSystem.h b/generic/tclFileSystem.h index 6be3e03..1eec7ff 100644 --- a/generic/tclFileSystem.h +++ b/generic/tclFileSystem.h @@ -33,7 +33,7 @@ MODULE_SCOPE void TclFSSetPathDetails(Tcl_Obj *pathPtr, const Tcl_Filesystem *fsPtr, ClientData clientData); MODULE_SCOPE Tcl_Obj * TclFSNormalizeAbsolutePath(Tcl_Interp *interp, Tcl_Obj *pathPtr); -MODULE_SCOPE int TclFSEpoch(void); +MODULE_SCOPE size_t TclFSEpoch(void); /* * Private shared variables for use by tclIOUtil.c and tclPathObj.c @@ -55,7 +55,7 @@ MODULE_SCOPE Tcl_PathType TclFSNonnativePathType(const char *pathPtr, MODULE_SCOPE Tcl_PathType TclGetPathType(Tcl_Obj *pathPtr, const Tcl_Filesystem **filesystemPtrPtr, int *driveNameLengthPtr, Tcl_Obj **driveNameRef); -MODULE_SCOPE int TclFSEpochOk(int filesystemEpoch); +MODULE_SCOPE int TclFSEpochOk(size_t filesystemEpoch); MODULE_SCOPE int TclFSCwdIsNative(void); MODULE_SCOPE Tcl_Obj * TclWinVolumeRelativeNormalize(Tcl_Interp *interp, const char *path, Tcl_Obj **useThisCwdPtr); diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 06e1b32..1d4f277 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -59,12 +59,12 @@ typedef struct FilesystemRecord { typedef struct ThreadSpecificData { int initialized; - int cwdPathEpoch; - int filesystemEpoch; + size_t cwdPathEpoch; + size_t filesystemEpoch; Tcl_Obj *cwdPathPtr; ClientData cwdClientData; FilesystemRecord *filesystemList; - int claims; + size_t claims; } ThreadSpecificData; /* @@ -215,7 +215,7 @@ static FilesystemRecord nativeFilesystemRecord = { * trigger cache cleanup in all threads. */ -static int theFilesystemEpoch = 1; +static size_t theFilesystemEpoch = 1; /* * Stores the linked list of filesystems. A 1:1 copy of this list is also @@ -231,7 +231,7 @@ TCL_DECLARE_MUTEX(filesystemMutex) */ static Tcl_Obj *cwdPathPtr = NULL; -static int cwdPathEpoch = 0; +static size_t cwdPathEpoch = 0; static ClientData cwdClientData = NULL; TCL_DECLARE_MUTEX(cwdMutex) @@ -645,7 +645,7 @@ FsGetFirstFilesystem(void) int TclFSEpochOk( - int filesystemEpoch) + size_t filesystemEpoch) { return (filesystemEpoch == 0 || filesystemEpoch == theFilesystemEpoch); } @@ -666,7 +666,7 @@ Disclaim(void) tsdPtr->claims--; } -int +size_t TclFSEpoch(void) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&fsDataKey); @@ -713,7 +713,9 @@ FsUpdateCwd( cwdClientData = TclNativeDupInternalRep(clientData); } - cwdPathEpoch++; + if (++cwdPathEpoch == 0) { + ++cwdPathEpoch; + } tsdPtr->cwdPathEpoch = cwdPathEpoch; Tcl_MutexUnlock(&cwdMutex); @@ -790,7 +792,9 @@ TclFinalizeFilesystem(void) } fsRecPtr = tmpFsRecPtr; } - theFilesystemEpoch++; + if (++theFilesystemEpoch == 0) { + ++theFilesystemEpoch; + } filesystemList = NULL; /* @@ -823,7 +827,9 @@ void TclResetFilesystem(void) { filesystemList = &nativeFilesystemRecord; - theFilesystemEpoch++; + if (++theFilesystemEpoch == 0) { + ++theFilesystemEpoch; + } #ifdef _WIN32 /* @@ -908,7 +914,9 @@ Tcl_FSRegister( * conceivably now belong to different filesystems. */ - theFilesystemEpoch++; + if (++theFilesystemEpoch == 0) { + ++theFilesystemEpoch; + } Tcl_MutexUnlock(&filesystemMutex); return TCL_OK; @@ -973,7 +981,9 @@ Tcl_FSUnregister( * (which would of course lead to memory exceptions). */ - theFilesystemEpoch++; + if (++theFilesystemEpoch == 0) { + ++theFilesystemEpoch; + } ckfree(fsRecPtr); @@ -1304,7 +1314,9 @@ Tcl_FSMountsChanged( */ Tcl_MutexLock(&filesystemMutex); - theFilesystemEpoch++; + if (++theFilesystemEpoch == 0) { + ++theFilesystemEpoch; + } Tcl_MutexUnlock(&filesystemMutex); } -- cgit v0.12