From e11daf6fb666f377464fdedddde9126ba31658d7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 26 Jun 2016 09:01:26 +0000 Subject: (cherry-pick) [c30087b04f] Install man pages with permissions 644 instead of 444. --- unix/installManPage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/installManPage b/unix/installManPage index 6bdccf0..1dbd232 100755 --- a/unix/installManPage +++ b/unix/installManPage @@ -105,7 +105,7 @@ for Target in $Names; do First=$Target sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \ $ManPage > $Dir/$First - chmod 444 $Dir/$First + chmod 644 $Dir/$First $Gzip $Dir/$First else ln $SymOrLoc$First$Gz $Dir/$Target$Gz -- cgit v0.12 From 4b6e8293285a111598e5dc2d37921ca6ff732c45 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 5 Jul 2016 22:05:16 +0000 Subject: Demonstrate that there is a problem. --- tests/oo.test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/oo.test b/tests/oo.test index 48e093a..88e1124 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -3424,6 +3424,36 @@ test oo-27.22 {variables declaration uniqueifies: Bug 3396896} -setup { } -cleanup { foo destroy } -result {v t} +test oo-27.23 {variable resolver leakage: Bug 1493a43044} -setup { + oo::class create Super + oo::class create Master { + superclass Super + variable member1 member2 + constructor {} { + set member1 master1 + set member2 master2 + } + method getChild {} { + Child new [self] + } + } + oo::class create Child { + superclass Super + variable member1 result + constructor {m} { + set [namespace current]::member1 child1 + namespace upvar [info object namespace $m] \ + member1 local1 member2 local2 + upvar 1 member1 local3 member2 local4 + set result [list $local1 $local2 $local3 $local4] + } + method result {} {return $result} + } +} -body { + [[Master new] getChild] result +} -cleanup { + Super destroy +} -result {master1 master2 master1 master2} # A feature that's not supported because the mechanism may change without # warning, but is supposed to work... -- cgit v0.12 From cb3f1f4d66a91e4efc123a4518e8fa171af58145 Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 7 Jul 2016 08:35:30 +0000 Subject: Also test the interpreted path. --- tests/oo.test | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/oo.test b/tests/oo.test index 88e1124..2601c37 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -3442,10 +3442,12 @@ test oo-27.23 {variable resolver leakage: Bug 1493a43044} -setup { variable member1 result constructor {m} { set [namespace current]::member1 child1 - namespace upvar [info object namespace $m] \ - member1 local1 member2 local2 - upvar 1 member1 local3 member2 local4 - set result [list $local1 $local2 $local3 $local4] + set ns [info object namespace $m] + namespace upvar $ns member1 l1 member2 l2 + upvar 1 member1 l3 member2 l4 + [format namespace] upvar $ns member1 l5 member2 l6 + [format upvar] 1 member1 l7 member2 l8 + set result [list $l1 $l2 $l3 $l4 $l5 $l6 $l7 $l8] } method result {} {return $result} } @@ -3453,7 +3455,7 @@ test oo-27.23 {variable resolver leakage: Bug 1493a43044} -setup { [[Master new] getChild] result } -cleanup { Super destroy -} -result {master1 master2 master1 master2} +} -result {master1 master2 master1 master2 master1 master2 master1 master2} # A feature that's not supported because the mechanism may change without # warning, but is supposed to work... -- cgit v0.12 From 38f4a53699309fdec415cf81e5c2ba6137ff8cf4 Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 7 Jul 2016 10:08:44 +0000 Subject: Expose the AVOID_RESOLVERS flag to [namespace upvar] implementations, which seem to need it. --- generic/tclExecute.c | 4 ++-- generic/tclInt.h | 15 ++++++++++++++ generic/tclNamesp.c | 4 ++-- generic/tclVar.c | 55 ++++++++++++++++++++-------------------------------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 1389382..8ddefda 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4413,8 +4413,8 @@ TEBCresume( savedNsPtr = iPtr->varFramePtr->nsPtr; iPtr->varFramePtr->nsPtr = (Namespace *) nsPtr; otherPtr = TclObjLookupVarEx(interp, OBJ_AT_TOS, NULL, - (TCL_NAMESPACE_ONLY | TCL_LEAVE_ERR_MSG), "access", - /*createPart1*/ 1, /*createPart2*/ 1, &varPtr); + (TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG|TCL_AVOID_RESOLVERS), + "access", /*createPart1*/ 1, /*createPart2*/ 1, &varPtr); iPtr->varFramePtr->nsPtr = savedNsPtr; if (!otherPtr) { TRACE_ERROR(interp); diff --git a/generic/tclInt.h b/generic/tclInt.h index fba4c7b..6d2db5d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -170,6 +170,21 @@ typedef struct Tcl_ResolverInfo { } Tcl_ResolverInfo; /* + * This flag bit should not interfere with TCL_GLOBAL_ONLY, + * TCL_NAMESPACE_ONLY, or TCL_LEAVE_ERR_MSG; it signals that the variable + * lookup is performed for upvar (or similar) purposes, with slightly + * different rules: + * - Bug #696893 - variable is either proc-local or in the current + * namespace; never follow the second (global) resolution path + * - Bug #631741 - do not use special namespace or interp resolvers + * + * It should also not collide with the (deprecated) TCL_PARSE_PART1 flag + * (Bug #835020) + */ + +#define TCL_AVOID_RESOLVERS 0x40000 + +/* *---------------------------------------------------------------- * Data structures related to namespaces. *---------------------------------------------------------------- diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 2c50a60..5930859 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -4538,8 +4538,8 @@ NamespaceUpvarCmd( savedNsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr; iPtr->varFramePtr->nsPtr = (Namespace *) nsPtr; otherPtr = TclObjLookupVarEx(interp, objv[0], NULL, - (TCL_NAMESPACE_ONLY | TCL_LEAVE_ERR_MSG), "access", - /*createPart1*/ 1, /*createPart2*/ 1, &arrayPtr); + (TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG|TCL_AVOID_RESOLVERS), + "access", /*createPart1*/ 1, /*createPart2*/ 1, &arrayPtr); iPtr->varFramePtr->nsPtr = (Namespace *) savedNsPtr; if (otherPtr == NULL) { return TCL_ERROR; diff --git a/generic/tclVar.c b/generic/tclVar.c index 51e2482..47c6e14 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -742,21 +742,6 @@ TclObjLookupVarEx( } /* - * This flag bit should not interfere with TCL_GLOBAL_ONLY, - * TCL_NAMESPACE_ONLY, or TCL_LEAVE_ERR_MSG; it signals that the variable - * lookup is performed for upvar (or similar) purposes, with slightly - * different rules: - * - Bug #696893 - variable is either proc-local or in the current - * namespace; never follow the second (global) resolution path - * - Bug #631741 - do not use special namespace or interp resolvers - * - * It should also not collide with the (deprecated) TCL_PARSE_PART1 flag - * (Bug #835020) - */ - -#define AVOID_RESOLVERS 0x40000 - -/* *---------------------------------------------------------------------- * * TclLookupSimpleVar -- @@ -805,8 +790,8 @@ TclLookupSimpleVar( Tcl_Obj *varNamePtr, /* This is a simple variable name that could * represent a scalar or an array. */ int flags, /* Only TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, - * AVOID_RESOLVERS and TCL_LEAVE_ERR_MSG bits - * matter. */ + * TCL_AVOID_RESOLVERS and TCL_LEAVE_ERR_MSG + * bits matter. */ const int create, /* If 1, create hash table entry for varname, * if it doesn't already exist. If 0, return * error if it doesn't exist. */ @@ -846,7 +831,7 @@ TclLookupSimpleVar( */ if ((cxtNsPtr->varResProc != NULL || iPtr->resolverPtr != NULL) - && !(flags & AVOID_RESOLVERS)) { + && !(flags & TCL_AVOID_RESOLVERS)) { resPtr = iPtr->resolverPtr; if (cxtNsPtr->varResProc) { result = cxtNsPtr->varResProc(interp, varName, @@ -899,7 +884,7 @@ TclLookupSimpleVar( *indexPtr = -1; flags = (flags | TCL_GLOBAL_ONLY) & ~TCL_NAMESPACE_ONLY; } else { - if (flags & AVOID_RESOLVERS) { + if (flags & TCL_AVOID_RESOLVERS) { flags = (flags | TCL_NAMESPACE_ONLY); } if (flags & TCL_NAMESPACE_ONLY) { @@ -914,7 +899,7 @@ TclLookupSimpleVar( varPtr = (Var *) ObjFindNamespaceVar(interp, varNamePtr, (Tcl_Namespace *) cxtNsPtr, - (flags | AVOID_RESOLVERS) & ~TCL_LEAVE_ERR_MSG); + (flags | TCL_AVOID_RESOLVERS) & ~TCL_LEAVE_ERR_MSG); if (varPtr == NULL) { Tcl_Obj *tailPtr; @@ -4396,15 +4381,15 @@ TclPtrObjMakeUpvar( /* * Lookup and eventually create the new variable. Set the flag bit - * AVOID_RESOLVERS to indicate the special resolution rules for upvar - * purposes: + * TCL_AVOID_RESOLVERS to indicate the special resolution rules for + * upvar purposes: * - Bug #696893 - variable is either proc-local or in the current * namespace; never follow the second (global) resolution path. * - Bug #631741 - do not use special namespace or interp resolvers. */ varPtr = TclLookupSimpleVar(interp, myNamePtr, - myFlags|AVOID_RESOLVERS, /* create */ 1, &errMsg, &index); + myFlags|TCL_AVOID_RESOLVERS, /* create */ 1, &errMsg, &index); if (varPtr == NULL) { TclObjVarErrMsg(interp, myNamePtr, NULL, "create", errMsg, -1); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", @@ -5695,11 +5680,12 @@ Tcl_FindNamespaceVar( * Otherwise, points to namespace in which to * resolve name. If NULL, look up name in the * current namespace. */ - int flags) /* An OR'd combination of: AVOID_RESOLVERS, - * TCL_GLOBAL_ONLY (look up name only in - * global namespace), TCL_NAMESPACE_ONLY (look - * up only in contextNsPtr, or the current - * namespace if contextNsPtr is NULL), and + int flags) /* An OR'd combination of: + * TCL_AVOID_RESOLVERS, TCL_GLOBAL_ONLY (look + * up name only in global namespace), + * TCL_NAMESPACE_ONLY (look up only in + * contextNsPtr, or the current namespace if + * contextNsPtr is NULL), and * TCL_LEAVE_ERR_MSG. If both TCL_GLOBAL_ONLY * and TCL_NAMESPACE_ONLY are given, * TCL_GLOBAL_ONLY is ignored. */ @@ -5725,11 +5711,12 @@ ObjFindNamespaceVar( * Otherwise, points to namespace in which to * resolve name. If NULL, look up name in the * current namespace. */ - int flags) /* An OR'd combination of: AVOID_RESOLVERS, - * TCL_GLOBAL_ONLY (look up name only in - * global namespace), TCL_NAMESPACE_ONLY (look - * up only in contextNsPtr, or the current - * namespace if contextNsPtr is NULL), and + int flags) /* An OR'd combination of: + * TCL_AVOID_RESOLVERS, TCL_GLOBAL_ONLY (look + * up name only in global namespace), + * TCL_NAMESPACE_ONLY (look up only in + * contextNsPtr, or the current namespace if + * contextNsPtr is NULL), and * TCL_LEAVE_ERR_MSG. If both TCL_GLOBAL_ONLY * and TCL_NAMESPACE_ONLY are given, * TCL_GLOBAL_ONLY is ignored. */ @@ -5759,7 +5746,7 @@ ObjFindNamespaceVar( cxtNsPtr = (Namespace *) TclGetCurrentNamespace(interp); } - if (!(flags & AVOID_RESOLVERS) && + if (!(flags & TCL_AVOID_RESOLVERS) && (cxtNsPtr->varResProc != NULL || iPtr->resolverPtr != NULL)) { resPtr = iPtr->resolverPtr; -- cgit v0.12 From fc2bc121acb78c5544d30d1e7ceb507397fe3e78 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 7 Jul 2016 18:44:56 +0000 Subject: To use a Tcl_Command token [aka (Command *)] for epoch checking, we must not permit it to be freed while we hold it or else it could be mistaken for another token allocated later that just happens to reside at the same address. (Command *) preservation machinery already exists, just need to use it. An extension facing the same problem might have to rely on command delete traces. Earlier revisions used (Namespace *) lifetime to achieve the same results, but that's really an indirect (possibly non-robust) path to achieving the proper goal. Valgrind is happy now. --- generic/tclEnsemble.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 5c47ce3..24b6b9a 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -93,7 +93,7 @@ typedef struct { int epoch; /* Used to confirm when the data in this * really structure matches up with the * ensemble. */ - Tcl_Command token; /* Reference to the comamnd for which this + Command *token; /* Reference to the command for which this * structure is a cache of the resolution. */ Tcl_Obj *fix; /* Corrected spelling, if needed. */ Tcl_HashEntry *hPtr; /* Direct link to entry in the subcommand @@ -1727,7 +1727,7 @@ NsEnsembleImplementationCmdNR( EnsembleCmdRep *ensembleCmd = subObj->internalRep.twoPtrValue.ptr1; if (ensembleCmd->epoch == ensemblePtr->epoch && - ensembleCmd->token == ensemblePtr->token) { + ensembleCmd->token == (Command *)ensemblePtr->token) { prefixObj = Tcl_GetHashValue(ensembleCmd->hPtr); Tcl_IncrRefCount(prefixObj); if (ensembleCmd->fix) { @@ -2404,7 +2404,8 @@ MakeCachedEnsembleCommand( */ ensembleCmd->epoch = ensemblePtr->epoch; - ensembleCmd->token = ensemblePtr->token; + ensembleCmd->token = (Command *) ensemblePtr->token; + ensembleCmd->token->refCount++; if (fix) { Tcl_IncrRefCount(fix); } @@ -2790,6 +2791,7 @@ FreeEnsembleCmdRep( { EnsembleCmdRep *ensembleCmd = objPtr->internalRep.twoPtrValue.ptr1; + TclCleanupCommandMacro(ensembleCmd->token); if (ensembleCmd->fix) { Tcl_DecrRefCount(ensembleCmd->fix); } @@ -2827,6 +2829,7 @@ DupEnsembleCmdRep( copyPtr->internalRep.twoPtrValue.ptr1 = ensembleCopy; ensembleCopy->epoch = ensembleCmd->epoch; ensembleCopy->token = ensembleCmd->token; + ensembleCopy->token->refCount++; ensembleCopy->fix = ensembleCmd->fix; if (ensembleCopy->fix) { Tcl_IncrRefCount(ensembleCopy->fix); -- cgit v0.12 From 1d9f88074f824a962f99296d5aefece2fa918a99 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 7 Jul 2016 19:50:02 +0000 Subject: Missed a cleanup line, which created a memleak. --- generic/tclEnsemble.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 24b6b9a..d2bd0a2 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -2384,6 +2384,7 @@ MakeCachedEnsembleCommand( if (objPtr->typePtr == &ensembleCmdType) { ensembleCmd = objPtr->internalRep.twoPtrValue.ptr1; + TclCleanupCommandMacro(ensembleCmd->token); if (ensembleCmd->fix) { Tcl_DecrRefCount(ensembleCmd->fix); } -- cgit v0.12 From 6e64f64efb7bf46602985c83e4ec87bfdefc8289 Mon Sep 17 00:00:00 2001 From: ashok Date: Fri, 8 Jul 2016 07:58:00 +0000 Subject: Bug [a47641a031]. TclJoinPath was calling TclNewFSPathObj with a first argument that was not an absolute path. Added a check for that. Fixes Windows test failures fileSystem-1.{3,4} --- generic/tclPathObj.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 99d576d..c2643bf 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -869,12 +869,16 @@ TclJoinPath( * object which can be normalized more efficiently. Currently we only * use the special case when we have exactly two elements, but we * could expand that in the future. + * + * Bugfix [a47641a0]. TclNewFSPathObj requires first argument + * to be an absolute path. Added a check for that elt is absolute. */ if ((i == (elements-2)) && (i == 0) - && (elt->typePtr == &tclFsPathType) - && !((elt->bytes != NULL) && (elt->bytes[0] == '\0'))) { - Tcl_Obj *tailObj = objv[i+1]; + && (elt->typePtr == &tclFsPathType) + && !((elt->bytes != NULL) && (elt->bytes[0] == '\0')) + && TclGetPathType(elt, NULL, NULL, NULL) == TCL_PATH_ABSOLUTE) { + Tcl_Obj *tailObj = objv[i+1]; type = TclGetPathType(tailObj, NULL, NULL, NULL); if (type == TCL_PATH_RELATIVE) { -- cgit v0.12 From 8f0cfce66a4fd94536faac0595c3d7d7c7844d64 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 8 Jul 2016 12:38:35 +0000 Subject: (cherry-pick): Bugfix [5d7ea04580]. Treat .cmd and .ps1 files are executable on Windows. --- doc/file.n | 4 +++- win/tclWinFile.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/file.n b/doc/file.n index 36eae79..43eae7a 100644 --- a/doc/file.n +++ b/doc/file.n @@ -156,7 +156,9 @@ returns \fB/home\fR (or something similar). \fBfile executable \fIname\fR . Returns \fB1\fR if file \fIname\fR is executable by the current user, -\fB0\fR otherwise. +\fB0\fR otherwise. On Windows, which does not have an executable attribute, +the command treats all directories and any files with extensions +\fBexe\fR, \fBcom\fR, \fBcmd\fR, \fBbat\fR or \fBps1\fR as executable. .TP \fBfile exists \fIname\fR . diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 41de4a8..e671058 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1783,7 +1783,7 @@ NativeAccess( * NativeIsExec -- * * Determines if a path is executable. On windows this is simply defined - * by whether the path ends in any of ".exe", ".com", or ".bat" + * by whether the path ends in a standard executable extension. * * Results: * 1 = executable, 0 = not. @@ -1834,6 +1834,8 @@ NativeIsExec( if ((strcasecmp(p, "exe") == 0) || (strcasecmp(p, "com") == 0) + || (strcasecmp(p, "cmd") == 0) + || (strcasecmp(p, "ps1") == 0) || (strcasecmp(p, "bat") == 0)) { /* * File that ends with .exe, .com, or .bat is executable. -- cgit v0.12 From 8435bb9d68cdb26190ded1caca280eaac0314444 Mon Sep 17 00:00:00 2001 From: ashok Date: Sat, 9 Jul 2016 08:27:00 +0000 Subject: Bugfix [ae61a67192]. file {stat, type, size} etc. support for built-in special Windows files/devices like CON. --- generic/tclCmdAH.c | 19 ++++++++++++++++++ tests/cmdAH.test | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- win/tclWinFile.c | 43 +++++++++++++++++++++++++++++++---------- win/tclWinPort.h | 14 ++++++++++++++ 4 files changed, 120 insertions(+), 12 deletions(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 54e0227..a53f1f7 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -1157,6 +1157,16 @@ FileAttrAccessTimeCmd( if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) { return TCL_ERROR; } +#if defined(_WIN32) + /* We use a value of 0 to indicate the access time not available */ + if (buf.st_atime == 0) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "could not get access time for file \"%s\"", + TclGetString(objv[1]))); + return TCL_ERROR; + } +#endif + if (objc == 3) { /* * Need separate variable for reading longs from an object on 64-bit @@ -1229,6 +1239,15 @@ FileAttrModifyTimeCmd( if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) { return TCL_ERROR; } +#if defined(_WIN32) + /* We use a value of 0 to indicate the modification time not available */ + if (buf.st_mtime == 0) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "could not get modification time for file \"%s\"", + TclGetString(objv[1]))); + return TCL_ERROR; + } +#endif if (objc == 3) { /* * Need separate variable for reading longs from an object on 64-bit diff --git a/tests/cmdAH.test b/tests/cmdAH.test index f2f7f8c..6240500 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -1026,6 +1026,16 @@ test cmdAH-20.6 {Tcl_FileObjCmd: atime touch} -setup { set modatime [file atime $file $newatime] expr {$newatime == $modatime ? 1 : "$newatime != $modatime"} } -result 1 +test cmdAH-20.7 { + Tcl_FileObjCmd: atime (built-in Windows names) +} -constraints {win} -body { + file atime con +} -result "could not get access time for file \"con\"" -returnCodes error +test cmdAH-20.7.1 { + Tcl_FileObjCmd: atime (built-in Windows names with dir path and extension) +} -constraints {win} -body { + file atime [file join [temporaryDirectory] CON.txt] +} -result "could not get access time for file \"[file join [temporaryDirectory] CON.txt]\"" -returnCodes error if {[testConstraint unix] && [file exists /tmp]} { removeFile touch.me /tmp @@ -1257,6 +1267,16 @@ test cmdAH-24.13 {Tcl_FileObjCmd: directory mtime} -setup { } -cleanup { file delete -force $dirname } -result {0 1} +test cmdAH-24.14 { + Tcl_FileObjCmd: mtime (built-in Windows names) +} -constraints {win} -body { + file mtime con +} -result "could not get modification time for file \"con\"" -returnCodes error +test cmdAH-24.14.1 { + Tcl_FileObjCmd: mtime (built-in Windows names with dir path and extension) +} -constraints {win} -body { + file mtime [file join [temporaryDirectory] CON.txt] +} -result "could not get modification time for file \"[file join [temporaryDirectory] CON.txt]\"" -returnCodes error # owned test cmdAH-25.1 {Tcl_FileObjCmd: owned} -returnCodes error -body { @@ -1306,6 +1326,16 @@ test cmdAH-27.2 {Tcl_FileObjCmd: size} { test cmdAH-27.3 {Tcl_FileObjCmd: size} { list [catch {file size _bogus_} msg] [string tolower $msg] $errorCode } {1 {could not read "_bogus_": no such file or directory} {POSIX ENOENT {no such file or directory}}} +test cmdAH-27.4 { + Tcl_FileObjCmd: size (built-in Windows names) +} -constraints {win} -body { + file size con +} -result 0 +test cmdAH-27.4.1 { + Tcl_FileObjCmd: size (built-in Windows names with dir path and extension) +} -constraints {win} -body { + file size [file join [temporaryDirectory] con.txt] +} -result 0 catch {testsetplatform $platform} removeFile $gorpfile @@ -1397,12 +1427,24 @@ test cmdAH-28.12 {Tcl_FileObjCmd: stat} -setup { } -cleanup { removeFile $filename } -result 1 +test cmdAH-28.13 {Tcl_FileObjCmd: stat (built-in Windows names)} -setup { + unset -nocomplain stat +} -body { + file stat con stat + lmap elem {atime ctime dev gid ino mode mtime nlink size type uid} {set stat($elem)} +} -result {0 0 -1 0 0 8630 0 0 0 characterSpecial 0} +test cmdAH-28.13.1 {Tcl_FileObjCmd: stat (built-in Windows names)} -setup { + unset -nocomplain stat +} -body { + file stat [file join [temporaryDirectory] CON.txt] stat + lmap elem {atime ctime dev gid ino mode mtime nlink size type uid} {set stat($elem)} +} -result {0 0 -1 0 0 8630 0 0 0 characterSpecial 0} unset -nocomplain stat # type test cmdAH-29.1 {Tcl_FileObjCmd: type} -returnCodes error -body { - file size a b -} -result {wrong # args: should be "file size name"} + file type a b +} -result {wrong # args: should be "file type name"} test cmdAH-29.2 {Tcl_FileObjCmd: type} { file type $dirfile } directory @@ -1437,6 +1479,16 @@ test cmdAH-29.4.1 {Tcl_FileObjCmd: type} -constraints {linkDirectory} -setup { test cmdAH-29.5 {Tcl_FileObjCmd: type} { list [catch {file type _bogus_} msg] [string tolower $msg] $errorCode } {1 {could not read "_bogus_": no such file or directory} {POSIX ENOENT {no such file or directory}}} +test cmdAH-29.6 { + Tcl_FileObjCmd: type (built-in Windows names) +} -constraints {win} -body { + file type con +} -result "characterSpecial" +test cmdAH-29.6.1 { + Tcl_FileObjCmd: type (built-in Windows names, with dir path and extension) +} -constraints {win} -body { + file type [file join [temporaryDirectory] CON.txt] +} -result "characterSpecial" # Error conditions test cmdAH-30.1 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 4b0b884..7f6dff9 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1953,6 +1953,7 @@ NativeStat( unsigned short mode; unsigned int inode = 0; HANDLE fileHandle; + DWORD fileType = FILE_TYPE_UNKNOWN; /* * If we can use 'createFile' on this, then we can use the resulting @@ -1960,6 +1961,14 @@ NativeStat( * other attributes reading APIs. If not, then we try to fall back on the * 'getFileAttributesExProc', and if that isn't available, then on even * simpler routines. + * + * Special consideration must be given to Windows hardcoded names + * like CON, NULL, COM1, LPT1 etc. For these, we still need to + * do the CreateFile as some may not exist (e.g. there is no CON + * in wish by default). However the subsequent GetFileInformationByHandle + * will fail. We do a WinIsReserved to see if it is one of the special + * names, and if successful, mock up a BY_HANDLE_FILE_INFORMATION + * structure. */ fileHandle = CreateFile(nativePath, GENERIC_READ, @@ -1970,19 +1979,26 @@ NativeStat( BY_HANDLE_FILE_INFORMATION data; if (GetFileInformationByHandle(fileHandle,&data) != TRUE) { - CloseHandle(fileHandle); - Tcl_SetErrno(ENOENT); - return -1; - } - CloseHandle(fileHandle); - + fileType = GetFileType(fileHandle); + CloseHandle(fileHandle); + if (fileType != FILE_TYPE_CHAR && fileType != FILE_TYPE_DISK) { + Tcl_SetErrno(ENOENT); + return -1; + } + /* Mock up the expected structure */ + memset(&data, 0, sizeof(data)); + statPtr->st_atime = 0; + statPtr->st_mtime = 0; + statPtr->st_ctime = 0; + } else { + CloseHandle(fileHandle); + statPtr->st_atime = ToCTime(data.ftLastAccessTime); + statPtr->st_mtime = ToCTime(data.ftLastWriteTime); + statPtr->st_ctime = ToCTime(data.ftCreationTime); + } attr = data.dwFileAttributes; - statPtr->st_size = ((Tcl_WideInt) data.nFileSizeLow) | (((Tcl_WideInt) data.nFileSizeHigh) << 32); - statPtr->st_atime = ToCTime(data.ftLastAccessTime); - statPtr->st_mtime = ToCTime(data.ftLastWriteTime); - statPtr->st_ctime = ToCTime(data.ftCreationTime); /* * On Unix, for directories, nlink apparently depends on the number of @@ -2038,6 +2054,13 @@ NativeStat( dev = NativeDev(nativePath); mode = NativeStatMode(attr, checkLinks, NativeIsExec(nativePath)); + if (fileType == FILE_TYPE_CHAR) { + mode &= ~S_IFMT; + mode |= S_IFCHR; + } else if (fileType == FILE_TYPE_DISK) { + mode &= ~S_IFMT; + mode |= S_IFBLK; + } statPtr->st_dev = (dev_t) dev; statPtr->st_ino = inode; diff --git a/win/tclWinPort.h b/win/tclWinPort.h index ca6b2bf..b486466 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -360,6 +360,20 @@ typedef DWORD_PTR * PDWORD_PTR; # define S_IFLNK 0120000 /* Symbolic Link */ #endif +/* + * Windows compilers do not define S_IFBLK. However, Tcl uses it in + * GetTypeFromMode to identify blockSpecial devices based on the + * value in the statsbuf st_mode field. We have no other way to pass this + * from NativeStat on Windows so are forced to define it here. + * The definition here is essentially what is seen on Linux and MingW. + * XXX - the root problem is Tcl using Unix definitions instead of + * abstracting the structure into a platform independent one. Sigh - perhaps + * Tcl 9 + */ +#ifndef S_IFBLK +# define S_IFBLK (S_IFDIR | S_IFCHR) +#endif + #ifndef S_ISREG # ifdef S_IFREG # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -- cgit v0.12 From 673b7ecc2109080c1d8ab85bede83600d5dfff1e Mon Sep 17 00:00:00 2001 From: ashok Date: Sat, 9 Jul 2016 11:13:48 +0000 Subject: Bugfix [3613671]. file owned implementation for Windows. --- doc/file.n | 7 +++--- generic/tclCmdAH.c | 17 +++++--------- tests/cmdAH.test | 6 +++++ win/tclWinFile.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++- win/tclWinInt.h | 1 + 5 files changed, 81 insertions(+), 16 deletions(-) diff --git a/doc/file.n b/doc/file.n index eeb67ed..58b03d8 100644 --- a/doc/file.n +++ b/doc/file.n @@ -484,10 +484,9 @@ not the effective ones. .TP \fBWindows\fR\0\0\0\0 . -The \fBfile owned\fR subcommand currently always reports that the current user -is the owner of the file, without regard for what the operating system -believes to be true, making an ownership test useless. This issue (#3613671) -may be fixed in a future release of Tcl. +The \fBfile owned\fR subcommand uses the user identifier (SID) of +the process token, not the thread token which may be impersonating +some other user. .SH EXAMPLES .PP This procedure shows how to search for C files in a given directory diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index a53f1f7..13d3df5 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -12,6 +12,9 @@ */ #include "tclInt.h" +#ifdef _WIN32 +# include "tclWinInt.h" +#endif #include /* @@ -1600,21 +1603,13 @@ FileAttrIsOwnedCmd( Tcl_WrongNumArgs(interp, 1, objv, "name"); return TCL_ERROR; } - if (GetStatBuf(NULL, objv[1], Tcl_FSStat, &buf) == TCL_OK) { - /* - * For Windows, there are no user ids associated with a file, so we - * always return 1. - * - * TODO: use GetSecurityInfo to get the real owner of the file and - * test for equivalence to the current user. - */ - #if defined(_WIN32) || defined(__CYGWIN__) - value = 1; + value = TclWinFileOwned(objv[1]); #else + if (GetStatBuf(NULL, objv[1], Tcl_FSStat, &buf) == TCL_OK) { value = (geteuid() == buf.st_uid); -#endif } +#endif Tcl_SetObjResult(interp, Tcl_NewBooleanObj(value)); return TCL_OK; } diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 6240500..c74bddb 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -1296,6 +1296,12 @@ test cmdAH-25.2.1 {Tcl_FileObjCmd: owned} -constraints unix -setup { test cmdAH-25.3 {Tcl_FileObjCmd: owned} {unix notRoot} { file owned / } 0 +test cmdAH-25.3.1 {Tcl_FileObjCmd: owned} -constraints win -body { + file owned $env(windir) +} -result 0 +test cmdAH-25.4 {Tcl_FileObjCmd: owned} -body { + file owned nosuchfile +} -result 0 # readlink test cmdAH-26.1 {Tcl_FileObjCmd: readlink} -returnCodes error -body { diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 7f6dff9..3e8a171 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -16,8 +16,9 @@ #include "tclFileSystem.h" #include #include -#include /* For TclpGetUserHome(). */ +#include /* For TclpGetUserHome(). */ #include /* For TclpGetUserHome(). */ +#include /* For GetNamedSecurityInfo */ #ifdef _MSC_VER # pragma comment(lib, "userenv.lib") @@ -3134,6 +3135,69 @@ TclpUtime( } /* + *--------------------------------------------------------------------------- + * + * TclWinFileOwned -- + * + * Returns 1 if the specified file exists and is owned by the current + * user and 0 otherwise. Like the Unix case, the check is made using + * the real process SID, not the effective (impersonation) one. + * + *--------------------------------------------------------------------------- + */ + +int +TclWinFileOwned( + Tcl_Obj *pathPtr) /* File whose ownership is to be checked */ +{ + const TCHAR *native; + PSID ownerSid = NULL; + PSECURITY_DESCRIPTOR secd = NULL; + HANDLE token; + LPBYTE buf = NULL; + DWORD bufsz; + int owned = 0; + + native = Tcl_FSGetNativePath(pathPtr); + + if (GetNamedSecurityInfo(native, SE_FILE_OBJECT, + OWNER_SECURITY_INFORMATION, &ownerSid, + NULL, NULL, NULL, &secd) != ERROR_SUCCESS) { + /* Either not a file, or we do not have access to it in which + case we are in all likelihood not the owner */ + return 0; + } + + /* + * Getting the current process SID is a multi-step process. + * We make the assumption that if a call fails, this process is + * so underprivileged it could not possibly own anything. Normally + * a process can *always* look up its own token. + */ + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) { + /* Find out how big the buffer needs to be */ + bufsz = 0; + GetTokenInformation(token, TokenUser, NULL, 0, &bufsz); + if (bufsz) { + buf = ckalloc(bufsz); + if (GetTokenInformation(token, TokenUser, buf, bufsz, &bufsz)) { + owned = EqualSid(ownerSid, ((PTOKEN_USER) buf)->User.Sid); + } + } + CloseHandle(token); + } + +vamoose: + /* Free allocations and be done */ + if (secd) + LocalFree(secd); /* Also frees ownerSid */ + if (buf) + ckfree(buf); + + return (owned != 0); /* Convert non-0 to 1 */ +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 9df424f..6b098f8 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -72,6 +72,7 @@ MODULE_SCOPE int TclWinSymLinkCopyDirectory(const TCHAR *LinkOriginal, const TCHAR *LinkCopy); MODULE_SCOPE int TclWinSymLinkDelete(const TCHAR *LinkOriginal, int linkOnly); +MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *); #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) MODULE_SCOPE void TclWinFreeAllocCache(void); MODULE_SCOPE void TclFreeAllocCache(void *); -- cgit v0.12 From cc8c25008d6a30ceb0b4a6946e4a3d45431637c6 Mon Sep 17 00:00:00 2001 From: ashok Date: Sat, 9 Jul 2016 14:18:22 +0000 Subject: Bugfix [9ece99d58b]. Make exec understand .CMD files on Windows. --- tests/exec.test | 16 ++++++++++++++++ win/tclWinFile.c | 1 - win/tclWinPipe.c | 7 ++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/exec.test b/tests/exec.test index 16a8320..38927d3 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -682,6 +682,22 @@ test exec-19.1 {exec >> uses O_APPEND} -constraints {exec unix} -setup { } -cleanup { removeFile $tmpfile } -result 14 + +# Tests to ensure batch files and .CMD (Bug 9ece99d58b) +# can be executed on Windows +test exec-20.0 {exec .bat file} -constraints {win} -body { + set log [makeFile {} exec20.log] + exec [makeFile "echo %1> $log" exec20.bat] "Testing exec-20.0" + viewFile $log +} -result "\"Testing exec-20.0\"" +test exec-20.1 {exec .CMD file} -constraints {win} -body { + set log [makeFile {} exec201.log] + exec [makeFile "echo %1> $log" exec201.CMD] "Testing exec-20.1" + viewFile $log +} -result "\"Testing exec-20.1\"" + + + # ---------------------------------------------------------------------- # cleanup diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 3e8a171..dbfdfd0 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1795,7 +1795,6 @@ NativeIsExec( if ((_tcsicmp(path+len-3, TEXT("exe")) == 0) || (_tcsicmp(path+len-3, TEXT("com")) == 0) || (_tcsicmp(path+len-3, TEXT("cmd")) == 0) - || (_tcsicmp(path+len-3, TEXT("ps1")) == 0) || (_tcsicmp(path+len-3, TEXT("bat")) == 0)) { return 1; } diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index aff8836..382addd 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -897,7 +897,7 @@ TclpGetPid( * * The complete Windows search path is searched to find the specified * executable. If an executable by the given name is not found, - * automatically tries appending ".com", ".exe", and ".bat" to the + * automatically tries appending standard extensions to the * executable name. * * Results: @@ -1292,7 +1292,7 @@ ApplicationType( Tcl_DString nameBuf, ds; const TCHAR *nativeName; TCHAR nativeFullPath[MAX_PATH]; - static const char extensions[][5] = {"", ".com", ".exe", ".bat"}; + static const char extensions[][5] = {"", ".com", ".exe", ".bat", ".cmd"}; /* * Look for the program as an external program. First try the name as it @@ -1337,7 +1337,8 @@ ApplicationType( Tcl_DStringFree(&ds); ext = strrchr(fullName, '.'); - if ((ext != NULL) && (strcasecmp(ext, ".bat") == 0)) { + if ((ext != NULL) && + (strcasecmp(ext, ".cmd") == 0 || strcasecmp(ext, ".bat") == 0)) { applType = APPL_DOS; break; } -- cgit v0.12 From 6b01fdf5d1344c640a5392e14bcdd7518758bbed Mon Sep 17 00:00:00 2001 From: ashok Date: Sat, 9 Jul 2016 14:23:24 +0000 Subject: Fixed docs for prior check-in (exec of .CMD files on Windows) --- doc/exec.n | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/exec.n b/doc/exec.n index 9d58d90..70ace32 100644 --- a/doc/exec.n +++ b/doc/exec.n @@ -271,8 +271,9 @@ limitation as \fBexec\fR wants to communicate over pipes. The Expect extension addresses this issue when communicating with a TUI application. .PP When attempting to execute an application, \fBexec\fR first searches for -the name as it was specified. Then, in order, \fB.com\fR, \fB.exe\fR, and -\fB.bat\fR are appended to the end of the specified name and it searches +the name as it was specified. Then, in order, +\fB.com\fR, \fB.exe\fR, \fB.bat\fR and \fB.cmd\fR +are appended to the end of the specified name and it searches for the longer name. If a directory name was not specified as part of the application name, the following directories are automatically searched in order when attempting to locate the application: -- cgit v0.12 From 9130b29ef9ede2cafefe32403248930ba6f94dee Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 9 Jul 2016 14:26:56 +0000 Subject: Revise INST_INVOKE_REPLACE to call EvalObjv with TCL_EVAL_INVOKE and no longer call EvalObjEx which does not support it reliably. Also convert to conventional list operations. --- generic/tclExecute.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 8ddefda..52865e6 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3153,20 +3153,7 @@ TEBCresume( fflush(stdout); } #endif /*TCL_COMPILE_DEBUG*/ - { - Tcl_Obj *copyPtr = Tcl_NewListObj(objc - opnd + 1, NULL); - register List *listRepPtr = copyPtr->internalRep.twoPtrValue.ptr1; - Tcl_Obj **copyObjv = &listRepPtr->elements; - int i; - listRepPtr->elemCount = objc - opnd + 1; - copyObjv[0] = objPtr; - memcpy(copyObjv+1, objv+opnd, sizeof(Tcl_Obj *) * (objc - opnd)); - for (i=1 ; idata.tebc.pc = (char *) pc; iPtr->cmdFramePtr = bcFramePtr; if (iPtr->flags & INTERP_DEBUG_FRAME) { @@ -3174,13 +3161,25 @@ TEBCresume( } TclInitRewriteEnsemble(interp, opnd, 1, objv); + + { + Tcl_Obj *copyPtr = Tcl_NewListObj(objc - opnd + 1, NULL); + + Tcl_ListObjAppendElement(NULL, copyPtr, objPtr); + Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, + objc - opnd, objv + opnd); + objPtr = copyPtr; + } + DECACHE_STACK_INFO(); pc += 6; TEBC_YIELD(); TclMarkTailcall(interp); - TclNRAddCallback(interp, TclClearRootEnsemble, NULL,NULL,NULL,NULL); - return TclNREvalObjEx(interp, objPtr, TCL_EVAL_INVOKE, NULL, INT_MIN); + TclNRAddCallback(interp, TclClearRootEnsemble, NULL, NULL, NULL, NULL); + Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv); + TclNRAddCallback(interp, TclNRReleaseValues, objPtr, NULL, NULL, NULL); + return TclNREvalObjv(interp, objc, objv, TCL_EVAL_INVOKE, NULL); /* * ----------------------------------------------------------------- -- cgit v0.12 From 39488ce3ef11fcbac48bd3c7e35b3ba3fb80c2de Mon Sep 17 00:00:00 2001 From: ashok Date: Sat, 9 Jul 2016 14:30:54 +0000 Subject: Fix missing constraints for Windows-specific tests --- tests/cmdAH.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cmdAH.test b/tests/cmdAH.test index c74bddb..ef933cb 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -1433,13 +1433,13 @@ test cmdAH-28.12 {Tcl_FileObjCmd: stat} -setup { } -cleanup { removeFile $filename } -result 1 -test cmdAH-28.13 {Tcl_FileObjCmd: stat (built-in Windows names)} -setup { +test cmdAH-28.13 {Tcl_FileObjCmd: stat (built-in Windows names)} -constraints {win} -setup { unset -nocomplain stat } -body { file stat con stat lmap elem {atime ctime dev gid ino mode mtime nlink size type uid} {set stat($elem)} } -result {0 0 -1 0 0 8630 0 0 0 characterSpecial 0} -test cmdAH-28.13.1 {Tcl_FileObjCmd: stat (built-in Windows names)} -setup { +test cmdAH-28.13.1 {Tcl_FileObjCmd: stat (built-in Windows names)} -constraints {win} -setup { unset -nocomplain stat } -body { file stat [file join [temporaryDirectory] CON.txt] stat -- cgit v0.12 From 1a4a8552102094aeb6294acf74d78623df4206d3 Mon Sep 17 00:00:00 2001 From: ashok Date: Sun, 10 Jul 2016 06:33:20 +0000 Subject: Fix compiler warnings (const-ness and unused label) that did not show up in the non-optimized build before last checkin. --- win/tclWinFile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/win/tclWinFile.c b/win/tclWinFile.c index dbfdfd0..4d7500b 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -3159,7 +3159,7 @@ TclWinFileOwned( native = Tcl_FSGetNativePath(pathPtr); - if (GetNamedSecurityInfo(native, SE_FILE_OBJECT, + if (GetNamedSecurityInfo((LPTSTR) native, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &ownerSid, NULL, NULL, NULL, &secd) != ERROR_SUCCESS) { /* Either not a file, or we do not have access to it in which @@ -3186,7 +3186,6 @@ TclWinFileOwned( CloseHandle(token); } -vamoose: /* Free allocations and be done */ if (secd) LocalFree(secd); /* Also frees ownerSid */ -- cgit v0.12 From 2d2ec051cf1bccebd8ceacb06ffb7ea6f332c72c Mon Sep 17 00:00:00 2001 From: ashok Date: Sun, 10 Jul 2016 06:41:54 +0000 Subject: Bugfix [da340d4f32]. clock-55.9 and clock-55.10 test failures. --- generic/tclClock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/generic/tclClock.c b/generic/tclClock.c index 949cb1c..c3b29e9 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -1499,7 +1499,19 @@ GetJulianDayFromEraYearMonthDay( * Try an initial conversion in the Gregorian calendar. */ +#if 0 /* BUG http://core.tcl.tk/tcl/tktview?name=da340d4f32 */ ym1o4 = ym1 / 4; +#else + /* + * Have to make sure quotient is truncated towards 0 when negative. + * See above bug for details. The casts are necessary. + */ + if (ym1 >= 0) + ym1o4 = ym1 / 4; + else { + ym1o4 = - (int) (((unsigned int) -ym1) / 4); + } +#endif if (ym1 % 4 < 0) { ym1o4--; } -- cgit v0.12 From 3503e831432d62edd78f63cb90a322d3ad51d6a3 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 10 Jul 2016 07:59:52 +0000 Subject: Fixes to namespace.test --- tests/namespace.test | 418 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 306 insertions(+), 112 deletions(-) diff --git a/tests/namespace.test b/tests/namespace.test index dc1d3bf..575695f 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -82,12 +82,14 @@ test namespace-4.2 {Tcl_PushCallFrame with isProcCallFrame=0} { test namespace-5.1 {Tcl_PopCallFrame, no vars} { namespace eval test_ns_1::blodge {} ;# pushes then pops frame } {} -test namespace-5.2 {Tcl_PopCallFrame, local vars must be deleted} { +test namespace-5.2 {Tcl_PopCallFrame, local vars must be deleted} -setup { + namespace eval test_ns_1 {} +} -body { proc test_ns_1::r {} { set a 123 } test_ns_1::r ;# pushes then pop's r's frame -} {123} +} -result {123} test namespace-6.1 {Tcl_CreateNamespace} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -194,7 +196,6 @@ test namespace-7.7 {Bug 1655305} -setup { interp delete slave } -result {} - test namespace-8.1 {TclTeardownNamespace, delete global namespace} { catch {interp delete test_interp} interp create test_interp @@ -303,15 +304,24 @@ test namespace-9.4 {Tcl_Import, simple import} { } test_ns_import::p } {cmd1: 123} -test namespace-9.5 {Tcl_Import, RFE 1230597} { +test namespace-9.5 {Tcl_Import, RFE 1230597} -setup { + namespace eval test_ns_import {} + namespace eval test_ns_export {} +} -body { list [catch {namespace eval test_ns_import {namespace import ::test_ns_export::*}} msg] $msg -} {0 {}} -test namespace-9.6 {Tcl_Import, cmd redefinition ok if allowOverwrite!=0} { +} -result {0 {}} +test namespace-9.6 {Tcl_Import, cmd redefinition ok if allowOverwrite!=0} -setup { + namespace eval test_ns_import {} + namespace eval ::test_ns_export { + proc cmd1 {args} {return "cmd1: $args"} + namespace export cmd1 + } +} -body { namespace eval test_ns_import { namespace import -force ::test_ns_export::* cmd1 555 } -} {cmd1: 555} +} -result {cmd1: 555} test namespace-9.7 {Tcl_Import, links are preserved if cmd is redefined} { catch {namespace delete {*}[namespace children :: test_ns_*]} namespace eval test_ns_export { @@ -329,7 +339,6 @@ test namespace-9.7 {Tcl_Import, links are preserved if cmd is redefined} { [test_ns_import::cmd1 g h i] \ [test_ns_export::cmd1 j k l] } {{cmd1: a b c} {cmd1: d e f} {} ::test_ns_export::cmd1 ::test_ns_export::cmd1 {new1: g h i} {new1: j k l}} - test namespace-9.8 {Tcl_Import: Bug 1017299} -setup { namespace eval one { namespace export cmd @@ -354,7 +363,6 @@ test namespace-9.8 {Tcl_Import: Bug 1017299} -setup { } -cleanup { namespace delete one two three } -match glob -result *::one::cmd - test namespace-9.9 {Tcl_Import: Bug 1017299} -setup { namespace eval one { namespace export cmd @@ -388,7 +396,13 @@ test namespace-10.2 {Tcl_ForgetImport, ignores patterns that don't match} { namespace forget ::test_ns_export::wombat } } {} -test namespace-10.3 {Tcl_ForgetImport, deletes matching imported cmds} { +test namespace-10.3 {Tcl_ForgetImport, deletes matching imported cmds} -setup { + namespace eval test_ns_export { + namespace export cmd1 + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + } +} -body { namespace eval test_ns_import { namespace import ::test_ns_export::* proc p {} {return [cmd1 123]} @@ -398,8 +412,7 @@ test namespace-10.3 {Tcl_ForgetImport, deletes matching imported cmds} { lappend l [info commands ::test_ns_import::*] lappend l [catch {cmd1 777} msg] $msg } -} [list [lsort {::test_ns_import::p ::test_ns_import::cmd1}] ::test_ns_import::p 1 {invalid command name "cmd1"}] - +} -result [list [lsort {::test_ns_import::p ::test_ns_import::cmd1}] ::test_ns_import::p 1 {invalid command name "cmd1"}] test namespace-10.4 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -417,7 +430,6 @@ test namespace-10.4 {Tcl_ForgetImport: Bug 560297} -setup { } -cleanup { namespace delete origin unrelated my } - test namespace-10.5 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -433,7 +445,6 @@ test namespace-10.5 {Tcl_ForgetImport: Bug 560297} -setup { } -cleanup { namespace delete origin my } -returnCodes error -match glob -result * - test namespace-10.6 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -450,7 +461,6 @@ test namespace-10.6 {Tcl_ForgetImport: Bug 560297} -setup { } -cleanup { namespace delete origin my your } -returnCodes error -match glob -result * - test namespace-10.7 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -471,7 +481,6 @@ test namespace-10.7 {Tcl_ForgetImport: Bug 560297} -setup { } -cleanup { namespace delete origin link link2 my } -returnCodes error -match glob -result * - test namespace-10.8 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -492,7 +501,6 @@ test namespace-10.8 {Tcl_ForgetImport: Bug 560297} -setup { } -cleanup { namespace delete origin link link2 my } - test namespace-10.9 {Tcl_ForgetImport: Bug 560297} -setup { namespace eval origin { namespace export cmd @@ -514,29 +522,47 @@ test namespace-10.9 {Tcl_ForgetImport: Bug 560297} -setup { namespace delete origin link link2 my } -returnCodes error -match glob -result * -test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} { +test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_export { namespace export cmd1 proc cmd1 {args} {return "cmd1: $args"} } list [namespace origin set] [namespace origin test_ns_export::cmd1] -} {::set ::test_ns_export::cmd1} -test namespace-11.2 {TclGetOriginalCommand, directly imported cmd} { +} -result {::set ::test_ns_export::cmd1} +test namespace-11.2 {TclGetOriginalCommand, directly imported cmd} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_export { + namespace export cmd1 + proc cmd1 {args} {return "cmd1: $args"} + } +} -body { namespace eval test_ns_import1 { namespace import ::test_ns_export::* namespace export * proc p {} {namespace origin cmd1} } list [test_ns_import1::p] [namespace origin test_ns_import1::cmd1] -} {::test_ns_export::cmd1 ::test_ns_export::cmd1} -test namespace-11.3 {TclGetOriginalCommand, indirectly imported cmd} { +} -result {::test_ns_export::cmd1 ::test_ns_export::cmd1} +test namespace-11.3 {TclGetOriginalCommand, indirectly imported cmd} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_export { + namespace export cmd1 + proc cmd1 {args} {return "cmd1: $args"} + } + namespace eval test_ns_import1 { + namespace import ::test_ns_export::* + namespace export * + proc p {} {namespace origin cmd1} + } +} -body { namespace eval test_ns_import2 { namespace import ::test_ns_import1::* proc q {} {return [cmd1 123]} } list [test_ns_import2::q] [namespace origin test_ns_import2::cmd1] -} {{cmd1: 123} ::test_ns_export::cmd1} +} -result {{cmd1: 123} ::test_ns_export::cmd1} test namespace-12.1 {InvokeImportedCmd} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -550,14 +576,23 @@ test namespace-12.1 {InvokeImportedCmd} { list [test_ns_import::cmd1] } {::test_ns_export} -test namespace-13.1 {DeleteImportedCmd, deletes imported cmds} { +test namespace-13.1 {DeleteImportedCmd, deletes imported cmds} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_export { + namespace export cmd1 + proc cmd1 {args} {namespace current} + } + namespace eval test_ns_import { + namespace import ::test_ns_export::* + } +} -body { namespace eval test_ns_import { set l {} lappend l [info commands ::test_ns_import::*] namespace forget ::test_ns_export::cmd1 lappend l [info commands ::test_ns_import::*] } -} {::test_ns_import::cmd1 {}} +} -result {::test_ns_import::cmd1 {}} test namespace-13.2 {DeleteImportedCmd, Bug a4494e28ed} { # Will panic if still buggy namespace eval src {namespace export foo; proc foo {} {}} @@ -568,7 +603,7 @@ test namespace-13.2 {DeleteImportedCmd, Bug a4494e28ed} { namespace delete src } {} -test namespace-14.1 {TclGetNamespaceForQualName, absolute names} { +test namespace-14.1 {TclGetNamespaceForQualName, absolute names} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} variable v 10 namespace eval test_ns_1::test_ns_2 { @@ -577,22 +612,41 @@ test namespace-14.1 {TclGetNamespaceForQualName, absolute names} { namespace eval test_ns_2 { variable v 30 } +} -body { namespace eval test_ns_1 { list $::v $::test_ns_2::v $::test_ns_1::test_ns_2::v \ [lsort [namespace children :: test_ns_*]] } -} [list 10 30 20 [lsort {::test_ns_1 ::test_ns_2}]] -test namespace-14.2 {TclGetNamespaceForQualName, invalid absolute names} { +} -result [list 10 30 20 [lsort {::test_ns_1 ::test_ns_2}]] +test namespace-14.2 {TclGetNamespaceForQualName, invalid absolute names} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + variable v 10 + namespace eval test_ns_1::test_ns_2 { + variable v 20 + } + namespace eval test_ns_2 { + variable v 30 + } +} -body { namespace eval test_ns_1 { list [catch {set ::test_ns_777::v} msg] $msg \ [catch {namespace children test_ns_777} msg] $msg } -} {1 {can't read "::test_ns_777::v": no such variable} 1 {namespace "test_ns_777" not found in "::test_ns_1"}} -test namespace-14.3 {TclGetNamespaceForQualName, relative names} { +} -result {1 {can't read "::test_ns_777::v": no such variable} 1 {namespace "test_ns_777" not found in "::test_ns_1"}} +test namespace-14.3 {TclGetNamespaceForQualName, relative names} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + variable v 10 + namespace eval test_ns_1::test_ns_2 { + variable v 20 + } + namespace eval test_ns_2 { + variable v 30 + } +} -body { namespace eval test_ns_1 { list $v $test_ns_2::v } -} {10 20} +} -result {10 20} test namespace-14.4 {TclGetNamespaceForQualName, relative ns names looked up only in current ns} { namespace eval test_ns_1::test_ns_2 { namespace eval foo {} @@ -619,57 +673,72 @@ test namespace-14.6 {TclGetNamespaceForQualName, relative ns names looked up onl [catch {namespace children test_ns_1} msg] $msg } } {::test_ns_1::test_ns_2::foo 1 {namespace "test_ns_1" not found in "::test_ns_1"}} -test namespace-14.7 {TclGetNamespaceForQualName, ignore extra :s if ns} { +test namespace-14.7 {TclGetNamespaceForQualName, ignore extra :s if ns} -setup { + namespace eval test_ns_1::test_ns_2::foo {} +} -body { namespace children test_ns_1::: -} {::test_ns_1::test_ns_2} -test namespace-14.8 {TclGetNamespaceForQualName, ignore extra :s if ns} { +} -result {::test_ns_1::test_ns_2} +test namespace-14.8 {TclGetNamespaceForQualName, ignore extra :s if ns} -setup { + namespace eval test_ns_1::test_ns_2::foo {} +} -body { namespace children :::test_ns_1:::::test_ns_2::: -} {::test_ns_1::test_ns_2::foo} +} -result {::test_ns_1::test_ns_2::foo} test namespace-14.9 {TclGetNamespaceForQualName, extra ::s are significant for vars} { set l {} lappend l [catch {set test_ns_1::test_ns_2::} msg] $msg namespace eval test_ns_1::test_ns_2 {variable {} 2525} lappend l [set test_ns_1::test_ns_2::] } {1 {can't read "test_ns_1::test_ns_2::": no such variable} 2525} -test namespace-14.10 {TclGetNamespaceForQualName, extra ::s are significant for vars} { - catch {unset test_ns_1::test_ns_2::} +test namespace-14.10 {TclGetNamespaceForQualName, extra ::s are significant for vars} -setup { + namespace eval test_ns_1::test_ns_2::foo {} + unset -nocomplain test_ns_1::test_ns_2:: set l {} +} -body { lappend l [catch {set test_ns_1::test_ns_2::} msg] $msg set test_ns_1::test_ns_2:: 314159 lappend l [set test_ns_1::test_ns_2::] -} {1 {can't read "test_ns_1::test_ns_2::": no such variable} 314159} -test namespace-14.11 {TclGetNamespaceForQualName, extra ::s are significant for commands} { +} -result {1 {can't read "test_ns_1::test_ns_2::": no such variable} 314159} +test namespace-14.11 {TclGetNamespaceForQualName, extra ::s are significant for commands} -setup { + namespace eval test_ns_1::test_ns_2::foo {} catch {rename test_ns_1::test_ns_2:: {}} set l {} +} -body { lappend l [catch {test_ns_1::test_ns_2:: hello} msg] $msg proc test_ns_1::test_ns_2:: {args} {return "\{\}: $args"} lappend l [test_ns_1::test_ns_2:: hello] -} {1 {invalid command name "test_ns_1::test_ns_2::"} {{}: hello}} -test namespace-14.12 {TclGetNamespaceForQualName, extra ::s are significant for vars} { +} -result {1 {invalid command name "test_ns_1::test_ns_2::"} {{}: hello}} +test namespace-14.12 {TclGetNamespaceForQualName, extra ::s are significant for vars} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_1 { variable {} set test_ns_1::(x) y } set test_ns_1::(x) -} y -test namespace-14.13 {TclGetNamespaceForQualName, namespace other than global ns can't have empty name} { +} -result y +test namespace-14.13 {TclGetNamespaceForQualName, namespace other than global ns can't have empty name} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} - list [catch {namespace eval test_ns_1 {proc {} {} {}; namespace eval {} {}; {}}} msg] $msg -} {1 {can't create namespace "": only global namespace can have empty name}} +} -returnCodes error -body { + namespace eval test_ns_1 { + proc {} {} {} + namespace eval {} {} + {} + } +} -result {can't create namespace "": only global namespace can have empty name} -test namespace-15.1 {Tcl_FindNamespace, absolute name found} { +test namespace-15.1 {Tcl_FindNamespace, absolute name found} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_delete { namespace eval test_ns_delete2 {} proc cmd {args} {namespace current} } list [namespace delete ::test_ns_delete::test_ns_delete2] \ [namespace children ::test_ns_delete] -} {{} {}} -test namespace-15.2 {Tcl_FindNamespace, absolute name not found} { - list [catch {namespace delete ::test_ns_delete::test_ns_delete2} msg] $msg -} {1 {unknown namespace "::test_ns_delete::test_ns_delete2" in namespace delete command}} +} -result {{} {}} +test namespace-15.2 {Tcl_FindNamespace, absolute name not found} -body { + namespace delete ::test_ns_delete::test_ns_delete2 +} -returnCodes error -result {unknown namespace "::test_ns_delete::test_ns_delete2" in namespace delete command} test namespace-15.3 {Tcl_FindNamespace, relative name found} { namespace eval test_ns_delete { namespace eval test_ns_delete2 {} @@ -685,17 +754,24 @@ test namespace-15.4 {Tcl_FindNamespace, relative name not found} { } } {1 {unknown namespace "test_ns_delete2" in namespace delete command}} -test namespace-16.1 {Tcl_FindCommand, absolute name found} { +test namespace-16.1 {Tcl_FindCommand, absolute name found} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_1 { proc cmd {args} {return "[namespace current]::cmd: $args"} variable v "::test_ns_1::cmd" eval $v one } -} {::test_ns_1::cmd: one} -test namespace-16.2 {Tcl_FindCommand, absolute name found} { +} -result {::test_ns_1::cmd: one} +test namespace-16.2 {Tcl_FindCommand, absolute name found} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1 { + proc cmd {args} {return "[namespace current]::cmd: $args"} + variable v "::test_ns_1::cmd" + } +} -body { eval $test_ns_1::v two -} {::test_ns_1::cmd: two} +} -result {::test_ns_1::cmd: two} test namespace-16.3 {Tcl_FindCommand, absolute name not found} { namespace eval test_ns_1 { variable v2 "::test_ns_1::ladidah" @@ -724,11 +800,16 @@ test namespace-16.7 {Tcl_FindCommand, relative name and TCL_GLOBAL_ONLY} { catch {rename unknown {}} catch {rename unknown.old unknown} -test namespace-16.8 {Tcl_FindCommand, relative name found} { +test namespace-16.8 {Tcl_FindCommand, relative name found} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1 { + proc cmd {args} {return "[namespace current]::cmd: $args"} + } +} -body { namespace eval test_ns_1 { cmd a b c } -} {::test_ns_1::cmd: a b c} +} -result {::test_ns_1::cmd: a b c} test namespace-16.9 {Tcl_FindCommand, relative name found} -body { proc cmd2 {args} {return "[namespace current]::cmd2: $args"} namespace eval test_ns_1 { @@ -750,20 +831,21 @@ test namespace-16.10 {Tcl_FindCommand, relative name found, only look in current } -cleanup { catch {rename cmd2 {}} } -result {::::cmd2: a b c} -test namespace-16.11 {Tcl_FindCommand, relative name not found} { +test namespace-16.11 {Tcl_FindCommand, relative name not found} -body { namespace eval test_ns_1 { - list [catch {cmd3 a b c} msg] $msg + cmd3 a b c } -} {1 {invalid command name "cmd3"}} +} -returnCodes error -result {invalid command name "cmd3"} -catch {unset x} -test namespace-17.1 {Tcl_FindNamespaceVar, absolute name found} { +unset -nocomplain x +test namespace-17.1 {Tcl_FindNamespaceVar, absolute name found} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { set x 314159 namespace eval test_ns_1 { set ::x } -} {314159} +} -result {314159} test namespace-17.2 {Tcl_FindNamespaceVar, absolute name found} { namespace eval test_ns_1 { variable x 777 @@ -778,27 +860,33 @@ test namespace-17.3 {Tcl_FindNamespaceVar, absolute name found} { set ::test_ns_1::test_ns_2::x } } {1111} -test namespace-17.4 {Tcl_FindNamespaceVar, absolute name not found} { +test namespace-17.4 {Tcl_FindNamespaceVar, absolute name not found} -body { namespace eval test_ns_1 { namespace eval test_ns_2 { variable x 1111 } - list [catch {set ::test_ns_1::test_ns_2::y} msg] $msg + set ::test_ns_1::test_ns_2::y } -} {1 {can't read "::test_ns_1::test_ns_2::y": no such variable}} -test namespace-17.5 {Tcl_FindNamespaceVar, absolute name and TCL_GLOBAL_ONLY} { +} -returnCodes error -result {can't read "::test_ns_1::test_ns_2::y": no such variable} +test namespace-17.5 {Tcl_FindNamespaceVar, absolute name and TCL_GLOBAL_ONLY} -setup { + namespace eval ::test_ns_1::test_ns_2 {} +} -body { namespace eval test_ns_1 { namespace eval test_ns_3 { variable ::test_ns_1::test_ns_2::x 2222 } } set ::test_ns_1::test_ns_2::x -} {2222} -test namespace-17.6 {Tcl_FindNamespaceVar, relative name found} { +} -result {2222} +test namespace-17.6 {Tcl_FindNamespaceVar, relative name found} -setup { + namespace eval test_ns_1 { + variable x 777 + } +} -body { namespace eval test_ns_1 { set x } -} {777} +} -result {777} test namespace-17.7 {Tcl_FindNamespaceVar, relative name found} { namespace eval test_ns_1 { unset x @@ -834,8 +922,9 @@ catch {unset x} catch {unset l} catch {rename foo {}} -test namespace-18.1 {TclResetShadowedCmdRefs, one-level check for command shadowing} { +test namespace-18.1 {TclResetShadowedCmdRefs, one-level check for command shadowing} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { proc foo {} {return "global foo"} namespace eval test_ns_1 { proc trigger {} { @@ -849,7 +938,7 @@ test namespace-18.1 {TclResetShadowedCmdRefs, one-level check for command shadow proc foo {} {return "foo in test_ns_1"} } lappend l [test_ns_1::trigger] -} {{global foo} {foo in test_ns_1}} +} -result {{global foo} {foo in test_ns_1}} test namespace-18.2 {TclResetShadowedCmdRefs, multilevel check for command shadowing} { namespace eval test_ns_2 { proc foo {} {return "foo in ::test_ns_2"} @@ -873,22 +962,31 @@ test namespace-18.2 {TclResetShadowedCmdRefs, multilevel check for command shado catch {unset l} catch {rename foo {}} -test namespace-19.1 {GetNamespaceFromObj, global name found} { +test namespace-19.1 {GetNamespaceFromObj, global name found} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_1::test_ns_2 {} namespace children ::test_ns_1 -} {::test_ns_1::test_ns_2} -test namespace-19.2 {GetNamespaceFromObj, relative name found} { +} -result {::test_ns_1::test_ns_2} +test namespace-19.2 {GetNamespaceFromObj, relative name found} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1::test_ns_2 {} +} -body { namespace eval test_ns_1 { namespace children test_ns_2 } -} {} -test namespace-19.3 {GetNamespaceFromObj, name not found} -body { +} -result {} +test namespace-19.3 {GetNamespaceFromObj, name not found} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_1 { namespace children test_ns_99 } } -returnCodes error -result {namespace "test_ns_99" not found in "::test_ns_1"} -test namespace-19.4 {GetNamespaceFromObj, invalidation of cached ns refs} { +test namespace-19.4 {GetNamespaceFromObj, invalidation of cached ns refs} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1::test_ns_2 {} +} -body { namespace eval test_ns_1 { proc foo {} { return [namespace children test_ns_2] @@ -900,7 +998,7 @@ test namespace-19.4 {GetNamespaceFromObj, invalidation of cached ns refs} { namespace delete test_ns_1::test_ns_2 namespace eval test_ns_1::test_ns_2::test_ns_3 {} lappend l [test_ns_1::foo] -} {{} ::test_ns_1::test_ns_2::test_ns_3} +} -result {{} ::test_ns_1::test_ns_2::test_ns_3} test namespace-20.1 {Tcl_NamespaceObjCmd, bad subcommand} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -913,24 +1011,34 @@ test namespace-20.3 {Tcl_NamespaceObjCmd, abbreviations are okay} { namespace ch :: test_ns_* } {} -test namespace-21.1 {NamespaceChildrenCmd, no args} { +test namespace-21.1 {NamespaceChildrenCmd, no args} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { + namespace eval test_ns_1::test_ns_2 {} + expr {"::test_ns_1" in [namespace children]} +} -result {1} +test namespace-21.2 {NamespaceChildrenCmd, no args} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} namespace eval test_ns_1::test_ns_2 {} - expr {[string first ::test_ns_1 [namespace children]] != -1} -} {1} -test namespace-21.2 {NamespaceChildrenCmd, no args} { +} -body { namespace eval test_ns_1 { namespace children } -} {::test_ns_1::test_ns_2} -test namespace-21.3 {NamespaceChildrenCmd, ns name given} { +} -result {::test_ns_1::test_ns_2} +test namespace-21.3 {NamespaceChildrenCmd, ns name given} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1::test_ns_2 {} +} -body { namespace children ::test_ns_1 -} {::test_ns_1::test_ns_2} -test namespace-21.4 {NamespaceChildrenCmd, ns name given} { +} -result {::test_ns_1::test_ns_2} +test namespace-21.4 {NamespaceChildrenCmd, ns name given} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1::test_ns_2 {} +} -body { namespace eval test_ns_1 { namespace children test_ns_2 } -} {} +} -result {} test namespace-21.5 {NamespaceChildrenCmd, too many args} { namespace eval test_ns_1 { list [catch {namespace children test_ns_2 xxx yyy} msg] $msg @@ -940,10 +1048,13 @@ test namespace-21.6 {NamespaceChildrenCmd, glob-style pattern given} { namespace eval test_ns_1::test_ns_foo {} namespace children test_ns_1 *f* } {::test_ns_1::test_ns_foo} -test namespace-21.7 {NamespaceChildrenCmd, glob-style pattern given} { +test namespace-21.7 {NamespaceChildrenCmd, glob-style pattern given} -setup { + catch {namespace delete {*}[namespace children :: test_ns_*]} + namespace eval test_ns_1::test_ns_2 {} +} -body { namespace eval test_ns_1::test_ns_foo {} lsort [namespace children test_ns_1 test*] -} [lsort {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_foo}] +} -result {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_foo} test namespace-21.8 {NamespaceChildrenCmd, trivial pattern starting with ::} { namespace eval test_ns_1 {} namespace children [namespace current] [fq test_ns_1] @@ -1038,15 +1149,25 @@ test namespace-25.3 {NamespaceEvalCmd, new namespace} { } test_ns_1::p } {314159} -test namespace-25.4 {NamespaceEvalCmd, existing namespace} { +test namespace-25.4 {NamespaceEvalCmd, existing namespace} -setup { + namespace eval test_ns_1 { + variable v 314159 + proc p {} { + variable v + return $v + } + } +} -body { namespace eval test_ns_1 { proc q {} {return [expr {[p]+1}]} } test_ns_1::q -} {314160} -test namespace-25.5 {NamespaceEvalCmd, multiple args} { +} -result {314160} +test namespace-25.5 {NamespaceEvalCmd, multiple args} -setup { + namespace eval test_ns_1 {variable v 314159} +} -body { namespace eval test_ns_1 "set" "v" -} {314159} +} -result {314159} test namespace-25.6 {NamespaceEvalCmd, error in eval'd script} { list [catch {namespace eval test_ns_1 {xxxx}} msg] $msg $::errorInfo } {1 {invalid command name "xxxx"} {invalid command name "xxxx" @@ -1097,21 +1218,50 @@ test namespace-26.4 {NamespaceExportCmd, one pattern} { } list [info commands test_ns_2::*] [test_ns_2::cmd1 hello] } {::test_ns_2::cmd1 {cmd1: hello}} -test namespace-26.5 {NamespaceExportCmd, sequence of patterns, patterns accumulate} { +test namespace-26.5 {NamespaceExportCmd, sequence of patterns, patterns accumulate} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} namespace eval test_ns_1 { + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + proc cmd3 {args} {return "cmd3: $args"} + proc cmd4 {args} {return "cmd4: $args"} namespace export cmd1 cmd3 } +} -body { namespace eval test_ns_2 { namespace import -force ::test_ns_1::* } list [lsort [info commands test_ns_2::*]] [test_ns_2::cmd3 hello] -} [list [lsort {::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd3: hello}] -test namespace-26.6 {NamespaceExportCmd, no patterns means return uniq'ed export list} { +} -result {{::test_ns_2::cmd1 ::test_ns_2::cmd3} {cmd3: hello}} +test namespace-26.6 {NamespaceExportCmd, no patterns means return uniq'ed export list} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} + namespace eval test_ns_1 { + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + proc cmd3 {args} {return "cmd3: $args"} + proc cmd4 {args} {return "cmd4: $args"} + namespace export cmd1 cmd3 + } +} -body { namespace eval test_ns_1 { namespace export } -} {cmd1 cmd3} -test namespace-26.7 {NamespaceExportCmd, -clear resets export list} { +} -result {cmd1 cmd3} +test namespace-26.7 {NamespaceExportCmd, -clear resets export list} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} + namespace eval test_ns_1 { + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + proc cmd3 {args} {return "cmd3: $args"} + proc cmd4 {args} {return "cmd4: $args"} + } +} -body { + namespace eval test_ns_1 { + namespace export cmd1 cmd3 + } + namespace eval test_ns_2 { + namespace import ::test_ns_1::* + } namespace eval test_ns_1 { namespace export -clear cmd4 } @@ -1119,7 +1269,7 @@ test namespace-26.7 {NamespaceExportCmd, -clear resets export list} { namespace import ::test_ns_1::* } list [lsort [info commands test_ns_2::*]] [test_ns_2::cmd4 hello] -} [list [lsort {::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd4: hello}] +} -result [list [lsort {::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd4: hello}] test namespace-26.8 {NamespaceExportCmd, -clear resets export list} { catch {namespace delete foo} namespace eval foo { @@ -1202,14 +1352,23 @@ test namespace-29.4 {NamespaceInscopeCmd, simple case} { } namespace inscope test_ns_1 cmd } {::test_ns_1::cmd: v=747, args=} -test namespace-29.5 {NamespaceInscopeCmd, has lappend semantics} { +test namespace-29.5 {NamespaceInscopeCmd, has lappend semantics} -setup { + namespace eval test_ns_1 { + variable v 747 + proc cmd {args} { + variable v + return "[namespace current]::cmd: v=$v, args=$args" + } + } +} -body { list [namespace inscope test_ns_1 cmd x y z] \ [namespace eval test_ns_1 [concat cmd [list x y z]]] -} {{::test_ns_1::cmd: v=747, args=x y z} {::test_ns_1::cmd: v=747, args=x y z}} -test namespace-29.6 {NamespaceInscopeCmd, 1400572} { +} -result {{::test_ns_1::cmd: v=747, args=x y z} {::test_ns_1::cmd: v=747, args=x y z}} +test namespace-29.6 {NamespaceInscopeCmd, 1400572} -setup { + namespace eval test_ns_1 {} +} -body { namespace inscope test_ns_1 {info level 0} -} {namespace inscope test_ns_1 {info level 0}} - +} -result {namespace inscope test_ns_1 {info level 0}} test namespace-30.1 {NamespaceOriginCmd, bad args} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -1330,7 +1489,8 @@ test namespace-34.3 {NamespaceWhichCmd, single arg is always command name} { test namespace-34.4 {NamespaceWhichCmd, bad args} { list [catch {namespace which a b} msg] $msg } {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}} -test namespace-34.5 {NamespaceWhichCmd, command lookup} { +test namespace-34.5 {NamespaceWhichCmd, command lookup} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} namespace eval test_ns_1 { namespace export cmd* variable v1 111 @@ -1343,6 +1503,7 @@ test namespace-34.5 {NamespaceWhichCmd, command lookup} { variable v2 222 proc p {} {} } +} -body { namespace eval test_ns_3 { namespace import ::test_ns_2::* variable v3 333 @@ -1352,26 +1513,59 @@ test namespace-34.5 {NamespaceWhichCmd, command lookup} { [namespace which -command ::test_ns_2::cmd2] \ [catch {namespace which -command ::test_ns_2::noSuchCmd} msg] $msg } -} {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2 0 {}} -test namespace-34.6 {NamespaceWhichCmd, -command is default} { +} -result {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2 0 {}} +test namespace-34.6 {NamespaceWhichCmd, -command is default} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} + namespace eval test_ns_1 { + namespace export cmd* + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + } + namespace eval test_ns_2 { + namespace export * + namespace import ::test_ns_1::* + proc p {} {} + } + namespace eval test_ns_3 { + namespace import ::test_ns_2::* + } +} -body { namespace eval test_ns_3 { list [namespace which foreach] \ [namespace which p] \ [namespace which cmd1] \ [namespace which ::test_ns_2::cmd2] } -} {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2} -test namespace-34.7 {NamespaceWhichCmd, variable lookup} { +} -result {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2} +test namespace-34.7 {NamespaceWhichCmd, variable lookup} -setup { + catch {namespace delete {*}[namespace children test_ns_*]} + namespace eval test_ns_1 { + namespace export cmd* + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + } + namespace eval test_ns_2 { + namespace export * + namespace import ::test_ns_1::* + variable v2 222 + proc p {} {} + } + namespace eval test_ns_3 { + variable v3 333 + namespace import ::test_ns_2::* + } +} -body { namespace eval test_ns_3 { list [namespace which -variable env] \ [namespace which -variable v3] \ [namespace which -variable ::test_ns_2::v2] \ [catch {namespace which -variable ::test_ns_2::noSuchVar} msg] $msg } -} {::env ::test_ns_3::v3 ::test_ns_2::v2 0 {}} +} -result {::env ::test_ns_3::v3 ::test_ns_2::v2 0 {}} -test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} { +test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} +} -body { namespace eval test_ns_1 { proc p {} { namespace delete [namespace current] @@ -1379,7 +1573,7 @@ test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} { } } test_ns_1::p -} {::test_ns_1} +} -result {::test_ns_1} test namespace-35.2 {FreeNsNameInternalRep, resulting ref count == 0} { namespace eval test_ns_1 { proc q {} { -- cgit v0.12 From 0754a0cceab613ca075ba25c3010f649ec3814a9 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 10 Jul 2016 12:45:34 +0000 Subject: Fix to resolver.test --- tests/resolver.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/resolver.test b/tests/resolver.test index e73ea50..f3d22e5 100644 --- a/tests/resolver.test +++ b/tests/resolver.test @@ -135,6 +135,9 @@ test resolver-1.5 {cmdNameObj sharing vs. cmd resolver: other than global NS} -s z } } + namespace eval :: { + variable r2 "" + } } -constraints testinterpresolver -body { set r0 [namespace eval ::ns2 {x}] set r1 [namespace eval ::ns2 {z}] -- cgit v0.12 From 5c3df7890ed66305538ce9b69f0c584a45271c07 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 10 Jul 2016 14:14:28 +0000 Subject: Fixes to namespace-old.test --- tests/namespace-old.test | 169 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 140 insertions(+), 29 deletions(-) diff --git a/tests/namespace-old.test b/tests/namespace-old.test index 1d8ba31..1d6a805 100644 --- a/tests/namespace-old.test +++ b/tests/namespace-old.test @@ -57,6 +57,12 @@ test namespace-old-1.9 {add elements to a namespace} { } } } {} +namespace eval test_ns_simple { + variable test_ns_x 0 + proc test {test_ns_x} { + return "test: $test_ns_x" + } +} test namespace-old-1.10 {commands in a namespace} { namespace eval test_ns_simple { info commands [namespace current]::*} } {::test_ns_simple::test} @@ -74,6 +80,12 @@ test namespace-old-1.13 {add to an existing namespace} { } } } "" +namespace eval test_ns_simple { + variable test_ns_y 123 + proc _backdoor {cmd} { + eval $cmd + } +} test namespace-old-1.14 {commands in a namespace} { lsort [namespace eval test_ns_simple {info commands [namespace current]::*}] } {::test_ns_simple::_backdoor ::test_ns_simple::test} @@ -128,6 +140,8 @@ test namespace-old-1.26 {namespace qualifiers are okay after $'s} { test namespace-old-1.27 {can create commands with null names} { proc test_ns_simple:: {args} {return $args} } {} +# Redeclare; later tests depend on it +proc test_ns_simple:: {args} {return $args} # ----------------------------------------------------------------------- # TEST: using "info" in namespace contexts @@ -212,6 +226,11 @@ test namespace-old-4.3 {command "namespace delete" doesn't support patterns} { } list [catch $cmd msg] $msg } {1 {unknown namespace "ns*" in namespace delete command}} +namespace eval test_ns_delete { + namespace eval ns1 {} + namespace eval ns2 {} + namespace eval another {} +} test namespace-old-4.4 {command "namespace delete" handles multiple args} { set cmd { namespace eval test_ns_delete { @@ -256,6 +275,24 @@ test namespace-old-5.3 {namespace qualifiers work in namespace command} { [namespace eval test_ns_hier1::test_ns_hier2 {namespace current}] \ [namespace eval ::test_ns_hier1::test_ns_hier2 {namespace current}] } {::test_ns_hier1 ::test_ns_hier1::test_ns_hier2 ::test_ns_hier1::test_ns_hier2} +set ::test_ns_var_global "var in ::" +proc test_ns_cmd_global {} {return "cmd in ::"} +namespace eval test_ns_hier1 { + variable test_ns_var_hier1 "particular to hier1" + proc test_ns_cmd_hier1 {} {return "particular to hier1"} + variable test_ns_level 1 + proc test_ns_show {} {return "[namespace current]: 1"} + namespace eval test_ns_hier2 { + variable test_ns_var_hier2 "particular to hier2" + proc test_ns_cmd_hier2 {} {return "particular to hier2"} + variable test_ns_level 2 + proc test_ns_show {} {return "[namespace current]: 2"} + namespace eval test_ns_hier3a {} + namespace eval test_ns_hier3b {} + } + namespace eval test_ns_hier2a {} + namespace eval test_ns_hier2b {} +} test namespace-old-5.4 {nested namespaces can access global namespace} { list [namespace eval test_ns_hier1 {set test_ns_var_global}] \ [namespace eval test_ns_hier1 {test_ns_cmd_global}] \ @@ -331,16 +368,12 @@ test namespace-old-5.21 {querying namespace parent for explicit namespace} { # ----------------------------------------------------------------------- # TEST: name resolution and caching # ----------------------------------------------------------------------- +set trigger {namespace eval test_ns_cache2 {namespace current}} +set trigger2 {namespace eval test_ns_cache2::test_ns_cache3 {namespace current}} test namespace-old-6.1 {relative ns names only looked up in current ns} { namespace eval test_ns_cache1 {} namespace eval test_ns_cache2 {} namespace eval test_ns_cache2::test_ns_cache3 {} - set trigger { - namespace eval test_ns_cache2 {namespace current} - } - set trigger2 { - namespace eval test_ns_cache2::test_ns_cache3 {namespace current} - } list [namespace eval test_ns_cache1 $trigger] \ [namespace eval test_ns_cache1 $trigger2] } {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3} @@ -354,20 +387,19 @@ test namespace-old-6.3 {relative ns names only looked up in current ns} { list [namespace eval test_ns_cache1 $trigger] \ [namespace eval test_ns_cache1 $trigger2] } {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3} +namespace eval test_ns_cache1::test_ns_cache2 {} test namespace-old-6.4 {relative ns names only looked up in current ns} { namespace delete test_ns_cache1::test_ns_cache2 list [namespace eval test_ns_cache1 $trigger] \ [namespace eval test_ns_cache1 $trigger2] } {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3} +namespace eval test_ns_cache1 { + proc trigger {} {test_ns_cache_cmd} +} test namespace-old-6.5 {define test commands} { proc test_ns_cache_cmd {} { return "global version" } - namespace eval test_ns_cache1 { - proc trigger {} { - test_ns_cache_cmd - } - } test_ns_cache1::trigger } {global version} test namespace-old-6.6 {one-level check for command shadowing} { @@ -376,24 +408,36 @@ test namespace-old-6.6 {one-level check for command shadowing} { } test_ns_cache1::trigger } {cache1 version} -test namespace-old-6.7 {renaming commands changes command epoch} { - namespace eval test_ns_cache1 { - rename test_ns_cache_cmd test_ns_new +proc test_ns_cache_cmd {} { + return "global version" +} +test namespace-old-6.7 {renaming commands changes command epoch} -setup { + proc test_ns_cache1::test_ns_cache_cmd {} { + return "cache1 version" } - test_ns_cache1::trigger -} {global version} -test namespace-old-6.8 {renaming back handles shadowing} { - namespace eval test_ns_cache1 { - rename test_ns_new test_ns_cache_cmd +} -body { + list [test_ns_cache1::trigger] \ + [namespace eval test_ns_cache1 {rename test_ns_cache_cmd test_ns_new}]\ + [test_ns_cache1::trigger] +} -result {{cache1 version} {} {global version}} +test namespace-old-6.8 {renaming back handles shadowing} -setup { + proc test_ns_cache1::test_ns_new {} { + return "cache1 version" } - test_ns_cache1::trigger -} {cache1 version} -test namespace-old-6.9 {deleting commands changes command epoch} { - namespace eval test_ns_cache1 { - rename test_ns_cache_cmd "" +} -body { + list [test_ns_cache1::trigger] \ + [namespace eval test_ns_cache1 {rename test_ns_new test_ns_cache_cmd}]\ + [test_ns_cache1::trigger] +} -result {{global version} {} {cache1 version}} +test namespace-old-6.9 {deleting commands changes command epoch} -setup { + proc test_ns_cache1::test_ns_cache_cmd {} { + return "cache1 version" } - test_ns_cache1::trigger -} {global version} +} -body { + list [test_ns_cache1::trigger] \ + [namespace eval test_ns_cache1 {rename test_ns_cache_cmd ""}] \ + [test_ns_cache1::trigger] +} -result {{cache1 version} {} {global version}} test namespace-old-6.10 {define test namespaces} { namespace eval test_ns_cache2 { proc test_ns_cache_cmd {} { @@ -412,6 +456,12 @@ test namespace-old-6.10 {define test namespaces} { } list [test_ns_cache1::trigger] [test_ns_cache1::test_ns_cache2::trigger] } {{global cache2 version} {global version}} +namespace eval test_ns_cache1 { + proc trigger {} { test_ns_cache2::test_ns_cache_cmd } + namespace eval test_ns_cache2 { + proc trigger {} { test_ns_cache_cmd } + } +} test namespace-old-6.11 {commands affect all parent namespaces} { proc test_ns_cache1::test_ns_cache2::test_ns_cache_cmd {} { return "cache2 version" @@ -423,18 +473,22 @@ test namespace-old-6.12 {define test variables} { set trigger {set test_ns_cache_var} namespace eval test_ns_cache1 $trigger } {global version} + set trigger {set test_ns_cache_var} test namespace-old-6.13 {one-level check for variable shadowing} { namespace eval test_ns_cache1 { variable test_ns_cache_var "cache1 version" } namespace eval test_ns_cache1 $trigger } {cache1 version} +variable ::test_ns_cache_var "global version" test namespace-old-6.14 {deleting variables changes variable epoch} { namespace eval test_ns_cache1 { - unset test_ns_cache_var + variable test_ns_cache_var "cache1 version" } - namespace eval test_ns_cache1 $trigger -} {global version} + list [namespace eval test_ns_cache1 $trigger] \ + [namespace eval test_ns_cache1 {unset test_ns_cache_var}] \ + [namespace eval test_ns_cache1 $trigger] +} {{cache1 version} {} {global version}} test namespace-old-6.15 {define test namespaces} { namespace eval test_ns_cache2 { variable test_ns_cache_var "global cache2 version" @@ -443,6 +497,7 @@ test namespace-old-6.15 {define test namespaces} { list [namespace eval test_ns_cache1 $trigger2] \ [namespace eval test_ns_cache1::test_ns_cache2 $trigger] } {{global cache2 version} {global version}} +set trigger2 {set test_ns_cache2::test_ns_cache_var} test namespace-old-6.16 {public variables affect all parent namespaces} { variable test_ns_cache1::test_ns_cache2::test_ns_cache_var "cache2 version" list [namespace eval test_ns_cache1 $trigger2] \ @@ -467,6 +522,7 @@ test namespace-old-6.19 {querying: namespace which -command} { test namespace-old-6.20 {command "namespace which" may not find commands} { namespace eval test_ns_cache1 {namespace which -command xyzzy} } {} +variable test_ns_cache1::test_ns_cache2::test_ns_cache_var "cache2 version" test namespace-old-6.21 {querying: namespace which -variable} { namespace eval test_ns_cache1::test_ns_cache2 { namespace which -variable test_ns_cache_var @@ -493,6 +549,18 @@ test namespace-old-7.1 {define test namespace} { } } } {} +namespace eval test_ns_uplevel { + variable x 0 + variable y 1 + proc show_vars {num} { + return [uplevel $num {info vars}] + } + proc test_uplevel {num} { + set a 0 + set b 1 + namespace eval ::test_ns_uplevel " return \[show_vars $num\] " + } +} test namespace-old-7.2 {uplevel can access namespace call frame} { list [expr {"x" in [test_ns_uplevel::test_uplevel 1]}] \ [expr {"y" in [test_ns_uplevel::test_uplevel 1]}] @@ -526,6 +594,17 @@ test namespace-old-7.8 {namespaces are included in the call stack} { } } } {} +namespace eval test_ns_upvar { + variable scope "test_ns_upvar" + proc show_val {var num} { + upvar $num $var x + return $x + } + proc test_upvar {num} { + set scope "test_ns_upvar::test_upvar" + namespace eval ::test_ns_upvar " return \[show_val scope $num\] " + } +} test namespace-old-7.9 {upvar can access namespace call frame} { test_ns_upvar::test_upvar 1 } {test_ns_upvar} @@ -581,6 +660,15 @@ test namespace-old-9.3 {define test namespaces for import} { } lsort [info commands test_ns_export::*] } {::test_ns_export::cmd1 ::test_ns_export::cmd2 ::test_ns_export::cmd3 ::test_ns_export::cmd4 ::test_ns_export::cmd5 ::test_ns_export::cmd6} +namespace eval test_ns_export { + namespace export cmd1 cmd2 cmd3 + proc cmd1 {args} {return "cmd1: $args"} + proc cmd2 {args} {return "cmd2: $args"} + proc cmd3 {args} {return "cmd3: $args"} + proc cmd4 {args} {return "cmd4: $args"} + proc cmd5 {args} {return "cmd5: $args"} + proc cmd6 {args} {return "cmd6: $args"} +} test namespace-old-9.4 {check export status} { set x "" namespace eval test_ns_import { @@ -592,6 +680,10 @@ test namespace-old-9.4 {check export status} { } set x } {::test_ns_import::cmd1 ::test_ns_import::cmd2 ::test_ns_import::cmd3} +namespace eval test_ns_import { + namespace export cmd1 cmd2 + namespace import ::test_ns_export::* +} test namespace-old-9.5 {empty import list in "namespace import" command} { namespace eval test_ns_import_empty { namespace import ::test_ns_export::* @@ -615,6 +707,7 @@ test namespace-old-9.8 {only exported commands are imported} { namespace import test_ns_import::cmd* set x [lsort [info commands cmd*]] } {cmd1 cmd2} +namespace import test_ns_import::cmd* test namespace-old-9.9 {imported commands work just the same as original} { list [cmd1 test 1 2 3] [test_ns_import::cmd1 test 4 5 6] } {{cmd1: test 1 2 3} {cmd1: test 4 5 6}} @@ -629,10 +722,19 @@ test namespace-old-9.10 {commands can be imported from many namespaces} { namespace import test_ns_import2::* lsort [concat [info commands cmd*] [info commands ncmd*]] } {cmd1 cmd2 ncmd ncmd1 ncmd2} +namespace eval test_ns_import2 { + namespace export ncmd ncmd1 ncmd2 + proc ncmd {args} {return "ncmd: $args"} + proc ncmd1 {args} {return "ncmd1: $args"} + proc ncmd2 {args} {return "ncmd2: $args"} + proc ncmd3 {args} {return "ncmd3: $args"} +} +namespace import test_ns_import2::* test namespace-old-9.11 {imported commands can be removed by deleting them} { rename cmd1 "" lsort [concat [info commands cmd*] [info commands ncmd*]] } {cmd2 ncmd ncmd1 ncmd2} +catch { rename cmd1 "" } test namespace-old-9.12 {command "namespace forget" checks for valid namespaces} { list [catch {namespace forget xyzzy::*} msg] $msg } {1 {unknown namespace in namespace forget pattern "xyzzy::*"}} @@ -653,6 +755,7 @@ test namespace-old-9.15 {existing commands can't be overwritten} { [cmd1 3 5] } {1 {can't import command "cmd1": already exists} 8} test namespace-old-9.16 {use "-force" option to override existing commands} { + proc cmd1 {x y} { return [expr $x+$y] } list [cmd1 3 5] \ [namespace import -force test_ns_import::cmd?] \ [cmd1 3 5] @@ -711,10 +814,18 @@ test namespace-old-10.6 {with many args, each "scope" adds new args} { set sval [namespace eval test_ns_inscope {namespace code {one two}}] namespace code "$sval three" } {::namespace inscope ::test_ns_inscope {one two} three} +namespace eval test_ns_inscope { + proc show {args} { + return "show: $args" + } +} test namespace-old-10.7 {scoped commands work with eval} { set cref [namespace eval test_ns_inscope {namespace code show}] list [eval $cref "a" "b c" "d e f"] } {{show: a b c d e f}} +namespace eval test_ns_inscope { + variable x "x-value" +} test namespace-old-10.8 {scoped commands execute in namespace context} { set cref [namespace eval test_ns_inscope { namespace code {set x "some new value"} -- cgit v0.12 From 958e525baf3292c31b387ce0306a8dc984419c6c Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 10 Jul 2016 19:28:57 +0000 Subject: [96fe2f1cc7] Plug memory leak. --- generic/tclExecute.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 52865e6..c0cbd9e 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3168,6 +3168,7 @@ TEBCresume( Tcl_ListObjAppendElement(NULL, copyPtr, objPtr); Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, objc - opnd, objv + opnd); + Tcl_DecrRefCount(objPtr); objPtr = copyPtr; } -- cgit v0.12 From d6146b2e552c294199df0354470b89fe955a7345 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 11 Jul 2016 17:13:09 +0000 Subject: Avoid memory leak in test. --- tests/socket.test | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/socket.test b/tests/socket.test index 8473602..d43c41c 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -1782,7 +1782,6 @@ test socket_$af-13.1 {Testing use of shared socket between two threads} -body { set i 0 vwait x close $f - thread::wait }]] set port [thread::send $serverthread {set listen}] set s [socket $localhost $port] -- cgit v0.12 From 59ded443ac132275413b2e6f6e9cb4eb6cba468b Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 11 Jul 2016 21:56:32 +0000 Subject: [cea0344a1] Restore a clearing of the ensemble rewrite in one execution path so attempts to use the data after free are not made. Test namespace-50.9 demonstrates the need for this. --- generic/tclExecute.c | 7 +++++++ tests/namespace.test | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index c0cbd9e..e539161 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2078,6 +2078,13 @@ TclNRExecuteByteCode( #endif /* + * Test namespace-50.9 demonstrates the need for this call. + * Use a --enable-symbols=mem bug to see. + */ + + TclResetRewriteEnsemble(interp, 1); + + /* * Push the callback for bytecode execution */ diff --git a/tests/namespace.test b/tests/namespace.test index 575695f..55505f1 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -2356,6 +2356,13 @@ test namespace-50.8 {[f961d7d1dd]} -setup { rename e {} rename target {} } +test namespace-50.9 {[cea0344a51]} -body { + namespace eval foo { + namespace eval bar { + namespace delete foo + } + } +} -returnCodes error -result {unknown namespace "foo" in namespace delete command} test namespace-51.1 {name resolution path control} -body { namespace eval ::test_ns_1 { -- cgit v0.12 From 2db2dfd35e31ce264948ce805c95046062ff5ccd Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 12 Jul 2016 13:23:21 +0000 Subject: Start RC branch for Tcl 8.6.6 --- README | 2 +- generic/tcl.h | 4 ++-- library/init.tcl | 2 +- unix/configure | 2 +- unix/configure.in | 2 +- unix/tcl.spec | 2 +- win/configure | 2 +- win/configure.in | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README b/README index f3e50dd..401b6e6 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tcl - This is the Tcl 8.6.5 source distribution. + This is the Tcl 8.6.6 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tcl from the URL above. diff --git a/generic/tcl.h b/generic/tcl.h index 3490049..3037ceb 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -56,10 +56,10 @@ extern "C" { #define TCL_MAJOR_VERSION 8 #define TCL_MINOR_VERSION 6 #define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TCL_RELEASE_SERIAL 5 +#define TCL_RELEASE_SERIAL 6 #define TCL_VERSION "8.6" -#define TCL_PATCH_LEVEL "8.6.5" +#define TCL_PATCH_LEVEL "8.6.6" /* *---------------------------------------------------------------------------- diff --git a/library/init.tcl b/library/init.tcl index 9fd2170..9ca4514 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -16,7 +16,7 @@ if {[info commands package] == ""} { error "version mismatch: library\nscripts expect Tcl version 7.5b1 or later but the loaded version is\nonly [info patchlevel]" } -package require -exact Tcl 8.6.5 +package require -exact Tcl 8.6.6 # Compute the auto path to use in this interpreter. # The values on the path come from several locations: diff --git a/unix/configure b/unix/configure index 2e774f7..38c3f9a 100755 --- a/unix/configure +++ b/unix/configure @@ -1335,7 +1335,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TCL_VERSION=8.6 TCL_MAJOR_VERSION=8 TCL_MINOR_VERSION=6 -TCL_PATCH_LEVEL=".5" +TCL_PATCH_LEVEL=".6" VERSION=${TCL_VERSION} EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"} diff --git a/unix/configure.in b/unix/configure.in index 5d4cfbe..1d86213 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TCL_VERSION=8.6 TCL_MAJOR_VERSION=8 TCL_MINOR_VERSION=6 -TCL_PATCH_LEVEL=".5" +TCL_PATCH_LEVEL=".6" VERSION=${TCL_VERSION} EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"} diff --git a/unix/tcl.spec b/unix/tcl.spec index 3044311..8bf77f3 100644 --- a/unix/tcl.spec +++ b/unix/tcl.spec @@ -4,7 +4,7 @@ Name: tcl Summary: Tcl scripting language development environment -Version: 8.6.5 +Version: 8.6.6 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index 2336111..e8e4b87 100755 --- a/win/configure +++ b/win/configure @@ -1311,7 +1311,7 @@ SHELL=/bin/sh TCL_VERSION=8.6 TCL_MAJOR_VERSION=8 TCL_MINOR_VERSION=6 -TCL_PATCH_LEVEL=".5" +TCL_PATCH_LEVEL=".6" VER=$TCL_MAJOR_VERSION$TCL_MINOR_VERSION TCL_DDE_VERSION=1.4 diff --git a/win/configure.in b/win/configure.in index a72b993..8bb9c48 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TCL_VERSION=8.6 TCL_MAJOR_VERSION=8 TCL_MINOR_VERSION=6 -TCL_PATCH_LEVEL=".5" +TCL_PATCH_LEVEL=".6" VER=$TCL_MAJOR_VERSION$TCL_MINOR_VERSION TCL_DDE_VERSION=1.4 -- cgit v0.12 From 71e7049f8ea65780583e847f2b3055b519395517 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 12 Jul 2016 13:44:26 +0000 Subject: Make hash type changable by compiling with -DTCL_HASH_TYPE=size_t (for example). Default (unsigned) cannot be changed in Tcl 8.x, that must wait until Tcl 9. --- doc/Hash.3 | 2 +- generic/tcl.h | 6 +++++- generic/tclHash.c | 12 ++++++------ generic/tclInt.h | 2 +- generic/tclObj.c | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/Hash.3 b/doc/Hash.3 index 4dc3623..aa79b86 100644 --- a/doc/Hash.3 +++ b/doc/Hash.3 @@ -281,7 +281,7 @@ The \fIhashKeyProc\fR member contains the address of a function called to calculate a hash value for the key. .PP .CS -typedef unsigned int \fBTcl_HashKeyProc\fR( +typedef TCL_HASH_TYPE \fBTcl_HashKeyProc\fR( Tcl_HashTable *\fItablePtr\fR, void *\fIkeyPtr\fR); .CE diff --git a/generic/tcl.h b/generic/tcl.h index 6061ea8..ded8d0b 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1157,11 +1157,15 @@ typedef struct Tcl_DString { * Forward declarations of Tcl_HashTable and related types. */ +#ifndef TCL_HASH_TYPE +# define TCL_HASH_TYPE unsigned +#endif + typedef struct Tcl_HashKeyType Tcl_HashKeyType; typedef struct Tcl_HashTable Tcl_HashTable; typedef struct Tcl_HashEntry Tcl_HashEntry; -typedef unsigned (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); +typedef TCL_HASH_TYPE (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr); typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr, void *keyPtr); diff --git a/generic/tclHash.c b/generic/tclHash.c index 3ea9dd9..ac9d40e 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -43,7 +43,7 @@ static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, void *keyPtr); static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); +static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Prototypes for the one word hash key methods. Not actually declared because @@ -65,7 +65,7 @@ static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr); static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr, void *keyPtr); static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); +static TCL_HASH_TYPE HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Function prototypes for static functions in this file: @@ -774,7 +774,7 @@ CompareArrayKeys( *---------------------------------------------------------------------- */ -static unsigned int +static TCL_HASH_TYPE HashArrayKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ @@ -787,7 +787,7 @@ HashArrayKey( count--, array++) { result += *array; } - return result; + return (TCL_HASH_TYPE) result; } /* @@ -870,7 +870,7 @@ CompareStringKeys( *---------------------------------------------------------------------- */ -static unsigned +static TCL_HASH_TYPE HashStringKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ @@ -916,7 +916,7 @@ HashStringKey( result += (result << 3) + UCHAR(c); } } - return result; + return (TCL_HASH_TYPE) result; } /* diff --git a/generic/tclInt.h b/generic/tclInt.h index c01b0c1..33476ed 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3977,7 +3977,7 @@ MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr, MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr); MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr); -MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr); +MODULE_SCOPE TCL_HASH_TYPE TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr); MODULE_SCOPE int TclFullFinalizationRequested(void); diff --git a/generic/tclObj.c b/generic/tclObj.c index 776b034..0cd7839 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4048,7 +4048,7 @@ TclFreeObjEntry( *---------------------------------------------------------------------- */ -unsigned int +TCL_HASH_TYPE TclHashObjKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ @@ -4098,7 +4098,7 @@ TclHashObjKey( result += (result << 3) + UCHAR(*++string); } } - return result; + return (TCL_HASH_TYPE) result; } /* -- cgit v0.12 From bcd1ebff474ba386f8fb7db75692a39ce5bcb8ca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 12 Jul 2016 14:02:17 +0000 Subject: Fix "file owned" for Cygwin: st_uid is only 16-bit there. --- generic/tclCmdAH.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 13d3df5..88cc17d 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -1596,14 +1596,19 @@ FileAttrIsOwnedCmd( int objc, Tcl_Obj *const objv[]) { +#ifdef __CYGWIN__ +#define geteuid() (short)(geteuid)() +#endif +#if !defined(_WIN32) Tcl_StatBuf buf; +#endif int value = 0; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "name"); return TCL_ERROR; } -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) value = TclWinFileOwned(objv[1]); #else if (GetStatBuf(NULL, objv[1], Tcl_FSStat, &buf) == TCL_OK) { -- cgit v0.12 From 2707284613f1df3c587790ac8a2757dc8592db63 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 12 Jul 2016 16:24:35 +0000 Subject: Dup test name. Bump to TclOO 1.0.5. --- generic/tclOO.h | 2 +- tests/info.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclOO.h b/generic/tclOO.h index 696908a..46f01fb 100644 --- a/generic/tclOO.h +++ b/generic/tclOO.h @@ -24,7 +24,7 @@ * win/tclooConfig.sh */ -#define TCLOO_VERSION "1.0.4" +#define TCLOO_VERSION "1.0.5" #define TCLOO_PATCHLEVEL TCLOO_VERSION #include "tcl.h" diff --git a/tests/info.test b/tests/info.test index e0fddb3..c4fd379 100644 --- a/tests/info.test +++ b/tests/info.test @@ -2398,7 +2398,7 @@ test info-33.35 {{*}, literal, simple, bytecompiled} -body { # ------------------------------------------------------------------------- unset -nocomplain res -test info-39.0 {Bug 4b61afd660} -setup { +test info-39.1 {Bug 4b61afd660} -setup { proc probe {} { return [dict get [info frame -1] line] } -- cgit v0.12 From 5fce2d6fcdbb4dcfaf883bece8154b866450c010 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 12 Jul 2016 16:46:08 +0000 Subject: tzdata2016f --- library/tzdata/America/Cambridge_Bay | 2 +- library/tzdata/America/Inuvik | 2 +- library/tzdata/America/Iqaluit | 2 +- library/tzdata/America/Pangnirtung | 2 +- library/tzdata/America/Rankin_Inlet | 2 +- library/tzdata/America/Resolute | 2 +- library/tzdata/America/Yellowknife | 2 +- library/tzdata/Antarctica/Casey | 2 +- library/tzdata/Antarctica/Davis | 4 +- library/tzdata/Antarctica/DumontDUrville | 4 +- library/tzdata/Antarctica/Macquarie | 4 +- library/tzdata/Antarctica/Mawson | 2 +- library/tzdata/Antarctica/Palmer | 2 +- library/tzdata/Antarctica/Rothera | 2 +- library/tzdata/Antarctica/Syowa | 2 +- library/tzdata/Antarctica/Troll | 2 +- library/tzdata/Antarctica/Vostok | 2 +- library/tzdata/Asia/Baku | 2 +- library/tzdata/Asia/Novokuznetsk | 133 +++++++++++++++--------------- library/tzdata/Asia/Novosibirsk | 135 ++++++++++++++++--------------- library/tzdata/Europe/Minsk | 6 +- library/tzdata/Indian/Kerguelen | 2 +- 22 files changed, 159 insertions(+), 159 deletions(-) diff --git a/library/tzdata/America/Cambridge_Bay b/library/tzdata/America/Cambridge_Bay index 23004bb..3115ee1 100644 --- a/library/tzdata/America/Cambridge_Bay +++ b/library/tzdata/America/Cambridge_Bay @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Cambridge_Bay) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1577923200 -25200 0 MST} {-880210800 -21600 1 MWT} {-769395600 -21600 1 MPT} diff --git a/library/tzdata/America/Inuvik b/library/tzdata/America/Inuvik index dd0d151..08f0fd6 100644 --- a/library/tzdata/America/Inuvik +++ b/library/tzdata/America/Inuvik @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Inuvik) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-536457600 -28800 0 PST} {-147888000 -21600 1 PDDT} {-131558400 -28800 0 PST} diff --git a/library/tzdata/America/Iqaluit b/library/tzdata/America/Iqaluit index 2a2e9fe..ff82866 100644 --- a/library/tzdata/America/Iqaluit +++ b/library/tzdata/America/Iqaluit @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Iqaluit) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-865296000 -14400 0 EWT} {-769395600 -14400 1 EPT} {-765396000 -18000 0 EST} diff --git a/library/tzdata/America/Pangnirtung b/library/tzdata/America/Pangnirtung index 640808e..14d8516 100644 --- a/library/tzdata/America/Pangnirtung +++ b/library/tzdata/America/Pangnirtung @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Pangnirtung) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1546300800 -14400 0 AST} {-880221600 -10800 1 AWT} {-769395600 -10800 1 APT} diff --git a/library/tzdata/America/Rankin_Inlet b/library/tzdata/America/Rankin_Inlet index 770ec5d..9ce9f8d 100644 --- a/library/tzdata/America/Rankin_Inlet +++ b/library/tzdata/America/Rankin_Inlet @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Rankin_Inlet) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-410227200 -21600 0 CST} {-147895200 -14400 1 CDDT} {-131565600 -21600 0 CST} diff --git a/library/tzdata/America/Resolute b/library/tzdata/America/Resolute index b4c0bab..a9881b4 100644 --- a/library/tzdata/America/Resolute +++ b/library/tzdata/America/Resolute @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Resolute) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-704937600 -21600 0 CST} {-147895200 -14400 1 CDDT} {-131565600 -21600 0 CST} diff --git a/library/tzdata/America/Yellowknife b/library/tzdata/America/Yellowknife index 44ca658..c6c4ed5 100644 --- a/library/tzdata/America/Yellowknife +++ b/library/tzdata/America/Yellowknife @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Yellowknife) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1104537600 -25200 0 MST} {-880210800 -21600 1 MWT} {-769395600 -21600 1 MPT} diff --git a/library/tzdata/Antarctica/Casey b/library/tzdata/Antarctica/Casey index 56d5df7..2573dac 100644 --- a/library/tzdata/Antarctica/Casey +++ b/library/tzdata/Antarctica/Casey @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Casey) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-31536000 28800 0 AWST} {1255802400 39600 0 CAST} {1267714800 28800 0 AWST} diff --git a/library/tzdata/Antarctica/Davis b/library/tzdata/Antarctica/Davis index 2762d2f..c98be2f 100644 --- a/library/tzdata/Antarctica/Davis +++ b/library/tzdata/Antarctica/Davis @@ -1,9 +1,9 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Davis) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-409190400 25200 0 DAVT} - {-163062000 0 0 zzz} + {-163062000 0 0 -00} {-28857600 25200 0 DAVT} {1255806000 18000 0 DAVT} {1268251200 25200 0 DAVT} diff --git a/library/tzdata/Antarctica/DumontDUrville b/library/tzdata/Antarctica/DumontDUrville index 41dc1e3..8d21d45 100644 --- a/library/tzdata/Antarctica/DumontDUrville +++ b/library/tzdata/Antarctica/DumontDUrville @@ -1,8 +1,8 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/DumontDUrville) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-725846400 36000 0 PMT} - {-566992800 0 0 zzz} + {-566992800 0 0 -00} {-415497600 36000 0 DDUT} } diff --git a/library/tzdata/Antarctica/Macquarie b/library/tzdata/Antarctica/Macquarie index 07ddff6..9ed0630 100644 --- a/library/tzdata/Antarctica/Macquarie +++ b/library/tzdata/Antarctica/Macquarie @@ -1,12 +1,12 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Macquarie) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-2214259200 36000 0 AEST} {-1680508800 39600 1 AEDT} {-1669892400 39600 0 AEDT} {-1665392400 36000 0 AEST} - {-1601719200 0 0 zzz} + {-1601719200 0 0 -00} {-94730400 36000 0 AEST} {-71136000 39600 1 AEDT} {-55411200 36000 0 AEST} diff --git a/library/tzdata/Antarctica/Mawson b/library/tzdata/Antarctica/Mawson index ba03ba1..e50aa07 100644 --- a/library/tzdata/Antarctica/Mawson +++ b/library/tzdata/Antarctica/Mawson @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Mawson) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-501206400 21600 0 MAWT} {1255809600 18000 0 MAWT} } diff --git a/library/tzdata/Antarctica/Palmer b/library/tzdata/Antarctica/Palmer index 5767985..62b17e1 100644 --- a/library/tzdata/Antarctica/Palmer +++ b/library/tzdata/Antarctica/Palmer @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Palmer) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-157766400 -14400 0 ART} {-152654400 -14400 0 ART} {-132955200 -10800 1 ARST} diff --git a/library/tzdata/Antarctica/Rothera b/library/tzdata/Antarctica/Rothera index 24d7f3e..3a219c7 100644 --- a/library/tzdata/Antarctica/Rothera +++ b/library/tzdata/Antarctica/Rothera @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Rothera) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {218246400 -10800 0 ROTT} } diff --git a/library/tzdata/Antarctica/Syowa b/library/tzdata/Antarctica/Syowa index 4d046b5..1fe030a 100644 --- a/library/tzdata/Antarctica/Syowa +++ b/library/tzdata/Antarctica/Syowa @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Syowa) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-407808000 10800 0 SYOT} } diff --git a/library/tzdata/Antarctica/Troll b/library/tzdata/Antarctica/Troll index 7d2b042..09727a8 100644 --- a/library/tzdata/Antarctica/Troll +++ b/library/tzdata/Antarctica/Troll @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Troll) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {1108166400 0 0 UTC} {1111885200 7200 1 CEST} {1130634000 0 0 UTC} diff --git a/library/tzdata/Antarctica/Vostok b/library/tzdata/Antarctica/Vostok index f846f65..a59868b 100644 --- a/library/tzdata/Antarctica/Vostok +++ b/library/tzdata/Antarctica/Vostok @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Vostok) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-380073600 21600 0 VOST} } diff --git a/library/tzdata/Asia/Baku b/library/tzdata/Asia/Baku index bc0701a..e9ee835 100644 --- a/library/tzdata/Asia/Baku +++ b/library/tzdata/Asia/Baku @@ -28,7 +28,7 @@ set TZData(:Asia/Baku) { {683496000 14400 0 AZST} {686098800 10800 0 AZT} {701823600 14400 1 AZST} - {717537600 14400 0 AZT} + {717548400 14400 0 AZT} {820440000 14400 0 AZT} {828234000 18000 1 AZST} {846378000 14400 0 AZT} diff --git a/library/tzdata/Asia/Novokuznetsk b/library/tzdata/Asia/Novokuznetsk index f079faa..a43a984 100644 --- a/library/tzdata/Asia/Novokuznetsk +++ b/library/tzdata/Asia/Novokuznetsk @@ -2,71 +2,70 @@ set TZData(:Asia/Novokuznetsk) { {-9223372036854775808 20928 0 LMT} - {-1441259328 21600 0 KRAT} - {-1247551200 25200 0 KRAMMTT} - {354906000 28800 1 KRAST} - {370713600 25200 0 KRAT} - {386442000 28800 1 KRAST} - {402249600 25200 0 KRAT} - {417978000 28800 1 KRAST} - {433785600 25200 0 KRAT} - {449600400 28800 1 KRAST} - {465332400 25200 0 KRAT} - {481057200 28800 1 KRAST} - {496782000 25200 0 KRAT} - {512506800 28800 1 KRAST} - {528231600 25200 0 KRAT} - {543956400 28800 1 KRAST} - {559681200 25200 0 KRAT} - {575406000 28800 1 KRAST} - {591130800 25200 0 KRAT} - {606855600 28800 1 KRAST} - {622580400 25200 0 KRAT} - {638305200 28800 1 KRAST} - {654634800 25200 0 KRAT} - {670359600 21600 0 KRAMMTT} - {670363200 25200 1 KRAST} - {686088000 21600 0 KRAT} - {695764800 25200 0 KRAMMTT} - {701809200 28800 1 KRAST} - {717534000 25200 0 KRAT} - {733258800 28800 1 KRAST} - {748983600 25200 0 KRAT} - {764708400 28800 1 KRAST} - {780433200 25200 0 KRAT} - {796158000 28800 1 KRAST} - {811882800 25200 0 KRAT} - {828212400 28800 1 KRAST} - {846356400 25200 0 KRAT} - {859662000 28800 1 KRAST} - {877806000 25200 0 KRAT} - {891111600 28800 1 KRAST} - {909255600 25200 0 KRAT} - {922561200 28800 1 KRAST} - {941310000 25200 0 KRAT} - {954010800 28800 1 KRAST} - {972759600 25200 0 KRAT} - {985460400 28800 1 KRAST} - {1004209200 25200 0 KRAT} - {1017514800 28800 1 KRAST} - {1035658800 25200 0 KRAT} - {1048964400 28800 1 KRAST} - {1067108400 25200 0 KRAT} - {1080414000 28800 1 KRAST} - {1099162800 25200 0 KRAT} - {1111863600 28800 1 KRAST} - {1130612400 25200 0 KRAT} - {1143313200 28800 1 KRAST} - {1162062000 25200 0 KRAT} - {1174762800 28800 1 KRAST} - {1193511600 25200 0 KRAT} - {1206817200 28800 1 KRAST} - {1224961200 25200 0 KRAT} - {1238266800 28800 1 KRAST} - {1256410800 25200 0 KRAT} - {1269716400 21600 0 NOVMMTT} - {1269720000 25200 1 NOVST} - {1288468800 21600 0 NOVT} - {1301169600 25200 0 NOVT} - {1414263600 25200 0 KRAT} + {-1441259328 21600 0 +06} + {-1247551200 25200 0 +08} + {354906000 28800 1 +08} + {370713600 25200 0 +07} + {386442000 28800 1 +08} + {402249600 25200 0 +07} + {417978000 28800 1 +08} + {433785600 25200 0 +07} + {449600400 28800 1 +08} + {465332400 25200 0 +07} + {481057200 28800 1 +08} + {496782000 25200 0 +07} + {512506800 28800 1 +08} + {528231600 25200 0 +07} + {543956400 28800 1 +08} + {559681200 25200 0 +07} + {575406000 28800 1 +08} + {591130800 25200 0 +07} + {606855600 28800 1 +08} + {622580400 25200 0 +07} + {638305200 28800 1 +08} + {654634800 25200 0 +07} + {670359600 21600 0 +07} + {670363200 25200 1 +07} + {686088000 21600 0 +06} + {695764800 25200 0 +08} + {701809200 28800 1 +08} + {717534000 25200 0 +07} + {733258800 28800 1 +08} + {748983600 25200 0 +07} + {764708400 28800 1 +08} + {780433200 25200 0 +07} + {796158000 28800 1 +08} + {811882800 25200 0 +07} + {828212400 28800 1 +08} + {846356400 25200 0 +07} + {859662000 28800 1 +08} + {877806000 25200 0 +07} + {891111600 28800 1 +08} + {909255600 25200 0 +07} + {922561200 28800 1 +08} + {941310000 25200 0 +07} + {954010800 28800 1 +08} + {972759600 25200 0 +07} + {985460400 28800 1 +08} + {1004209200 25200 0 +07} + {1017514800 28800 1 +08} + {1035658800 25200 0 +07} + {1048964400 28800 1 +08} + {1067108400 25200 0 +07} + {1080414000 28800 1 +08} + {1099162800 25200 0 +07} + {1111863600 28800 1 +08} + {1130612400 25200 0 +07} + {1143313200 28800 1 +08} + {1162062000 25200 0 +07} + {1174762800 28800 1 +08} + {1193511600 25200 0 +07} + {1206817200 28800 1 +08} + {1224961200 25200 0 +07} + {1238266800 28800 1 +08} + {1256410800 25200 0 +07} + {1269716400 21600 0 +07} + {1269720000 25200 1 +07} + {1288468800 21600 0 +06} + {1301169600 25200 0 +07} } diff --git a/library/tzdata/Asia/Novosibirsk b/library/tzdata/Asia/Novosibirsk index 54c83fa..21f5c00 100644 --- a/library/tzdata/Asia/Novosibirsk +++ b/library/tzdata/Asia/Novosibirsk @@ -2,71 +2,72 @@ set TZData(:Asia/Novosibirsk) { {-9223372036854775808 19900 0 LMT} - {-1579476700 21600 0 NOVT} - {-1247551200 25200 0 NOVMMTT} - {354906000 28800 1 NOVST} - {370713600 25200 0 NOVT} - {386442000 28800 1 NOVST} - {402249600 25200 0 NOVT} - {417978000 28800 1 NOVST} - {433785600 25200 0 NOVT} - {449600400 28800 1 NOVST} - {465332400 25200 0 NOVT} - {481057200 28800 1 NOVST} - {496782000 25200 0 NOVT} - {512506800 28800 1 NOVST} - {528231600 25200 0 NOVT} - {543956400 28800 1 NOVST} - {559681200 25200 0 NOVT} - {575406000 28800 1 NOVST} - {591130800 25200 0 NOVT} - {606855600 28800 1 NOVST} - {622580400 25200 0 NOVT} - {638305200 28800 1 NOVST} - {654634800 25200 0 NOVT} - {670359600 21600 0 NOVMMTT} - {670363200 25200 1 NOVST} - {686088000 21600 0 NOVT} - {695764800 25200 0 NOVMMTT} - {701809200 28800 1 NOVST} - {717534000 25200 0 NOVT} - {733258800 28800 1 NOVST} - {738090000 25200 0 NOVST} - {748987200 21600 0 NOVT} - {764712000 25200 1 NOVST} - {780436800 21600 0 NOVT} - {796161600 25200 1 NOVST} - {811886400 21600 0 NOVT} - {828216000 25200 1 NOVST} - {846360000 21600 0 NOVT} - {859665600 25200 1 NOVST} - {877809600 21600 0 NOVT} - {891115200 25200 1 NOVST} - {909259200 21600 0 NOVT} - {922564800 25200 1 NOVST} - {941313600 21600 0 NOVT} - {954014400 25200 1 NOVST} - {972763200 21600 0 NOVT} - {985464000 25200 1 NOVST} - {1004212800 21600 0 NOVT} - {1017518400 25200 1 NOVST} - {1035662400 21600 0 NOVT} - {1048968000 25200 1 NOVST} - {1067112000 21600 0 NOVT} - {1080417600 25200 1 NOVST} - {1099166400 21600 0 NOVT} - {1111867200 25200 1 NOVST} - {1130616000 21600 0 NOVT} - {1143316800 25200 1 NOVST} - {1162065600 21600 0 NOVT} - {1174766400 25200 1 NOVST} - {1193515200 21600 0 NOVT} - {1206820800 25200 1 NOVST} - {1224964800 21600 0 NOVT} - {1238270400 25200 1 NOVST} - {1256414400 21600 0 NOVT} - {1269720000 25200 1 NOVST} - {1288468800 21600 0 NOVT} - {1301169600 25200 0 NOVT} - {1414263600 21600 0 NOVT} + {-1579476700 21600 0 +06} + {-1247551200 25200 0 +08} + {354906000 28800 1 +08} + {370713600 25200 0 +07} + {386442000 28800 1 +08} + {402249600 25200 0 +07} + {417978000 28800 1 +08} + {433785600 25200 0 +07} + {449600400 28800 1 +08} + {465332400 25200 0 +07} + {481057200 28800 1 +08} + {496782000 25200 0 +07} + {512506800 28800 1 +08} + {528231600 25200 0 +07} + {543956400 28800 1 +08} + {559681200 25200 0 +07} + {575406000 28800 1 +08} + {591130800 25200 0 +07} + {606855600 28800 1 +08} + {622580400 25200 0 +07} + {638305200 28800 1 +08} + {654634800 25200 0 +07} + {670359600 21600 0 +07} + {670363200 25200 1 +07} + {686088000 21600 0 +06} + {695764800 25200 0 +08} + {701809200 28800 1 +08} + {717534000 25200 0 +07} + {733258800 28800 1 +08} + {738090000 25200 0 +07} + {748987200 21600 0 +06} + {764712000 25200 1 +07} + {780436800 21600 0 +06} + {796161600 25200 1 +07} + {811886400 21600 0 +06} + {828216000 25200 1 +07} + {846360000 21600 0 +06} + {859665600 25200 1 +07} + {877809600 21600 0 +06} + {891115200 25200 1 +07} + {909259200 21600 0 +06} + {922564800 25200 1 +07} + {941313600 21600 0 +06} + {954014400 25200 1 +07} + {972763200 21600 0 +06} + {985464000 25200 1 +07} + {1004212800 21600 0 +06} + {1017518400 25200 1 +07} + {1035662400 21600 0 +06} + {1048968000 25200 1 +07} + {1067112000 21600 0 +06} + {1080417600 25200 1 +07} + {1099166400 21600 0 +06} + {1111867200 25200 1 +07} + {1130616000 21600 0 +06} + {1143316800 25200 1 +07} + {1162065600 21600 0 +06} + {1174766400 25200 1 +07} + {1193515200 21600 0 +06} + {1206820800 25200 1 +07} + {1224964800 21600 0 +06} + {1238270400 25200 1 +07} + {1256414400 21600 0 +06} + {1269720000 25200 1 +07} + {1288468800 21600 0 +06} + {1301169600 25200 0 +07} + {1414263600 21600 0 +06} + {1469304000 25200 0 +07} } diff --git a/library/tzdata/Europe/Minsk b/library/tzdata/Europe/Minsk index 5e47063..2857e5b 100644 --- a/library/tzdata/Europe/Minsk +++ b/library/tzdata/Europe/Minsk @@ -30,10 +30,10 @@ set TZData(:Europe/Minsk) { {606870000 14400 1 MSD} {622594800 10800 0 MSK} {631141200 10800 0 MSK} - {670374000 10800 1 EEST} + {670374000 7200 0 EEMMTT} + {670377600 10800 1 EEST} {686102400 7200 0 EET} - {701820000 10800 1 EEST} - {717544800 10800 0 EEST} + {701827200 10800 1 EEST} {717552000 7200 0 EET} {733276800 10800 1 EEST} {749001600 7200 0 EET} diff --git a/library/tzdata/Indian/Kerguelen b/library/tzdata/Indian/Kerguelen index b41b85a..8820010 100644 --- a/library/tzdata/Indian/Kerguelen +++ b/library/tzdata/Indian/Kerguelen @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Indian/Kerguelen) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-631152000 18000 0 TFT} } -- cgit v0.12 From b158cee02890bb3c7bfc278400fd93b16fa35490 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 12 Jul 2016 21:25:27 +0000 Subject: [3606388] Make variable-related tests work on their own. --- tests/set-old.test | 4 +- tests/set.test | 113 +++++++++++++++++++++++++++++++++-------------------- tests/var.test | 46 +++++++++++++++------- 3 files changed, 105 insertions(+), 58 deletions(-) diff --git a/tests/set-old.test b/tests/set-old.test index 94b6901..1c68f91 100644 --- a/tests/set-old.test +++ b/tests/set-old.test @@ -14,7 +14,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest + package require tcltest 2 namespace import -force ::tcltest::* } @@ -865,6 +865,8 @@ test set-old-10.13 {array enumeration errors} { list [catch {array done a b c} msg] $msg } {1 {wrong # args: should be "array donesearch arrayName searchId"}} test set-old-10.14 {array enumeration errors} { + catch {unset a} + set a(a) a list [catch {array done a b} msg] $msg } {1 {illegal search identifier "b"}} test set-old-10.15 {array enumeration errors} { diff --git a/tests/set.test b/tests/set.test index 18119f5..374ff7a 100644 --- a/tests/set.test +++ b/tests/set.test @@ -22,7 +22,7 @@ testConstraint testset2 [llength [info commands testset2]] catch {unset x} catch {unset i} - + test set-1.1 {TclCompileSetCmd: missing variable name} { list [catch {set} msg] $msg } {1 {wrong # args: should be "set varName ?newValue?"}} @@ -39,16 +39,18 @@ test set-1.4 {TclCompileSetCmd: simple variable name in quotes} { set i 17 list [set "i"] $i } {17 17} -test set-1.5 {TclCompileSetCmd: simple variable name in braces} { +test set-1.5 {TclCompileSetCmd: simple variable name in braces} -setup { catch {unset {a simple var}} +} -body { set {a simple var} 27 list [set {a simple var}] ${a simple var} -} {27 27} -test set-1.6 {TclCompileSetCmd: simple array variable name} { +} -result {27 27} +test set-1.6 {TclCompileSetCmd: simple array variable name} -setup { catch {unset a} +} -body { set a(foo) 37 list [set a(foo)] $a(foo) -} {37 37} +} -result {37 37} test set-1.7 {TclCompileSetCmd: non-simple (computed) variable name} { set x "i" set i 77 @@ -149,22 +151,24 @@ test set-1.14 {TclCompileSetCmd: simple local name, >255 locals} { } 260locals } {1234} -test set-1.15 {TclCompileSetCmd: variable is array} { +test set-1.15 {TclCompileSetCmd: variable is array} -setup { catch {unset a} +} -body { set x 27 set x [set a(foo) 11] catch {unset a} set x -} 11 -test set-1.16 {TclCompileSetCmd: variable is array, elem substitutions} { +} -result 11 +test set-1.16 {TclCompileSetCmd: variable is array, elem substitutions} -setup { catch {unset a} +} -body { set i 5 set x 789 set a(foo5) 27 set x [set a(foo$i)] catch {unset a} set x -} 27 +} -result 27 test set-1.17 {TclCompileSetCmd: doing assignment, simple int} { set i 5 @@ -211,7 +215,7 @@ test set-1.25 {TclCompileSetCmd: var is array, braced (no subs)} { test set-1.26 {TclCompileSetCmd: various array constructs} { # Test all kinds of array constructs that TclCompileSetCmd # may feel inclined to tamper with. - proc p {} { + apply {{} { set a x set be(hej) 1 ; # hej set be($a) 1 ; # x @@ -230,28 +234,33 @@ test set-1.26 {TclCompileSetCmd: various array constructs} { set [string range bet 0 1](foo) 1 ; # foo set be([set be(a:$a)][set b\e($a)]) 1 ; # 51 return [lsort [array names be]] - } - p + }} } [lsort {hej x $a x,hej x,x c(x ww a:x hej,1,hej hug {a a} {x ,ugg,hej} x,h"ej {b c} foo 51}]; # " just a matching end quote -test set-2.1 {set command: runtime error, bad variable name} { +test set-2.1 {set command: runtime error, bad variable name} -setup { unset -nocomplain {"foo} +} -body { list [catch {set {"foo}} msg] $msg $::errorInfo -} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable +} -result {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable while executing "set {"foo}"}} -test set-2.2 {set command: runtime error, not array variable} { - catch {unset b} +# Stop my editor highlighter " from being confused +test set-2.2 {set command: runtime error, not array variable} -setup { + unset -nocomplain b +} -body { set b 44 list [catch {set b(123)} msg] $msg -} {1 {can't read "b(123)": variable isn't array}} -test set-2.3 {set command: runtime error, errors in reading variables} { - catch {unset a} +} -result {1 {can't read "b(123)": variable isn't array}} +test set-2.3 {set command: runtime error, errors in reading variables} -setup { + unset -nocomplain a +} -body { set a(6) 44 list [catch {set a(18)} msg] $msg -} {1 {can't read "a(18)": no such element in array}} -test set-2.4 {set command: runtime error, readonly variable} -body { +} -result {1 {can't read "a(18)": no such element in array}} +test set-2.4 {set command: runtime error, readonly variable} -setup { + unset -nocomplain x +} -body { proc readonly args {error "variable is read-only"} set x 123 trace var x w readonly @@ -260,12 +269,18 @@ test set-2.4 {set command: runtime error, readonly variable} -body { while executing * "set x 1"}} -test set-2.5 {set command: runtime error, basic array operations} { +test set-2.5 {set command: runtime error, basic array operations} -setup { + unset -nocomplain a +} -body { + array set a {} list [catch {set a(other)} msg] $msg -} {1 {can't read "a(other)": no such element in array}} -test set-2.6 {set command: runtime error, basic array operations} { +} -result {1 {can't read "a(other)": no such element in array}} +test set-2.6 {set command: runtime error, basic array operations} -setup { + unset -nocomplain a +} -body { + array set a {} list [catch {set a} msg] $msg -} {1 {can't read "a": variable is array}} +} -result {1 {can't read "a": variable is array}} # Test the uncompiled version of set @@ -479,25 +494,29 @@ test set-3.24 {uncompiled set command: too many arguments} { $z msg } {wrong # args: should be "set varName ?newValue?"} -test set-4.1 {uncompiled set command: runtime error, bad variable name} { +test set-4.1 {uncompiled set command: runtime error, bad variable name} -setup { unset -nocomplain {"foo} +} -body { set z set list [catch {$z {"foo}} msg] $msg $::errorInfo -} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable +} -result {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable while executing "$z {"foo}"}} -test set-4.2 {uncompiled set command: runtime error, not array variable} { - set z set +# Stop my editor highlighter " from being confused +test set-4.2 {uncompiled set command: runtime error, not array variable} -setup { catch {unset b} +} -body { + set z set $z b 44 list [catch {$z b(123)} msg] $msg -} {1 {can't read "b(123)": variable isn't array}} -test set-4.3 {uncompiled set command: runtime error, errors in reading variables} { - set z set - catch {unset a} +} -result {1 {can't read "b(123)": variable isn't array}} +test set-4.3 {uncompiled set command: runtime error, errors in reading variables} -setup { + catch {unset a} +} -body { + set z set $z a(6) 44 list [catch {$z a(18)} msg] $msg -} {1 {can't read "a(18)": no such element in array}} +} -result {1 {can't read "a(18)": no such element in array}} test set-4.4 {uncompiled set command: runtime error, readonly variable} -body { set z set proc readonly args {error "variable is read-only"} @@ -508,27 +527,33 @@ test set-4.4 {uncompiled set command: runtime error, readonly variable} -body { while executing * "$z x 1"}} -test set-4.5 {uncompiled set command: runtime error, basic array operations} { +test set-4.5 {uncompiled set command: runtime error, basic array operations} -setup { + unset -nocomplain a + array set a {} +} -body { set z set list [catch {$z a(other)} msg] $msg -} {1 {can't read "a(other)": no such element in array}} -test set-4.6 {set command: runtime error, basic array operations} { +} -result {1 {can't read "a(other)": no such element in array}} +test set-4.6 {set command: runtime error, basic array operations} -setup { + unset -nocomplain a + array set a {} +} -body { set z set list [catch {$z a} msg] $msg -} {1 {can't read "a": variable is array}} +} -result {1 {can't read "a": variable is array}} -test set-5.1 {error on malformed array name} testset2 { +test set-5.1 {error on malformed array name} -constraints testset2 -setup { unset -nocomplain z +} -body { catch {testset2 z(a) b} msg catch {testset2 z(b) a} msg1 list $msg $msg1 -} {{can't read "z(a)(b)": variable isn't array} {can't read "z(b)(a)": variable isn't array}} - +} -result {{can't read "z(a)(b)": variable isn't array} {can't read "z(b)(a)": variable isn't array}} # In a mem-debug build, this test will crash unless Bug 3602706 is fixed. test set-5.2 {Bug 3602706} -body { testset2 ::tcl_platform not-in-there } -returnCodes error -result * -match glob - + # cleanup catch {unset a} catch {unset b} @@ -537,3 +562,7 @@ catch {unset x} catch {unset z} ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/var.test b/tests/var.test index b6b09fd..690bd10 100644 --- a/tests/var.test +++ b/tests/var.test @@ -44,10 +44,12 @@ test var-1.1 {TclLookupVar, Array handling} -setup { set arr(foo) 37 list [$x i] $i [$x arr(foo)] $arr(foo) } -result {11 11 38 38} +set ::x "global value" +namespace eval test_ns_var { + variable x "namespace value" +} test var-1.2 {TclLookupVar, TCL_GLOBAL_ONLY implies global namespace var} { - set x "global value" namespace eval test_ns_var { - variable x "namespace value" proc p {} { global x ;# specifies TCL_GLOBAL_ONLY to get global x return $x @@ -261,6 +263,7 @@ test var-3.7 {MakeUpvar, my var has ::s} -setup { } } -result {789789} test var-3.8 {MakeUpvar, my var already exists in global ns} -setup { + upvar #0 aaaaa xxxxx catch {unset aaaaa} catch {unset xxxxx} } -body { @@ -274,6 +277,8 @@ test var-3.9 {MakeUpvar, my var has invalid ns name} -setup { } -returnCodes error -body { set aaaaa 789789 upvar #0 aaaaa test_ns_fred::lnk +} -cleanup { + unset ::aaaaa } -result {can't create "test_ns_fred::lnk": parent namespace doesn't exist} test var-3.10 {MakeUpvar, between namespaces} -body { namespace eval {} { @@ -282,8 +287,6 @@ test var-3.10 {MakeUpvar, between namespaces} -body { set foo::bar 1 list $bar $foo::bar } -} -cleanup { - unset ::aaaaa } -result {1 1} test var-3.11 {MakeUpvar, my var looks like array elem} -setup { catch {unset aaaaa} @@ -322,9 +325,11 @@ test var-5.2 {Tcl_GetVariableFullName, namespace variable} { namespace which -variable martha } } {::test_ns_var::martha} -test var-5.3 {Tcl_GetVariableFullName, namespace variable} { +test var-5.3 {Tcl_GetVariableFullName, namespace variable} -setup { + namespace eval test_ns_var {variable martha} +} -body { namespace which -variable test_ns_var::martha -} {::test_ns_var::martha} +} -result {::test_ns_var::martha} test var-6.1 {Tcl_GlobalObjCmd, variable is qualified by a namespace name} { namespace eval test_ns_var { @@ -348,6 +353,7 @@ test var-6.2 {Tcl_GlobalObjCmd, variable is qualified by a namespace name} { test_ns_var::p } {java} test var-6.3 {Tcl_GlobalObjCmd, variable named {} qualified by a namespace name} { + namespace eval ::test_ns_var::test_ns_nested {} set ::test_ns_var::test_ns_nested:: 24 apply {{} { global ::test_ns_var::test_ns_nested:: @@ -389,20 +395,26 @@ test var-7.2 {Tcl_VariableObjCmd, if new and no value, leave undefined} { } list [info exists test_ns_var::two] [catch {set test_ns_var::two} msg] $msg } {0 1 {can't read "test_ns_var::two": no such variable}} -test var-7.3 {Tcl_VariableObjCmd, "define" var already created above} { +test var-7.3 {Tcl_VariableObjCmd, "define" var already created above} -setup { + catch {namespace delete test_ns_var} + namespace eval test_ns_var {variable one 1} +} -body { namespace eval test_ns_var { variable two 2 } list [lsort [info vars test_ns_var::*]] \ [namespace eval test_ns_var {set two}] -} [list [lsort {::test_ns_var::two ::test_ns_var::one}] 2] -test var-7.4 {Tcl_VariableObjCmd, list of vars} { +} -result [list [lsort {::test_ns_var::two ::test_ns_var::one}] 2] +test var-7.4 {Tcl_VariableObjCmd, list of vars} -setup { + catch {namespace delete test_ns_var} + namespace eval test_ns_var {variable one 1; variable two 2} +} -body { namespace eval test_ns_var { variable three 3 four 4 } list [lsort [info vars test_ns_var::*]] \ [namespace eval test_ns_var {expr $three+$four}] -} [list [lsort {::test_ns_var::four ::test_ns_var::three ::test_ns_var::two ::test_ns_var::one}] 7] +} -result [list [lsort {::test_ns_var::four ::test_ns_var::three ::test_ns_var::two ::test_ns_var::one}] 7] test var-7.5 {Tcl_VariableObjCmd, value for last var is optional} -setup { catch {unset a} catch {unset five} @@ -476,7 +488,9 @@ test var-7.9 {Tcl_VariableObjCmd, mark as namespace var so var persists until na [lsort {::test_ns_var2::x ::test_ns_var2::z}] 0 0\ {1 {can't unset "test_ns_var2::z": no such variable}}\ {}] -test var-7.10 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} { +test var-7.10 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} -setup { + namespace eval test_ns_var { variable eight 8 } +} -body { namespace eval test_ns_var { proc p {} { variable eight @@ -484,14 +498,16 @@ test var-7.10 {Tcl_VariableObjCmd, variable cmd inside proc creates local link v } p } -} {8 eight} -test var-7.11 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} { +} -result {8 eight} +test var-7.11 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} -setup { + namespace eval test_ns_var { variable eight 8 } +} -body { proc p {} { ;# note this proc is at global :: scope variable test_ns_var::eight list [set eight] [info vars] } p -} {8 eight} +} -result {8 eight} test var-7.12 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} { namespace eval test_ns_var { variable {} {My name is empty} @@ -774,7 +790,7 @@ test var-17.1 {TclArraySet [Bug 1669489]} -setup { test var-18.1 {array unset and unset traces: Bug 2939073} -setup { set already 0 - unset x + unset -nocomplain x } -body { array set x {e 1 i 1} trace add variable x unset {apply {args { -- cgit v0.12 From 09c67efdce34a8588ab4cb53e007e8ec603dc081 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 12 Jul 2016 21:30:34 +0000 Subject: [3606125] Make parser-related tests work on their own. --- tests/parseOld.test | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/parseOld.test b/tests/parseOld.test index a6e07a2..504d063 100644 --- a/tests/parseOld.test +++ b/tests/parseOld.test @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest +package require tcltest 2 namespace import ::tcltest::* ::tcltest::loadTestedCommands @@ -37,7 +37,7 @@ proc getArgs args { global argv set argv $args } - + # Basic argument parsing. test parseOld-1.1 {basic argument parsing} { @@ -296,6 +296,7 @@ test parseOld-8.4 {semi-colons} { # The following checks are to ensure that the interpreter's result # gets re-initialized by Tcl_Eval in all the right places. +set a 22 test parseOld-9.1 {result initialization} {concat abc} abc test parseOld-9.2 {result initialization} {concat abc; proc foo {} {}} {} test parseOld-9.3 {result initialization} {concat abc; proc foo {} $a} {} @@ -408,6 +409,8 @@ test parseOld-11.7 {long values} { set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH] llength $b } 43 +# Duplicate action of previous test +llength [set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH]] test parseOld-11.8 {long values} { set b } $a @@ -538,8 +541,12 @@ test parseOld-15.4 {TclScriptEnd procedure} { test parseOld-15.5 {TclScriptEnd procedure} { info complete "xyz \[abc" } {0} - + # cleanup set argv $savedArgv ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: -- cgit v0.12 From ab2a78be642be26075e2998347d71359a6b3c500 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 13 Jul 2016 19:06:22 +0000 Subject: New private flag value INDEX_TEMP_TABLE. Used to signal to Tcl_GetIndexFromObj*() routines that the table in which lookups are done has a fleeting existence. Thus there is no value in caching any results, since the cache can never be useful. Improvement over existing hackery where cache is stored and then freed to avoid bogus results. Likely candidate to eventually push to the public interface. --- generic/tclFCmd.c | 10 ++-------- generic/tclIndexObj.c | 13 +++++++------ generic/tclInt.h | 9 +++++++++ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index bb814ea..80898fc 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -1079,12 +1079,9 @@ TclFileAttrsCmd( } if (Tcl_GetIndexFromObj(interp, objv[0], attributeStrings, - "option", 0, &index) != TCL_OK) { + "option", INDEX_TEMP_TABLE, &index) != TCL_OK) { goto end; } - if (attributeStringsAllocated != NULL) { - TclFreeIntRep(objv[0]); - } if (Tcl_FSFileAttrsGet(interp, index, filePtr, &objPtr) != TCL_OK) { goto end; @@ -1107,12 +1104,9 @@ TclFileAttrsCmd( for (i = 0; i < objc ; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], attributeStrings, - "option", 0, &index) != TCL_OK) { + "option", INDEX_TEMP_TABLE, &index) != TCL_OK) { goto end; } - if (attributeStringsAllocated != NULL) { - TclFreeIntRep(objv[i]); - } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", TclGetString(objv[i]))); diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 2281d22..c6873af 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -114,6 +114,7 @@ Tcl_GetIndexFromObj( int flags, /* 0 or TCL_EXACT */ int *indexPtr) /* Place to store resulting integer index. */ { + if (!(flags & INDEX_TEMP_TABLE)) { /* * See if there is a valid cached result from a previous lookup (doing the @@ -135,6 +136,7 @@ Tcl_GetIndexFromObj( return TCL_OK; } } + } return Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, sizeof(char *), msg, flags, indexPtr); } @@ -211,13 +213,8 @@ GetIndexFromObjList( tablePtr[objc] = NULL; result = Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, - sizeof(char *), msg, flags, indexPtr); - - /* - * The internal rep must be cleared since tablePtr will go away. - */ + sizeof(char *), msg, flags | INDEX_TEMP_TABLE, indexPtr); - TclFreeIntRep(objPtr); ckfree(tablePtr); return result; @@ -279,6 +276,7 @@ Tcl_GetIndexFromObjStruct( * See if there is a valid cached result from a previous lookup. */ + if (!(flags & INDEX_TEMP_TABLE)) { if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.twoPtrValue.ptr1; if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { @@ -286,6 +284,7 @@ Tcl_GetIndexFromObjStruct( return TCL_OK; } } + } /* * Lookup the value of the object in the table. Accept unique @@ -340,6 +339,7 @@ Tcl_GetIndexFromObjStruct( * operation. */ + if (!(flags & INDEX_TEMP_TABLE)) { if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.twoPtrValue.ptr1; } else { @@ -351,6 +351,7 @@ Tcl_GetIndexFromObjStruct( indexRep->tablePtr = (void *) tablePtr; indexRep->offset = offset; indexRep->index = index; + } *indexPtr = index; return TCL_OK; diff --git a/generic/tclInt.h b/generic/tclInt.h index 33476ed..4ecac7d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2548,6 +2548,15 @@ typedef struct TclFileAttrProcs { } TclFileAttrProcs; /* + * Private flag value which controls Tcl_GetIndexFromObj*() routines + * to instruct them not to cache lookups because the table will not + * live long enough to make it worthwhile. Must not clash with public + * flag value TCL_EXACT. + */ + +#define INDEX_TEMP_TABLE 2 + +/* * Opaque handle used in pipeline routines to encapsulate platform-dependent * state. */ -- cgit v0.12 From b91a1c74a96cb667373be1fa8b3da13dc82d071d Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 14 Jul 2016 08:05:35 +0000 Subject: Tidy up some references to INDEX_TEMP_TABLE. --- generic/tclIndexObj.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index c6873af..6a3e4e3 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -114,15 +114,13 @@ Tcl_GetIndexFromObj( int flags, /* 0 or TCL_EXACT */ int *indexPtr) /* Place to store resulting integer index. */ { - if (!(flags & INDEX_TEMP_TABLE)) { - /* * See if there is a valid cached result from a previous lookup (doing the * check here saves the overhead of calling Tcl_GetIndexFromObjStruct in * the common case where the result is cached). */ - if (objPtr->typePtr == &indexType) { + if (!(flags & INDEX_TEMP_TABLE) && objPtr->typePtr == &indexType) { IndexRep *indexRep = objPtr->internalRep.twoPtrValue.ptr1; /* @@ -136,7 +134,6 @@ Tcl_GetIndexFromObj( return TCL_OK; } } - } return Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, sizeof(char *), msg, flags, indexPtr); } @@ -276,15 +273,13 @@ Tcl_GetIndexFromObjStruct( * See if there is a valid cached result from a previous lookup. */ - if (!(flags & INDEX_TEMP_TABLE)) { - if (objPtr->typePtr == &indexType) { + if (!(flags & INDEX_TEMP_TABLE) && objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.twoPtrValue.ptr1; if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { *indexPtr = indexRep->index; return TCL_OK; } } - } /* * Lookup the value of the object in the table. Accept unique @@ -340,17 +335,17 @@ Tcl_GetIndexFromObjStruct( */ if (!(flags & INDEX_TEMP_TABLE)) { - if (objPtr->typePtr == &indexType) { - indexRep = objPtr->internalRep.twoPtrValue.ptr1; - } else { - TclFreeIntRep(objPtr); - indexRep = ckalloc(sizeof(IndexRep)); - objPtr->internalRep.twoPtrValue.ptr1 = indexRep; - objPtr->typePtr = &indexType; - } - indexRep->tablePtr = (void *) tablePtr; - indexRep->offset = offset; - indexRep->index = index; + if (objPtr->typePtr == &indexType) { + indexRep = objPtr->internalRep.twoPtrValue.ptr1; + } else { + TclFreeIntRep(objPtr); + indexRep = ckalloc(sizeof(IndexRep)); + objPtr->internalRep.twoPtrValue.ptr1 = indexRep; + objPtr->typePtr = &indexType; + } + indexRep->tablePtr = (void *) tablePtr; + indexRep->offset = offset; + indexRep->index = index; } *indexPtr = index; -- cgit v0.12 From c65f04435b80a065f992d534fcd8bfc9a5a0e8ef Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 14 Jul 2016 08:31:00 +0000 Subject: [77d58e3a7a] Test case independence: chanio, cmdah, env, history. --- tests/chanio.test | 23 +++++++++++++++++++---- tests/cmdAH.test | 8 ++++++-- tests/env.test | 12 ++++++++++-- tests/history.test | 5 +++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 2738fc6..29f42c3 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -4160,12 +4160,20 @@ test chan-io-33.4 {Tcl_Gets with long line} -setup { } -cleanup { chan close $f } -result {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} -test chan-io-33.5 {Tcl_Gets with long line} { +test chan-io-33.5 {Tcl_Gets with long line} -setup { + set f [open $path(test3) w] + puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + puts $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + close $f +} -body { set f [open $path(test3)] set x [chan gets $f y] chan close $f list $x $y -} {260 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} +} -result {260 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} test chan-io-33.6 {Tcl_Gets and end of file} -setup { file delete $path(test3) set x {} @@ -6765,7 +6773,12 @@ test chan-io-52.10 {TclCopyChannel & encodings} {fcopy} { chan close $out file size $path(utf8-fcopy.txt) } 5 -test chan-io-52.11 {TclCopyChannel & encodings} {fcopy} { +test chan-io-52.11 {TclCopyChannel & encodings} -setup { + set f [open $path(utf8-fcopy.txt) w] + fconfigure $f -encoding utf-8 + puts $f "\u0410\u0410" + close $f +} -constraints {fcopy} -body { # binary to encoding => the input has to be in utf-8 to make sense to the # encoder set in [open $path(utf8-fcopy.txt) r] @@ -6777,7 +6790,9 @@ test chan-io-52.11 {TclCopyChannel & encodings} {fcopy} { chan close $in chan close $out file size $path(kyrillic.txt) -} 3 +} -cleanup { + file delete $path(utf8-fcopy.txt) +} -result 3 test chan-io-53.1 {CopyData} -setup { file delete $path(test1) diff --git a/tests/cmdAH.test b/tests/cmdAH.test index ef933cb..6418aae 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -141,9 +141,13 @@ test cmdAH-2.6.2 {cd} -constraints {unix nonPortable} -setup { } -cleanup { cd $dir } -result {/} -test cmdAH-2.6.3 {Tcl_CdObjCmd, bug #3118489} -returnCodes error -body { +test cmdAH-2.6.3 {Tcl_CdObjCmd, bug #3118489} -setup { + set dir [pwd] +} -returnCodes error -body { cd .\0 -} -result "couldn't change working directory to \".\0\": no such file or directory" +} -cleanup { + cd $dir +} -match glob -result "couldn't change working directory to \".\0\": *" test cmdAH-2.7 {Tcl_ConcatObjCmd} { concat } {} diff --git a/tests/env.test b/tests/env.test index 9f59fbc..0dd4f98 100644 --- a/tests/env.test +++ b/tests/env.test @@ -19,7 +19,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { # Some tests require the "exec" command. # Skip them if exec is not defined. testConstraint exec [llength [info commands exec]] - + # # These tests will run on any platform (and indeed crashed on the Mac). So put # them before you test for the existance of exec. @@ -147,6 +147,7 @@ test env-2.2 {adding environment variables} -setup { } -result {NAME1=test string} test env-2.3 {adding environment variables} -setup { encoding system iso8859-1 + set env(NAME1) "test string" } -constraints {exec} -body { set env(NAME2) "more" getenv @@ -156,6 +157,8 @@ test env-2.3 {adding environment variables} -setup { NAME2=more} test env-2.4 {adding environment variables} -setup { encoding system iso8859-1 + set env(NAME1) "test string" + set env(NAME2) "more" } -constraints {exec} -body { set env(XYZZY) "garbage" getenv @@ -165,7 +168,9 @@ test env-2.4 {adding environment variables} -setup { NAME2=more XYZZY=garbage} +set env(NAME1) "test string" set env(NAME2) "new value" +set env(XYZZY) "garbage" test env-3.1 {changing environment variables} -setup { encoding system iso8859-1 } -constraints {exec} -body { @@ -177,6 +182,7 @@ test env-3.1 {changing environment variables} -setup { } -result {NAME1=test string NAME2=new value XYZZY=garbage} +unset -nocomplain env(NAME2) test env-4.1 {unsetting environment variables: default} -setup { encoding system iso8859-1 @@ -195,6 +201,7 @@ test env-4.2 {unsetting environment variables} -setup { unset env(XYZZY) encoding system $sysenc } -result {XYZZY=garbage} +unset -nocomplain env(NAME1) env(XYZZY) test env-4.3 {setting international environment variables} -setup { encoding system iso8859-1 } -constraints {exec} -body { @@ -213,6 +220,7 @@ test env-4.4 {changing international environment variables} -setup { } -result {\u00a7=\u00a7} test env-4.5 {unsetting international environment variables} -setup { encoding system iso8859-1 + set env(\ua7) \ua7 } -body { set env(\ub6) \ua7 unset env(\ua7) @@ -323,7 +331,7 @@ test env-7.3 {[9b4702]: testing existence of env(some_thing) should not destroy return [info exists ::env(test7_3)] }} } -result 1 - + # Restore the environment variables at the end of the test. foreach name [array names env] { diff --git a/tests/history.test b/tests/history.test index c562796..7549beb 100644 --- a/tests/history.test +++ b/tests/history.test @@ -233,6 +233,7 @@ if {[testConstraint history]} { test history-8.1 {clear option} history {catch {history clear junk}} 1 test history-8.2 {clear option} history {history clear} {} if {[testConstraint history]} { + history clear history add "Testing" } test history-8.3 {clear option} history {history} { 1 Testing} @@ -248,3 +249,7 @@ test history-9.2 {miscellaneous} history { # cleanup ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: -- cgit v0.12 From 18d118050e87e9f2665c7da4358836e37dbd7a0f Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 14 Jul 2016 14:40:37 +0000 Subject: New test demonstrates memleak discovered by Rolf Ade. --- tests/var.test | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/var.test b/tests/var.test index e223f6e..803bbda 100644 --- a/tests/var.test +++ b/tests/var.test @@ -26,6 +26,21 @@ testConstraint testupvar [llength [info commands testupvar]] testConstraint testgetvarfullname [llength [info commands testgetvarfullname]] testConstraint testsetnoerr [llength [info commands testsetnoerr]] testConstraint memory [llength [info commands memory]] +if {[testConstraint memory]} { + proc getbytes {} { + return [lindex [split [memory info] \n] 3 3] + } + proc leaktest {script {iterations 3}} { + set end [getbytes] + for {set i 0} {$i < $iterations} {incr i} { + uplevel 1 $script + set tmp $end + set end [getbytes] + } + return [expr {$end - $tmp}] + } +} + catch {rename p ""} catch {namespace delete test_ns_var} @@ -912,9 +927,6 @@ test var-21.0 {PushVarNameWord OBOE in compiled unset} -setup { } -result 1 test var-22.0 {leak in array element unset: Bug a3309d01db} -setup { - proc getbytes {} { - lindex [split [memory info] \n] 3 3 - } proc doit k { variable A set A($k) {} @@ -934,13 +946,9 @@ test var-22.0 {leak in array element unset: Bug a3309d01db} -setup { set leakedBytes [expr {$end - $tmp}] } -cleanup { array unset A - rename getbytes {} rename doit {} } -result 0 test var-22.1 {leak in localVarName intrep: Bug 80304238ac} -setup { - proc getbytes {} { - lindex [split [memory info] \n] 3 3 - } proc doit {} { interp create slave slave eval { @@ -962,15 +970,21 @@ test var-22.1 {leak in localVarName intrep: Bug 80304238ac} -setup { set leakedBytes [expr {$end - $tmp}] } -cleanup { array unset A - rename getbytes {} rename doit {} } -result 0 +test var-22.2 {leak in parsedVarName} -constraints memory -body { + set i 0 + leaktest {lappend x($i)} +} -cleanup { + unset -nocomplain i x +} -result 0 catch {namespace delete ns} catch {unset arr} catch {unset v} +catch {rename getbytes ""} catch {rename p ""} catch {namespace delete test_ns_var} catch {namespace delete test_ns_var2} -- cgit v0.12 From 35eb3535af4c4a03667bbf2b4fcde538d5e875fe Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 14 Jul 2016 15:17:58 +0000 Subject: Plug memory leak created in recent variable Tcl_ObjType reform. --- generic/tclVar.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/generic/tclVar.c b/generic/tclVar.c index a9bedd7..091baf8 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -577,11 +577,7 @@ TclObjLookupVarEx( } return NULL; } - if ((part2Ptr = part1Ptr->internalRep.twoPtrValue.ptr2)) { - if (createPart2) { - Tcl_IncrRefCount(part2Ptr); - } - } + part2Ptr = part1Ptr->internalRep.twoPtrValue.ptr2; part1Ptr = part1Ptr->internalRep.twoPtrValue.ptr1; typePtr = part1Ptr->typePtr; if (typePtr == &localVarNameType) { @@ -622,9 +618,6 @@ TclObjLookupVarEx( len1 = i; part2Ptr = Tcl_NewStringObj(part2, len2); - if (createPart2) { - Tcl_IncrRefCount(part2Ptr); - } /* * Free the internal rep of the original part1Ptr, now renamed -- cgit v0.12 From 10f81d78ff4d5f5931412700726ce05d14d02fad Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 14 Jul 2016 17:58:45 +0000 Subject: Stop checking case that can never happen. --- generic/tclNamesp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 5930859..1fef919 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -2883,9 +2883,9 @@ GetNamespaceFromObj( resNamePtr = objPtr->internalRep.twoPtrValue.ptr1; nsPtr = resNamePtr->nsPtr; refNsPtr = resNamePtr->refNsPtr; - if (!(nsPtr->flags & NS_DYING) && (interp == nsPtr->interp) && - (!refNsPtr || ((interp == refNsPtr->interp) && - (refNsPtr== (Namespace *) Tcl_GetCurrentNamespace(interp))))){ + if (!(nsPtr->flags & NS_DYING) && (interp == nsPtr->interp) + && (!refNsPtr || (refNsPtr == + (Namespace *) TclGetCurrentNamespace(interp)))) { *nsPtrPtr = (Tcl_Namespace *) nsPtr; return TCL_OK; } @@ -4779,7 +4779,7 @@ SetNsNameFromAny( if ((name[0] == ':') && (name[1] == ':')) { resNamePtr->refNsPtr = NULL; } else { - resNamePtr->refNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp); + resNamePtr->refNsPtr = (Namespace *) TclGetCurrentNamespace(interp); } resNamePtr->refCount = 1; TclFreeIntRep(objPtr); -- cgit v0.12 From b136b0307e6b079262352c8541c019519fb34f6e Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 15 Jul 2016 02:33:11 +0000 Subject: One of the validity checks for the "cmdName" type is to see if the resolved command has been deleted by checking for the CMD_IS_DELETED flag. Only one thing sets this flag -- Tcl_DeleteCommandFromToken(), and every time it sets that flag it also bumps the cmdEpoch of the Command as well. The "cmdName" type is already validating that epoch. It gains nothing to be checking the CMD_IS_DELETED flag too. Eliminated the pointless test. --- generic/tclObj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index 0cd7839..8aaf78e 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4156,7 +4156,6 @@ Tcl_GetCommandFromObj( register Command *cmdPtr = resPtr->cmdPtr; if ((cmdPtr->cmdEpoch == resPtr->cmdEpoch) - && !(cmdPtr->flags & CMD_IS_DELETED) && (interp == cmdPtr->nsPtr->interp) && !(cmdPtr->nsPtr->flags & NS_DYING)) { register Namespace *refNsPtr = (Namespace *) -- cgit v0.12 From 048a4d7e224034d072341b7c9c633801ca9fa19b Mon Sep 17 00:00:00 2001 From: ashok Date: Fri, 15 Jul 2016 03:12:09 +0000 Subject: Fix docs and test failures. I had rolled back .PS1 (Powershell files) as being executable without fixing tests and docs. --- doc/file.n | 2 +- tests/cmdAH.test | 7 ++++--- tests/fileName.test | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/file.n b/doc/file.n index 58b03d8..2f8b70c 100644 --- a/doc/file.n +++ b/doc/file.n @@ -164,7 +164,7 @@ returns \fB/home\fR (or something similar). Returns \fB1\fR if file \fIname\fR is executable by the current user, \fB0\fR otherwise. On Windows, which does not have an executable attribute, the command treats all directories and any files with extensions -\fBexe\fR, \fBcom\fR, \fBcmd\fR, \fBbat\fR or \fBps1\fR as executable. +\fBexe\fR, \fBcom\fR, \fBcmd\fR or \fBbat\fR as executable. .TP \fBfile exists \fIname\fR . diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 6418aae..b4ef605 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -882,9 +882,10 @@ test cmdAH-18.3 {Tcl_FileObjCmd: executable} {unix testchmod} { } 1 test cmdAH-18.5 {Tcl_FileObjCmd: executable} -constraints {win} -body { # On pc, must be a .exe, .com, etc. - set x [file exe $gorpfile] + set x {} set gorpexes {} - foreach ext {exe com cmd bat ps1} { + foreach ext {exe com cmd bat} { + lappend x [file exe nosuchfile.$ext] set gorpexe [makeFile foo gorp.$ext] lappend gorpexes $gorpexe lappend x [file exe $gorpexe] [file exe [string toupper $gorpexe]] @@ -894,7 +895,7 @@ test cmdAH-18.5 {Tcl_FileObjCmd: executable} -constraints {win} -body { foreach gorpexe $gorpexes { removeFile $gorpexe } -} -result {0 1 1 1 1 1 1 1 1 1 1} +} -result {0 1 1 0 1 1 0 1 1 0 1 1} test cmdAH-18.6 {Tcl_FileObjCmd: executable} {} { # Directories are always executable. file exe $dirfile diff --git a/tests/fileName.test b/tests/fileName.test index a19bd1e..387d844 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -1468,7 +1468,7 @@ if {[testConstraint testsetplatform]} { } test filename-17.2 {windows specific glob with executable} -body { makeDirectory execglob - foreach ext {exe com cmd bat ps1 notexecutable} { + foreach ext {exe com cmd bat notexecutable} { makeFile contents execglob/abc.$ext } lsort [glob -nocomplain -dir [temporaryDirectory]/execglob -tails -types x *] @@ -1477,7 +1477,7 @@ test filename-17.2 {windows specific glob with executable} -body { removeFile execglob/abc.$ext } removeDirectory execglob -} -result {abc.bat abc.cmd abc.com abc.exe abc.ps1} +} -result {abc.bat abc.cmd abc.com abc.exe} test filename-17.3 {Bug 2571597} win { set p /a file pathtype $p -- cgit v0.12 From cbd642eea303b0db3eec81529c27f2045984f22a Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 15 Jul 2016 05:39:09 +0000 Subject: [77d58e3a7a] Test case independence: interp. --- tests/interp.test | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/tests/interp.test b/tests/interp.test index 4bc9fe2..f9c1aec 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -71,9 +71,11 @@ test interp-2.2 {basic interpreter creation} { test interp-2.3 {basic interpreter creation} { catch {interp create -safe} } 0 -test interp-2.4 {basic interpreter creation} { - list [catch {interp create a} msg] $msg -} {1 {interpreter named "a" already exists, cannot create}} +test interp-2.4 {basic interpreter creation} -setup { + catch {interp create a} +} -returnCodes error -body { + interp create a +} -result {interpreter named "a" already exists, cannot create} test interp-2.5 {basic interpreter creation} { interp create b -safe } b @@ -89,11 +91,13 @@ test interp-2.8 {basic interpreter creation} { test interp-2.9 {basic interpreter creation} { interp create -safe -- -froboz1 } -froboz1 -test interp-2.10 {basic interpreter creation} { +test interp-2.10 {basic interpreter creation} -setup { + catch {interp create a} +} -body { interp create {a x1} interp create {a x2} interp create {a x3} -safe -} {a x3} +} -result {a x3} test interp-2.11 {anonymous interps vs existing procs} { set x [interp create] regexp "interp(\[0-9]+)" $x dummy thenum @@ -140,19 +144,26 @@ test interp-3.5 {testing interp exists and interp slaves} -body { test interp-3.6 {testing interp exists and interp slaves} { interp exists } 1 -test interp-3.7 {testing interp exists and interp slaves} { +test interp-3.7 {testing interp exists and interp slaves} -setup { + catch {interp create a} +} -body { interp slaves -} a +} -result a test interp-3.8 {testing interp exists and interp slaves} -body { interp slaves a b c } -returnCodes error -result {wrong # args: should be "interp slaves ?path?"} -test interp-3.9 {testing interp exists and interp slaves} { +test interp-3.9 {testing interp exists and interp slaves} -setup { + catch {interp create a} +} -body { interp create {a a2} -safe expr {"a2" in [interp slaves a]} -} 1 -test interp-3.10 {testing interp exists and interp slaves} { +} -result 1 +test interp-3.10 {testing interp exists and interp slaves} -setup { + catch {interp create a} + catch {interp create {a a2}} +} -body { interp exists {a a2} -} 1 +} -result 1 # Part 3: Testing "interp delete" test interp-3.11 {testing interp delete} { @@ -222,6 +233,7 @@ test interp-6.3 {testing eval} { a eval {proc foo {} {expr 3 + 5}} a eval foo } 8 +catch {a eval {proc foo {} {expr 3 + 5}}} test interp-6.4 {testing eval} { interp eval a foo } 8 @@ -230,6 +242,7 @@ test interp-6.5 {testing eval} { interp eval {a x2} {proc frob {} {expr 4 * 9}} interp eval {a x2} frob } 36 +catch {interp create {a x2}} test interp-6.6 {testing eval} -returnCodes error -body { interp eval {a x2} foo } -result {invalid command name "foo"} @@ -243,9 +256,11 @@ proc in_master {args} { test interp-7.1 {testing basic alias creation} { a alias foo in_master } foo +catch {a alias foo in_master} test interp-7.2 {testing basic alias creation} { a alias bar in_master a1 a2 a3 } bar +catch {a alias bar in_master a1 a2 a3} # Test 6.3 has been deleted. test interp-7.3 {testing basic alias creation} { a alias foo @@ -476,9 +491,13 @@ test interp-13.4 {testing issafe arg checking} { } {1 {wrong # args: should be "a issafe"}} # part 14: testing interp aliases -test interp-14.1 {testing interp aliases} { - interp aliases -} "" +test interp-14.1 {testing interp aliases} -setup { + interp create abc +} -body { + interp eval abc {interp aliases} +} -cleanup { + interp delete abc +} -result "" test interp-14.2 {testing interp aliases} { catch {interp delete a} interp create a -- cgit v0.12 From 059c3bec3a774772ceff7fc2fcc5c7bf690ab8cf Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 15 Jul 2016 12:36:33 +0000 Subject: Stop using the tclCmdNameType to store failed command lookups. If we don't find a command, there's nothing to store, so better not to shimmer at all. --- generic/tclObj.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index 8aaf78e..e335ac3 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4152,7 +4152,7 @@ Tcl_GetCommandFromObj( */ resPtr = objPtr->internalRep.twoPtrValue.ptr1; - if ((objPtr->typePtr == &tclCmdNameType) && (resPtr != NULL)) { + if (objPtr->typePtr == &tclCmdNameType) { register Command *cmdPtr = resPtr->cmdPtr; if ((cmdPtr->cmdEpoch == resPtr->cmdEpoch) @@ -4281,7 +4281,6 @@ FreeCmdNameInternalRep( { register ResolvedCmdName *resPtr = objPtr->internalRep.twoPtrValue.ptr1; - if (resPtr != NULL) { /* * Decrement the reference count of the ResolvedCmdName structure. If * there are no more uses, free the ResolvedCmdName structure. @@ -4299,7 +4298,6 @@ FreeCmdNameInternalRep( TclCleanupCommandMacro(cmdPtr); ckfree(resPtr); } - } objPtr->typePtr = NULL; } @@ -4332,9 +4330,7 @@ DupCmdNameInternalRep( copyPtr->internalRep.twoPtrValue.ptr1 = resPtr; copyPtr->internalRep.twoPtrValue.ptr2 = NULL; - if (resPtr != NULL) { resPtr->refCount++; - } copyPtr->typePtr = &tclCmdNameType; } @@ -4387,16 +4383,23 @@ SetCmdNameFromAny( Tcl_FindCommand(interp, name, /*ns*/ NULL, /*flags*/ 0); /* + * Stop shimmering and caching nothing when we found nothing. Just + * report the failure to find the command as an error. + */ + + if (cmdPtr == NULL) { + return TCL_ERROR; + } + + /* * Free the old internalRep before setting the new one. Do this after * getting the string rep to allow the conversion code (in particular, * Tcl_GetStringFromObj) to use that old internalRep. */ - if (cmdPtr) { cmdPtr->refCount++; resPtr = objPtr->internalRep.twoPtrValue.ptr1; - if ((objPtr->typePtr == &tclCmdNameType) - && resPtr && (resPtr->refCount == 1)) { + if ((objPtr->typePtr == &tclCmdNameType) && (resPtr->refCount == 1)) { /* * Reuse the old ResolvedCmdName struct instead of freeing it */ @@ -4434,12 +4437,6 @@ SetCmdNameFromAny( resPtr->refNsId = currNsPtr->nsId; resPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; } - } else { - TclFreeIntRep(objPtr); - objPtr->internalRep.twoPtrValue.ptr1 = NULL; - objPtr->internalRep.twoPtrValue.ptr2 = NULL; - objPtr->typePtr = &tclCmdNameType; - } return TCL_OK; } -- cgit v0.12 From ed70e9d86101ea6352b6623c9ca09ef68749abd9 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 15 Jul 2016 14:19:07 +0000 Subject: Factor the cmdName intrep setting code into common utility routine. --- generic/tclObj.c | 138 +++++++++++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index e335ac3..b145d7e 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4203,54 +4203,73 @@ Tcl_GetCommandFromObj( *---------------------------------------------------------------------- */ -void -TclSetCmdNameObj( - Tcl_Interp *interp, /* Points to interpreter containing command - * that should be cached in objPtr. */ - register Tcl_Obj *objPtr, /* Points to Tcl object to be changed to a - * CmdName object. */ - Command *cmdPtr) /* Points to Command structure that the - * CmdName object should refer to. */ +static void +SetCmdNameObj( + Tcl_Interp *interp, + Tcl_Obj *objPtr, + Command *cmdPtr, + ResolvedCmdName *resPtr) { Interp *iPtr = (Interp *) interp; - register ResolvedCmdName *resPtr; - register Namespace *currNsPtr; - const char *name; + ResolvedCmdName *fillPtr; + const char *name = TclGetString(objPtr); - if (objPtr->typePtr == &tclCmdNameType) { - return; + if (resPtr) { + fillPtr = resPtr; + } else { + fillPtr = ckalloc(sizeof(ResolvedCmdName)); + fillPtr->refCount = 1; } + fillPtr->cmdPtr = cmdPtr; cmdPtr->refCount++; - resPtr = ckalloc(sizeof(ResolvedCmdName)); - resPtr->cmdPtr = cmdPtr; - resPtr->cmdEpoch = cmdPtr->cmdEpoch; - resPtr->refCount = 1; + fillPtr->cmdEpoch = cmdPtr->cmdEpoch; - name = TclGetString(objPtr); - if ((*name++ == ':') && (*name == ':')) { + /* NOTE: relying on NULL termination here. */ + if ((name[0] == ':') && (name[1] == ':')) { /* - * The name is fully qualified: set the referring namespace to - * NULL. + * Fully qualified names always resolve to same thing. No need + * to record resolution context information. */ - resPtr->refNsPtr = NULL; + fillPtr->refNsPtr = NULL; + fillPtr->refNsId = 0; /* Will not be read */ + fillPtr->refNsCmdEpoch = 0; /* Will not be read */ } else { /* - * Get the current namespace. + * Record current state of current namespace as the resolution + * context of this command name lookup. */ + Namespace *currNsPtr = iPtr->varFramePtr->nsPtr; - currNsPtr = iPtr->varFramePtr->nsPtr; + fillPtr->refNsPtr = currNsPtr; + fillPtr->refNsId = currNsPtr->nsId; + fillPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; + } - resPtr->refNsPtr = currNsPtr; - resPtr->refNsId = currNsPtr->nsId; - resPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; + if (resPtr == NULL) { + TclFreeIntRep(objPtr); + + objPtr->internalRep.twoPtrValue.ptr1 = fillPtr; + objPtr->internalRep.twoPtrValue.ptr2 = NULL; + objPtr->typePtr = &tclCmdNameType; } +} - TclFreeIntRep(objPtr); - objPtr->internalRep.twoPtrValue.ptr1 = resPtr; - objPtr->internalRep.twoPtrValue.ptr2 = NULL; - objPtr->typePtr = &tclCmdNameType; +void +TclSetCmdNameObj( + Tcl_Interp *interp, /* Points to interpreter containing command + * that should be cached in objPtr. */ + register Tcl_Obj *objPtr, /* Points to Tcl object to be changed to a + * CmdName object. */ + Command *cmdPtr) /* Points to Command structure that the + * CmdName object should refer to. */ +{ + if (objPtr->typePtr == &tclCmdNameType) { + return; + } + + SetCmdNameObj(interp, objPtr, cmdPtr, NULL); } /* @@ -4360,10 +4379,8 @@ SetCmdNameFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ register Tcl_Obj *objPtr) /* The object to convert. */ { - Interp *iPtr = (Interp *) interp; const char *name; register Command *cmdPtr; - Namespace *currNsPtr; register ResolvedCmdName *resPtr; if (interp == NULL) { @@ -4391,52 +4408,23 @@ SetCmdNameFromAny( return TCL_ERROR; } - /* - * Free the old internalRep before setting the new one. Do this after - * getting the string rep to allow the conversion code (in particular, - * Tcl_GetStringFromObj) to use that old internalRep. - */ - - cmdPtr->refCount++; - resPtr = objPtr->internalRep.twoPtrValue.ptr1; - if ((objPtr->typePtr == &tclCmdNameType) && (resPtr->refCount == 1)) { - /* - * Reuse the old ResolvedCmdName struct instead of freeing it - */ + resPtr = objPtr->internalRep.twoPtrValue.ptr1; + if ((objPtr->typePtr == &tclCmdNameType) && (resPtr->refCount == 1)) { + /* + * Re-use existing ResolvedCmdName struct when possible. + * Cleanup the old fields that need it. + */ - Command *oldCmdPtr = resPtr->cmdPtr; + Command *oldCmdPtr = resPtr->cmdPtr; - if (--oldCmdPtr->refCount == 0) { - TclCleanupCommandMacro(oldCmdPtr); - } - } else { - TclFreeIntRep(objPtr); - resPtr = ckalloc(sizeof(ResolvedCmdName)); - resPtr->refCount = 1; - objPtr->internalRep.twoPtrValue.ptr1 = resPtr; - objPtr->internalRep.twoPtrValue.ptr2 = NULL; - objPtr->typePtr = &tclCmdNameType; + if (--oldCmdPtr->refCount == 0) { + TclCleanupCommandMacro(oldCmdPtr); } - resPtr->cmdPtr = cmdPtr; - resPtr->cmdEpoch = cmdPtr->cmdEpoch; - if ((*name++ == ':') && (*name == ':')) { - /* - * The name is fully qualified: set the referring namespace to - * NULL. - */ - - resPtr->refNsPtr = NULL; - } else { - /* - * Get the current namespace. - */ - - currNsPtr = iPtr->varFramePtr->nsPtr; + } else { + resPtr = NULL; + } - resPtr->refNsPtr = currNsPtr; - resPtr->refNsId = currNsPtr->nsId; - resPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; - } + SetCmdNameObj(interp, objPtr, cmdPtr, resPtr); return TCL_OK; } -- cgit v0.12 From 9cc388df3d06570e47d68f284a74f4fa26b45426 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 15 Jul 2016 14:20:34 +0000 Subject: Remove unmaintained disabled speculative code. Such things are for branches and history. --- generic/tclProc.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/generic/tclProc.c b/generic/tclProc.c index 81d3b25..bed520a 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -2654,30 +2654,6 @@ TclNRApplyObjCmd( procPtr = lambdaPtr->internalRep.twoPtrValue.ptr1; } -#define JOE_EXTENSION 0 -/* - * Note: this code is NOT FUNCTIONAL due to the NR implementation; DO NOT - * ENABLE! Leaving here as reminder to (a) TIP the suggestion, and (b) adapt - * the code. (MS) - */ - -#if JOE_EXTENSION - else { - /* - * Joe English's suggestion to allow cmdNames to function as lambdas. - */ - - Tcl_Obj *elemPtr; - int numElem; - - if ((lambdaPtr->typePtr == &tclCmdNameType) || - (TclListObjGetElements(interp, lambdaPtr, &numElem, - &elemPtr) == TCL_OK && numElem == 1)) { - return Tcl_EvalObjv(interp, objc-1, objv+1, 0); - } - } -#endif - if ((procPtr == NULL) || (procPtr->iPtr != iPtr)) { result = SetLambdaFromAny(interp, lambdaPtr); if (result != TCL_OK) { -- cgit v0.12 From 9015a7b063d96172512c54d84395d2b260d4d330 Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 16 Jul 2016 11:42:38 +0000 Subject: [77d58e3a7a] Test case independence: io, load, msgcat, namespace, safe. --- tests/io.test | 16 ++++++++++++++-- tests/load.test | 54 ++++++++++++++++++++++++++++++++++------------------ tests/msgcat.test | 11 +++++++++-- tests/namespace.test | 13 ++++++++----- tests/safe.test | 20 ++++++------------- 5 files changed, 72 insertions(+), 42 deletions(-) diff --git a/tests/io.test b/tests/io.test index 6b6ad6d..9573cc6 100644 --- a/tests/io.test +++ b/tests/io.test @@ -4285,6 +4285,13 @@ test io-33.4 {Tcl_Gets with long line} { close $f set x } {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} +set f [open $path(test3) w] +puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +puts $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +close $f test io-33.5 {Tcl_Gets with long line} { set f [open $path(test3)] set x [gets $f y] @@ -7141,7 +7148,12 @@ test io-52.10 {TclCopyChannel & encodings} {fcopy} { file size $path(utf8-fcopy.txt) } 5 -test io-52.11 {TclCopyChannel & encodings} {fcopy} { +test io-52.11 {TclCopyChannel & encodings} -setup { + set out [open $path(utf8-fcopy.txt) w] + fconfigure $out -encoding utf-8 -translation lf + puts $out "\u0410\u0410" + close $out +} -constraints {fcopy} -body { # binary to encoding => the input has to be # in utf-8 to make sense to the encoder @@ -7157,7 +7169,7 @@ test io-52.11 {TclCopyChannel & encodings} {fcopy} { close $out file size $path(kyrillic.txt) -} 3 +} -result 3 test io-52.12 {coverage of -translation auto} { file delete $path(test1) $path(test2) diff --git a/tests/load.test b/tests/load.test index 9536271..7c4b47f 100644 --- a/tests/load.test +++ b/tests/load.test @@ -124,9 +124,11 @@ test load-3.2 {error in _Init procedure, slave interpreter} \ test load-4.1 {reloading package into same interpreter} [list $dll $loaded] { list [catch {load [file join $testDir pkga$ext] pkga} msg] $msg } {0 {}} -test load-4.2 {reloading package into same interpreter} [list $dll $loaded] { - list [catch {load [file join $testDir pkga$ext] pkgb} msg] $msg -} [list 1 "file \"[file join $testDir pkga$ext]\" is already loaded for package \"Pkga\""] +test load-4.2 {reloading package into same interpreter} -setup { + catch {load [file join $testDir pkga$ext] pkga} +} -constraints [list $dll $loaded] -returnCodes error -body { + load [file join $testDir pkga$ext] pkgb +} -result "file \"[file join $testDir pkga$ext]\" is already loaded for package \"Pkga\"" test load-5.1 {file name not specified and no static package: pick default} \ [list $dll $loaded] { @@ -169,26 +171,40 @@ test load-7.3 {Tcl_StaticPackage procedure} [list teststaticpkg] { load {} More set x } {not loaded} -test load-7.4 {Tcl_StaticPackage procedure, redundant calls} \ - [list teststaticpkg $dll $loaded] { - teststaticpkg Double 0 1 - teststaticpkg Double 0 1 - info loaded - } [concat [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkge$ext] Pkge] [list [file join $testDir pkgb$ext] Pkgb] [list [file join $testDir pkga$ext] Pkga]] $alreadyTotalLoaded] +catch {load [file join $testDir pkga$ext] pkga} +catch {load [file join $testDir pkgb$ext] pkgb} +catch {load [file join $testDir pkge$ext] pkge} +set currentRealPackages [list [list [file join $testDir pkge$ext] Pkge] [list [file join $testDir pkgb$ext] Pkgb] [list [file join $testDir pkga$ext] Pkga]] +test load-7.4 {Tcl_StaticPackage procedure, redundant calls} -setup { + teststaticpkg Test 1 0 + teststaticpkg Another 0 0 + teststaticpkg More 0 1 +} -constraints [list teststaticpkg $dll $loaded] -body { + teststaticpkg Double 0 1 + teststaticpkg Double 0 1 + info loaded +} -result [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded] +teststaticpkg Test 1 1 +teststaticpkg Another 0 1 +teststaticpkg More 0 1 +teststaticpkg Double 0 1 test load-8.1 {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] { - info loaded -} [concat [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkge$ext] Pkge] [list [file join $testDir pkgb$ext] Pkgb] [list [file join $testDir pkga$ext] Pkga]] $alreadyTotalLoaded] -test load-8.2 {TclGetLoadedPackages procedure} [list teststaticpkg] { - list [catch {info loaded gorp} msg] $msg -} {1 {could not find interpreter "gorp"}} -test load-8.3 {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] { - list [info loaded {}] [info loaded child] -} [list [concat [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded] [list {{} Test} [list [file join $testDir pkgb$ext] Pkgb]]] + lsort -index 1 [info loaded] +} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded]] +test load-8.2 {TclGetLoadedPackages procedure} -body { + info loaded gorp +} -returnCodes error -result {could not find interpreter "gorp"} +test load-8.3a {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] { + lsort -index 1 [info loaded {}] +} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga] [list [file join $testDir pkgb$ext] Pkgb] {*}$alreadyLoaded]] +test load-8.3b {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] { + lsort -index 1 [info loaded child] +} [lsort -index 1 [list {{} Test} [list [file join $testDir pkgb$ext] Pkgb]]] test load-8.4 {TclGetLoadedPackages procedure} [list $dll $loaded teststaticpkg] { load [file join $testDir pkgb$ext] pkgb - list [info loaded {}] [lsort [info commands pkgb_*]] -} [list [concat [list [list [file join $testDir pkgb$ext] Pkgb] {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded] {pkgb_demo pkgb_sub pkgb_unsafe}] + list [lsort -index 1 [info loaded {}]] [lsort [info commands pkgb_*]] +} [list [lsort -index 1 [concat [list [list [file join $testDir pkgb$ext] Pkgb] {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded]] {pkgb_demo pkgb_sub pkgb_unsafe}] interp delete child test load-9.1 {Tcl_StaticPackage, load already-loaded package into another interp} \ diff --git a/tests/msgcat.test b/tests/msgcat.test index 8647f9c..ae35272 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -68,6 +68,7 @@ namespace eval ::msgcat::test { set result c } } + test msgcat-0.$count [list \ locale initialization from environment variables $setVars \ ] -setup { @@ -973,7 +974,10 @@ namespace eval ::msgcat::test { } set bgerrorsaved [interp bgerror {}] interp bgerror {} [namespace code callbackproc] - + + variable locale + if {![info exist locale]} { set locale [mclocale] } + test msgcat-14.1 {invokation loadcmd} -setup { mcforgetpackage mclocale $locale @@ -1068,7 +1072,7 @@ namespace eval ::msgcat::test { mc k1 } -returnCodes 1\ -result {fail} - + interp bgerror {} $bgerrorsaved cleanupTests @@ -1076,3 +1080,6 @@ namespace eval ::msgcat::test { namespace delete ::msgcat::test return +# Local Variables: +# mode: tcl +# End: diff --git a/tests/namespace.test b/tests/namespace.test index 55505f1..de7009d 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -846,6 +846,7 @@ test namespace-17.1 {Tcl_FindNamespaceVar, absolute name found} -setup { set ::x } } -result {314159} +variable ::x 314159 test namespace-17.2 {Tcl_FindNamespaceVar, absolute name found} { namespace eval test_ns_1 { variable x 777 @@ -889,23 +890,25 @@ test namespace-17.6 {Tcl_FindNamespaceVar, relative name found} -setup { } -result {777} test namespace-17.7 {Tcl_FindNamespaceVar, relative name found} { namespace eval test_ns_1 { + variable x 777 unset x set x ;# must be global x now } } {314159} -test namespace-17.8 {Tcl_FindNamespaceVar, relative name not found} { +test namespace-17.8 {Tcl_FindNamespaceVar, relative name not found} -body { namespace eval test_ns_1 { - list [catch {set wuzzat} msg] $msg + set wuzzat } -} {1 {can't read "wuzzat": no such variable}} +} -returnCodes error -result {can't read "wuzzat": no such variable} test namespace-17.9 {Tcl_FindNamespaceVar, relative name and TCL_GLOBAL_ONLY} { namespace eval test_ns_1 { variable a hello } set test_ns_1::a } {hello} -test namespace-17.10 {Tcl_FindNamespaceVar, interference with cached varNames} { +test namespace-17.10 {Tcl_FindNamespaceVar, interference with cached varNames} -setup { namespace eval test_ns_1 {} +} -body { proc test_ns {} { set ::test_ns_1::a 0 } @@ -916,7 +919,7 @@ test namespace-17.10 {Tcl_FindNamespaceVar, interference with cached varNames} { namespace eval test_ns_1 set a 1 namespace delete test_ns_1 return $a -} 1 +} -result 1 catch {unset a} catch {unset x} diff --git a/tests/safe.test b/tests/safe.test index 94c1755..6c9c6c9 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -211,8 +211,8 @@ test safe-7.3 {check that safe subinterpreters work} { } {ok {} 0} # test source control on file name +set i "a" test safe-8.1 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} } -body { safe::interpCreate $i @@ -221,7 +221,6 @@ test safe-8.1 {safe source control on file} -setup { safe::interpDelete $i } -result {wrong # args: should be "source ?-encoding E? fileName"} test safe-8.2 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} } -body { safe::interpCreate $i @@ -230,7 +229,6 @@ test safe-8.2 {safe source control on file} -setup { safe::interpDelete $i } -result {wrong # args: should be "source ?-encoding E? fileName"} test safe-8.3 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} set log {} proc safe-test-log {str} {lappend ::log $str} @@ -245,7 +243,6 @@ test safe-8.3 {safe source control on file} -setup { safe::interpDelete $i } -result {1 {permission denied} {{ERROR for slave a : ".": is a directory}}} test safe-8.4 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} set log {} proc safe-test-log {str} {global log; lappend log $str} @@ -260,7 +257,6 @@ test safe-8.4 {safe source control on file} -setup { safe::interpDelete $i } -result {1 {permission denied} {{ERROR for slave a : "/abc/def": not in access_path}}} test safe-8.5 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} set log {} proc safe-test-log {str} {global log; lappend log $str} @@ -279,7 +275,6 @@ test safe-8.5 {safe source control on file} -setup { safe::interpDelete $i } -result [list 1 {no such file or directory} [list "ERROR for slave a : [file join [info library] blah]:no such file or directory"]] test safe-8.6 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} set log {} proc safe-test-log {str} {global log; lappend log $str} @@ -296,7 +291,6 @@ test safe-8.6 {safe source control on file} -setup { safe::interpDelete $i } -result [list 1 {no such file or directory} [list "ERROR for slave a : [file join [info library] blah.tcl]:no such file or directory"]] test safe-8.7 {safe source control on file} -setup { - set i "a" catch {safe::interpDelete $i} set log {} proc safe-test-log {str} {global log; lappend log $str} @@ -315,7 +309,6 @@ test safe-8.7 {safe source control on file} -setup { safe::interpDelete $i } -result [list 1 {no such file or directory} [list "ERROR for slave a : [file join [info library] xxxxxxxxxxx.tcl]:no such file or directory"]] test safe-8.8 {safe source forbids -rsrc} -setup { - set i "a" catch {safe::interpDelete $i} safe::interpCreate $i } -body { @@ -349,8 +342,8 @@ test safe-8.10 {safe source and return} -setup { removeFile $returnScript } -result ok +set i "a" test safe-9.1 {safe interps' deleteHook} -setup { - set i "a" catch {safe::interpDelete $i} set res {} } -body { @@ -365,7 +358,6 @@ test safe-9.1 {safe interps' deleteHook} -setup { list [interp eval $i exit] $res } -result {{} {arg1 arg2 a}} test safe-9.2 {safe interps' error in deleteHook} -setup { - set i "a" catch {safe::interpDelete $i} set res {} set log {} @@ -531,14 +523,14 @@ test safe-11.7.1 {testing safe encoding} -setup { } -body { catch {interp eval $i encoding convertfrom} m o dict get $o -errorinfo -} -returnCodes ok -cleanup { +} -returnCodes ok -match glob -cleanup { unset -nocomplain m o safe::interpDelete $i } -result {wrong # args: should be "encoding convertfrom ?encoding? data" while executing "encoding convertfrom" invoked from within -"::interp invokehidden interp1 encoding convertfrom" +"::interp invokehidden interp* encoding convertfrom" invoked from within "encoding convertfrom" invoked from within @@ -555,14 +547,14 @@ test safe-11.8.1 {testing safe encoding} -setup { } -body { catch {interp eval $i encoding convertto} m o dict get $o -errorinfo -} -returnCodes ok -cleanup { +} -returnCodes ok -match glob -cleanup { unset -nocomplain m o safe::interpDelete $i } -result {wrong # args: should be "encoding convertto ?encoding? data" while executing "encoding convertto" invoked from within -"::interp invokehidden interp1 encoding convertto" +"::interp invokehidden interp* encoding convertto" invoked from within "encoding convertto" invoked from within -- cgit v0.12 From 812e86e692342eea4435ae5eb01bce552c7350e2 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 17 Jul 2016 11:56:28 +0000 Subject: [77d58e3a7a] Test case independence: unload. --- tests/tcltest.test | 7 ++- tests/unload.test | 170 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 125 insertions(+), 52 deletions(-) diff --git a/tests/tcltest.test b/tests/tcltest.test index e66678b..728a018 100644 --- a/tests/tcltest.test +++ b/tests/tcltest.test @@ -46,6 +46,7 @@ makeFile { cd [temporaryDirectory] testConstraint exec [llength [info commands exec]] + # test -help # Child processes because -help [exit]s. test tcltest-1.1 {tcltest -help} {exec} { @@ -1824,9 +1825,13 @@ test tcltest-26.2 {Bug/RFE 1017151} -setup { ---- errorInfo: body error * ---- errorInfo(cleanup): cleanup error*} - + cleanupTests } namespace delete ::tcltest::test return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/unload.test b/tests/unload.test index 5a374c4..73f1091 100644 --- a/tests/unload.test +++ b/tests/unload.test @@ -45,6 +45,14 @@ testConstraint teststaticpkg [llength [info commands teststaticpkg]] testConstraint testsimplefilesystem \ [llength [info commands testsimplefilesystem]] +proc loadIfNotPresent {pkg args} { + global testDir ext + set loaded [lmap x [info loaded {*}$args] {lindex $x 1}] + if {[string totitle $pkg] ni $loaded} { + load [file join $testDir $pkg$ext] + } +} + # Basic tests: parameter testing... test unload-1.1 {basic errors} -returnCodes error -body { unload @@ -73,7 +81,7 @@ set pkgua_detached {} set pkgua_unloaded {} # Tests for loading/unloading in trusted (non-safe) interpreters... test unload-2.1 {basic loading of non-unloadable package, with guess for package name} [list $dll $loaded] { - load [file join $testDir pkga$ext] + loadIfNotPresent pkga list [pkga_eq abc def] [lsort [info commands pkga_*]] } {0 {pkga_eq pkga_quote}} test unload-2.2 {basic loading of unloadable package, with guess for package name} [list $dll $loaded] { @@ -82,28 +90,43 @@ test unload-2.2 {basic loading of unloadable package, with guess for package nam [pkgua_eq abc def] [lsort [info commands pkgua_*]] \ $pkgua_loaded $pkgua_detached $pkgua_unloaded } {{} {} {} {} 0 {pkgua_eq pkgua_quote} . {} {}} -test unload-2.3 {basic unloading of non-unloadable package, with guess for package name} [list $dll $loaded] { - list [catch {unload [file join $testDir pkga$ext]} msg] \ - [string map [list [file join $testDir pkga$ext] file] $msg] -} {1 {file "file" cannot be unloaded under a trusted interpreter}} -test unload-2.4 {basic unloading of unloadable package, with guess for package name} [list $dll $loaded] { +test unload-2.3 {basic unloading of non-unloadable package, with guess for package name} -setup { + loadIfNotPresent pkga +} -constraints [list $dll $loaded] -returnCodes error -match glob -body { + unload [file join $testDir pkga$ext] +} -result {file "*" cannot be unloaded under a trusted interpreter} +test unload-2.4 {basic unloading of unloadable package, with guess for package name} -setup { + loadIfNotPresent pkgua +} -constraints [list $dll $loaded] -body { list $pkgua_loaded $pkgua_detached $pkgua_unloaded \ [unload [file join $testDir pkgua$ext]] \ [info commands pkgua_*] \ $pkgua_loaded $pkgua_detached $pkgua_unloaded -} {. {} {} {} {} . . .} -test unload-2.5 {reloading of unloaded package, with guess for package name} [list $dll $loaded] { +} -result {. {} {} {} {} . . .} +test unload-2.5 {reloading of unloaded package, with guess for package name} -setup { + if {$pkgua_loaded eq ""} { + loadIfNotPresent pkgua + unload [file join $testDir pkgua$ext] + } +} -constraints [list $dll $loaded] -body { list $pkgua_loaded $pkgua_detached $pkgua_unloaded \ [load [file join $testDir pkgua$ext]] \ [pkgua_eq abc def] [lsort [info commands pkgua_*]] \ $pkgua_loaded $pkgua_detached $pkgua_unloaded -} {. . . {} 0 {pkgua_eq pkgua_quote} .. . .} -test unload-2.6 {basic unloading of re-loaded package, with guess for package name} [list $dll $loaded] { +} -result {. . . {} 0 {pkgua_eq pkgua_quote} .. . .} +test unload-2.6 {basic unloading of re-loaded package, with guess for package name} -setup { + # Establish expected state + if {$pkgua_loaded eq ""} { + loadIfNotPresent pkgua + unload [file join $testDir pkgua$ext] + load [file join $testDir pkgua$ext] + } +} -constraints [list $dll $loaded] -body { list $pkgua_loaded $pkgua_detached $pkgua_unloaded \ [unload [file join $testDir pkgua$ext]] \ [info commands pkgua_*] \ $pkgua_loaded $pkgua_detached $pkgua_unloaded -} {.. . . {} {} .. .. ..} +} -result {.. . . {} {} .. .. ..} # Tests for loading/unloading in safe interpreters... interp create -safe child @@ -127,38 +150,52 @@ test unload-3.2 {basic loading of unloadable package in a safe interpreter, with [lsort [child eval info commands pkgua_*]] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] } {{{} {} {}} {} 0 {pkgua_eq pkgua_quote} {. {} {}}} -test unload-3.3 {unloading of a package that has never been loaded from a safe interpreter} \ - [list $dll $loaded] { - list [catch {unload [file join $testDir pkga$ext] {} child} msg] \ - [string map [list [file join $testDir pkga$ext] file] $msg] -} {1 {file "file" has never been loaded in this interpreter}} -test unload-3.4 {basic unloading of a non-unloadable package from a safe interpreter, with guess for package name} \ - [list $dll $loaded] { - list [catch {unload [file join $testDir pkgb$ext] {} child} msg] \ - [string map [list [file join $testDir pkgb$ext] file] $msg] -} {1 {file "file" cannot be unloaded under a safe interpreter}} -test unload-3.5 {basic unloading of an unloadable package from a safe interpreter, with guess for package name} \ - [list $dll $loaded] { +test unload-3.3 {unloading of a package that has never been loaded from a safe interpreter} -setup { + loadIfNotPresent pkga +} -constraints [list $dll $loaded] -returnCodes error -match glob -body { + unload [file join $testDir pkga$ext] {} child +} -result {file "*" has never been loaded in this interpreter} +test unload-3.4 {basic unloading of a non-unloadable package from a safe interpreter, with guess for package name} -setup { + if {[lsearch -index 1 [info loaded child] Pkgb] == -1} { + load [file join $testDir pkgb$ext] pKgB child + } +} -constraints [list $dll $loaded] -returnCodes error -match glob -body { + unload [file join $testDir pkgb$ext] {} child +} -result {file "*" cannot be unloaded under a safe interpreter} +test unload-3.5 {basic unloading of an unloadable package from a safe interpreter, with guess for package name} -setup { + if {[lsearch -index 1 [info loaded child] Pkgua] == -1} { + load [file join $testDir pkgua$ext] pkgua child + } +} -constraints [list $dll $loaded] -body { list [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [unload [file join $testDir pkgua$ext] {} child] \ [child eval info commands pkgua_*] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{. {} {}} {} {} {. . .}} -test unload-3.6 {reloading of unloaded package in a safe interpreter, with guess for package name} \ - [list $dll $loaded] { +} -result {{. {} {}} {} {} {. . .}} +test unload-3.6 {reloading of unloaded package in a safe interpreter, with guess for package name} -setup { + if {[child eval set pkgua_loaded] eq ""} { + load [file join $testDir pkgua$ext] {} child + unload [file join $testDir pkgua$ext] {} child + } +} -constraints [list $dll $loaded] -body { list [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [load [file join $testDir pkgua$ext] {} child] \ [child eval pkgua_eq abc def] \ [lsort [child eval info commands pkgua_*]] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{. . .} {} 0 {pkgua_eq pkgua_quote} {.. . .}} -test unload-3.7 {basic unloading of re-loaded package from a safe interpreter, with package name conversion} \ - [list $dll $loaded] { +} -result {{. . .} {} 0 {pkgua_eq pkgua_quote} {.. . .}} +test unload-3.7 {basic unloading of re-loaded package from a safe interpreter, with package name conversion} -setup { + if {[child eval set pkgua_loaded] eq ""} { + load [file join $testDir pkgua$ext] {} child + unload [file join $testDir pkgua$ext] {} child + load [file join $testDir pkgua$ext] {} child + } +} -constraints [list $dll $loaded] -body { list [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [unload [file join $testDir pkgua$ext] pKgUa child] \ [child eval info commands pkgua_*] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{.. . .} {} {} {.. .. ..}} +} -result {{.. . .} {} {} {.. .. ..}} # Tests for loading/unloading of a package among multiple interpreters... interp create child-trusted @@ -167,56 +204,89 @@ child-trusted eval { set pkgua_detached {} set pkgua_unloaded {} } +array set load {M 0 C 0 T 0} ## Load package in main trusted interpreter... -test unload-4.1 {loading of unloadable package in trusted interpreter, with guess for package name} \ - [list $dll $loaded] { +test unload-4.1 {loading of unloadable package in trusted interpreter, with guess for package name} -setup { + set pkgua_loaded "" + set pkgua_detached "" + set pkgua_unloaded "" + incr load(M) +} -constraints [list $dll $loaded] -body { list [list $pkgua_loaded $pkgua_detached $pkgua_unloaded] \ [load [file join $testDir pkgua$ext]] \ [pkgua_eq abc def] [lsort [info commands pkgua_*]] \ [list $pkgua_loaded $pkgua_detached $pkgua_unloaded] -} {{.. .. ..} {} 0 {pkgua_eq pkgua_quote} {... .. ..}} +} -result {{{} {} {}} {} 0 {pkgua_eq pkgua_quote} {. {} {}}} ## Load package in child-safe interpreter... -test unload-4.2 {basic loading of unloadable package in a safe interpreter, with package name conversion} \ - [list $dll $loaded] { +test unload-4.2 {basic loading of unloadable package in a safe interpreter, with package name conversion} -setup { + child eval { + set pkgua_loaded "" + set pkgua_detached "" + set pkgua_unloaded "" + } + incr load(C) +} -constraints [list $dll $loaded] -body { list [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [load [file join $testDir pkgua$ext] pKgUA child] \ [child eval pkgua_eq abc def] \ [lsort [child eval info commands pkgua_*]] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{.. .. ..} {} 0 {pkgua_eq pkgua_quote} {... .. ..}} +} -result {{{} {} {}} {} 0 {pkgua_eq pkgua_quote} {. {} {}}} ## Load package in child-trusted interpreter... -test unload-4.3 {basic loading of unloadable package in a second trusted interpreter, with package name conversion} \ - [list $dll $loaded] { +test unload-4.3 {basic loading of unloadable package in a second trusted interpreter, with package name conversion} -setup { + incr load(T) +} -constraints [list $dll $loaded] -body { list [child-trusted eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [load [file join $testDir pkgua$ext] pkguA child-trusted] \ [child-trusted eval pkgua_eq abc def] \ [lsort [child-trusted eval info commands pkgua_*]] \ [child-trusted eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{{} {} {}} {} 0 {pkgua_eq pkgua_quote} {. {} {}}} +} -result {{{} {} {}} {} 0 {pkgua_eq pkgua_quote} {. {} {}}} ## Unload the package from the main trusted interpreter... -test unload-4.4 {basic unloading of unloadable package from trusted interpreter, with guess for package name} \ - [list $dll $loaded] { +test unload-4.4 {basic unloading of unloadable package from trusted interpreter, with guess for package name} -setup { + if {!$load(M)} { + load [file join $testDir pkgua$ext] + } + if {!$load(C)} { + load [file join $testDir pkgua$ext] {} child + incr load(C) + } + if {!$load(T)} { + load [file join $testDir pkgua$ext] {} child-trusted + incr load(T) + } +} -constraints [list $dll $loaded] -body { list [list $pkgua_loaded $pkgua_detached $pkgua_unloaded] \ [unload [file join $testDir pkgua$ext]] \ [info commands pkgua_*] \ [list $pkgua_loaded $pkgua_detached $pkgua_unloaded] -} {{... .. ..} {} {} {... ... ..}} +} -result {{. {} {}} {} {} {. . {}}} ## Unload the package from the child safe interpreter... -test unload-4.5 {basic unloading of unloadable package from a safe interpreter, with guess for package name} \ - [list $dll $loaded] { +test unload-4.5 {basic unloading of unloadable package from a safe interpreter, with guess for package name} -setup { + if {!$load(C)} { + load [file join $testDir pkgua$ext] {} child + } + if {!$load(T)} { + load [file join $testDir pkgua$ext] {} child-trusted + incr load(T) + } +} -constraints [list $dll $loaded] -body { list [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [unload [file join $testDir pkgua$ext] {} child] \ [child eval info commands pkgua_*] \ [child eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{... .. ..} {} {} {... ... ..}} +} -result {{. {} {}} {} {} {. . {}}} ## Unload the package from the child trusted interpreter... -test unload-4.6 {basic unloading of unloadable package from a safe interpreter, with guess for package name} \ - [list $dll $loaded] { +test unload-4.6 {basic unloading of unloadable package from a safe interpreter, with guess for package name} -setup { + if {!$load(T)} { + load [file join $testDir pkgua$ext] {} child-trusted + } +} -constraints [list $dll $loaded] -body { list [child-trusted eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] \ [unload [file join $testDir pkgua$ext] {} child-trusted] \ [child-trusted eval info commands pkgua_*] \ [child-trusted eval {list $pkgua_loaded $pkgua_detached $pkgua_unloaded}] -} {{. {} {}} {} {} {. . .}} +} -result {{. {} {}} {} {} {. . .}} test unload-5.1 {unload a module loaded from vfs} \ -constraints [list $dll $loaded testsimplefilesystem] \ @@ -230,9 +300,7 @@ test unload-5.1 {unload a module loaded from vfs} \ list [catch {unload simplefs:/pkgua$ext} msg] $msg } \ -result {0 {}} - - - + # cleanup interp delete child interp delete child-trusted -- cgit v0.12 From 30b6493bb7a01568ed7fa236badef647b30ad038 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 17 Jul 2016 12:02:27 +0000 Subject: [77d58e3a7a] Test case independence: var. --- tests/var.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/var.test b/tests/var.test index 690bd10..297034a 100644 --- a/tests/var.test +++ b/tests/var.test @@ -169,7 +169,9 @@ test var-1.17 {TclLookupVar, resurrect array element via upvar to deleted array: set result } } {0 2 1 {can't set "foo": upvar refers to element in deleted array}} -test var-1.18 {TclLookupVar, resurrect array element via upvar to deleted array: uncompiled code path} { +test var-1.18 {TclLookupVar, resurrect array element via upvar to deleted array: uncompiled code path} -setup { + unset -nocomplain test_ns_var::x +} -body { namespace eval test_ns_var { variable result {} variable x @@ -181,7 +183,7 @@ test var-1.18 {TclLookupVar, resurrect array element via upvar to deleted array: namespace delete [namespace current] set result } -} {0 2 1 {can't set "foo": upvar refers to element in deleted array}} +} -result {0 2 1 {can't set "foo": upvar refers to element in deleted array}} test var-1.19 {TclLookupVar, right error message when parsing variable name} -body { [format set] thisvar(doesntexist) } -returnCodes error -result {can't read "thisvar(doesntexist)": no such variable} -- cgit v0.12 From a127a9e4aa8b2a9a386cd7fe694bfef8f1cf5264 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 18 Jul 2016 16:26:44 +0000 Subject: [104f2885bb] Rework the "chan" Tcl_ObjType to properly validate cached channel name lookups. --- generic/tclIO.c | 161 ++++++++++++++++++++++++++------------------------------ generic/tclIO.h | 6 +-- tests/io.test | 19 +++++++ 3 files changed, 97 insertions(+), 89 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 7bc849e..615fe60 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -312,14 +312,20 @@ static int WillRead(Channel *chanPtr); && (strncmp(optionName, (nameString), len) == 0)) /* - * The ChannelObjType type. We actually store the ChannelState structure - * as that lives longest and we want to return the bottomChanPtr when - * requested (consistent with Tcl_GetChannel). The setFromAny and - * updateString can be NULL as they should not be called. + * The ChannelObjType type. Used to store the result of looking up + * a channel name in the context of an interp. Saves the lookup + * result and values needed to check its continued validity. */ +typedef struct ResolvedChanName { + ChannelState *statePtr; /* The saved lookup result */ + Tcl_Interp *interp; /* The interp in which the lookup was done. */ + int epoch; /* The epoch of the channel when the lookup + * was done. Use to verify validity. */ + int refCount; /* Share this struct among many Tcl_Obj. */ +} ResolvedChanName; + static void DupChannelIntRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr); -static int SetChannelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static void FreeChannelIntRep(Tcl_Obj *objPtr); static Tcl_ObjType chanObjType = { @@ -327,18 +333,9 @@ static Tcl_ObjType chanObjType = { FreeChannelIntRep, /* freeIntRepProc */ DupChannelIntRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc SetChannelFromAny */ + NULL /* setFromAnyProc */ }; -#define GET_CHANNELSTATE(objPtr) \ - ((ChannelState *) (objPtr)->internalRep.twoPtrValue.ptr1) -#define SET_CHANNELSTATE(objPtr, storePtr) \ - ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (storePtr)) -#define GET_CHANNELINTERP(objPtr) \ - ((Tcl_Interp *) (objPtr)->internalRep.twoPtrValue.ptr2) -#define SET_CHANNELINTERP(objPtr, storePtr) \ - ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (storePtr)) - #define BUSY_STATE(st,fl) \ ((((st)->csPtrR) && ((fl) & TCL_READABLE)) || \ (((st)->csPtrW) && ((fl) & TCL_WRITABLE))) @@ -936,7 +933,7 @@ DeleteChannelTable( */ Tcl_DeleteHashEntry(hPtr); - SetFlag(statePtr, CHANNEL_TAINTED); + statePtr->epoch++; statePtr->refCount--; if (statePtr->refCount <= 0) { if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED)) { @@ -1280,7 +1277,7 @@ DetachChannel( return TCL_ERROR; } Tcl_DeleteHashEntry(hPtr); - SetFlag(statePtr, CHANNEL_TAINTED); + statePtr->epoch++; /* * Remove channel handlers that refer to this interpreter, so that @@ -1413,12 +1410,57 @@ TclGetChannelFromObj( int flags) { ChannelState *statePtr; + ResolvedChanName *resPtr = NULL; + Tcl_Channel chan; + + if (interp == NULL) { + return TCL_ERROR; + } + + if (objPtr->typePtr == &chanObjType) { + /* + * Confirm validity of saved lookup results. + */ + + resPtr = (ResolvedChanName *) objPtr->internalRep.twoPtrValue.ptr1; + statePtr = resPtr->statePtr; + if ((resPtr->interp == interp) /* Same interp context */ + /* No epoch change in channel since lookup */ + && (resPtr->epoch == statePtr->epoch)) { + + /* Have a valid saved lookup. Jump to end to return it. */ + goto valid; + } + } + + chan = Tcl_GetChannel(interp, TclGetString(objPtr), NULL); - if (SetChannelFromAny(interp, objPtr) != TCL_OK) { + if (chan == NULL) { + if (resPtr) { + FreeChannelIntRep(objPtr); + } return TCL_ERROR; } - statePtr = GET_CHANNELSTATE(objPtr); + if (resPtr && resPtr->refCount == 1) { + /* Re-use the ResolvedCmdName struct */ + Tcl_Release((ClientData) resPtr->statePtr); + + } else { + TclFreeIntRep(objPtr); + + resPtr = (ResolvedChanName *) ckalloc(sizeof(ResolvedChanName)); + resPtr->refCount = 1; + objPtr->internalRep.twoPtrValue.ptr1 = (ClientData) resPtr; + objPtr->typePtr = &chanObjType; + } + statePtr = ((Channel *)chan)->state; + resPtr->statePtr = statePtr; + Tcl_Preserve((ClientData) statePtr); + resPtr->interp = interp; + resPtr->epoch = statePtr->epoch; + + valid: *channelPtr = (Tcl_Channel) (statePtr->bottomChanPtr); if (modePtr != NULL) { @@ -1568,6 +1610,8 @@ Tcl_CreateChannel( statePtr->chanMsg = NULL; statePtr->unreportedMsg = NULL; + statePtr->epoch = 0; + /* * Link the channel into the list of all channels; create an on-exit * handler if there is not one already, to close off all the channels in @@ -10439,78 +10483,17 @@ DupChannelIntRep( register Tcl_Obj *copyPtr) /* Object with internal rep to set. Must not * currently have an internal rep.*/ { - ChannelState *statePtr = GET_CHANNELSTATE(srcPtr); + ResolvedChanName *resPtr + = (ResolvedChanName *) srcPtr->internalRep.twoPtrValue.ptr1; - SET_CHANNELSTATE(copyPtr, statePtr); - SET_CHANNELINTERP(copyPtr, GET_CHANNELINTERP(srcPtr)); - Tcl_Preserve((ClientData) statePtr); + resPtr->refCount++; + copyPtr->internalRep.twoPtrValue.ptr1 = resPtr; copyPtr->typePtr = srcPtr->typePtr; } /* *---------------------------------------------------------------------- * - * SetChannelFromAny -- - * - * Create an internal representation of type "Channel" for an object. - * - * Results: - * This operation always succeeds and returns TCL_OK. - * - * Side effects: - * Any old internal reputation for objPtr is freed and the internal - * representation is set to "Channel". - * - *---------------------------------------------------------------------- - */ - -static int -SetChannelFromAny( - Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr) /* The object to convert. */ -{ - ChannelState *statePtr; - - if (interp == NULL) { - return TCL_ERROR; - } - if (objPtr->typePtr == &chanObjType) { - /* - * TODO: TAINT Flag and dup'd channel values? - * The channel is valid until any call to DetachChannel occurs. - * Ensure consistency checks are done. - */ - - statePtr = GET_CHANNELSTATE(objPtr); - if (GotFlag(statePtr, CHANNEL_TAINTED|CHANNEL_CLOSED)) { - ResetFlag(statePtr, CHANNEL_TAINTED); - Tcl_Release((ClientData) statePtr); - objPtr->typePtr = NULL; - } else if (interp != GET_CHANNELINTERP(objPtr)) { - Tcl_Release((ClientData) statePtr); - objPtr->typePtr = NULL; - } - } - if (objPtr->typePtr != &chanObjType) { - Tcl_Channel chan = Tcl_GetChannel(interp, TclGetString(objPtr), NULL); - - if (chan == NULL) { - return TCL_ERROR; - } - - TclFreeIntRep(objPtr); - statePtr = ((Channel *)chan)->state; - Tcl_Preserve((ClientData) statePtr); - SET_CHANNELSTATE(objPtr, statePtr); - SET_CHANNELINTERP(objPtr, interp); - objPtr->typePtr = &chanObjType; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * * FreeChannelIntRep -- * * Release statePtr storage. @@ -10528,7 +10511,15 @@ static void FreeChannelIntRep( Tcl_Obj *objPtr) /* Object with internal rep to free. */ { - Tcl_Release((ClientData) GET_CHANNELSTATE(objPtr)); + ResolvedChanName *resPtr + = (ResolvedChanName *) objPtr->internalRep.twoPtrValue.ptr1; + + objPtr->typePtr = NULL; + if (--resPtr->refCount) { + return; + } + Tcl_Release((ClientData) resPtr->statePtr); + ckfree((char *)resPtr); } #if 0 diff --git a/generic/tclIO.h b/generic/tclIO.h index 348a9c5..d096798 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -214,6 +214,8 @@ typedef struct ChannelState { * because it happened in the background. The * value is the chanMg, if any. #219's * companion to 'unreportedError'. */ + int epoch; /* Used to test validity of stored channelname + * lookup results. */ } ChannelState; /* @@ -275,10 +277,6 @@ typedef struct ChannelState { * usable, but it may not be closed * again from within the close * handler. */ -#define CHANNEL_TAINTED (1<<20) /* Channel stack structure has changed. - * Used by Channel Tcl_Obj type to - * determine if we have to revalidate - * the channel. */ /* * Local Variables: diff --git a/tests/io.test b/tests/io.test index 50c5808..7275b42 100644 --- a/tests/io.test +++ b/tests/io.test @@ -38,6 +38,7 @@ testConstraint testfevent [llength [info commands testfevent]] testConstraint testchannelevent [llength [info commands testchannelevent]] testConstraint testmainthread [llength [info commands testmainthread]] testConstraint testthread [llength [info commands testthread]] +testConstraint testobj [llength [info commands testobj]] # You need a *very* special environment to do some tests. In # particular, many file systems do not support large-files... @@ -8522,6 +8523,24 @@ test io-73.5 {effect of eof on encoding end flags} -setup { removeFile io-73.5 } -result [list 1 1 more\u00a0data 1] +test io-74.1 {[104f2885bb] improper cache validity check} -setup { + set fn [makeFile {} io-74.1] + set rfd [open $fn r] + testobj freeallvars + interp create slave +} -constraints testobj -body { + teststringobj set 1 [string range $rfd 0 end] + read [teststringobj get 1] + testobj duplicate 1 2 + interp transfer {} $rfd slave + catch {read [teststringobj get 1]} + read [teststringobj get 2] +} -cleanup { + interp delete slave + testobj freeallvars + removeFile io-74.1 +} -returnCodes error -match glob -result {can not find channel named "*"} + # ### ### ### ######### ######### ######### # cleanup -- cgit v0.12 From 3030616f91ca88f302a094e9f7388f5c7971fe3a Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 19 Jul 2016 15:00:51 +0000 Subject: Remove outdated comment. --- generic/tclVar.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tclVar.c b/generic/tclVar.c index 47c6e14..2adffbc 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -219,10 +219,6 @@ static Tcl_SetFromAnyProc PanicOnSetVarName; * or NULL if it is this same obj * twoPtrValue.ptr2: index into locals table * - * nsVarName - INTERNALREP DEFINITION: - * twoPtrValue.ptr1: pointer to the namespace containing the reference - * twoPtrValue.ptr2: pointer to the corresponding Var - * * parsedVarName - INTERNALREP DEFINITION: * twoPtrValue.ptr1: pointer to the array name Tcl_Obj, or NULL if it is a * scalar variable -- cgit v0.12 From 883ca7abcd437926de756a838f60e7574f111881 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 19 Jul 2016 19:31:28 +0000 Subject: [0363f0146c] Fix [array startsearch] id handling to support var name variations --- generic/tclInt.h | 1 - generic/tclObj.c | 1 - generic/tclVar.c | 171 ++++++++++--------------------------------------------- 3 files changed, 31 insertions(+), 142 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 4ecac7d..b39c8ea 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2707,7 +2707,6 @@ MODULE_SCOPE const Tcl_ObjType tclListType; MODULE_SCOPE const Tcl_ObjType tclDictType; MODULE_SCOPE const Tcl_ObjType tclProcBodyType; MODULE_SCOPE const Tcl_ObjType tclStringType; -MODULE_SCOPE const Tcl_ObjType tclArraySearchType; MODULE_SCOPE const Tcl_ObjType tclEnsembleCmdType; #ifndef TCL_WIDE_INT_IS_LONG MODULE_SCOPE const Tcl_ObjType tclWideIntType; diff --git a/generic/tclObj.c b/generic/tclObj.c index b145d7e..df17f13 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -402,7 +402,6 @@ TclInitObjSubsystem(void) Tcl_RegisterObjType(&tclListType); Tcl_RegisterObjType(&tclDictType); Tcl_RegisterObjType(&tclByteCodeType); - Tcl_RegisterObjType(&tclArraySearchType); Tcl_RegisterObjType(&tclCmdNameType); Tcl_RegisterObjType(&tclRegexpType); Tcl_RegisterObjType(&tclProcBodyType); diff --git a/generic/tclVar.c b/generic/tclVar.c index 091baf8..a4f1ec5 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -149,6 +149,7 @@ static const char *isArrayElement = */ typedef struct ArraySearch { + Tcl_Obj *name; /* Name of this search */ int id; /* Integer id used to distinguish among * multiple concurrent searches for the same * array. */ @@ -188,8 +189,6 @@ static ArraySearch * ParseSearchId(Tcl_Interp *interp, const Var *varPtr, static void UnsetVarStruct(Var *varPtr, Var *arrayPtr, Interp *iPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags, int index); -static int SetArraySearchObj(Tcl_Interp *interp, - Tcl_Obj *objPtr); /* * Functions defined in this file that may be exported in the future for use @@ -235,22 +234,6 @@ static const Tcl_ObjType tclParsedVarNameType = { FreeParsedVarName, DupParsedVarName, NULL, NULL }; -/* - * Type of Tcl_Objs used to speed up array searches. - * - * INTERNALREP DEFINITION: - * twoPtrValue.ptr1: searchIdNumber (cast to pointer) - * twoPtrValue.ptr2: variableNameStartInString (cast to pointer) - * - * Note that the value stored in ptr2 is the offset into the string of the - * start of the variable name and not the address of the variable name itself, - * as this can be safely copied. - */ - -const Tcl_ObjType tclArraySearchType = { - "array search", - NULL, NULL, NULL, SetArraySearchObj -}; Var * TclVarHashCreateVar( @@ -2966,8 +2949,9 @@ ArrayStartSearchCmd( searchPtr->nextEntry = VarHashFirstEntry(varPtr->value.tablePtr, &searchPtr->search); Tcl_SetHashValue(hPtr, searchPtr); - Tcl_SetObjResult(interp, - Tcl_ObjPrintf("s-%d-%s", searchPtr->id, varName)); + searchPtr->name = Tcl_ObjPrintf("s-%d-%s", searchPtr->id, varName); + Tcl_IncrRefCount(searchPtr->name); + Tcl_SetObjResult(interp, searchPtr->name); return TCL_OK; } @@ -3291,6 +3275,7 @@ ArrayDoneSearchCmd( } } } + Tcl_DecrRefCount(searchPtr->name); ckfree(searchPtr); return TCL_OK; } @@ -4930,75 +4915,6 @@ Tcl_UpvarObjCmd( /* *---------------------------------------------------------------------- * - * SetArraySearchObj -- - * - * This function converts the given tcl object into one that has the - * "array search" internal type. - * - * Results: - * TCL_OK if the conversion succeeded, and TCL_ERROR if it failed (when - * an error message will be placed in the interpreter's result.) - * - * Side effects: - * Updates the internal type and representation of the object to make - * this an array-search object. See the tclArraySearchType declaration - * above for details of the internal representation. - * - *---------------------------------------------------------------------- - */ - -static int -SetArraySearchObj( - Tcl_Interp *interp, - Tcl_Obj *objPtr) -{ - const char *string; - char *end; /* Can't be const due to strtoul defn. */ - int id; - size_t offset; - - /* - * Get the string representation. Make it up-to-date if necessary. - */ - - string = TclGetString(objPtr); - - /* - * Parse the id into the three parts separated by dashes. - */ - - if ((string[0] != 's') || (string[1] != '-')) { - goto syntax; - } - id = strtoul(string+2, &end, 10); - if ((end == (string+2)) || (*end != '-')) { - goto syntax; - } - - /* - * Can't perform value check in this context, so place reference to place - * in string to use for the check in the object instead. - */ - - end++; - offset = end - string; - - TclFreeIntRep(objPtr); - objPtr->typePtr = &tclArraySearchType; - objPtr->internalRep.twoPtrValue.ptr1 = INT2PTR(id); - objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(offset); - return TCL_OK; - - syntax: - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "illegal search identifier \"%s\"", string)); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAYSEARCH", string, NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * * ParseSearchId -- * * This function translates from a tcl object to a pointer to an active @@ -5009,10 +4925,6 @@ SetArraySearchObj( * or NULL if there isn't one. If NULL is returned, the interp's result * contains an error message. * - * Side effects: - * The tcl object might have its internal type and representation - * modified. - * *---------------------------------------------------------------------- */ @@ -5028,65 +4940,43 @@ ParseSearchId( * name. */ { Interp *iPtr = (Interp *) interp; - register const char *string; - register size_t offset; - int id; ArraySearch *searchPtr; - const char *varName = TclGetString(varNamePtr); - - /* - * Parse the id. - */ - - if ((handleObj->typePtr != &tclArraySearchType) - && (SetArraySearchObj(interp, handleObj) != TCL_OK)) { - return NULL; - } - - /* - * Extract the information out of the Tcl_Obj. - */ - - id = PTR2INT(handleObj->internalRep.twoPtrValue.ptr1); - string = TclGetString(handleObj); - offset = PTR2INT(handleObj->internalRep.twoPtrValue.ptr2); - - /* - * This test cannot be placed inside the Tcl_Obj machinery, since it is - * dependent on the variable context. - */ - - if (strcmp(string+offset, varName) != 0) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "search identifier \"%s\" isn't for variable \"%s\"", - string, varName)); - goto badLookup; - } - - /* - * Search through the list of active searches on the interpreter to see if - * the desired one exists. - * - * Note that we cannot store the searchPtr directly in the Tcl_Obj as that - * would run into trouble when DeleteSearches() was called so we must scan - * this list every time. - */ + const char *handle = TclGetString(handleObj); + char *end; if (varPtr->flags & VAR_SEARCH_ACTIVE) { Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&iPtr->varSearches, varPtr); + /* First look for same (Tcl_Obj *) */ for (searchPtr = Tcl_GetHashValue(hPtr); searchPtr != NULL; searchPtr = searchPtr->nextPtr) { - if (searchPtr->id == id) { + if (searchPtr->name == handleObj) { return searchPtr; } } + /* Fallback: do string compares. */ + for (searchPtr = Tcl_GetHashValue(hPtr); searchPtr != NULL; + searchPtr = searchPtr->nextPtr) { + if (strcmp(TclGetString(searchPtr->name), handle) == 0) { + return searchPtr; + } + } + } + if ((handle[0] != 's') || (handle[1] != '-') + || (strtoul(handle + 2, &end, 10), end == (handle + 2)) + || (*end != '-')) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "illegal search identifier \"%s\"", handle)); + } else if (strcmp(end + 1, TclGetString(varNamePtr)) != 0) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "search identifier \"%s\" isn't for variable \"%s\"", + handle, TclGetString(varNamePtr))); + } else { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "couldn't find search \"%s\"", handle)); } - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "couldn't find search \"%s\"", string)); - badLookup: - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAYSEARCH", string, NULL); + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAYSEARCH", handle, NULL); return NULL; } @@ -5121,6 +5011,7 @@ DeleteSearches( for (searchPtr = Tcl_GetHashValue(sPtr); searchPtr != NULL; searchPtr = nextPtr) { nextPtr = searchPtr->nextPtr; + Tcl_DecrRefCount(searchPtr->name); ckfree(searchPtr); } arrayVarPtr->flags &= ~VAR_SEARCH_ACTIVE; -- cgit v0.12 From 27f4a98be411aa6878d45e7e86e5c90cf2208c92 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 19 Jul 2016 19:33:35 +0000 Subject: "array search" is no longer a registered Tcl_ObjType. --- tests/obj.test | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/obj.test b/tests/obj.test index 7bf00f7..a8d2d20 100644 --- a/tests/obj.test +++ b/tests/obj.test @@ -26,7 +26,6 @@ testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}] test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} testobj { set r 1 foreach {t} { - {array search} bytearray bytecode cmdName -- cgit v0.12 From c235e3492b4494286cee64ae3a29ff161c62a821 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 19 Jul 2016 20:40:27 +0000 Subject: Factor out common prologue. --- generic/tclVar.c | 176 +++++++++++++++---------------------------------------- 1 file changed, 48 insertions(+), 128 deletions(-) diff --git a/generic/tclVar.c b/generic/tclVar.c index 1d08832..56c5a05 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -189,6 +189,7 @@ static ArraySearch * ParseSearchId(Tcl_Interp *interp, const Var *varPtr, static void UnsetVarStruct(Var *varPtr, Var *arrayPtr, Interp *iPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags, int index); +static Var * VerifyArray(Tcl_Interp *interp, Tcl_Obj *varNameObj); /* * Functions defined in this file that may be exported in the future for use @@ -2870,34 +2871,22 @@ TclArraySet( */ /* ARGSUSED */ -static int -ArrayStartSearchCmd( - ClientData clientData, + +static Var * +VerifyArray( Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) + Tcl_Obj *varNameObj) { Interp *iPtr = (Interp *) interp; - Var *varPtr, *arrayPtr; - Tcl_HashEntry *hPtr; - Tcl_Obj *varNameObj; - int isNew; - ArraySearch *searchPtr; - const char *varName; - - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "arrayName"); - return TCL_ERROR; - } - varNameObj = objv[1]; + const char *varName = TclGetString(varNameObj); + Var *arrayPtr; /* * Locate the array variable. */ - varPtr = TclObjLookupVarEx(interp, varNameObj, NULL, /*flags*/ 0, + Var *varPtr = TclObjLookupVarEx(interp, varNameObj, NULL, /*flags*/ 0, /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr); - varName = TclGetString(varNameObj); /* * Special array trace used to keep the env array in sync for array names, @@ -2909,7 +2898,7 @@ ArrayStartSearchCmd( if (TclObjCallVarTraces(iPtr, arrayPtr, varPtr, varNameObj, NULL, (TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY| TCL_TRACE_ARRAY), /* leaveErrMsg */ 1, -1) == TCL_ERROR) { - return TCL_ERROR; + return NULL; } } @@ -2919,11 +2908,36 @@ ArrayStartSearchCmd( * traces. */ - if ((varPtr == NULL) || !TclIsVarArray(varPtr) - || TclIsVarUndefined(varPtr)) { + if ((varPtr == NULL) || !TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" isn't an array", varName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAY", varName, NULL); + return NULL; + } + + return varPtr; +} + +static int +ArrayStartSearchCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) +{ + Interp *iPtr = (Interp *) interp; + Var *varPtr; + Tcl_HashEntry *hPtr; + int isNew; + ArraySearch *searchPtr; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "arrayName"); + return TCL_ERROR; + } + + varPtr = VerifyArray(interp, objv[1]); + if (varPtr == NULL) { return TCL_ERROR; } @@ -2945,7 +2959,7 @@ ArrayStartSearchCmd( searchPtr->nextEntry = VarHashFirstEntry(varPtr->value.tablePtr, &searchPtr->search); Tcl_SetHashValue(hPtr, searchPtr); - searchPtr->name = Tcl_ObjPrintf("s-%d-%s", searchPtr->id, varName); + searchPtr->name = Tcl_ObjPrintf("s-%d-%s", searchPtr->id, TclGetString(objv[1])); Tcl_IncrRefCount(searchPtr->name); Tcl_SetObjResult(interp, searchPtr->name); return TCL_OK; @@ -2977,7 +2991,7 @@ ArrayAnyMoreCmd( Tcl_Obj *const objv[]) { Interp *iPtr = (Interp *) interp; - Var *varPtr, *arrayPtr; + Var *varPtr; Tcl_Obj *varNameObj, *searchObj; int gotValue; ArraySearch *searchPtr; @@ -2989,42 +3003,11 @@ ArrayAnyMoreCmd( varNameObj = objv[1]; searchObj = objv[2]; - /* - * Locate the array variable. - */ - - varPtr = TclObjLookupVarEx(interp, varNameObj, NULL, /*flags*/ 0, - /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr); - - /* - * Special array trace used to keep the env array in sync for array names, - * array get, etc. - */ - - if (varPtr && (varPtr->flags & VAR_TRACED_ARRAY) - && (TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr))) { - if (TclObjCallVarTraces(iPtr, arrayPtr, varPtr, varNameObj, NULL, - (TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY| - TCL_TRACE_ARRAY), /* leaveErrMsg */ 1, -1) == TCL_ERROR) { - return TCL_ERROR; - } - } - - /* - * Verify that it is indeed an array variable. This test comes after the - * traces - the variable may actually become an array as an effect of said - * traces. - */ - - if ((varPtr == NULL) || !TclIsVarArray(varPtr) - || TclIsVarUndefined(varPtr)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "\"%s\" isn't an array", TclGetString(varNameObj))); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAY", - TclGetString(varNameObj), NULL); + varPtr = VerifyArray(interp, varNameObj); + if (varPtr == NULL) { return TCL_ERROR; } - + /* * Get the search. */ @@ -3083,8 +3066,7 @@ ArrayNextElementCmd( int objc, Tcl_Obj *const objv[]) { - Interp *iPtr = (Interp *) interp; - Var *varPtr, *arrayPtr; + Var *varPtr; Tcl_Obj *varNameObj, *searchObj; ArraySearch *searchPtr; @@ -3095,41 +3077,10 @@ ArrayNextElementCmd( varNameObj = objv[1]; searchObj = objv[2]; - /* - * Locate the array variable. - */ - - varPtr = TclObjLookupVarEx(interp, varNameObj, NULL, /*flags*/ 0, - /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr); - - /* - * Special array trace used to keep the env array in sync for array names, - * array get, etc. - */ - - if (varPtr && (varPtr->flags & VAR_TRACED_ARRAY) - && (TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr))) { - if (TclObjCallVarTraces(iPtr, arrayPtr, varPtr, varNameObj, NULL, - (TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY| - TCL_TRACE_ARRAY), /* leaveErrMsg */ 1, -1) == TCL_ERROR) { - return TCL_ERROR; - } - } - - /* - * Verify that it is indeed an array variable. This test comes after the - * traces - the variable may actually become an array as an effect of said - * traces. - */ - - if ((varPtr == NULL) || !TclIsVarArray(varPtr) - || TclIsVarUndefined(varPtr)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "\"%s\" isn't an array", TclGetString(varNameObj))); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAY", - TclGetString(varNameObj), NULL); + varPtr = VerifyArray(interp, varNameObj); + if (varPtr == NULL) { return TCL_ERROR; - } + } /* * Get the search. @@ -3193,7 +3144,7 @@ ArrayDoneSearchCmd( Tcl_Obj *const objv[]) { Interp *iPtr = (Interp *) interp; - Var *varPtr, *arrayPtr; + Var *varPtr; Tcl_HashEntry *hPtr; Tcl_Obj *varNameObj, *searchObj; ArraySearch *searchPtr, *prevPtr; @@ -3205,39 +3156,8 @@ ArrayDoneSearchCmd( varNameObj = objv[1]; searchObj = objv[2]; - /* - * Locate the array variable. - */ - - varPtr = TclObjLookupVarEx(interp, varNameObj, NULL, /*flags*/ 0, - /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr); - - /* - * Special array trace used to keep the env array in sync for array names, - * array get, etc. - */ - - if (varPtr && (varPtr->flags & VAR_TRACED_ARRAY) - && (TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr))) { - if (TclObjCallVarTraces(iPtr, arrayPtr, varPtr, varNameObj, NULL, - (TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY| - TCL_TRACE_ARRAY), /* leaveErrMsg */ 1, -1) == TCL_ERROR) { - return TCL_ERROR; - } - } - - /* - * Verify that it is indeed an array variable. This test comes after the - * traces - the variable may actually become an array as an effect of said - * traces. - */ - - if ((varPtr == NULL) || !TclIsVarArray(varPtr) - || TclIsVarUndefined(varPtr)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "\"%s\" isn't an array", TclGetString(varNameObj))); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAY", - TclGetString(varNameObj), NULL); + varPtr = VerifyArray(interp, varNameObj); + if (varPtr == NULL) { return TCL_ERROR; } -- cgit v0.12 From 05c0da6eee9a84deb417980eb524efd8395516ec Mon Sep 17 00:00:00 2001 From: venkat Date: Wed, 20 Jul 2016 03:05:01 +0000 Subject: Update tzdata to 2016f from ietf.org --- library/tzdata/America/Cambridge_Bay | 2 +- library/tzdata/America/Inuvik | 2 +- library/tzdata/America/Iqaluit | 2 +- library/tzdata/America/Pangnirtung | 2 +- library/tzdata/America/Rankin_Inlet | 2 +- library/tzdata/America/Resolute | 2 +- library/tzdata/America/Yellowknife | 2 +- library/tzdata/Antarctica/Casey | 2 +- library/tzdata/Antarctica/Davis | 4 +- library/tzdata/Antarctica/DumontDUrville | 4 +- library/tzdata/Antarctica/Macquarie | 4 +- library/tzdata/Antarctica/Mawson | 2 +- library/tzdata/Antarctica/Palmer | 2 +- library/tzdata/Antarctica/Rothera | 2 +- library/tzdata/Antarctica/Syowa | 2 +- library/tzdata/Antarctica/Troll | 2 +- library/tzdata/Antarctica/Vostok | 2 +- library/tzdata/Asia/Baku | 2 +- library/tzdata/Asia/Novokuznetsk | 133 +++++++++++++++--------------- library/tzdata/Asia/Novosibirsk | 135 ++++++++++++++++--------------- library/tzdata/Europe/Minsk | 6 +- library/tzdata/Indian/Kerguelen | 2 +- 22 files changed, 159 insertions(+), 159 deletions(-) diff --git a/library/tzdata/America/Cambridge_Bay b/library/tzdata/America/Cambridge_Bay index 23004bb..3115ee1 100644 --- a/library/tzdata/America/Cambridge_Bay +++ b/library/tzdata/America/Cambridge_Bay @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Cambridge_Bay) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1577923200 -25200 0 MST} {-880210800 -21600 1 MWT} {-769395600 -21600 1 MPT} diff --git a/library/tzdata/America/Inuvik b/library/tzdata/America/Inuvik index dd0d151..08f0fd6 100644 --- a/library/tzdata/America/Inuvik +++ b/library/tzdata/America/Inuvik @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Inuvik) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-536457600 -28800 0 PST} {-147888000 -21600 1 PDDT} {-131558400 -28800 0 PST} diff --git a/library/tzdata/America/Iqaluit b/library/tzdata/America/Iqaluit index 2a2e9fe..ff82866 100644 --- a/library/tzdata/America/Iqaluit +++ b/library/tzdata/America/Iqaluit @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Iqaluit) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-865296000 -14400 0 EWT} {-769395600 -14400 1 EPT} {-765396000 -18000 0 EST} diff --git a/library/tzdata/America/Pangnirtung b/library/tzdata/America/Pangnirtung index 640808e..14d8516 100644 --- a/library/tzdata/America/Pangnirtung +++ b/library/tzdata/America/Pangnirtung @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Pangnirtung) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1546300800 -14400 0 AST} {-880221600 -10800 1 AWT} {-769395600 -10800 1 APT} diff --git a/library/tzdata/America/Rankin_Inlet b/library/tzdata/America/Rankin_Inlet index 770ec5d..9ce9f8d 100644 --- a/library/tzdata/America/Rankin_Inlet +++ b/library/tzdata/America/Rankin_Inlet @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Rankin_Inlet) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-410227200 -21600 0 CST} {-147895200 -14400 1 CDDT} {-131565600 -21600 0 CST} diff --git a/library/tzdata/America/Resolute b/library/tzdata/America/Resolute index b4c0bab..a9881b4 100644 --- a/library/tzdata/America/Resolute +++ b/library/tzdata/America/Resolute @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Resolute) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-704937600 -21600 0 CST} {-147895200 -14400 1 CDDT} {-131565600 -21600 0 CST} diff --git a/library/tzdata/America/Yellowknife b/library/tzdata/America/Yellowknife index 44ca658..c6c4ed5 100644 --- a/library/tzdata/America/Yellowknife +++ b/library/tzdata/America/Yellowknife @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:America/Yellowknife) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-1104537600 -25200 0 MST} {-880210800 -21600 1 MWT} {-769395600 -21600 1 MPT} diff --git a/library/tzdata/Antarctica/Casey b/library/tzdata/Antarctica/Casey index 56d5df7..2573dac 100644 --- a/library/tzdata/Antarctica/Casey +++ b/library/tzdata/Antarctica/Casey @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Casey) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-31536000 28800 0 AWST} {1255802400 39600 0 CAST} {1267714800 28800 0 AWST} diff --git a/library/tzdata/Antarctica/Davis b/library/tzdata/Antarctica/Davis index 2762d2f..c98be2f 100644 --- a/library/tzdata/Antarctica/Davis +++ b/library/tzdata/Antarctica/Davis @@ -1,9 +1,9 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Davis) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-409190400 25200 0 DAVT} - {-163062000 0 0 zzz} + {-163062000 0 0 -00} {-28857600 25200 0 DAVT} {1255806000 18000 0 DAVT} {1268251200 25200 0 DAVT} diff --git a/library/tzdata/Antarctica/DumontDUrville b/library/tzdata/Antarctica/DumontDUrville index 41dc1e3..8d21d45 100644 --- a/library/tzdata/Antarctica/DumontDUrville +++ b/library/tzdata/Antarctica/DumontDUrville @@ -1,8 +1,8 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/DumontDUrville) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-725846400 36000 0 PMT} - {-566992800 0 0 zzz} + {-566992800 0 0 -00} {-415497600 36000 0 DDUT} } diff --git a/library/tzdata/Antarctica/Macquarie b/library/tzdata/Antarctica/Macquarie index 07ddff6..9ed0630 100644 --- a/library/tzdata/Antarctica/Macquarie +++ b/library/tzdata/Antarctica/Macquarie @@ -1,12 +1,12 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Macquarie) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-2214259200 36000 0 AEST} {-1680508800 39600 1 AEDT} {-1669892400 39600 0 AEDT} {-1665392400 36000 0 AEST} - {-1601719200 0 0 zzz} + {-1601719200 0 0 -00} {-94730400 36000 0 AEST} {-71136000 39600 1 AEDT} {-55411200 36000 0 AEST} diff --git a/library/tzdata/Antarctica/Mawson b/library/tzdata/Antarctica/Mawson index ba03ba1..e50aa07 100644 --- a/library/tzdata/Antarctica/Mawson +++ b/library/tzdata/Antarctica/Mawson @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Mawson) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-501206400 21600 0 MAWT} {1255809600 18000 0 MAWT} } diff --git a/library/tzdata/Antarctica/Palmer b/library/tzdata/Antarctica/Palmer index 5767985..62b17e1 100644 --- a/library/tzdata/Antarctica/Palmer +++ b/library/tzdata/Antarctica/Palmer @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Palmer) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-157766400 -14400 0 ART} {-152654400 -14400 0 ART} {-132955200 -10800 1 ARST} diff --git a/library/tzdata/Antarctica/Rothera b/library/tzdata/Antarctica/Rothera index 24d7f3e..3a219c7 100644 --- a/library/tzdata/Antarctica/Rothera +++ b/library/tzdata/Antarctica/Rothera @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Rothera) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {218246400 -10800 0 ROTT} } diff --git a/library/tzdata/Antarctica/Syowa b/library/tzdata/Antarctica/Syowa index 4d046b5..1fe030a 100644 --- a/library/tzdata/Antarctica/Syowa +++ b/library/tzdata/Antarctica/Syowa @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Syowa) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-407808000 10800 0 SYOT} } diff --git a/library/tzdata/Antarctica/Troll b/library/tzdata/Antarctica/Troll index 7d2b042..09727a8 100644 --- a/library/tzdata/Antarctica/Troll +++ b/library/tzdata/Antarctica/Troll @@ -1,7 +1,7 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Troll) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {1108166400 0 0 UTC} {1111885200 7200 1 CEST} {1130634000 0 0 UTC} diff --git a/library/tzdata/Antarctica/Vostok b/library/tzdata/Antarctica/Vostok index f846f65..a59868b 100644 --- a/library/tzdata/Antarctica/Vostok +++ b/library/tzdata/Antarctica/Vostok @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Antarctica/Vostok) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-380073600 21600 0 VOST} } diff --git a/library/tzdata/Asia/Baku b/library/tzdata/Asia/Baku index bc0701a..e9ee835 100644 --- a/library/tzdata/Asia/Baku +++ b/library/tzdata/Asia/Baku @@ -28,7 +28,7 @@ set TZData(:Asia/Baku) { {683496000 14400 0 AZST} {686098800 10800 0 AZT} {701823600 14400 1 AZST} - {717537600 14400 0 AZT} + {717548400 14400 0 AZT} {820440000 14400 0 AZT} {828234000 18000 1 AZST} {846378000 14400 0 AZT} diff --git a/library/tzdata/Asia/Novokuznetsk b/library/tzdata/Asia/Novokuznetsk index f079faa..a43a984 100644 --- a/library/tzdata/Asia/Novokuznetsk +++ b/library/tzdata/Asia/Novokuznetsk @@ -2,71 +2,70 @@ set TZData(:Asia/Novokuznetsk) { {-9223372036854775808 20928 0 LMT} - {-1441259328 21600 0 KRAT} - {-1247551200 25200 0 KRAMMTT} - {354906000 28800 1 KRAST} - {370713600 25200 0 KRAT} - {386442000 28800 1 KRAST} - {402249600 25200 0 KRAT} - {417978000 28800 1 KRAST} - {433785600 25200 0 KRAT} - {449600400 28800 1 KRAST} - {465332400 25200 0 KRAT} - {481057200 28800 1 KRAST} - {496782000 25200 0 KRAT} - {512506800 28800 1 KRAST} - {528231600 25200 0 KRAT} - {543956400 28800 1 KRAST} - {559681200 25200 0 KRAT} - {575406000 28800 1 KRAST} - {591130800 25200 0 KRAT} - {606855600 28800 1 KRAST} - {622580400 25200 0 KRAT} - {638305200 28800 1 KRAST} - {654634800 25200 0 KRAT} - {670359600 21600 0 KRAMMTT} - {670363200 25200 1 KRAST} - {686088000 21600 0 KRAT} - {695764800 25200 0 KRAMMTT} - {701809200 28800 1 KRAST} - {717534000 25200 0 KRAT} - {733258800 28800 1 KRAST} - {748983600 25200 0 KRAT} - {764708400 28800 1 KRAST} - {780433200 25200 0 KRAT} - {796158000 28800 1 KRAST} - {811882800 25200 0 KRAT} - {828212400 28800 1 KRAST} - {846356400 25200 0 KRAT} - {859662000 28800 1 KRAST} - {877806000 25200 0 KRAT} - {891111600 28800 1 KRAST} - {909255600 25200 0 KRAT} - {922561200 28800 1 KRAST} - {941310000 25200 0 KRAT} - {954010800 28800 1 KRAST} - {972759600 25200 0 KRAT} - {985460400 28800 1 KRAST} - {1004209200 25200 0 KRAT} - {1017514800 28800 1 KRAST} - {1035658800 25200 0 KRAT} - {1048964400 28800 1 KRAST} - {1067108400 25200 0 KRAT} - {1080414000 28800 1 KRAST} - {1099162800 25200 0 KRAT} - {1111863600 28800 1 KRAST} - {1130612400 25200 0 KRAT} - {1143313200 28800 1 KRAST} - {1162062000 25200 0 KRAT} - {1174762800 28800 1 KRAST} - {1193511600 25200 0 KRAT} - {1206817200 28800 1 KRAST} - {1224961200 25200 0 KRAT} - {1238266800 28800 1 KRAST} - {1256410800 25200 0 KRAT} - {1269716400 21600 0 NOVMMTT} - {1269720000 25200 1 NOVST} - {1288468800 21600 0 NOVT} - {1301169600 25200 0 NOVT} - {1414263600 25200 0 KRAT} + {-1441259328 21600 0 +06} + {-1247551200 25200 0 +08} + {354906000 28800 1 +08} + {370713600 25200 0 +07} + {386442000 28800 1 +08} + {402249600 25200 0 +07} + {417978000 28800 1 +08} + {433785600 25200 0 +07} + {449600400 28800 1 +08} + {465332400 25200 0 +07} + {481057200 28800 1 +08} + {496782000 25200 0 +07} + {512506800 28800 1 +08} + {528231600 25200 0 +07} + {543956400 28800 1 +08} + {559681200 25200 0 +07} + {575406000 28800 1 +08} + {591130800 25200 0 +07} + {606855600 28800 1 +08} + {622580400 25200 0 +07} + {638305200 28800 1 +08} + {654634800 25200 0 +07} + {670359600 21600 0 +07} + {670363200 25200 1 +07} + {686088000 21600 0 +06} + {695764800 25200 0 +08} + {701809200 28800 1 +08} + {717534000 25200 0 +07} + {733258800 28800 1 +08} + {748983600 25200 0 +07} + {764708400 28800 1 +08} + {780433200 25200 0 +07} + {796158000 28800 1 +08} + {811882800 25200 0 +07} + {828212400 28800 1 +08} + {846356400 25200 0 +07} + {859662000 28800 1 +08} + {877806000 25200 0 +07} + {891111600 28800 1 +08} + {909255600 25200 0 +07} + {922561200 28800 1 +08} + {941310000 25200 0 +07} + {954010800 28800 1 +08} + {972759600 25200 0 +07} + {985460400 28800 1 +08} + {1004209200 25200 0 +07} + {1017514800 28800 1 +08} + {1035658800 25200 0 +07} + {1048964400 28800 1 +08} + {1067108400 25200 0 +07} + {1080414000 28800 1 +08} + {1099162800 25200 0 +07} + {1111863600 28800 1 +08} + {1130612400 25200 0 +07} + {1143313200 28800 1 +08} + {1162062000 25200 0 +07} + {1174762800 28800 1 +08} + {1193511600 25200 0 +07} + {1206817200 28800 1 +08} + {1224961200 25200 0 +07} + {1238266800 28800 1 +08} + {1256410800 25200 0 +07} + {1269716400 21600 0 +07} + {1269720000 25200 1 +07} + {1288468800 21600 0 +06} + {1301169600 25200 0 +07} } diff --git a/library/tzdata/Asia/Novosibirsk b/library/tzdata/Asia/Novosibirsk index 54c83fa..21f5c00 100644 --- a/library/tzdata/Asia/Novosibirsk +++ b/library/tzdata/Asia/Novosibirsk @@ -2,71 +2,72 @@ set TZData(:Asia/Novosibirsk) { {-9223372036854775808 19900 0 LMT} - {-1579476700 21600 0 NOVT} - {-1247551200 25200 0 NOVMMTT} - {354906000 28800 1 NOVST} - {370713600 25200 0 NOVT} - {386442000 28800 1 NOVST} - {402249600 25200 0 NOVT} - {417978000 28800 1 NOVST} - {433785600 25200 0 NOVT} - {449600400 28800 1 NOVST} - {465332400 25200 0 NOVT} - {481057200 28800 1 NOVST} - {496782000 25200 0 NOVT} - {512506800 28800 1 NOVST} - {528231600 25200 0 NOVT} - {543956400 28800 1 NOVST} - {559681200 25200 0 NOVT} - {575406000 28800 1 NOVST} - {591130800 25200 0 NOVT} - {606855600 28800 1 NOVST} - {622580400 25200 0 NOVT} - {638305200 28800 1 NOVST} - {654634800 25200 0 NOVT} - {670359600 21600 0 NOVMMTT} - {670363200 25200 1 NOVST} - {686088000 21600 0 NOVT} - {695764800 25200 0 NOVMMTT} - {701809200 28800 1 NOVST} - {717534000 25200 0 NOVT} - {733258800 28800 1 NOVST} - {738090000 25200 0 NOVST} - {748987200 21600 0 NOVT} - {764712000 25200 1 NOVST} - {780436800 21600 0 NOVT} - {796161600 25200 1 NOVST} - {811886400 21600 0 NOVT} - {828216000 25200 1 NOVST} - {846360000 21600 0 NOVT} - {859665600 25200 1 NOVST} - {877809600 21600 0 NOVT} - {891115200 25200 1 NOVST} - {909259200 21600 0 NOVT} - {922564800 25200 1 NOVST} - {941313600 21600 0 NOVT} - {954014400 25200 1 NOVST} - {972763200 21600 0 NOVT} - {985464000 25200 1 NOVST} - {1004212800 21600 0 NOVT} - {1017518400 25200 1 NOVST} - {1035662400 21600 0 NOVT} - {1048968000 25200 1 NOVST} - {1067112000 21600 0 NOVT} - {1080417600 25200 1 NOVST} - {1099166400 21600 0 NOVT} - {1111867200 25200 1 NOVST} - {1130616000 21600 0 NOVT} - {1143316800 25200 1 NOVST} - {1162065600 21600 0 NOVT} - {1174766400 25200 1 NOVST} - {1193515200 21600 0 NOVT} - {1206820800 25200 1 NOVST} - {1224964800 21600 0 NOVT} - {1238270400 25200 1 NOVST} - {1256414400 21600 0 NOVT} - {1269720000 25200 1 NOVST} - {1288468800 21600 0 NOVT} - {1301169600 25200 0 NOVT} - {1414263600 21600 0 NOVT} + {-1579476700 21600 0 +06} + {-1247551200 25200 0 +08} + {354906000 28800 1 +08} + {370713600 25200 0 +07} + {386442000 28800 1 +08} + {402249600 25200 0 +07} + {417978000 28800 1 +08} + {433785600 25200 0 +07} + {449600400 28800 1 +08} + {465332400 25200 0 +07} + {481057200 28800 1 +08} + {496782000 25200 0 +07} + {512506800 28800 1 +08} + {528231600 25200 0 +07} + {543956400 28800 1 +08} + {559681200 25200 0 +07} + {575406000 28800 1 +08} + {591130800 25200 0 +07} + {606855600 28800 1 +08} + {622580400 25200 0 +07} + {638305200 28800 1 +08} + {654634800 25200 0 +07} + {670359600 21600 0 +07} + {670363200 25200 1 +07} + {686088000 21600 0 +06} + {695764800 25200 0 +08} + {701809200 28800 1 +08} + {717534000 25200 0 +07} + {733258800 28800 1 +08} + {738090000 25200 0 +07} + {748987200 21600 0 +06} + {764712000 25200 1 +07} + {780436800 21600 0 +06} + {796161600 25200 1 +07} + {811886400 21600 0 +06} + {828216000 25200 1 +07} + {846360000 21600 0 +06} + {859665600 25200 1 +07} + {877809600 21600 0 +06} + {891115200 25200 1 +07} + {909259200 21600 0 +06} + {922564800 25200 1 +07} + {941313600 21600 0 +06} + {954014400 25200 1 +07} + {972763200 21600 0 +06} + {985464000 25200 1 +07} + {1004212800 21600 0 +06} + {1017518400 25200 1 +07} + {1035662400 21600 0 +06} + {1048968000 25200 1 +07} + {1067112000 21600 0 +06} + {1080417600 25200 1 +07} + {1099166400 21600 0 +06} + {1111867200 25200 1 +07} + {1130616000 21600 0 +06} + {1143316800 25200 1 +07} + {1162065600 21600 0 +06} + {1174766400 25200 1 +07} + {1193515200 21600 0 +06} + {1206820800 25200 1 +07} + {1224964800 21600 0 +06} + {1238270400 25200 1 +07} + {1256414400 21600 0 +06} + {1269720000 25200 1 +07} + {1288468800 21600 0 +06} + {1301169600 25200 0 +07} + {1414263600 21600 0 +06} + {1469304000 25200 0 +07} } diff --git a/library/tzdata/Europe/Minsk b/library/tzdata/Europe/Minsk index 5e47063..2857e5b 100644 --- a/library/tzdata/Europe/Minsk +++ b/library/tzdata/Europe/Minsk @@ -30,10 +30,10 @@ set TZData(:Europe/Minsk) { {606870000 14400 1 MSD} {622594800 10800 0 MSK} {631141200 10800 0 MSK} - {670374000 10800 1 EEST} + {670374000 7200 0 EEMMTT} + {670377600 10800 1 EEST} {686102400 7200 0 EET} - {701820000 10800 1 EEST} - {717544800 10800 0 EEST} + {701827200 10800 1 EEST} {717552000 7200 0 EET} {733276800 10800 1 EEST} {749001600 7200 0 EET} diff --git a/library/tzdata/Indian/Kerguelen b/library/tzdata/Indian/Kerguelen index b41b85a..8820010 100644 --- a/library/tzdata/Indian/Kerguelen +++ b/library/tzdata/Indian/Kerguelen @@ -1,6 +1,6 @@ # created by tools/tclZIC.tcl - do not edit set TZData(:Indian/Kerguelen) { - {-9223372036854775808 0 0 zzz} + {-9223372036854775808 0 0 -00} {-631152000 18000 0 TFT} } -- cgit v0.12 From fcf66a8c31f5c02f6b8337c822d21e55c07df7f6 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 20 Jul 2016 15:43:08 +0000 Subject: Use the new private flag INDEX_TEMP_TABLE in testing command too. --- generic/tclTestObj.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index a637498..6053ae3 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -577,23 +577,9 @@ TestindexobjCmd( } argv[objc-4] = NULL; - /* - * Tcl_GetIndexFromObj assumes that the table is statically-allocated so - * that its address is different for each index object. If we accidently - * allocate a table at the same address as that cached in the index - * object, clear out the object's cached state. - */ - - if (objv[3]->typePtr != NULL - && !strcmp("index", objv[3]->typePtr->name)) { - indexRep = objv[3]->internalRep.twoPtrValue.ptr1; - if (indexRep->tablePtr == (void *) argv) { - TclFreeIntRep(objv[3]); - } - } - result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3], - argv, "token", (allowAbbrev? 0 : TCL_EXACT), &index); + argv, "token", INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT), + &index); ckfree(argv); if (result == TCL_OK) { Tcl_SetIntObj(Tcl_GetObjResult(interp), index); -- cgit v0.12 From 1eff5acecce7c6cae25d692ba941f02c9961dc74 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 20 Jul 2016 16:32:16 +0000 Subject: Use strchr() to parse array variable syntax. --- generic/tclVar.c | 58 +++++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/generic/tclVar.c b/generic/tclVar.c index 56c5a05..20fce82 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -504,9 +504,8 @@ TclObjLookupVarEx( register Var *varPtr; /* Points to the variable's in-frame Var * structure. */ const char *part1; - int index, len1, len2; + int index, len; int parsed = 0; - Tcl_Obj *objPtr; const Tcl_ObjType *typePtr = part1Ptr->typePtr; const char *errMsg = NULL; CallFrame *varFramePtr = iPtr->varFramePtr; @@ -566,18 +565,17 @@ TclObjLookupVarEx( } parsed = 1; } - part1 = TclGetStringFromObj(part1Ptr, &len1); + part1 = TclGetStringFromObj(part1Ptr, &len); - if (!parsed && len1 && (*(part1 + len1 - 1) == ')')) { + if (!parsed && len && (*(part1 + len - 1) == ')')) { /* * part1Ptr is possibly an unparsed array element. */ - register int i; + part2 = strchr(part1, '('); + if (part2) { + Tcl_Obj *arrayPtr; - len2 = -1; - for (i = 0; i < len1; i++) { - if (*(part1 + i) == '(') { if (part2Ptr != NULL) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, msg, @@ -588,44 +586,18 @@ TclObjLookupVarEx( return NULL; } - /* - * part1Ptr points to an array element; first copy the element - * name to a new string part2. - */ - - part2 = part1 + i + 1; - len2 = len1 - i - 2; - len1 = i; - - part2Ptr = Tcl_NewStringObj(part2, len2); - - /* - * Free the internal rep of the original part1Ptr, now renamed - * objPtr, and set it to tclParsedVarNameType. - */ + arrayPtr = Tcl_NewStringObj(part1, (part2 - part1)); + part2Ptr = Tcl_NewStringObj(part2 + 1, len - (part2 - part1) - 2); - objPtr = part1Ptr; - TclFreeIntRep(objPtr); - objPtr->typePtr = &tclParsedVarNameType; + TclFreeIntRep(part1Ptr); - /* - * Define a new string object to hold the new part1Ptr, i.e., - * the array name. Set the internal rep of objPtr, reset - * typePtr and part1 to contain the references to the array - * name. - */ - - TclNewStringObj(part1Ptr, part1, len1); - Tcl_IncrRefCount(part1Ptr); - - objPtr->internalRep.twoPtrValue.ptr1 = part1Ptr; - Tcl_IncrRefCount(part2Ptr); - objPtr->internalRep.twoPtrValue.ptr2 = part2Ptr; + Tcl_IncrRefCount(arrayPtr); + part1Ptr->internalRep.twoPtrValue.ptr1 = arrayPtr; + Tcl_IncrRefCount(part2Ptr); + part1Ptr->internalRep.twoPtrValue.ptr2 = part2Ptr; + part1Ptr->typePtr = &tclParsedVarNameType; - typePtr = part1Ptr->typePtr; - part1 = TclGetString(part1Ptr); - break; - } + part1Ptr = arrayPtr; } } -- cgit v0.12 From a7a2c2e589efa82857ba0a2526acede975aa89d0 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 20 Jul 2016 17:39:04 +0000 Subject: Streamline TclObjLookupVarEx --- generic/tclVar.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/generic/tclVar.c b/generic/tclVar.c index 20fce82..55eb436 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -501,15 +501,13 @@ TclObjLookupVarEx( * is set to NULL. */ { Interp *iPtr = (Interp *) interp; + CallFrame *varFramePtr = iPtr->varFramePtr; register Var *varPtr; /* Points to the variable's in-frame Var * structure. */ - const char *part1; - int index, len; - int parsed = 0; - const Tcl_ObjType *typePtr = part1Ptr->typePtr; const char *errMsg = NULL; - CallFrame *varFramePtr = iPtr->varFramePtr; - const char *part2 = part2Ptr? TclGetString(part2Ptr):NULL; + int index, parsed = 0; + const Tcl_ObjType *typePtr = part1Ptr->typePtr; + *arrayPtrPtr = NULL; if (typePtr == &localVarNameType) { @@ -525,7 +523,7 @@ TclObjLookupVarEx( */ Tcl_Obj *namePtr = part1Ptr->internalRep.twoPtrValue.ptr1; - Tcl_Obj *checkNamePtr = localName(iPtr->varFramePtr, localIndex); + Tcl_Obj *checkNamePtr = localName(varFramePtr, localIndex); if ((!namePtr && (checkNamePtr == part1Ptr)) || (namePtr && (checkNamePtr == namePtr))) { @@ -565,15 +563,21 @@ TclObjLookupVarEx( } parsed = 1; } - part1 = TclGetStringFromObj(part1Ptr, &len); - if (!parsed && len && (*(part1 + len - 1) == ')')) { + if (!parsed) { + /* * part1Ptr is possibly an unparsed array element. */ - part2 = strchr(part1, '('); - if (part2) { + int len; + const char *part1 = TclGetStringFromObj(part1Ptr, &len); + + if (len > 1 && (part1[len - 1] == ')')) { + + const char *part2 = strchr(part1, '('); + + if (part2) { Tcl_Obj *arrayPtr; if (part2Ptr != NULL) { @@ -598,6 +602,7 @@ TclObjLookupVarEx( part1Ptr->typePtr = &tclParsedVarNameType; part1Ptr = arrayPtr; + } } } @@ -607,8 +612,6 @@ TclObjLookupVarEx( * the cached types if possible. */ - TclFreeIntRep(part1Ptr); - varPtr = TclLookupSimpleVar(interp, part1Ptr, flags, createPart1, &errMsg, &index); if (varPtr == NULL) { @@ -624,11 +627,12 @@ TclObjLookupVarEx( * Cache the newly found variable if possible. */ + TclFreeIntRep(part1Ptr); if (index >= 0) { /* * An indexed local variable. */ - Tcl_Obj *cachedNamePtr = localName(iPtr->varFramePtr, index); + Tcl_Obj *cachedNamePtr = localName(varFramePtr, index); part1Ptr->typePtr = &localVarNameType; if (part1Ptr != cachedNamePtr) { -- cgit v0.12 From 5ad954783e49a00f738e29083586df9f8c9411e0 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 20 Jul 2016 20:39:16 +0000 Subject: Stop internals intrusion into lists. --- generic/tclExecute.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index f1205b0..a2a465a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5283,23 +5283,10 @@ TEBCresume( toIdx = objc-1; } if (fromIdx == 0 && toIdx != objc-1 && !Tcl_IsShared(valuePtr)) { - /* - * BEWARE! This is looking inside the implementation of the - * list type. - */ - - List *listPtr = valuePtr->internalRep.twoPtrValue.ptr1; - - if (listPtr->refCount == 1) { - for (index=toIdx+1; indexelemCount = toIdx+1; - listPtr->canonicalFlag = 1; - TclInvalidateStringRep(valuePtr); - TRACE_APPEND(("%.30s\n", O2S(valuePtr))); - NEXT_INST_F(9, 0, 0); - } + Tcl_ListObjReplace(interp, valuePtr, + toIdx + 1, LIST_MAX, 0, NULL); + TRACE_APPEND(("%.30s\n", O2S(valuePtr))); + NEXT_INST_F(9, 0, 0); } objResultPtr = Tcl_NewListObj(toIdx-fromIdx+1, objv+fromIdx); } else { -- cgit v0.12 From fa9c51579645df87feccb20a43ac952d79e2e0c9 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 21 Jul 2016 16:20:38 +0000 Subject: Update changes file. --- changes | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/changes b/changes index 1e24269..2ba6d42 100644 --- a/changes +++ b/changes @@ -8624,3 +8624,77 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich) 2016-02-22 (bug)[9b4702] [info exists env(missing)] kills trace (nijtmans) --- Released 8.6.5, February 29, 2016 --- http://core.tcl.tk/tcl/ for details + +2016-03-01 (bug)[803042] mem leak due to reference cycle (porter) + +2016-03-08 (bug)[bbc304] reflected watch race condition (porter) + +2016-03-17 (bug)[fadc99] compile-5.3 (rodriguez,porter) + +2016-03-17 (enhancement)[1a25fd] compile [variable ${ns}::v] (porter) + +2016-03-20 (bug)[1af8de] crash in compiled [string replace] (harder,fellows) + +2016-03-21 (bug)[d30718] segv in notifier finalize (hirofumi,nijtmans) + +2016-03-23 (enhancement)[7d0db7] parallel make (yarda,nijtmans) + +2016-03-23 [f12535] enable test bindings customization (vogel,nijtmans) + +2016-04-04 (bug)[47ac84] compiled [lreplace] fixes (aspect,ferrieux,fellows) + *** POTENTIAL INCOMPATIBILITY *** + +2016-04-08 (bug)[866368] RE \w includes 'Punctuation Connector' (nijtmans) + +2016-04-08 (bug)[2538f3] Win crash Tcl_OpenTcpServer() (griffin) + +2016-04-10 [07d13d] Restore TclBlend support lost in 8.6.1 (buratti) + +2016-05-13 (bug)[3154ea] Mem corruption in assembler exceptions (tkob,kenny) + +2016-05-13 (bug) registry package support any Unicode env (nijtmans) +=> registry 1.3.2 + +2016-05-21 (bug)[f7d4e] [namespace delete] performance (fellows) + +2016-06-02 (TIP 447) execution time verbosity option (cerutti) +=> tcltest 2.4.0 + +2016-06-16 (bug)[16828b] crash due to [vwait] trace undo fail (dah,porter) + +2016-06-16 (enhancement)[4b61af] good [info frame] from more cases (beric) + +2016-06-21 (bug)[c383eb] crash in [glob -path a] (oehlmann,porter) + +2016-06-21 (update) Update Unicode data to 9.0 (nijtmans) + *** POTENTIAL INCOMPATIBILITY *** + +2016-06-22 (bug)[16896d] Tcl_DString tolerate append to self. (dah,porter) + +2016-06-23 (bug)[d55322] crash in [dict update] (yorick,fellows) + +2016-06-27 (bug)[dd260a] crash in [chan configure -dictionary] (madden,aspect) + +2016-07-02 (bug)[f961d7] usage message with parameters with spaces (porter) + *** POTENTIAL INCOMPATIBILITY *** + +2016-07-02 (enhancement)[09fabc] Sort order of -relateddir (lanam) + +2016-07-07 (bug)[5d7ca0] Win: [file executable] for .cmd and .ps1 (nadkarni) + *** POTENTIAL INCOMPATIBILITY *** + +2016-07-08 (bug)[a47641] [file normalize] & Windows junctions (nadkarni) + +2016-07-09 [ae61a6] [file] handling of Win hardcoded names (CON) (nadkarni) + *** POTENTIAL INCOMPATIBILITY *** + +2016-07-09 [3613671] [file owned] (more) useful on Win (nadkarni) + +2016-07-09 (bug)[1493a4] [namespace upvar] use of resolvers (beric,fellows) + *** POTENTIAL INCOMPATIBILITY *** + +2016-07-10 (bug)[da340d] integer division in clock math (nadkarni) + +2016-07-20 tzdata updated to Olson's tzdata2016f (venkat) + +--- Released 8.6.6, August ?, 2016 --- http://core.tcl.tk/tcl/ for details -- cgit v0.12 From 6239155e85e232727ff14b9f2a6992158ca5a781 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Jul 2016 14:00:01 +0000 Subject: Set release date --- changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes b/changes index 2ba6d42..034380b 100644 --- a/changes +++ b/changes @@ -8697,4 +8697,4 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich) 2016-07-20 tzdata updated to Olson's tzdata2016f (venkat) ---- Released 8.6.6, August ?, 2016 --- http://core.tcl.tk/tcl/ for details +--- Released 8.6.6, July 27, 2016 --- http://core.tcl.tk/tcl/ for details -- cgit v0.12 From 7b960b4cdbdb05dd87c12eff280e839eace1cd54 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Jul 2016 15:28:50 +0000 Subject: test repairs --- tests/chanio.test | 2 -- tests/info.test | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 29f42c3..9a27233 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -6790,8 +6790,6 @@ test chan-io-52.11 {TclCopyChannel & encodings} -setup { chan close $in chan close $out file size $path(kyrillic.txt) -} -cleanup { - file delete $path(utf8-fcopy.txt) } -result 3 test chan-io-53.1 {CopyData} -setup { diff --git a/tests/info.test b/tests/info.test index c4fd379..42f5a96 100644 --- a/tests/info.test +++ b/tests/info.test @@ -1841,7 +1841,7 @@ test info-30.48 {Bug 2850901} testevalex { # ------------------------------------------------------------------------- # literal sharing 2, bug 2933089 -test info-39.1 {location information not confused by literal sharing, bug 2933089} -setup { +test info-40.1 {location information not confused by literal sharing, bug 2933089} -setup { set result {} proc print_one {} {} -- cgit v0.12 From 3e6a6753f751ed2cec8c6119d295e4ae7be26852 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 24 Jul 2016 12:45:07 +0000 Subject: Make a few tests more resilient to differences in the semantics of pipes between operating systems. --- doc/chan.n | 12 ++++++++++++ tests/zlib.test | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/chan.n b/doc/chan.n index 7ea0d19..cc53d3b 100644 --- a/doc/chan.n +++ b/doc/chan.n @@ -547,6 +547,18 @@ this, spawn with "2>@" or ">@" redirection operators onto the write side of a pipe, and then immediately close it in the parent. This is necessary to get an EOF on the read side once the child has exited or otherwise closed its output. +.RS +.PP +Note that the pipe buffering semantics can vary at the operating system level +substantially; it is not safe to assume that a write performed on the output +side of the pipe will appear instantly to the input side. This is a +fundamental difference and Tcl cannot conceal it. The overall stream semantics +\fIare\fR compatible, so blocking reads and writes will not see most of the +differences, but the details of what exactly gets written when are not. This +is most likely to show up when using pipelines for testing; care should be +taken to ensure that deadlocks do not occur and that potential short reads are +allowed for. +.RE .VE 8.6 .TP \fBchan pop \fIchannelId\fR diff --git a/tests/zlib.test b/tests/zlib.test index c9e5f10..8a040d8 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -251,9 +251,10 @@ test zlib-8.8 {transformation and fconfigure} -setup { } -constraints zlib -body { zlib push compress $outSide -dictionary $spdyDict fconfigure $outSide -blocking 0 -translation binary -buffering none - fconfigure $inSide -blocking 0 -translation binary + fconfigure $inSide -blocking 1 -translation binary puts -nonewline $outSide $spdyHeaders chan pop $outSide + chan close $outSide set compressed [read $inSide] catch {zlib decompress $compressed} err opt list [string length [zlib compress $spdyHeaders]] \ @@ -269,10 +270,11 @@ test zlib-8.9 {transformation and fconfigure} -setup { } -constraints zlib -body { zlib push compress $outSide -dictionary $spdyDict fconfigure $outSide -blocking 0 -translation binary -buffering none - fconfigure $inSide -blocking 0 -translation binary + fconfigure $inSide -blocking 1 -translation binary puts -nonewline $outSide $spdyHeaders set result [fconfigure $outSide -checksum] chan pop $outSide + chan close $outSide $strm put -dictionary $spdyDict [read $inSide] lappend result [string length $spdyHeaders] [string length [$strm get]] } -cleanup { @@ -285,9 +287,10 @@ test zlib-8.10 {transformation and fconfigure} -setup { } -constraints {zlib recentZlib} -body { zlib push deflate $outSide -dictionary $spdyDict fconfigure $outSide -blocking 0 -translation binary -buffering none - fconfigure $inSide -blocking 0 -translation binary + fconfigure $inSide -blocking 1 -translation binary puts -nonewline $outSide $spdyHeaders chan pop $outSide + chan close $outSide set compressed [read $inSide] catch { zlib inflate $compressed @@ -306,9 +309,10 @@ test zlib-8.11 {transformation and fconfigure} -setup { } -constraints zlib -body { zlib push deflate $outSide -dictionary $spdyDict fconfigure $outSide -blocking 0 -translation binary -buffering none - fconfigure $inSide -blocking 0 -translation binary + fconfigure $inSide -blocking 1 -translation binary puts -nonewline $outSide $spdyHeaders chan pop $outSide + chan close $outSide $strm put -dictionary $spdyDict [read $inSide] list [string length $spdyHeaders] [string length [$strm get]] } -cleanup { -- cgit v0.12 From f6a4d71bada6d59b1daf550d919038e8e34ba666 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 24 Jul 2016 13:09:40 +0000 Subject: [6a19dedc2e] "Clarified" what the units are that [chan copy] uses for -size and that synchronous copying returns. --- doc/chan.n | 14 ++++++++------ doc/fcopy.n | 12 +++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/chan.n b/doc/chan.n index 7ea0d19..36d56f8 100644 --- a/doc/chan.n +++ b/doc/chan.n @@ -287,12 +287,14 @@ slow destinations like network sockets. .RS .PP The \fBchan copy\fR command transfers data from \fIinputChan\fR until -end of file or \fIsize\fR bytes have been transferred. If no -\fB\-size\fR argument is given, then the copy goes until end of file. -All the data read from \fIinputChan\fR is copied to \fIoutputChan\fR. -Without the \fB\-command\fR option, \fBchan copy\fR blocks until the -copy is complete and returns the number of bytes written to -\fIoutputChan\fR. +end of file or \fIsize\fR bytes or characters have been transferred; +\fIsize\fR is in bytes if the two channels are using the same encoding, +and is in characters otherwise. If no \fB\-size\fR argument is given, +then the copy goes until end of file. All the data read from +\fIinputChan\fR is copied to \fIoutputChan\fR. Without the +\fB\-command\fR option, \fBchan copy\fR blocks until the copy is +complete and returns the number of bytes or characters (using the same +rules as for the \fB\-size\fR option) written to \fIoutputChan\fR. .PP The \fB\-command\fR argument makes \fBchan copy\fR work in the background. In this case it returns immediately and the diff --git a/doc/fcopy.n b/doc/fcopy.n index e5dd1d6..d39c803 100644 --- a/doc/fcopy.n +++ b/doc/fcopy.n @@ -25,12 +25,15 @@ network sockets. .PP The \fBfcopy\fR command transfers data from \fIinchan\fR until end of file -or \fIsize\fR bytes have been -transferred. If no \fB\-size\fR argument is given, +or \fIsize\fR bytes or characters have been +transferred; \fIsize\fR is in bytes if the two channels are using the +same encoding, and is in characters otherwise. +If no \fB\-size\fR argument is given, then the copy goes until end of file. All the data read from \fIinchan\fR is copied to \fIoutchan\fR. Without the \fB\-command\fR option, \fBfcopy\fR blocks until the copy is complete -and returns the number of bytes written to \fIoutchan\fR. +and returns the number of bytes or characters (using the same rules as +for the \fB\-size\fR option) written to \fIoutchan\fR. .PP The \fB\-command\fR argument makes \fBfcopy\fR work in the background. In this case it returns immediately and the \fIcallback\fR is invoked @@ -174,3 +177,6 @@ vwait done eof(n), fblocked(n), fconfigure(n), file(n) .SH KEYWORDS blocking, channel, end of line, end of file, nonblocking, read, translation +'\" Local Variables: +'\" mode: nroff +'\" End: -- cgit v0.12 From a6063330c474dde9b388bfeda1b1bb746aebf23a Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 26 Aug 2016 13:46:37 +0000 Subject: Merge dup-removal into search loop so we avoid pre-processing efforts on data that are never used. Contributed patch from Brian Griffin. --- library/auto.tcl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/library/auto.tcl b/library/auto.tcl index 02edcc4..97ea8af 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -122,11 +122,9 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { # uniquify $dirs in order array set seen {} foreach i $dirs { - # Take note that the [file normalize] below has been noted to cause - # difficulties for the freewrap utility. See Bug 1072136. Until - # freewrap resolves the matter, one might work around the problem by - # disabling that branch. + # Make sure $i is unique under normalization. Avoid repeated [source]. if {[interp issafe]} { + # Safe interps have no [file normalize]. set norm $i } else { set norm [file normalize $i] @@ -135,10 +133,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { continue } set seen($norm) {} - lappend uniqdirs $i - } - set dirs $uniqdirs - foreach i $dirs { + set the_library $i set file [file join $i $initScript] -- cgit v0.12 From d84492f3906d20d05b547a4fa90286fe0a59bb37 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Aug 2016 13:00:32 +0000 Subject: Don't ever allow UTF-8 sequences of more than 4 characters to be generated or parsed, even when TCL_UTF_MAX>4: According to current Unicode standard, a byte string of >4 characters can never form a single UTF-8 character. And a few minor micro-optimizations related to UTF-8 handling. --- generic/tclUtf.c | 68 ++++++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index b878149..68119a4 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -73,16 +73,7 @@ static const unsigned char totalBytes[256] = { #else 1,1,1,1,1,1,1,1, #endif -#if TCL_UTF_MAX > 4 - 5,5,5,5, -#else - 1,1,1,1, -#endif -#if TCL_UTF_MAX > 5 - 6,6,6,6 -#else - 1,1,1,1 -#endif + 1,1,1,1,1,1,1,1 }; /* @@ -111,14 +102,14 @@ INLINE static int UtfCount( int ch) /* The Tcl_UniChar whose size is returned. */ { - if ((ch > 0) && (ch < UNICODE_SELF)) { + if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) { return 1; } if (ch <= 0x7FF) { return 2; } #if TCL_UTF_MAX > 3 - if ((ch > 0xFFFF) && (ch <= 0x10FFFF)) { + if (((unsigned)(ch - 0x10000) <= 0xfffff)) { return 4; } #endif @@ -152,7 +143,7 @@ Tcl_UniCharToUtf( * large enough to hold the UTF-8 character * (at most TCL_UTF_MAX bytes). */ { - if ((ch > 0) && (ch < UNICODE_SELF)) { + if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) { buf[0] = (char) ch; return 1; } @@ -180,11 +171,7 @@ Tcl_UniCharToUtf( } } #endif - three: - buf[2] = (char) ((ch | 0x80) & 0xBF); - buf[1] = (char) (((ch >> 6) | 0x80) & 0xBF); - buf[0] = (char) ((ch >> 12) | 0xE0); - return 3; + goto three; } #if TCL_UTF_MAX > 3 @@ -199,7 +186,11 @@ Tcl_UniCharToUtf( } ch = 0xFFFD; - goto three; +three: + buf[2] = (char) ((ch | 0x80) & 0xBF); + buf[1] = (char) (((ch >> 6) | 0x80) & 0xBF); + buf[0] = (char) ((ch >> 12) | 0xE0); + return 3; } /* @@ -314,9 +305,6 @@ Tcl_UtfToUniChar( * A two-byte-character lead-byte not followed by trail-byte * represents itself. */ - - *chPtr = (Tcl_UniChar) byte; - return 1; } else if (byte < 0xF0) { if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80)) { /* @@ -332,31 +320,23 @@ Tcl_UtfToUniChar( * A three-byte-character lead-byte not followed by two trail-bytes * represents itself. */ - - *chPtr = (Tcl_UniChar) byte; - return 1; } #if TCL_UTF_MAX > 3 - { - int ch, total, trail; - - total = totalBytes[byte]; - trail = total - 1; - if (trail > 0) { - ch = byte & (0x3F >> trail); - do { - src++; - if ((*src & 0xC0) != 0x80) { - *chPtr = byte; - return 1; - } - ch <<= 6; - ch |= (*src & 0x3F); - trail--; - } while (trail > 0); - *chPtr = ch; - return total; + else if (byte < 0xF8) { + if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80) && ((src[3] & 0xC0) == 0x80)) { + /* + * Four-byte-character lead byte followed by three trail bytes. + */ + + *chPtr = (Tcl_UniChar) (((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12) + | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)); + return 4; } + + /* + * A three-byte-character lead-byte not followed by two trail-bytes + * represents itself. + */ } #endif -- cgit v0.12 From 8dac135fc9c8efae2cc3113bc975ab871ff2271f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 5 Sep 2016 13:55:00 +0000 Subject: Allow additional optional "interp" argument for testinterpresolver command. Not used yet in any test-case. Protect panic in tclLiteral.c for possible null-pointer access. (cherry-picked from Gustaf Neuman's interpresolver patch). Eliminate some unecessary spacing. --- generic/tclCmdAH.c | 2 +- generic/tclExecute.c | 2 +- generic/tclLiteral.c | 3 ++- generic/tclTest.c | 13 ++++++++++--- tests/resolver.test | 2 +- win/tclWinFile.c | 8 ++++---- win/tclWinPipe.c | 2 +- win/tclWinPort.h | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 88cc17d..4c299f8 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -1597,7 +1597,7 @@ FileAttrIsOwnedCmd( Tcl_Obj *const objv[]) { #ifdef __CYGWIN__ -#define geteuid() (short)(geteuid)() +#define geteuid() (short)(geteuid)() #endif #if !defined(_WIN32) Tcl_StatBuf buf; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index e539161..34d92d3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3173,7 +3173,7 @@ TEBCresume( Tcl_Obj *copyPtr = Tcl_NewListObj(objc - opnd + 1, NULL); Tcl_ListObjAppendElement(NULL, copyPtr, objPtr); - Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, + Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, objc - opnd, objv + opnd); Tcl_DecrRefCount(objPtr); objPtr = copyPtr; diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 03200ca..26c21db 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -431,12 +431,13 @@ TclRegisterLiteral( * Is it in the interpreter's global literal table? If not, create it. */ + globalPtr = NULL; objPtr = TclCreateLiteral(iPtr, bytes, length, hash, &new, nsPtr, flags, &globalPtr); objIndex = AddLocalLiteralEntry(envPtr, objPtr, localHash); #ifdef TCL_COMPILE_DEBUG - if (globalPtr->refCount < 1) { + if (globalPtr != NULL && globalPtr->refCount < 1) { Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %d", "TclRegisterLiteral", (length>60? 60 : length), bytes, globalPtr->refCount); diff --git a/generic/tclTest.c b/generic/tclTest.c index e33d263..b3508f1 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -7449,9 +7449,16 @@ TestInterpResolverCmd( int idx; #define RESOLVER_KEY "testInterpResolver" - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "up|down"); - return TCL_ERROR; + if ((objc < 2) || (objc > 3)) { + Tcl_WrongNumArgs(interp, 1, objv, "up|down ?interp?"); + return TCL_ERROR; + } + if (objc == 3) { + interp = Tcl_GetSlave(interp, Tcl_GetString(objv[2])); + if (interp == NULL) { + Tcl_AppendResult(interp, "provided interpreter not found", NULL); + return TCL_ERROR; + } } if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT, &idx) != TCL_OK) { diff --git a/tests/resolver.test b/tests/resolver.test index f3d22e5..aaad02c 100644 --- a/tests/resolver.test +++ b/tests/resolver.test @@ -187,7 +187,7 @@ test resolver-2.1 {compiled var resolver: Bug #3383616} -setup { # During the compilation the compiled var resolver, the resolve-specific # var info is allocated, during the execution of the body, the variable is # fetched and cached. - x; + x # During later calls, the cached variable is reused. x # When the proc is freed, the resolver-specific resolver var info is diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 4d7500b..6662327 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -3166,8 +3166,8 @@ TclWinFileOwned( case we are in all likelihood not the owner */ return 0; } - - /* + + /* * Getting the current process SID is a multi-step process. * We make the assumption that if a call fails, this process is * so underprivileged it could not possibly own anything. Normally @@ -3191,10 +3191,10 @@ TclWinFileOwned( LocalFree(secd); /* Also frees ownerSid */ if (buf) ckfree(buf); - + return (owned != 0); /* Convert non-0 to 1 */ } - + /* * Local Variables: * mode: c diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 382addd..4666deb 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1337,7 +1337,7 @@ ApplicationType( Tcl_DStringFree(&ds); ext = strrchr(fullName, '.'); - if ((ext != NULL) && + if ((ext != NULL) && (strcasecmp(ext, ".cmd") == 0 || strcasecmp(ext, ".bat") == 0)) { applType = APPL_DOS; break; diff --git a/win/tclWinPort.h b/win/tclWinPort.h index b486466..159a708 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -360,7 +360,7 @@ typedef DWORD_PTR * PDWORD_PTR; # define S_IFLNK 0120000 /* Symbolic Link */ #endif -/* +/* * Windows compilers do not define S_IFBLK. However, Tcl uses it in * GetTypeFromMode to identify blockSpecial devices based on the * value in the statsbuf st_mode field. We have no other way to pass this -- cgit v0.12