From f61c3bdb284cedeb0db64a332f84bba54262565c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 1 May 2018 19:02:32 +0000 Subject: Start implementing TIP #497. regexp's now are >BMP-aware. WIP --- generic/regc_locale.c | 4 +- generic/regcustom.h | 12 ++--- generic/regex.h | 2 +- generic/tclInt.h | 9 ++++ generic/tclRegexp.c | 39 +++++++++------- generic/tclUtf.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 29 deletions(-) diff --git a/generic/regc_locale.c b/generic/regc_locale.c index 002b264..19ac511 100644 --- a/generic/regc_locale.c +++ b/generic/regc_locale.c @@ -828,7 +828,7 @@ element( */ Tcl_DStringInit(&ds); - np = Tcl_UniCharToUtfDString(startp, (int)len, &ds); + np = TclUnicodeToUtfDString(startp, (int)len, &ds); for (cn=cnames; cn->name!=NULL; cn++) { if (strlen(cn->name)==len && strncmp(cn->name, np, len)==0) { break; /* NOTE BREAK OUT */ @@ -1000,7 +1000,7 @@ cclass( len = endp - startp; Tcl_DStringInit(&ds); - np = Tcl_UniCharToUtfDString(startp, (int)len, &ds); + np = TclUnicodeToUtfDString(startp, (int)len, &ds); /* * Map the name to the corresponding enumerated value. diff --git a/generic/regcustom.h b/generic/regcustom.h index 095385d..5befada 100644 --- a/generic/regcustom.h +++ b/generic/regcustom.h @@ -66,7 +66,7 @@ #undef __REG_NOCHAR #endif /* Interface types */ -#define __REG_WIDE_T Tcl_UniChar +#define __REG_WIDE_T unsigned #define __REG_REGOFF_T long /* Not really right, but good enough... */ /* Names and declarations */ #define __REG_WIDE_COMPILE TclReComp @@ -81,22 +81,16 @@ * Internal character type and related. */ -typedef Tcl_UniChar chr; /* The type itself. */ +typedef unsigned chr; /* The type itself. */ typedef int pchr; /* What it promotes to. */ typedef unsigned uchr; /* Unsigned type that will hold a chr. */ typedef int celt; /* Type to hold chr, or NOCELT */ #define NOCELT (-1) /* Celt value which is not valid chr */ #define CHR(c) (UCHAR(c)) /* Turn char literal into chr literal */ #define DIGITVAL(c) ((c)-'0') /* Turn chr digit into its value */ -#if TCL_UTF_MAX > 4 #define CHRBITS 32 /* Bits in a chr; must not use sizeof */ #define CHR_MIN 0x00000000 /* Smallest and largest chr; the value */ -#define CHR_MAX 0x10ffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ -#else -#define CHRBITS 16 /* Bits in a chr; must not use sizeof */ -#define CHR_MIN 0x0000 /* Smallest and largest chr; the value */ -#define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ -#endif +#define CHR_MAX 0x0010ffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ /* * Functions operating on chr. diff --git a/generic/regex.h b/generic/regex.h index 8845f72..0b559f4 100644 --- a/generic/regex.h +++ b/generic/regex.h @@ -99,7 +99,7 @@ extern "C" { #undef __REG_NOCHAR #endif /* interface types */ -#define __REG_WIDE_T Tcl_UniChar +#define __REG_WIDE_T unsigned #define __REG_REGOFF_T long /* not really right, but good enough... */ /* names and declarations */ #define __REG_WIDE_COMPILE TclReComp diff --git a/generic/tclInt.h b/generic/tclInt.h index 50048e9..28549d9 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3985,6 +3985,15 @@ MODULE_SCOPE int TclPtrUnsetVarIdx(Tcl_Interp *interp, Var *varPtr, MODULE_SCOPE void TclInvalidateNsPath(Namespace *nsPtr); MODULE_SCOPE void TclFindArrayPtrElements(Var *arrayPtr, Tcl_HashTable *tablePtr); +#if TCL_UTF_MAX <= 4 +MODULE_SCOPE char * TclUnicodeToUtfDString(const unsigned *uniStr, + int uniLength, Tcl_DString *dsPtr); +MODULE_SCOPE unsigned * TclUtfToUnicodeDString(const char *src, int length, + Tcl_DString *dsPtr); +#else +# define TclUnicodeToUtfDString Tcl_UniCharToUtfDString +# define TclUtfToUnicodeDString Tcl_UtfToUniCharDString +#endif /* * The new extended interface to the variable traces. diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 5f8dc20..79b979c 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -90,8 +90,8 @@ static void DupRegexpInternalRep(Tcl_Obj *srcPtr, static void FinalizeRegexp(ClientData clientData); static void FreeRegexp(TclRegexp *regexpPtr); static void FreeRegexpInternalRep(Tcl_Obj *objPtr); -static int RegExpExecUniChar(Tcl_Interp *interp, Tcl_RegExp re, - const Tcl_UniChar *uniString, int numChars, +static int RegExpExecUnicode(Tcl_Interp *interp, Tcl_RegExp re, + const __REG_WIDE_T *uniString, int numChars, int nmatches, int flags); static int SetRegexpFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); @@ -175,7 +175,7 @@ Tcl_RegExpExec( int flags, result, numChars; TclRegexp *regexp = (TclRegexp *) re; Tcl_DString ds; - const Tcl_UniChar *ustr; + const __REG_WIDE_T *ustr; /* * If the starting point is offset from the beginning of the buffer, then @@ -200,9 +200,9 @@ Tcl_RegExpExec( */ Tcl_DStringInit(&ds); - ustr = Tcl_UtfToUniCharDString(text, -1, &ds); - numChars = Tcl_DStringLength(&ds) / sizeof(Tcl_UniChar); - result = RegExpExecUniChar(interp, re, ustr, numChars, -1 /* nmatches */, + ustr = TclUtfToUnicodeDString(text, -1, &ds); + numChars = Tcl_DStringLength(&ds) / sizeof(__REG_WIDE_T); + result = RegExpExecUnicode(interp, re, ustr, numChars, -1 /* nmatches */, flags); Tcl_DStringFree(&ds); @@ -261,7 +261,7 @@ Tcl_RegExpRange( /* *--------------------------------------------------------------------------- * - * RegExpExecUniChar -- + * RegExpExecUnicode -- * * Execute the regular expression matcher using a compiled form of a * regular expression and save information about any match that is found. @@ -279,12 +279,12 @@ Tcl_RegExpRange( */ static int -RegExpExecUniChar( +RegExpExecUnicode( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tcl_RegExp re, /* Compiled regular expression; returned by a * previous call to Tcl_GetRegExpFromObj */ - const Tcl_UniChar *wString, /* String against which to match re. */ - int numChars, /* Length of Tcl_UniChar string (must be + const __REG_WIDE_T *wString, /* String against which to match re. */ + int numChars, /* Length of Unicode string (must be * >=0). */ int nmatches, /* How many subexpression matches (counting * the whole match as subexpression 0) are of @@ -432,8 +432,9 @@ Tcl_RegExpExecObj( int flags) /* Regular expression execution flags. */ { TclRegexp *regexpPtr = (TclRegexp *) re; - Tcl_UniChar *udata; - int length; + Tcl_DString ds; + __REG_WIDE_T *udata; + int length, result; int reflags = regexpPtr->flags; #define TCL_REG_GLOBOK_FLAGS \ (TCL_REG_ADVANCED | TCL_REG_NOSUB | TCL_REG_NOCASE) @@ -464,7 +465,9 @@ Tcl_RegExpExecObj( regexpPtr->string = NULL; regexpPtr->objPtr = textObj; - udata = Tcl_GetUnicodeFromObj(textObj, &length); + Tcl_DStringInit(&ds); + udata = TclUtfToUnicodeDString(Tcl_GetString(textObj), -1, &ds); + length = Tcl_DStringLength(&ds)/sizeof(__REG_WIDE_T); if (offset > length) { offset = length; @@ -472,7 +475,9 @@ Tcl_RegExpExecObj( udata += offset; length -= offset; - return RegExpExecUniChar(interp, re, udata, length, nmatches, flags); + result = RegExpExecUnicode(interp, re, udata, length, nmatches, flags); + Tcl_DStringFree(&ds); + return result; } /* @@ -858,7 +863,7 @@ CompileRegexp( int flags) /* Compilation flags. */ { TclRegexp *regexpPtr; - const Tcl_UniChar *uniString; + const __REG_WIDE_T *uniString; int numChars, status, i, exact; Tcl_DString stringBuf; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -923,8 +928,8 @@ CompileRegexp( */ Tcl_DStringInit(&stringBuf); - uniString = Tcl_UtfToUniCharDString(string, length, &stringBuf); - numChars = Tcl_DStringLength(&stringBuf) / sizeof(Tcl_UniChar); + uniString = TclUtfToUnicodeDString(string, length, &stringBuf); + numChars = Tcl_DStringLength(&stringBuf) / sizeof(__REG_WIDE_T); /* * Compile the string and check for errors. diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 1d73a7a..259a124 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -235,6 +235,63 @@ Tcl_UniCharToUtfDString( /* *--------------------------------------------------------------------------- * + * TclUnicodeToUtfDString -- + * + * Convert the given Unicode string to UTF-8. + * + * Results: + * The return value is a pointer to the UTF-8 representation of the + * Unicode string. Storage for the return value is appended to the end of + * dsPtr. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +#if TCL_UTF_MAX <= 4 +char * +TclUnicodeToUtfDString( + const unsigned *uniStr, /* Unicode string to convert to UTF-8. */ + int uniLength, /* Length of Unicode string in Tcl_UniChars + * (must be >= 0). */ + Tcl_DString *dsPtr) /* UTF-8 representation of string is appended + * to this previously initialized DString. */ +{ + const unsigned *w, *wEnd; + char *p, *string; + int oldLength; + + /* + * UTF-8 string length in bytes will be <= Unicode string length * 4. + */ + + oldLength = Tcl_DStringLength(dsPtr); + Tcl_DStringSetLength(dsPtr, (oldLength + uniLength + 1) * 4); + string = Tcl_DStringValue(dsPtr) + oldLength; + + p = string; + wEnd = uniStr + uniLength; + for (w = uniStr; w < wEnd; ) { + if ((*w & 0xD800) == 0xD800) { + *p++ = (*w >> 12) | 0xE0; + *p++ = ((*w >> 6) & 0x3F) | 0x80; + *p++ = (*w & 0x3F) | 0xE0; + } else { + p += Tcl_UniCharToUtf(*w, p); + } + w++; + } + Tcl_DStringSetLength(dsPtr, oldLength + (p - string)); + + return string; +} +#endif + +/* + *--------------------------------------------------------------------------- + * * Tcl_UtfToUniChar -- * * Extract the Tcl_UniChar represented by the UTF-8 string. Bad UTF-8 @@ -439,6 +496,74 @@ Tcl_UtfToUniCharDString( /* *--------------------------------------------------------------------------- * + * TclUtfToUnicodeDString -- + * + * Convert the UTF-8 string to Unicode. + * + * Results: + * The return value is a pointer to the Unicode representation of the + * UTF-8 string. Storage for the return value is appended to the end of + * dsPtr. The Unicode string is terminated with a Unicode NULL character. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ +#if TCL_UTF_MAX <= 4 +unsigned * +TclUtfToUnicodeDString( + const char *src, /* UTF-8 string to convert to Unicode. */ + int length, /* Length of UTF-8 string in bytes, or -1 for + * strlen(). */ + Tcl_DString *dsPtr) /* Unicode representation of string is + * appended to this previously initialized + * DString. */ +{ + Tcl_UniChar ch = 0; + unsigned *w, *wString; + const char *p, *end; + int oldLength, len; + + if (length < 0) { + length = strlen(src); + } + + /* + * Unicode string length in Tcl_UniChars will be <= UTF-8 string length in + * bytes. + */ + + oldLength = Tcl_DStringLength(dsPtr); +/* TODO: fix overreach! */ + Tcl_DStringSetLength(dsPtr, + (int) ((oldLength + length + 1) * sizeof(unsigned))); + wString = (unsigned *) (Tcl_DStringValue(dsPtr) + oldLength); + + w = wString; + end = src + length; + for (p = src; p < end; ) { + len = TclUtfToUniChar(p, &ch); + if (!len) { + int high = ch; + len = TclUtfToUniChar(p, &ch); + *w++ = ((high & 0x7ff) << 10) + (ch & 0x7ff) + 0x10000; + } else { + *w++ = ch; + } + p += len; + } + *w = '\0'; + Tcl_DStringSetLength(dsPtr, + (oldLength + ((char *) w - (char *) wString))); + + return wString; +} +#endif + +/* + *--------------------------------------------------------------------------- + * * Tcl_UtfCharComplete -- * * Determine if the UTF-8 string of the given length is long enough to be -- cgit v0.12 From 8265ea67d6285031031eeee4037a3b9b35262a10 Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 11 May 2019 15:04:57 +0000 Subject: Convert deprecation to elimination for Tcl 9. --- doc/TraceVar.3 | 5 +++-- generic/tcl.h | 4 ---- generic/tclTrace.c | 16 ---------------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/doc/TraceVar.3 b/doc/TraceVar.3 index ef5d80a..dd72563 100644 --- a/doc/TraceVar.3 +++ b/doc/TraceVar.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -.TH Tcl_TraceVar 3 8.7 Tcl "Tcl Library Procedures" +.TH Tcl_TraceVar 3 9.0 Tcl "Tcl Library Procedures" .so man.macros .BS .SH NAME @@ -333,7 +333,8 @@ The routine \fBTcl_InterpDeleted\fR is an important tool for this. When \fBTcl_InterpDeleted\fR returns 1, \fIproc\fR will not be able to invoke any scripts in \fIinterp\fR. You may encounter old code using a deprecated flag value \fBTCL_INTERP_DESTROYED\fR to signal this -condition, but any supported code should be converted to stop using it. +condition, but Tcl 9 no longer supports this. Any supported code +must be converted to stop using it. .PP A trace procedure can be called at any time, even when there are partially formed results stored in the interpreter. If diff --git a/generic/tcl.h b/generic/tcl.h index ee8ab68..160de7a 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -887,10 +887,6 @@ typedef struct Tcl_DString { #define TCL_TRACE_UNSETS 0x40 #define TCL_TRACE_DESTROYED 0x80 -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 -#define TCL_INTERP_DESTROYED 0x100 -#endif - #define TCL_LEAVE_ERR_MSG 0x200 #define TCL_TRACE_ARRAY 0x800 #ifndef TCL_REMOVE_OBSOLETE_TRACES diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 56010e4..e3b02b7 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -2565,9 +2565,6 @@ TclObjCallVarTraces( leaveErrMsg); } -#undef TCL_INTERP_DESTROYED -#define TCL_INTERP_DESTROYED 0x100 - int TclCallVarTraces( Interp *iPtr, /* Interpreter containing variable. */ @@ -2647,13 +2644,6 @@ TclCallVarTraces( } /* - * Ignore any caller-provided TCL_INTERP_DESTROYED flag. Only we can - * set it correctly. - */ - - flags &= ~TCL_INTERP_DESTROYED; - - /* * Invoke traces on the array containing the variable, if relevant. */ @@ -2675,9 +2665,6 @@ TclCallVarTraces( if (state == NULL) { state = Tcl_SaveInterpState((Tcl_Interp *) iPtr, code); } - if (Tcl_InterpDeleted((Tcl_Interp *) iPtr)) { - flags |= TCL_INTERP_DESTROYED; - } result = tracePtr->traceProc(tracePtr->clientData, (Tcl_Interp *) iPtr, part1, part2, flags); if (result != NULL) { @@ -2719,9 +2706,6 @@ TclCallVarTraces( if (state == NULL) { state = Tcl_SaveInterpState((Tcl_Interp *) iPtr, code); } - if (Tcl_InterpDeleted((Tcl_Interp *) iPtr)) { - flags |= TCL_INTERP_DESTROYED; - } result = tracePtr->traceProc(tracePtr->clientData, (Tcl_Interp *) iPtr, part1, part2, flags); if (result != NULL) { -- cgit v0.12 From 4864626e88652c0a09494ade3aacab44a122777e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 5 Jul 2019 13:34:24 +0000 Subject: Fix [4718b41c56d8c135] for win32. Now timestamps on Win32 can be > 19 january 2038. Caveat: Now Tcl MUST be compiled with VS2005+, or any other compiler which has C headers compatible with VC2005+ (latest mingw-w64 is OK too!) Tcl on Win32 is now no longer compiled with _USE_32BIT_TIME_T, so this is (potentially) binary incompatible. --- generic/tcl.h | 19 ++++--------------- generic/tclBasic.c | 8 ++++---- win/tclWinFile.c | 14 +++++++------- win/tclWinPort.h | 3 +-- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 46561b5..37895b8 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -308,15 +308,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; #define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) #if defined(_WIN32) -# ifdef __BORLANDC__ - typedef struct stati64 Tcl_StatBuf; -# elif defined(_WIN64) - typedef struct __stat64 Tcl_StatBuf; -# elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T) - typedef struct _stati64 Tcl_StatBuf; -# else - typedef struct _stat32i64 Tcl_StatBuf; -# endif /* _MSC_VER < 1400 */ + typedef struct __stat64 Tcl_StatBuf; #elif defined(__CYGWIN__) typedef struct { dev_t st_dev; @@ -329,13 +321,10 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; dev_t st_rdev; /* Here is a 4-byte gap */ long long st_size; - struct {long tv_sec;} st_atim; - struct {long tv_sec;} st_mtim; - struct {long tv_sec;} st_ctim; - /* Here is a 4-byte gap */ + struct {long long tv_sec;} st_atim; + struct {long long tv_sec;} st_mtim; + struct {long long tv_sec;} st_ctim; } Tcl_StatBuf; -#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) - typedef struct stat64 Tcl_StatBuf; #else typedef struct stat Tcl_StatBuf; #endif diff --git a/generic/tclBasic.c b/generic/tclBasic.c index f957dc8..d35fa47 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -639,14 +639,14 @@ Tcl_CreateInterp(void) } #if defined(_WIN32) && !defined(_WIN64) - if (sizeof(time_t) != 4) { + if (sizeof(time_t) != 8) { /*NOTREACHED*/ - Tcl_Panic(" is not compatible with MSVC"); + Tcl_Panic(" is not compatible with VS2005+"); } if ((offsetof(Tcl_StatBuf,st_atime) != 32) - || (offsetof(Tcl_StatBuf,st_ctime) != 40)) { + || (offsetof(Tcl_StatBuf,st_ctime) != 48)) { /*NOTREACHED*/ - Tcl_Panic(" is not compatible with MSVC"); + Tcl_Panic(" is not compatible with VS2005+"); } #endif diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 080156e..14c4378 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -149,8 +149,8 @@ typedef struct { * Other typedefs required by this code. */ -static time_t ToCTime(FILETIME fileTime); -static void FromCTime(time_t posixTime, FILETIME *fileTime); +static __time64_t ToCTime(FILETIME fileTime); +static void FromCTime(__time64_t posixTime, FILETIME *fileTime); /* * Declarations for local functions defined in this file: @@ -2265,7 +2265,7 @@ NativeStatMode( * * ToCTime -- * - * Converts a Windows FILETIME to a time_t in UTC. + * Converts a Windows FILETIME to a __time64_t in UTC. * * Results: * Returns the count of seconds from the Posix epoch. @@ -2273,7 +2273,7 @@ NativeStatMode( *------------------------------------------------------------------------ */ -static time_t +static __time64_t ToCTime( FILETIME fileTime) /* UTC time */ { @@ -2282,7 +2282,7 @@ ToCTime( convertedTime.LowPart = fileTime.dwLowDateTime; convertedTime.HighPart = (LONG) fileTime.dwHighDateTime; - return (time_t) ((convertedTime.QuadPart - + return (__time64_t) ((convertedTime.QuadPart - (Tcl_WideInt) POSIX_EPOCH_AS_FILETIME) / (Tcl_WideInt) 10000000); } @@ -2291,7 +2291,7 @@ ToCTime( * * FromCTime -- * - * Converts a time_t to a Windows FILETIME + * Converts a __time64_t to a Windows FILETIME * * Results: * Returns the count of 100-ns ticks seconds from the Windows epoch. @@ -2301,7 +2301,7 @@ ToCTime( static void FromCTime( - time_t posixTime, + __time64_t posixTime, FILETIME *fileTime) /* UTC Time */ { LARGE_INTEGER convertedTime; diff --git a/win/tclWinPort.h b/win/tclWinPort.h index e74ee1c..5bcf76c 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -15,8 +15,7 @@ #define _TCLWINPORT #if !defined(_WIN64) && defined(BUILD_tcl) -/* See [Bug 3354324]: file mtime sets wrong time */ -# define _USE_32BIT_TIME_T +# define __MINGW_USE_VC2005_COMPAT #endif /* -- cgit v0.12 From 44952e7c43df343677cc3b6e2e455bda44b416f2 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 12 Jul 2019 14:32:39 +0000 Subject: restore test-cases covering bug-4718b41c56 (partially revert last checkin, cherrypick from 8.7), set constraint time64bit to 1 (always valid in 9.0) --- tests/cmdAH.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 54c4413..3d8f4f5 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -21,6 +21,7 @@ catch [list package require -exact Tcltest [info patchlevel]] testConstraint testchmod [llength [info commands testchmod]] testConstraint testsetplatform [llength [info commands testsetplatform]] testConstraint testvolumetype [llength [info commands testvolumetype]] +testConstraint time64bit 1 testConstraint linkDirectory [expr { ![testConstraint win] || ($::tcl_platform(osVersion) >= 5.0 @@ -1288,6 +1289,22 @@ test cmdAH-24.14.1 { file mtime [file join [temporaryDirectory] CON.txt] } -match regexp -result {could not (?:get modification time|read)} -returnCodes error +# 3155760000 is 64-bit unix time, Wed Jan 01 00:00:00 GMT 2070: +test cmdAH-24.20.1 {Tcl_FileObjCmd: atime 64-bit time_t, bug [4718b41c56]} -constraints {time64bit} -setup { + set filename [makeFile "" foo.text] +} -body { + list [file atime $filename 3155760000] [file atime $filename] +} -cleanup { + removeFile $filename +} -result {3155760000 3155760000} +test cmdAH-24.20.2 {Tcl_FileObjCmd: mtime 64-bit time_t, bug [4718b41c56]} -constraints {time64bit} -setup { + set filename [makeFile "" foo.text] +} -body { + list [file mtime $filename 3155760000] [file mtime $filename] +} -cleanup { + file delete -force $filename +} -result {3155760000 3155760000} + # owned test cmdAH-25.1 {Tcl_FileObjCmd: owned} -returnCodes error -body { file owned a b -- cgit v0.12 From 9888ccda67f1a91d95ba372d5f008f939da39b6b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 5 Aug 2019 20:15:15 +0000 Subject: Fix signature of TclWCharToUtfDString for TCL_UTF_MAX=6, and handling of length -1 --- generic/tclInt.h | 4 ++-- generic/tclUtf.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index cb08a54..1631316 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3175,9 +3175,9 @@ MODULE_SCOPE void TclRegisterCommandTypeName( #if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32)) MODULE_SCOPE int TclUtfToWChar(const char *src, WCHAR *chPtr); MODULE_SCOPE char * TclWCharToUtfDString(const WCHAR *uniStr, - int uniLength, Tcl_DString *dsPtr); + size_t uniLength, Tcl_DString *dsPtr); MODULE_SCOPE WCHAR * TclUtfToWCharDString(const char *src, - int length, Tcl_DString *dsPtr); + size_t length, Tcl_DString *dsPtr); #else # define TclUtfToWChar TclUtfToUniChar # define TclWCharToUtfDString Tcl_UniCharToUtfDString diff --git a/generic/tclUtf.c b/generic/tclUtf.c index ef89a6a..e27e465 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -269,7 +269,7 @@ Tcl_UniCharToUtfDString( char * TclWCharToUtfDString( const WCHAR *uniStr, /* WCHAR string to convert to UTF-8. */ - int uniLength, /* Length of WCHAR string in Tcl_UniChars + size_t uniLength, /* Length of WCHAR string in Tcl_UniChars * (must be >= 0). */ Tcl_DString *dsPtr) /* UTF-8 representation of string is appended * to this previously initialized DString. */ @@ -636,7 +636,7 @@ Tcl_UtfToUniCharDString( WCHAR * TclUtfToWCharDString( const char *src, /* UTF-8 string to convert to Unicode. */ - int length, /* Length of UTF-8 string in bytes, or -1 for + size_t length, /* Length of UTF-8 string in bytes, or -1 for * strlen(). */ Tcl_DString *dsPtr) /* Unicode representation of string is * appended to this previously initialized @@ -646,7 +646,7 @@ TclUtfToWCharDString( const char *p, *end; int oldLength; - if (length < 0) { + if (length == TCL_AUTO_LENGTH) { length = strlen(src); } -- cgit v0.12 From 6ba55114e28426856f8905b08e31340c268459d5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 11 Aug 2019 21:17:35 +0000 Subject: Fix handling of length (size_t)-1 in tclMain.c. This should fix handling of command-line arguments with TCL_UTF_MAX=6, necessary to make tclsh run at all ... --- generic/tclMain.c | 2 +- generic/tclUtf.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/generic/tclMain.c b/generic/tclMain.c index ea69b2d..31e6438 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -70,7 +70,7 @@ NewNativeObj( Tcl_DString ds; #ifdef UNICODE - if (length > 0) { + if (length != TCL_AUTO_LENGTH) { length *= sizeof(WCHAR); } Tcl_WinTCharToUtf(string, length, &ds); diff --git a/generic/tclUtf.c b/generic/tclUtf.c index e27e465..c3b5163 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -276,7 +276,8 @@ TclWCharToUtfDString( { const WCHAR *w, *wEnd; char *p, *string; - int oldLength, len = 1; + size_t oldLength; + int len = 1; /* * UTF-8 string length in bytes will be <= Unicode string length * 4. @@ -644,14 +645,14 @@ TclUtfToWCharDString( { WCHAR ch = 0, *w, *wString; const char *p, *end; - int oldLength; + size_t oldLength; if (length == TCL_AUTO_LENGTH) { length = strlen(src); } /* - * Unicode string length in Tcl_UniChars will be <= UTF-8 string length in + * Unicode string length in WCHARs will be <= UTF-8 string length in * bytes. */ -- cgit v0.12 From cef22b73ee8b85982687b86863635d8e57e7c959 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 5 Sep 2019 07:17:54 +0000 Subject: previous commit should not have been a merge-mark ... --- win/tclWinPort.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 5bcf76c..aae6592 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -14,7 +14,7 @@ #ifndef _TCLWINPORT #define _TCLWINPORT -#if !defined(_WIN64) && defined(BUILD_tcl) +#if !defined(_WIN64) # define __MINGW_USE_VC2005_COMPAT #endif -- cgit v0.12 From 556c0dbc24744d656c4e3b7ebe4810fd1dc089a5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 14 Sep 2019 13:11:55 +0000 Subject: Two paces where TCL_AUTO_LENGTH should be used --- generic/tclUtf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 644939b..b12e8bf 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -240,7 +240,7 @@ Tcl_UniCharToUtfDString( if (uniStr == NULL) { return NULL; } - if (uniLength < 0) { + if (uniLength == TCL_AUTO_LENGTH) { uniLength = 0; w = uniStr; while (*w != '\0') { @@ -282,7 +282,7 @@ Tcl_Char16ToUtfDString( if (uniStr == NULL) { return NULL; } - if (uniLength < 0) { + if (uniLength == TCL_AUTO_LENGTH) { uniLength = 0; w = uniStr; -- cgit v0.12 From 0153d6f564a91a55104e15fd3fbeb0afc9735302 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 25 Sep 2019 11:51:41 +0000 Subject: Make Tcl_WinUtfToTChar/Tcl_WinTCharToUtf really deprecate in 9.0 (now that no battery-extensions use it any more) Remove two functions which are not used any more (they changed to macro's earlier) --- generic/tclObj.c | 129 ------------------------------------------------- generic/tclPlatDecls.h | 2 +- 2 files changed, 1 insertion(+), 130 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index f8fecbd..d711adb 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2503,135 +2503,6 @@ UpdateStringOfInt( /* *---------------------------------------------------------------------- * - * Tcl_NewLongObj -- - * - * If a client is compiled with TCL_MEM_DEBUG defined, calls to - * Tcl_NewLongObj to create a new long integer object end up calling the - * debugging function Tcl_DbNewLongObj instead. - * - * Otherwise, if the client is compiled without TCL_MEM_DEBUG defined, - * calls to Tcl_NewLongObj result in a call to one of the two - * Tcl_NewLongObj implementations below. We provide two implementations - * so that the Tcl core can be compiled to do memory debugging of the - * core even if a client does not request it for itself. - * - * Integer and long integer objects share the same "integer" type - * implementation. We store all integers as longs and Tcl_GetIntFromObj - * checks whether the current value of the long can be represented by an - * int. - * - * Results: - * The newly created object is returned. This object will have an invalid - * string representation. The returned object has ref count 0. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -#ifndef TCL_NO_DEPRECATED -#undef Tcl_NewLongObj -#ifdef TCL_MEM_DEBUG - -Tcl_Obj * -Tcl_NewLongObj( - long longValue) /* Long integer used to initialize the - * new object. */ -{ - return Tcl_DbNewWideIntObj(longValue, "unknown", 0); -} - -#else /* if not TCL_MEM_DEBUG */ - -Tcl_Obj * -Tcl_NewLongObj( - long longValue) /* Long integer used to initialize the - * new object. */ -{ - Tcl_Obj *objPtr; - - TclNewIntObj(objPtr, longValue); - return objPtr; -} -#endif /* if TCL_MEM_DEBUG */ -#endif /* TCL_NO_DEPRECATED */ - -/* - *---------------------------------------------------------------------- - * - * Tcl_DbNewLongObj -- - * - * If a client is compiled with TCL_MEM_DEBUG defined, calls to - * Tcl_NewIntObj and Tcl_NewLongObj to create new integer or long integer - * objects end up calling the debugging function Tcl_DbNewLongObj - * instead. We provide two implementations of Tcl_DbNewLongObj so that - * whether the Tcl core is compiled to do memory debugging of the core is - * independent of whether a client requests debugging for itself. - * - * When the core is compiled with TCL_MEM_DEBUG defined, Tcl_DbNewLongObj - * calls Tcl_DbCkalloc directly with the file name and line number from - * its caller. This simplifies debugging since then the [memory active] - * command will report the caller's file name and line number when - * reporting objects that haven't been freed. - * - * Otherwise, when the core is compiled without TCL_MEM_DEBUG defined, - * this function just returns the result of calling Tcl_NewLongObj. - * - * Results: - * The newly created long integer object is returned. This object will - * have an invalid string representation. The returned object has ref - * count 0. - * - * Side effects: - * Allocates memory. - * - *---------------------------------------------------------------------- - */ - -#ifndef TCL_NO_DEPRECATED -#undef Tcl_DbNewLongObj -#ifdef TCL_MEM_DEBUG - -Tcl_Obj * -Tcl_DbNewLongObj( - long longValue, /* Long integer used to initialize the new - * object. */ - const char *file, /* The name of the source file calling this - * function; used for debugging. */ - int line) /* Line number in the source file; used for - * debugging. */ -{ - Tcl_Obj *objPtr; - - TclDbNewObj(objPtr, file, line); - /* Optimized TclInvalidateStringRep */ - objPtr->bytes = NULL; - - objPtr->internalRep.wideValue = longValue; - objPtr->typePtr = &tclIntType; - return objPtr; -} - -#else /* if not TCL_MEM_DEBUG */ - -Tcl_Obj * -Tcl_DbNewLongObj( - long longValue, /* Long integer used to initialize the new - * object. */ - const char *file, /* The name of the source file calling this - * function; used for debugging. */ - int line) /* Line number in the source file; used for - * debugging. */ -{ - return Tcl_NewWideIntObj(longValue); -} -#endif /* TCL_MEM_DEBUG */ -#endif /* TCL_NO_DEPRECATED */ - -/* - *---------------------------------------------------------------------- - * * Tcl_GetLongFromObj -- * * Attempt to return an long integer from the Tcl object "objPtr". If the diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index b1f6ecd..18e464c 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -99,7 +99,7 @@ extern const TclPlatStubs *tclPlatStubsPtr; #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT -#if defined(USE_TCL_STUBS) && defined(_WIN32) +#if defined(USE_TCL_STUBS) && defined(_WIN32) && !defined(TCL_NO_DEPRECATED) #define Tcl_WinUtfToTChar(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \ (TCHAR *)Tcl_UtfToChar16DString((string), (len), (dsPtr))) #define Tcl_WinTCharToUtf(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \ -- cgit v0.12 From 80a7abf7e553cc0c0ea01f10df7790996460b133 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 27 Sep 2019 13:02:39 +0000 Subject: Adapt test-case to full-utf correct behaviour --- tests/string.test | 14 +++++++------- tests/utf.test | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/string.test b/tests/string.test index c54b5ba..299c765 100644 --- a/tests/string.test +++ b/tests/string.test @@ -31,7 +31,7 @@ proc makeShared {s} {uplevel 1 [list lappend copy $s]; return $s} testConstraint testobj [expr {[info commands testobj] ne {}}] testConstraint testindexobj [expr {[info commands testindexobj] ne {}}] testConstraint testevalex [expr {[info commands testevalex] ne {}}] -testConstraint tip389 [expr {[string length \U010000] == 2}] +testConstraint fullutf [expr {[string length \U010000] == 1}] # Used for constraining memory leak tests testConstraint memory [llength [info commands memory]] @@ -505,9 +505,9 @@ test string-5.19.$noComp {string index, bytearray object out of bounds} { test string-5.20.$noComp {string index, bytearray object out of bounds} { run {string index [binary format I* {0x50515253 0x52}] 20} } {} -test string-5.21.$noComp {string index, surrogates, bug [11ae2be95dac9417]} tip389 { +test string-5.21.$noComp {string index, surrogates, bug [11ae2be95dac9417]} fullutf { run {list [string index a\U100000b 1] [string index a\U100000b 2] [string index a\U100000b 3]} -} [list \U100000 {} b] +} [list \U100000 b {}] proc largest_int {} { @@ -1502,9 +1502,9 @@ test string-12.22.$noComp {string range, shimmering binary/index} { binary scan $s a* x run {string range $s $s end} } 000000001 -test string-12.23.$noComp {string range, surrogates, bug [11ae2be95dac9417]} tip389 { +test string-12.23.$noComp {string range, surrogates, bug [11ae2be95dac9417]} fullutf { run {list [string range a\U100000b 1 1] [string range a\U100000b 2 2] [string range a\U100000b 3 3]} -} [list \U100000 {} b] +} [list \U100000 b {}] test string-13.1.$noComp {string repeat} { list [catch {run {string repeat}} msg] $msg @@ -1743,10 +1743,10 @@ test string-17.7.$noComp {string totitle, unicode} { test string-17.8.$noComp {string totitle, compiled} { lindex [run {string totitle [list aa bb [list cc]]}] 0 } Aa -test string-17.9.$noComp {string totitle, surrogates, bug [11ae2be95dac9417]} tip389 { +test string-17.9.$noComp {string totitle, surrogates, bug [11ae2be95dac9417]} fullutf { run {list [string totitle a\U118c0c 1 1] [string totitle a\U118c0c 2 2] \ [string totitle a\U118c0c 3 3]} -} [list a\U118a0c a\U118c0C a\U118c0C] +} [list a\U118a0c a\U118c0C a\U118c0c] test string-18.1.$noComp {string trim} { list [catch {run {string trim}} msg] $msg diff --git a/tests/utf.test b/tests/utf.test index 979c4a6..45698e4 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -21,7 +21,7 @@ testConstraint testbytestring [llength [info commands testbytestring]] catch {unset x} # Some tests require support for 4-byte UTF-8 sequences -testConstraint tip389 [expr {[string length \U010000] == 2}] +testConstraint fullutf [expr {[string length \U010000] == 1}] test utf-1.1 {Tcl_UniCharToUtf: 1 byte sequences} testbytestring { expr {"\x01" eq [testbytestring "\x01"]} @@ -78,12 +78,12 @@ test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} testbytestrin test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} testbytestring { string length [testbytestring "\xE4\xb9\x8e"] } {1} -test utf-2.8 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {tip389 testbytestring} -body { +test utf-2.8 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {fullutf testbytestring} -body { string length [testbytestring "\xF0\x90\x80\x80"] -} -result {2} -test utf-2.9 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {tip389 testbytestring} -body { +} -result {1} +test utf-2.9 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {fullutf testbytestring} -body { string length [testbytestring "\xF4\x8F\xBF\xBF"] -} -result {2} +} -result {1} test utf-2.10 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail, underflow} testbytestring { string length [testbytestring "\xF0\x8F\xBF\xBF"] } {4} -- cgit v0.12 From e9121854f920a1649aab0470f552174d29c41c9d Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 25 Oct 2019 01:16:54 +0000 Subject: Remove /System from auto_path on macOS because Apple has deprecated its own ancient installation of Tcl/Tk --- unix/configure | 4 ++-- unix/configure.ac | 4 ++-- unix/tcl.m4 | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/unix/configure b/unix/configure index e9607db..57fbd11 100755 --- a/unix/configure +++ b/unix/configure @@ -10375,9 +10375,9 @@ VERSION=${TCL_VERSION} if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ - TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks" + TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl ~/Library/Frameworks /Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" elif test "$prefix/lib" != "$libdir"; then TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}" else diff --git a/unix/configure.ac b/unix/configure.ac index 8335b20..fe88066 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -930,9 +930,9 @@ VERSION=${TCL_VERSION} if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ - TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks" + TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl ~/Library/Frameworks /Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" elif test "$prefix/lib" != "$libdir"; then TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index e592e18..5edb91a 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -77,7 +77,6 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tcl.framework/tclConfig.sh" ; then ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" @@ -210,7 +209,6 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tk.framework/tkConfig.sh" ; then ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" -- cgit v0.12 From 2d699b3818a62e40f4875dcbe68dc6b9bff12d24 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Fri, 25 Oct 2019 13:17:28 +0000 Subject: If NO_REALPATH is defined, raise an error instead of building a broken Tcl. --- unix/tclUnixFCmd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index db49024..dd868ef 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -268,6 +268,11 @@ MODULE_SCOPE long tclMacOSXDarwinRelease; #else # define haveRealpath 1 #endif +#else /* NO_REALPATH */ +/* + * At least TclpObjNormalizedPath now requires REALPATH +*/ +#error NO_REALPATH is not supported #endif /* NO_REALPATH */ #ifdef HAVE_FTS -- cgit v0.12 From 2cd7aa2260d55c56deb2a17a759a8b1fe2f62ef2 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 27 Oct 2019 22:14:41 +0000 Subject: Remove /System from auto_path on macOS; change seems to have been overwritten by other merge --- macosx/README | 4 ++-- unix/configure.ac | 4 ++-- unix/tcl.m4 | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/macosx/README b/macosx/README index 8340dfa..6384bf0 100644 --- a/macosx/README +++ b/macosx/README @@ -36,8 +36,8 @@ Weak-linking is available on OS X 10.2 or later, it additionally allows Tcl built on 10.x to run on any 10.y with x > y >= z (for a chosen z >= 2). - Tcl extensions can be installed in any of: - $HOME/Library/Tcl /Library/Tcl /System/Library/Tcl - $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks + $HOME/Library/Tcl /Library/Tcl + $HOME/Library/Frameworks /Library/Frameworks (searched in that order). Given a potential package directory $pkg, Tcl on OSX checks for the file $pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl. diff --git a/unix/configure.ac b/unix/configure.ac index 8335b20..3bd6919 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -930,9 +930,9 @@ VERSION=${TCL_VERSION} if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ - TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks" + TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" elif test "$prefix/lib" != "$libdir"; then TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index e592e18..5edb91a 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -77,7 +77,6 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tcl.framework/tclConfig.sh" ; then ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" @@ -210,7 +209,6 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tk.framework/tkConfig.sh" ; then ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" -- cgit v0.12 From 56f2abbf899a635cf10a1ab0993ff76f2ef6a13e Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 27 Oct 2019 22:22:50 +0000 Subject: further refinement of configure to remove /System --- unix/configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/configure b/unix/configure index e9607db..57fbd11 100755 --- a/unix/configure +++ b/unix/configure @@ -10375,9 +10375,9 @@ VERSION=${TCL_VERSION} if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ - TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks" + TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl ~/Library/Frameworks /Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" elif test "$prefix/lib" != "$libdir"; then TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}" else -- cgit v0.12 From 16ee735e92526dcb8faceb4889bbcc7200f0993b Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 5 Nov 2019 22:05:21 +0000 Subject: Bump to version 9.0a1 for release. --- README.md | 2 +- generic/tcl.h | 4 ++-- library/init.tcl | 2 +- unix/configure | 2 +- unix/configure.ac | 2 +- unix/tcl.spec | 2 +- win/configure | 2 +- win/configure.ac | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 240cdf2..559c1c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # README: Tcl -This is the **Tcl 9.0a0** source distribution. +This is the **Tcl 9.0a1** source distribution. You can get any source release of Tcl from [our distribution site](https://sourceforge.net/projects/tcl/files/Tcl/). diff --git a/generic/tcl.h b/generic/tcl.h index 03189c6..97dd42b 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -51,10 +51,10 @@ extern "C" { #define TCL_MAJOR_VERSION 9 #define TCL_MINOR_VERSION 0 #define TCL_RELEASE_LEVEL TCL_ALPHA_RELEASE -#define TCL_RELEASE_SERIAL 0 +#define TCL_RELEASE_SERIAL 1 #define TCL_VERSION "9.0" -#define TCL_PATCH_LEVEL "9.0a0" +#define TCL_PATCH_LEVEL "9.0a1" #if defined(RC_INVOKED) /* diff --git a/library/init.tcl b/library/init.tcl index 0879064..9ca3eba 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -19,7 +19,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 9.0a0 +package require -exact Tcl 9.0a1 # 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 e10128e..a0d565a 100755 --- a/unix/configure +++ b/unix/configure @@ -2382,7 +2382,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TCL_VERSION=9.0 TCL_MAJOR_VERSION=9 TCL_MINOR_VERSION=0 -TCL_PATCH_LEVEL="a0" +TCL_PATCH_LEVEL="a1" VERSION=${TCL_VERSION} EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"} diff --git a/unix/configure.ac b/unix/configure.ac index 1b80fb3..19f1c64 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TCL_VERSION=9.0 TCL_MAJOR_VERSION=9 TCL_MINOR_VERSION=0 -TCL_PATCH_LEVEL="a0" +TCL_PATCH_LEVEL="a1" VERSION=${TCL_VERSION} EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"} diff --git a/unix/tcl.spec b/unix/tcl.spec index 0858ee7..e703e27 100644 --- a/unix/tcl.spec +++ b/unix/tcl.spec @@ -4,7 +4,7 @@ Name: tcl Summary: Tcl scripting language development environment -Version: 9.0a0 +Version: 9.0a1 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index 4dd6a28..e7a301f 100755 --- a/win/configure +++ b/win/configure @@ -2197,7 +2197,7 @@ SHELL=/bin/sh TCL_VERSION=9.0 TCL_MAJOR_VERSION=9 TCL_MINOR_VERSION=0 -TCL_PATCH_LEVEL="a0" +TCL_PATCH_LEVEL="a1" VER=$TCL_MAJOR_VERSION$TCL_MINOR_VERSION TCL_DDE_VERSION=1.4 diff --git a/win/configure.ac b/win/configure.ac index 985aa0a..9901f64 100644 --- a/win/configure.ac +++ b/win/configure.ac @@ -14,7 +14,7 @@ SHELL=/bin/sh TCL_VERSION=9.0 TCL_MAJOR_VERSION=9 TCL_MINOR_VERSION=0 -TCL_PATCH_LEVEL="a0" +TCL_PATCH_LEVEL="a1" VER=$TCL_MAJOR_VERSION$TCL_MINOR_VERSION TCL_DDE_VERSION=1.4 -- cgit v0.12 From 6802d4740cdcf85a687bdf5144b8c4c91301f78d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Nov 2019 22:18:37 +0000 Subject: Twice ckfree() -> Tcl_Free() --- generic/tclCompile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 1c284df..a2dc7cb 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -2182,7 +2182,7 @@ TclCompileScript( Tcl_LogCommandInfo(interp, script, parsePtr->commandStart, parsePtr->term + 1 - parsePtr->commandStart); TclCompileSyntaxError(interp, envPtr); - ckfree(parsePtr); + Tcl_Free(parsePtr); return; } @@ -2258,7 +2258,7 @@ TclCompileScript( Tcl_FreeParse(parsePtr); } while (numBytes > 0); - ckfree(parsePtr); + Tcl_Free(parsePtr); } if (lastCmdIdx == -1) { -- cgit v0.12 From cbeadca7616cf2561c856e6bb03ab041b33d7a36 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Nov 2019 22:30:07 +0000 Subject: Silence MSVC C4090 warnings when using ckfree() in certain situations. Problem reported by fvogel. --- generic/tcl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generic/tcl.h b/generic/tcl.h index 03189c6..bd05166 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2269,7 +2269,12 @@ EXTERN int TclZipfs_AppHook(int *argc, char ***argv); */ #define ckalloc Tcl_Alloc -#define ckfree Tcl_Free +#ifdef _MSC_VER + /* Silence invalid C4090 warnings */ +# define ckfree(a) Tcl_Free((char *)(a)) +#else +# define ckfree Tcl_Free +#endif #define ckrealloc Tcl_Realloc #define attemptckalloc Tcl_AttemptAlloc #define attemptckrealloc Tcl_AttemptRealloc -- cgit v0.12 From 8665d6160812e8c89fef07e3510761c9b13147ff Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 7 Nov 2019 08:41:17 +0000 Subject: Silence MSVC C4090 warnings when using ckrealloc(). Also make sure that Tcl itself doesn't use ckalloc() and friends any more. --- generic/tcl.h | 24 ++++++++++++++---------- generic/tclCompile.c | 2 +- generic/tclTomMathDecls.h | 17 ++++------------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index bd05166..1050cfb 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2265,19 +2265,23 @@ EXTERN int TclZipfs_AppHook(int *argc, char ***argv); /* *---------------------------------------------------------------------------- * The following declarations map ckalloc and ckfree to Tcl_Alloc and - * Tcl_Free. + * Tcl_Free for use in Tcl-8.x-compatible extensions. */ -#define ckalloc Tcl_Alloc -#ifdef _MSC_VER - /* Silence invalid C4090 warnings */ -# define ckfree(a) Tcl_Free((char *)(a)) -#else -# define ckfree Tcl_Free +#ifndef BUILD_tcl +# define ckalloc Tcl_Alloc +# define attemptckalloc Tcl_AttemptAlloc +# ifdef _MSC_VER + /* Silence invalid C4090 warnings */ +# define ckfree(a) Tcl_Free((char *)(a)) +# define ckrealloc(a,b) Tcl_Realloc((char *)(a),(b)) +# define attemptckrealloc(a,b) Tcl_AttemptRealloc((char *)(a),(b)) +# else +# define ckfree Tcl_Free +# define ckrealloc Tcl_Realloc +# define attemptckrealloc Tcl_AttemptRealloc +# endif #endif -#define ckrealloc Tcl_Realloc -#define attemptckalloc Tcl_AttemptAlloc -#define attemptckrealloc Tcl_AttemptRealloc #ifndef TCL_MEM_DEBUG diff --git a/generic/tclCompile.c b/generic/tclCompile.c index a2dc7cb..59c5ba0 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -2169,7 +2169,7 @@ TclCompileScript( * many nested compilations (body enclosed in body) can cause abnormal * program termination with a stack overflow exception, bug [fec0c17d39]. */ - Tcl_Parse *parsePtr = ckalloc(sizeof(Tcl_Parse)); + Tcl_Parse *parsePtr = Tcl_Alloc(sizeof(Tcl_Parse)); do { const char *next; diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index d69a018..3eaff4e 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -34,19 +34,10 @@ /* Define custom memory allocation for libtommath */ -/* MODULE_SCOPE void* TclBNAlloc( size_t ); */ -#define TclBNAlloc(s) ((void*)Tcl_Alloc((size_t)(s))) -/* MODULE_SCOPE void* TclBNCalloc( size_t, size_t ); */ -#define TclBNCalloc(m,s) memset(ckalloc((size_t)(m)*(size_t)(s)),0,(size_t)(m)*(size_t)(s)) -/* MODULE_SCOPE void* TclBNRealloc( void*, size_t ); */ -#define TclBNRealloc(x,s) ((void*)Tcl_Realloc((char*)(x),(size_t)(s))) -/* MODULE_SCOPE void TclBNFree( void* ); */ -#define TclBNFree(x) (Tcl_Free((char*)(x))) - -#define MP_MALLOC(size) TclBNAlloc(size) -#define MP_CALLOC(nmemb, size) TclBNCalloc(nmemb, size) -#define MP_REALLOC(mem, oldsize, newsize) TclBNRealloc(mem, newsize) -#define MP_FREE(mem, size) TclBNFree(mem) +#define MP_MALLOC(size) Tcl_Alloc(size) +#define MP_CALLOC(nmemb, size) memset(Tcl_Alloc((nmemb)*(size)),0,(nmemb)*(size)) +#define MP_REALLOC(mem, oldsize, newsize) Tcl_Realloc(mem, newsize) +#define MP_FREE(mem, size) Tcl_Free(mem) MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len); -- cgit v0.12 From 69aedf8b1703268a158483088544f839dc3206d5 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Nov 2019 21:01:36 +0000 Subject: reset changes baseline --- changes | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 199 insertions(+), 29 deletions(-) diff --git a/changes b/changes index 2ce48bd..bf50b63 100644 --- a/changes +++ b/changes @@ -8796,6 +8796,55 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich) --- Released 8.6.7, August 9, 2017 --- https://core.tcl-lang.org/tcl/ for details +Changes to 8.7a1 include all changes to the 8.6 line through 8.6.7, +plus the following, which focuses on the high-level feature changes +in this changeset (new minor version) rather than bug fixes: + +2016-03-17 (bug)[0b8c38] socket accept callbacks always in global ns (porter) + *** POTENTIAL INCOMPATIBILITY *** + +2016-07-01 Hack accommodations for legacy Itcl 3 disabled (porter) + +2016-07-12 Make TCL_HASH_TYPE build-time configurable (nijtmans) + +2016-07-19 (bug)[0363f0] Partial array search ID reform (porter) + +2016-07-19 (feature removed) Tcl_ObjType "array search" unregistered (porter) + *** POTENTIAL INCOMPATIBILITY for Tcl_GetObjType("array search") *** + +2016-10-04 Server socket on port 0 chooses port supporting IPv4 * IPv6 (max) + +2016-11-25 [array names -regexp] supports backrefs (goth) + +2017-01-04 (TIP 456) New routine Tcl_OpenTcpServerEx() (limeboy) + +2017-01-04 (TIP 459) New subcommand [package files] (nijtmans) + +2017-01-16 threaded allocator initialization repair (vasiljevic,nijtmans) + +2017-01-30 Add to Win shell builtins: assoc ftype move (ashok) + +2017-03-31 TCL_MEM_DEBUG facilities better support 64-bit memory (nijtmans) + +2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans) + +2017-05-18 (TIP 458) New epoll or kqueue notifiers are default (alborboz) + +2017-05-31 Purge build support for SunOS-4.* (stu) + +2017-06-22 (TIP 463) New option [regsub ... -command ...] (fellows) + +2017-06-22 (TIP 470) Tcl_GetDefineContextObject();[oo::define [self]] (fellows) +=> TclOO 1.2.0 + +2017-06-23 (TIP 472) Support 0d as prefix of decimal numbers (iyer,griffin) + +2017-08-31 (bug)[2a9465] http state 100 continue handling broken (oehlmann) + +2017-09-02 (bug)[0e4d88] replace command, delete trace kills namespace (porter) + +--- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tcl/ for details + 2017-08-10 [array names -regexp] supports backrefs (goth) 2017-08-10 Fix gcc build failures due to #pragma placement (cassoff,fellows) @@ -8895,58 +8944,179 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich) - Released 8.6.9, November 16, 2018 - details at http://core.tcl-lang.org/tcl/ - -Changes to 8.7a1 include all changes to the 8.6 line through 8.6.7, +2018-11-22 (bug)[7a9dc5] [file normalize ~/~foo] segfault (sebres) + +2018-12-30 (bug)[3cf3a9] variable 'timezone' deprecated in vc2017 (nijtmans) + +2019-01-09 (bug)[cc1e91] [list [list {*}[set a " "]]] regression (sebres) + +2019-02-01 (bug)[e3f481] tests var-1.2[01] (sebres) + +2019-03-01 (new) Update to Unicode 12.0 (nijtmans) + +2019-03-05 (new)[TIP 527] New command [timerate] (sebres) + +2019-03-08 (bug)[39fed4] [package require] memory validity (hume,porter) + +2019-04-23 (new) New command tcl::unsupported::corotype (fellows) + +2019-05-04 (bug) memlink when namespace deletion kills linked var (porter) + +2019-05-28 (new) README file converted to README.md in Markdown (nijtmans) + +2019-06-17 (bug)[8b9854] [info level 0] regression with ensembles (porter) + +2019-06-20 (bug)[6bdadf] crash multi-arg write-traced [lappend] (fellows,porter) + +2019-06-21 (bug)[f8a33c] crash Tcl_Exit before init (brooks,sebres) + +2019-08-27 (bug)[fa6bf3] Bytecode fails epoch recovery at numLevel=0 (sebres) + +2019-08-29 (bug)[fec0c1] C stack overflow compiling bytecode (ade,sebres) + +2019-09-12 tzdata updated to Olson's tzdata2019c (jima) + +2019-09-20 (new) registry/dde no longer need -DUNICODE (nijtmans) +=> registry 1.3.4 +=> dde 1.4.2 + +2019-10-02 (bug)[16768d] Fix [info hostname] on NetBSD (rytaro) + +2019-10-23 (new) libtommath updated to release 1.2.0 (nijtmans) + +2019-10-25 OSX: system Tcl deprecated. End default use of its packages. (walzer) + +2019-10-28 (bug)[bcd100] bad fs cache when system encoding changes (coulter) + +2019-11-15 (bug)[135804] segfault in [next] after destroy (coulter,sebres) + +- Released 8.6.10, Nov 21, 2019 - details at http://core.tcl-lang.org/tcl/ - + +Changes to 8.7a3 include all changes to the 8.6 line through 8.6.10, plus the following, which focuses on the high-level feature changes in this changeset (new minor version) rather than bug fixes: -2016-03-17 (bug)[0b8c38] socket accept callbacks always in global ns (porter) - *** POTENTIAL INCOMPATIBILITY *** +2017-11-01 (bug)[3c32a3] crash deleting class mixed into instance (coulter) -2016-07-01 Hack accommodations for legacy Itcl 3 disabled (porter) +2017-11-03 [TIP 345] eliminate the encoding 'identity' (porter) -2016-07-12 Make TCL_HASH_TYPE build-time configurable (nijtmans) +2017-11-04 (bug)[0d902e] [string first] on ASCII stored as Unicode (fellows) -2016-07-19 (bug)[0363f0] Partial array search ID reform (porter) +2017-11-17 [TIP 422] Mark all Tcl_*VA() routines deprecated. (nijtmans) -2016-07-19 (feature removed) Tcl_ObjType "array search" unregistered (porter) - *** POTENTIAL INCOMPATIBILITY for Tcl_GetObjType("array search") *** +2017-11-20 (support) Ended use of the obsolete values.h header (culler) -2016-10-04 Server socket on port 0 chooses port supporting IPv4 * IPv6 (max) +2017-11-30 (bug)[8e1e31] [lsort] ordering of U+0000 (nijtmans) -2016-11-25 [array names -regexp] supports backrefs (goth) +2017-12-07 [TIP 487] Terminate support for pre-XP Windows (nijtmans) -2017-01-04 (TIP 456) New routine Tcl_OpenTcpServerEx() (limeboy) +2017-12-08 [TIP 477] Reform of nmake build (nadkarni) -2017-01-04 (TIP 459) New subcommand [package files] (nijtmans) +2017-12-20 (bug)[ba1419] Crash: complex ensemble delete, namespace-7.8 (coulter) -2017-01-16 threaded allocator initialization repair (vasiljevic,nijtmans) +2018-01-17 [TIP 485] Removal of many deprecated features (nijtmans) -2017-01-30 Add to Win shell builtins: assoc ftype move (ashok) +2018-01-27 (bug) Crash in [join $l $l], join-4.1 (porter) -2017-03-31 TCL_MEM_DEBUG facilities better support 64-bit memory (nijtmans) +2018-02-06 [TIP 493] Cease Distribution of http 1.0 (porter) -2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans) +2018-02-06 [TIP 484] internal rep for native ints are all 64-bit (nijtmans) -2017-05-18 (TIP 458) New epoll or kqueue notifiers are default (alborboz) +2018-02-14 [TIP 476] Scan/Printf consistency (nijtmans) -2017-05-31 Purge build support for SunOS-4.* (stu) +2018-03-05 [TIP 351] [lsearch] striding -2017-06-22 (TIP 463) New option [regsub ... -command ...] (fellows) +2018-03-05 [TIPs 330,336] tighten access to Interp fields (porter) -2017-06-22 (TIP 470) Tcl_GetDefineContextObject();[oo::define [self]] (fellows) -=> TclOO 1.2.0 +2018-03-12 [TIP 462] [::tcl::process] -2017-06-23 (TIP 472) Support 0d as prefix of decimal numbers (iyer,griffin) +2018-03-12 [TIP 490] add oo support for msgcat => msgcat 1.7.0 (oehlmann) -2017-08-31 (bug)[2a9465] http state 100 continue handling broken (oehlmann) +2018-03-12 [TIP 499] custom locale preference list (oehlmann) +=> msgcat 1.7.0 -2017-09-02 (bug)[0e4d88] replace command, delete trace kills namespace (porter) +2018-03-20 [TIP 503] End CONST84 support for Tcl 8.3 (porter) ---- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tcl/ for details +2018-03-30 Refactored [lrange] (spjuth) -2018-03-12 (TIP 490) add oo support for msgcat => msgcat 1.7.0 (oehlmann) +2018-04-20 [TIP 389] Unicode beyond BMP (nijtmans) -2018-03-12 (TIP 499) custom locale preference list (oehlmann) -=> msgcat 1.7.0 +2018-04-20 [TIP 421] [array for] + +2018-05-11 [TIP 425] Windows panic callback use of UTF-8 + +2018-05-17 [TIP 491] Phase out --disable-threads support + +2018-06-03 [TIP 500] TclOO Private Methods and Variables + +2018-07-26 (bug)[ba921a] [string cat] of bytearrays (coulter,porter) + +2018-09-02 [TIP 478] Many new features in TclOO (lester,fellows) + +2018-09-04 (bug)[540bed] [binary format w] from bignum (nijtmans) + +2018-09-12 [TIP 430] zipfs and embedded script library (woods) + +2018-09-26 [TIP 508] [array default] (bonnet,fellows) + +2018-09-27 [TIP 515] level value reform (nijtmans) + +2018-09-27 [TIP 516] More OO slot operations (fellows) + +2018-09-27 [TIP 426] [info cmdtype] (fellows) + +2018-09-28 [TIP 509] Cross platform reentrant mutex + +2018-10-08 [TIP 514] native integers are 64-bit + +2018-10-12 [TIP 502] index value reform (porter) + +2018-11-06 [TIP 406] http cookies (fellows) + +2018-11-06 [TIP 445] Tcl_ObjType utilities (migrate to Tcl 9) (porter) + +2018-11-06 [TIP 501] [string is dict] + +2018-11-06 [TIP 519] inline export/unexport option for [oo::define] + +2018-11-06 [TIP 523] [lpop] + +2018-11-06 [TIP 524] TclOO custom dialects + +2018-11-06 [TIP 506] Tcl_(Incr|Decr)RefCount macros -> functions (porter) + +2018-11-15 [TIP 512] No stub for Tcl_SetExitProc() + +2019-04-08 (bug)[45b9fa] crash in [try] (coulter) + +2019-04-14 [TIP 160] terminal and serial channel controls + +2019-04-14 [TIP 312] more types for Tcl_LinkVar + +2019-04-14 [TIP 367] [lremove] + +2019-04-14 [TIP 504] [string insert] + +2019-04-16 [TIP 342] [dict getwithdefault] + +2019-05-25 [TIP 431] [file tempdir] + +2019-05-25 [TIP 383] [coroinject], [coroprobe] + +2019-05-31 [TIP 544] Tcl_GetIntForIndex() + +2019-06-12 Replace TclOffset() with offsetof() + +2019-06-15 [TIP 461] string compare operators for [expr] + +2019-06-16 [TIP 521] floating point classification functions for [expr] + +2019-06-20 (bug)[6bdadf] crash multi-arg traced [lappend] (fellows) + +2019-06-28 [TIP 547] New encodings utf-16, ucs-2 + +2019-09-14 [TIP 414] Tcl_InitSubsystems() + +2019-09-14 [TIP 548] wchar_t conversion functions -- Released 8.7a3, Nov 30, 2018 --- http://core.tcl-lang.org/tcl/ for details - +- Released 8.7a3, Nov 21, 2019 --- http://core.tcl-lang.org/tcl/ for details - -- cgit v0.12 From 5a7c86fa3290bf11eb1a4c98246a130cbee7d023 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Nov 2019 21:08:12 +0000 Subject: Start record of the changes only in Tcl 9. --- changes | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/changes b/changes index bf50b63..11da99a 100644 --- a/changes +++ b/changes @@ -9120,3 +9120,14 @@ in this changeset (new minor version) rather than bug fixes: 2019-09-14 [TIP 548] wchar_t conversion functions - Released 8.7a3, Nov 21, 2019 --- http://core.tcl-lang.org/tcl/ for details - + +Changes to 9.0a1 include all changes to the 8.7 line through 8.7a3, +plus the following, which focuses on the high-level feature changes +in this changeset (new minor version) rather than bug fixes: + +2017-11-03 [TIP 114] Leading zero integer no longer means octal + + + + +- Released 9.0a1, Nov 25, 2019 --- http://core.tcl-lang.org/tcl/ for details - -- cgit v0.12 From 18e4f3d635ef84d601225e1f064d80dea6a665d9 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Nov 2019 21:26:09 +0000 Subject: complete changes --- changes | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/changes b/changes index 11da99a..8112306 100644 --- a/changes +++ b/changes @@ -9127,7 +9127,16 @@ in this changeset (new minor version) rather than bug fixes: 2017-11-03 [TIP 114] Leading zero integer no longer means octal +2017-11-03 [TIP 278] Revise variable name resolution, solve "Creative Writing" +2017-11-03 [TIPs 330,336] Encapsulate struct Tcl_Interp +2017-11-17 [TIP 422] Remove all Tcl_*VA() routines + +2017-12-15 [TIP 488] Disable magic $::tcl_precision + +2018-10-08 [TIP 494] Increased support for size_t value ranges + +2019-05-31 [TIP 537] 64-bit indices in regexp matching - Released 9.0a1, Nov 25, 2019 --- http://core.tcl-lang.org/tcl/ for details - -- cgit v0.12 From 8f533db35fcc6fecc814d6e6e5b966fb7225c045 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 13 Dec 2019 13:33:33 +0000 Subject: Remove deprecated libtommath stub entries --- generic/tclStubInit.c | 50 ++++------------------------------------------- generic/tclTomMath.decls | 28 ++++++++++++++------------ generic/tclTomMathDecls.h | 42 ++++++++++++--------------------------- 3 files changed, 32 insertions(+), 88 deletions(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 95303d7..4980c79 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -128,20 +128,6 @@ #define TclBN_mp_toom_sqr s_mp_toom_sqr -mp_err TclBN_mp_set_int(mp_int *a, unsigned long i) -{ - TclBN_mp_set_u64(a, i); - return MP_OKAY; -} - -static mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) -{ - TclBN_mp_set_u64(a, i); - return MP_OKAY; -} - -#define TclBN_mp_set_ul (void (*)(mp_int *a, unsigned long i))TclBN_mp_set_long - mp_err MP_WUR TclBN_mp_expt_u32(const mp_int *a, unsigned int b, mp_int *c) { return mp_expt_u32(a, b, c); } @@ -182,34 +168,6 @@ mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *c) { return mp_mul_d(a, b, c); } -mp_err TclBN_mp_div_3(const mp_int *a, mp_int *c, unsigned int *d) { - mp_digit d2; - mp_err result = mp_div_d(a, 3, c, &d2); - if (d) { - *d = d2; - } - return result; -} - -int TclBN_mp_expt_d_ex(const mp_int *a, unsigned int b, mp_int *c, int fast) -{ - return TclBN_mp_expt_u32(a, b, c); -} - -mp_err TclBN_mp_init_ul(mp_int *a, unsigned long b) -{ - return TclBN_mp_init_u64(a,b); -} - -mp_err TclBN_mp_init_l(mp_int *a, long b) -{ - return TclBN_mp_init_i64(a,b); -} - -void TclBN_mp_set(mp_int *a, unsigned int b) { - TclBN_mp_set_u64(a, b); -} - #ifdef _WIN32 # define TclUnixWaitForFile 0 # define TclUnixCopyFile 0 @@ -758,7 +716,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_read_radix, /* 36 */ TclBN_mp_rshd, /* 37 */ TclBN_mp_shrink, /* 38 */ - TclBN_mp_set, /* 39 */ + 0, /* 39 */ 0, /* 40 */ TclBN_mp_sqrt, /* 41 */ TclBN_mp_sub, /* 42 */ @@ -780,10 +738,10 @@ const TclTomMathStubs tclTomMathStubs = { 0, /* 58 */ 0, /* 59 */ 0, /* 60 */ - TclBN_mp_init_ul, /* 61 */ - TclBN_mp_set_ul, /* 62 */ + 0, /* 61 */ + 0, /* 62 */ TclBN_mp_cnt_lsb, /* 63 */ - TclBN_mp_init_l, /* 64 */ + 0, /* 64 */ TclBN_mp_init_i64, /* 65 */ TclBN_mp_init_u64, /* 66 */ 0, /* 67 */ diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 0753bad..9afb284 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -141,9 +141,10 @@ declare 37 { declare 38 { mp_err MP_WUR TclBN_mp_shrink(mp_int *a) } -declare 39 {deprecated {macro calling mp_set_u64}} { - void TclBN_mp_set(mp_int *a, unsigned int b) -} +# Removed in 9.0 +#declare 39 {deprecated {macro calling mp_set_u64}} { +# void TclBN_mp_set(mp_int *a, unsigned int b) +#} # Removed in 9.0 #declare 40 {nostub {is private function in libtommath}} { # mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b) @@ -179,18 +180,21 @@ declare 48 { declare 49 { void TclBN_mp_zero(mp_int *a) } -declare 61 {deprecated {macro calling mp_init_u64}} { - mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i) -} -declare 62 {deprecated {macro calling mp_set_u64}} { - void TclBN_mp_set_ul(mp_int *a, unsigned long i) -} +# Removed in 9.0 +#declare 61 {deprecated {macro calling mp_init_u64}} { +# mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i) +#} +# Removed in 9.0 +#declare 62 {deprecated {macro calling mp_set_u64}} { +# void TclBN_mp_set_ul(mp_int *a, unsigned long i) +#} declare 63 { int MP_WUR TclBN_mp_cnt_lsb(const mp_int *a) } -declare 64 {deprecated {macro calling mp_init_i64}} { - int TclBN_mp_init_l(mp_int *bignum, long initVal) -} +# Removed in 9.0 +#declare 64 {deprecated {macro calling mp_init_i64}} { +# int TclBN_mp_init_l(mp_int *bignum, long initVal) +#} declare 65 { int MP_WUR TclBN_mp_init_i64(mp_int *bignum, int64_t initVal) } diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 1fe5ea9..d182171 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -152,12 +152,6 @@ MODULE_SCOPE mp_err TclBN_s_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c); #define s_mp_toom_sqr TclBN_mp_toom_sqr #endif /* !TCL_WITH_EXTERNAL_TOMMATH */ -#define mp_init_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_init_ul") TclBN_mp_init_u64(a,(unsigned int)(b))) -#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),((unsigned int)(b))),MP_OKAY)) -#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),(long)(b)),MP_OKAY)) -#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_u64") (TclBN_mp_set_u64((a),(b)),MP_OKAY)) -#define mp_unsigned_bin_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_ubin_size") (int)TclBN_mp_ubin_size(mp)) - #undef TCL_STORAGE_CLASS #ifdef BUILD_tcl # define TCL_STORAGE_CLASS DLLEXPORT @@ -275,9 +269,7 @@ EXTERN mp_err TclBN_mp_read_radix(mp_int *a, const char *str, EXTERN void TclBN_mp_rshd(mp_int *a, int shift); /* 38 */ EXTERN mp_err TclBN_mp_shrink(mp_int *a) MP_WUR; -/* 39 */ -TCL_DEPRECATED("macro calling mp_set_u64") -void TclBN_mp_set(mp_int *a, unsigned int b); +/* Slot 39 is reserved */ /* Slot 40 is reserved */ /* 41 */ EXTERN mp_err TclBN_mp_sqrt(const mp_int *a, mp_int *b) MP_WUR; @@ -308,17 +300,11 @@ EXTERN void TclBN_mp_zero(mp_int *a); /* Slot 58 is reserved */ /* Slot 59 is reserved */ /* Slot 60 is reserved */ -/* 61 */ -TCL_DEPRECATED("macro calling mp_init_u64") -mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i); -/* 62 */ -TCL_DEPRECATED("macro calling mp_set_u64") -void TclBN_mp_set_ul(mp_int *a, unsigned long i); +/* Slot 61 is reserved */ +/* Slot 62 is reserved */ /* 63 */ EXTERN int TclBN_mp_cnt_lsb(const mp_int *a) MP_WUR; -/* 64 */ -TCL_DEPRECATED("macro calling mp_init_i64") -int TclBN_mp_init_l(mp_int *bignum, long initVal); +/* Slot 64 is reserved */ /* 65 */ EXTERN int TclBN_mp_init_i64(mp_int *bignum, int64_t initVal) MP_WUR; /* 66 */ @@ -392,7 +378,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix) MP_WUR; /* 36 */ void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */ mp_err (*tclBN_mp_shrink) (mp_int *a) MP_WUR; /* 38 */ - TCL_DEPRECATED_API("macro calling mp_set_u64") void (*tclBN_mp_set) (mp_int *a, unsigned int b); /* 39 */ + void (*reserved39)(void); void (*reserved40)(void); mp_err (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b) MP_WUR; /* 41 */ mp_err (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 42 */ @@ -414,10 +400,10 @@ typedef struct TclTomMathStubs { void (*reserved58)(void); void (*reserved59)(void); void (*reserved60)(void); - TCL_DEPRECATED_API("macro calling mp_init_u64") mp_err (*tclBN_mp_init_ul) (mp_int *a, unsigned long i); /* 61 */ - TCL_DEPRECATED_API("macro calling mp_set_u64") void (*tclBN_mp_set_ul) (mp_int *a, unsigned long i); /* 62 */ + void (*reserved61)(void); + void (*reserved62)(void); int (*tclBN_mp_cnt_lsb) (const mp_int *a) MP_WUR; /* 63 */ - TCL_DEPRECATED_API("macro calling mp_init_i64") int (*tclBN_mp_init_l) (mp_int *bignum, long initVal); /* 64 */ + void (*reserved64)(void); int (*tclBN_mp_init_i64) (mp_int *bignum, int64_t initVal) MP_WUR; /* 65 */ int (*tclBN_mp_init_u64) (mp_int *bignum, uint64_t initVal) MP_WUR; /* 66 */ void (*reserved67)(void); @@ -525,8 +511,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_rshd) /* 37 */ #define TclBN_mp_shrink \ (tclTomMathStubsPtr->tclBN_mp_shrink) /* 38 */ -#define TclBN_mp_set \ - (tclTomMathStubsPtr->tclBN_mp_set) /* 39 */ +/* Slot 39 is reserved */ /* Slot 40 is reserved */ #define TclBN_mp_sqrt \ (tclTomMathStubsPtr->tclBN_mp_sqrt) /* 41 */ @@ -554,14 +539,11 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; /* Slot 58 is reserved */ /* Slot 59 is reserved */ /* Slot 60 is reserved */ -#define TclBN_mp_init_ul \ - (tclTomMathStubsPtr->tclBN_mp_init_ul) /* 61 */ -#define TclBN_mp_set_ul \ - (tclTomMathStubsPtr->tclBN_mp_set_ul) /* 62 */ +/* Slot 61 is reserved */ +/* Slot 62 is reserved */ #define TclBN_mp_cnt_lsb \ (tclTomMathStubsPtr->tclBN_mp_cnt_lsb) /* 63 */ -#define TclBN_mp_init_l \ - (tclTomMathStubsPtr->tclBN_mp_init_l) /* 64 */ +/* Slot 64 is reserved */ #define TclBN_mp_init_i64 \ (tclTomMathStubsPtr->tclBN_mp_init_i64) /* 65 */ #define TclBN_mp_init_u64 \ -- cgit v0.12 From 9118bcfb5fc11ee3cb496e1da2d648c6ea447a6b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 13 Dec 2019 15:09:59 +0000 Subject: More tweaks to libtommath functions signatures: No need any more to stay binary compatible with Tcl 8.x, so we can use the mp_digit type now. --- generic/tclStubInit.c | 54 +++----------------- generic/tclTomMath.decls | 25 +++++----- generic/tclTomMathDecls.h | 124 +++++++++++----------------------------------- 3 files changed, 51 insertions(+), 152 deletions(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 4980c79..8cae2f5 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -65,24 +65,29 @@ #undef Tcl_UtfToUniChar #define TclBN_mp_add mp_add +#define TclBN_mp_add_d mp_add_d #define TclBN_mp_and mp_and #define TclBN_mp_clamp mp_clamp #define TclBN_mp_clear mp_clear #define TclBN_mp_clear_multi mp_clear_multi #define TclBN_mp_cmp mp_cmp +#define TclBN_mp_cmp_d mp_cmp_d #define TclBN_mp_cmp_mag mp_cmp_mag #define TclBN_mp_cnt_lsb mp_cnt_lsb #define TclBN_mp_copy mp_copy #define TclBN_mp_count_bits mp_count_bits #define TclBN_mp_div mp_div +#define TclBN_mp_div_d mp_div_d #define TclBN_mp_div_2 mp_div_2 #define TclBN_mp_div_2d mp_div_2d #define TclBN_mp_exch mp_exch +#define TclBN_mp_expt_u32 mp_expt_u32 #define TclBN_mp_get_mag_u64 mp_get_mag_u64 #define TclBN_mp_grow mp_grow #define TclBN_mp_init mp_init #define TclBN_mp_init_copy mp_init_copy #define TclBN_mp_init_multi mp_init_multi +#define TclBN_mp_init_set mp_init_set #define TclBN_mp_init_size mp_init_size #define TclBN_mp_init_i64 mp_init_i64 #define TclBN_mp_init_u64 mp_init_u64 @@ -90,6 +95,7 @@ #define TclBN_mp_mod mp_mod #define TclBN_mp_mod_2d mp_mod_2d #define TclBN_mp_mul mp_mul +#define TclBN_mp_mul_d mp_mul_d #define TclBN_mp_mul_2 mp_mul_2 #define TclBN_mp_mul_2d mp_mul_2d #define TclBN_mp_neg mp_neg @@ -104,11 +110,8 @@ #define TclBN_mp_sqr mp_sqr #define TclBN_mp_sqrt mp_sqrt #define TclBN_mp_sub mp_sub +#define TclBN_mp_sub_d mp_sub_d #define TclBN_mp_signed_rsh mp_signed_rsh -#define TclBN_mp_tc_and TclBN_mp_and -#define TclBN_mp_tc_div_2d mp_signed_rsh -#define TclBN_mp_tc_or TclBN_mp_or -#define TclBN_mp_tc_xor TclBN_mp_xor #define TclBN_mp_to_radix mp_to_radix #define TclBN_mp_to_ubin mp_to_ubin #define TclBN_mp_ubin_size mp_ubin_size @@ -127,47 +130,6 @@ #define TclBN_mp_toom_mul s_mp_toom_mul #define TclBN_mp_toom_sqr s_mp_toom_sqr - -mp_err MP_WUR TclBN_mp_expt_u32(const mp_int *a, unsigned int b, mp_int *c) { - return mp_expt_u32(a, b, c); -} -mp_err TclBN_mp_add_d(const mp_int *a, unsigned int b, mp_int *c) { - return mp_add_d(a, b, c); -} -mp_err TclBN_mp_cmp_d(const mp_int *a, unsigned int b) { - return mp_cmp_d(a, b); -} -mp_err TclBN_mp_sub_d(const mp_int *a, unsigned int b, mp_int *c) { - return mp_sub_d(a, b, c); -} -mp_err TclBN_mp_div_d(const mp_int *a, unsigned int b, mp_int *c, unsigned int *d) { - mp_digit d2; - mp_err result = mp_div_d(a, b, c, (d ? &d2 : NULL)); - if (d) { - *d = d2; - } - return result; -} -mp_err TclBN_mp_div_ld(const mp_int *a, uint64_t b, mp_int *c, uint64_t *d) { - mp_err result; - mp_digit d2; - - if ((b | (mp_digit)-1) != (mp_digit)-1) { - return MP_VAL; - } - result = mp_div_d(a, b, c, (d ? &d2 : NULL)); - if (d) { - *d = d2; - } - return result; -} -mp_err TclBN_mp_init_set(mp_int *a, unsigned int b) { - return mp_init_set(a, b); -} -mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *c) { - return mp_mul_d(a, b, c); -} - #ifdef _WIN32 # define TclUnixWaitForFile 0 # define TclUnixCopyFile 0 @@ -756,7 +718,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_signed_rsh, /* 76 */ 0, /* 77 */ TclBN_mp_to_ubin, /* 78 */ - TclBN_mp_div_ld, /* 79 */ + 0, /* 79 */ TclBN_mp_to_radix, /* 80 */ }; diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 9afb284..a47f7ef 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -33,7 +33,7 @@ declare 2 { mp_err MP_WUR TclBN_mp_add(const mp_int *a, const mp_int *b, mp_int *c) } declare 3 { - mp_err MP_WUR TclBN_mp_add_d(const mp_int *a, unsigned int b, mp_int *c) + mp_err MP_WUR TclBN_mp_add_d(const mp_int *a, mp_digit b, mp_int *c) } declare 4 { mp_err MP_WUR TclBN_mp_and(const mp_int *a, const mp_int *b, mp_int *c) @@ -51,7 +51,7 @@ declare 8 { mp_ord MP_WUR TclBN_mp_cmp(const mp_int *a, const mp_int *b) } declare 9 { - mp_ord MP_WUR TclBN_mp_cmp_d(const mp_int *a, unsigned int b) + mp_ord MP_WUR TclBN_mp_cmp_d(const mp_int *a, mp_digit b) } declare 10 { mp_ord MP_WUR TclBN_mp_cmp_mag(const mp_int *a, const mp_int *b) @@ -66,7 +66,7 @@ declare 13 { mp_err MP_WUR TclBN_mp_div(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r) } declare 14 { - mp_err MP_WUR TclBN_mp_div_d(const mp_int *a, unsigned int b, mp_int *q, unsigned int *r) + mp_err MP_WUR TclBN_mp_div_d(const mp_int *a, mp_digit b, mp_int *q, mp_digit *r) } declare 15 { mp_err MP_WUR TclBN_mp_div_2(const mp_int *a, mp_int *q) @@ -76,13 +76,13 @@ declare 16 { } # Removed in 9.0 #declare 17 {deprecated {is private function in libtommath}} { -# mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, unsigned int *r) +# mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, mp_digit *r) #} declare 18 { void TclBN_mp_exch(mp_int *a, mp_int *b) } declare 19 { - mp_err MP_WUR TclBN_mp_expt_u32(const mp_int *a, unsigned int b, mp_int *c) + mp_err MP_WUR TclBN_mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c) } declare 20 { mp_err MP_WUR TclBN_mp_grow(mp_int *a, int size) @@ -97,7 +97,7 @@ declare 23 { mp_err MP_WUR TclBN_mp_init_multi(mp_int *a, ...) } declare 24 { - mp_err MP_WUR TclBN_mp_init_set(mp_int *a, unsigned int b) + mp_err MP_WUR TclBN_mp_init_set(mp_int *a, mp_digit b) } declare 25 { mp_err MP_WUR TclBN_mp_init_size(mp_int *a, int size) @@ -115,7 +115,7 @@ declare 29 { mp_err MP_WUR TclBN_mp_mul(const mp_int *a, const mp_int *b, mp_int *p) } declare 30 { - mp_err MP_WUR TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *p) + mp_err MP_WUR TclBN_mp_mul_d(const mp_int *a, mp_digit b, mp_int *p) } declare 31 { mp_err MP_WUR TclBN_mp_mul_2(const mp_int *a, mp_int *p) @@ -156,7 +156,7 @@ declare 42 { mp_err MP_WUR TclBN_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) } declare 43 { - mp_err MP_WUR TclBN_mp_sub_d(const mp_int *a, unsigned int b, mp_int *c) + mp_err MP_WUR TclBN_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c) } # Removed in 9.0 #declare 44 { @@ -204,7 +204,7 @@ declare 66 { # Removed in 9.0 #declare 67 { -# mp_err TclBN_mp_expt_d_ex(const mp_int *a, unsigned int b, mp_int *c, int fast) +# mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) #} # Added in libtommath 1.0.1 declare 68 { @@ -238,9 +238,10 @@ declare 76 { declare 78 { int MP_WUR TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) } -declare 79 { - mp_err MP_WUR TclBN_mp_div_ld(const mp_int *a, uint64_t b, mp_int *q, uint64_t *r) -} +# Removed in 9.0 +#declare 79 { +# mp_err MP_WUR TclBN_mp_div_ld(const mp_int *a, mp_digit b, mp_int *q, mp_digit *r) +#} declare 80 { int MP_WUR TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix) } diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index d182171..6716f9a 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -35,13 +35,13 @@ /* Define custom memory allocation for libtommath */ /* MODULE_SCOPE void* TclBNAlloc( size_t ); */ -#define TclBNAlloc(s) ((void*)ckalloc((size_t)(s))) +#define TclBNAlloc(s) ((void*)Tcl_Alloc(s)) /* MODULE_SCOPE void* TclBNCalloc( size_t, size_t ); */ -#define TclBNCalloc(m,s) memset(ckalloc((size_t)(m)*(size_t)(s)),0,(size_t)(m)*(size_t)(s)) +#define TclBNCalloc(m,s) memset(Tcl_Alloc((size_t)(m)*(size_t)(s)),0,(size_t)(m)*(size_t)(s)) /* MODULE_SCOPE void* TclBNRealloc( void*, size_t ); */ -#define TclBNRealloc(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s))) +#define TclBNRealloc(x,s) ((void*)Tcl_Realloc((char*)(x),(size_t)(s))) /* MODULE_SCOPE void TclBNFree( void* ); */ -#define TclBNFree(x) (ckfree((char*)(x))) +#define TclBNFree(x) (Tcl_Free((char*)(x))) #undef MP_MALLOC #undef MP_CALLOC @@ -56,57 +56,45 @@ # define MODULE_SCOPE extern #endif -MODULE_SCOPE mp_err TclBN_s_mp_add_d(const mp_int *a, mp_digit b, mp_int *c); -MODULE_SCOPE mp_ord TclBN_s_mp_cmp_d(const mp_int *a, mp_digit b); -MODULE_SCOPE mp_err TclBN_s_mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d); -MODULE_SCOPE mp_err TclBN_s_mp_div_3(const mp_int *a, mp_int *c, mp_digit *b); -MODULE_SCOPE mp_err TclBN_s_mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c); -MODULE_SCOPE mp_err TclBN_s_mp_init_set(mp_int *a, mp_digit b); -MODULE_SCOPE mp_err TclBN_s_mp_mul_d(const mp_int *a, mp_digit b, mp_int *c); -MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len); -MODULE_SCOPE void TclBN_s_mp_set(mp_int *a, mp_digit b); -MODULE_SCOPE mp_err TclBN_s_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c); - - /* Rename the global symbols in libtommath to avoid linkage conflicts */ #ifndef TCL_WITH_EXTERNAL_TOMMATH #define bn_reverse TclBN_reverse #define mp_add TclBN_mp_add -#define mp_add_d TclBN_s_mp_add_d +#define mp_add_d TclBN_mp_add_d #define mp_and TclBN_mp_and #define mp_clamp TclBN_mp_clamp #define mp_clear TclBN_mp_clear #define mp_clear_multi TclBN_mp_clear_multi #define mp_cmp TclBN_mp_cmp -#define mp_cmp_d TclBN_s_mp_cmp_d +#define mp_cmp_d TclBN_mp_cmp_d #define mp_cmp_mag TclBN_mp_cmp_mag #define mp_cnt_lsb TclBN_mp_cnt_lsb #define mp_copy TclBN_mp_copy #define mp_count_bits TclBN_mp_count_bits #define mp_div TclBN_mp_div -#define mp_div_d TclBN_s_mp_div_d +#define mp_div_d TclBN_mp_div_d #define mp_div_2 TclBN_mp_div_2 -#define mp_div_3 TclBN_s_mp_div_3 +#define mp_div_3 TclBN_mp_div_3 #define mp_div_2d TclBN_mp_div_2d #define mp_exch TclBN_mp_exch #define mp_expt_d TclBN_mp_expt_d #define mp_expt_d_ex TclBN_mp_expt_d_ex -#define mp_expt_u32 TclBN_s_mp_expt_u32 +#define mp_expt_u32 TclBN_mp_expt_u32 #define mp_get_mag_u64 TclBN_mp_get_mag_u64 #define mp_grow TclBN_mp_grow #define mp_init TclBN_mp_init #define mp_init_copy TclBN_mp_init_copy #define mp_init_i64 TclBN_mp_init_i64 #define mp_init_multi TclBN_mp_init_multi -#define mp_init_set TclBN_s_mp_init_set +#define mp_init_set TclBN_mp_init_set #define mp_init_size TclBN_mp_init_size #define mp_init_u64 TclBN_mp_init_u64 #define mp_lshd TclBN_mp_lshd #define mp_mod TclBN_mp_mod #define mp_mod_2d TclBN_mp_mod_2d #define mp_mul TclBN_mp_mul -#define mp_mul_d TclBN_s_mp_mul_d +#define mp_mul_d TclBN_mp_mul_d #define mp_mul_2 TclBN_mp_mul_2 #define mp_mul_2d TclBN_mp_mul_2d #define mp_neg TclBN_mp_neg @@ -124,7 +112,7 @@ MODULE_SCOPE mp_err TclBN_s_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c); #define mp_sqr TclBN_mp_sqr #define mp_sqrt TclBN_mp_sqrt #define mp_sub TclBN_mp_sub -#define mp_sub_d TclBN_s_mp_sub_d +#define mp_sub_d TclBN_mp_sub_d #define mp_signed_rsh TclBN_mp_signed_rsh #define mp_tc_and TclBN_mp_and #define mp_tc_div_2d TclBN_mp_signed_rsh @@ -187,7 +175,7 @@ EXTERN int TclBN_revision(void) MP_WUR; EXTERN mp_err TclBN_mp_add(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 3 */ -EXTERN mp_err TclBN_mp_add_d(const mp_int *a, unsigned int b, +EXTERN mp_err TclBN_mp_add_d(const mp_int *a, mp_digit b, mp_int *c) MP_WUR; /* 4 */ EXTERN mp_err TclBN_mp_and(const mp_int *a, const mp_int *b, @@ -201,7 +189,7 @@ EXTERN void TclBN_mp_clear_multi(mp_int *a, ...); /* 8 */ EXTERN mp_ord TclBN_mp_cmp(const mp_int *a, const mp_int *b) MP_WUR; /* 9 */ -EXTERN mp_ord TclBN_mp_cmp_d(const mp_int *a, unsigned int b) MP_WUR; +EXTERN mp_ord TclBN_mp_cmp_d(const mp_int *a, mp_digit b) MP_WUR; /* 10 */ EXTERN mp_ord TclBN_mp_cmp_mag(const mp_int *a, const mp_int *b) MP_WUR; /* 11 */ @@ -212,8 +200,8 @@ EXTERN int TclBN_mp_count_bits(const mp_int *a) MP_WUR; EXTERN mp_err TclBN_mp_div(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r) MP_WUR; /* 14 */ -EXTERN mp_err TclBN_mp_div_d(const mp_int *a, unsigned int b, - mp_int *q, unsigned int *r) MP_WUR; +EXTERN mp_err TclBN_mp_div_d(const mp_int *a, mp_digit b, + mp_int *q, mp_digit *r) MP_WUR; /* 15 */ EXTERN mp_err TclBN_mp_div_2(const mp_int *a, mp_int *q) MP_WUR; /* 16 */ @@ -223,7 +211,7 @@ EXTERN mp_err TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, /* 18 */ EXTERN void TclBN_mp_exch(mp_int *a, mp_int *b); /* 19 */ -EXTERN mp_err TclBN_mp_expt_u32(const mp_int *a, unsigned int b, +EXTERN mp_err TclBN_mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c) MP_WUR; /* 20 */ EXTERN mp_err TclBN_mp_grow(mp_int *a, int size) MP_WUR; @@ -234,7 +222,7 @@ EXTERN mp_err TclBN_mp_init_copy(mp_int *a, const mp_int *b) MP_WUR; /* 23 */ EXTERN mp_err TclBN_mp_init_multi(mp_int *a, ...) MP_WUR; /* 24 */ -EXTERN mp_err TclBN_mp_init_set(mp_int *a, unsigned int b) MP_WUR; +EXTERN mp_err TclBN_mp_init_set(mp_int *a, mp_digit b) MP_WUR; /* 25 */ EXTERN mp_err TclBN_mp_init_size(mp_int *a, int size) MP_WUR; /* 26 */ @@ -248,7 +236,7 @@ EXTERN mp_err TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r) MP_WUR; EXTERN mp_err TclBN_mp_mul(const mp_int *a, const mp_int *b, mp_int *p) MP_WUR; /* 30 */ -EXTERN mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, +EXTERN mp_err TclBN_mp_mul_d(const mp_int *a, mp_digit b, mp_int *p) MP_WUR; /* 31 */ EXTERN mp_err TclBN_mp_mul_2(const mp_int *a, mp_int *p) MP_WUR; @@ -277,7 +265,7 @@ EXTERN mp_err TclBN_mp_sqrt(const mp_int *a, mp_int *b) MP_WUR; EXTERN mp_err TclBN_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 43 */ -EXTERN mp_err TclBN_mp_sub_d(const mp_int *a, unsigned int b, +EXTERN mp_err TclBN_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c) MP_WUR; /* Slot 44 is reserved */ /* Slot 45 is reserved */ @@ -328,9 +316,7 @@ EXTERN mp_err TclBN_mp_signed_rsh(const mp_int *a, int b, /* 78 */ EXTERN int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) MP_WUR; -/* 79 */ -EXTERN mp_err TclBN_mp_div_ld(const mp_int *a, uint64_t b, - mp_int *q, uint64_t *r) MP_WUR; +/* Slot 79 is reserved */ /* 80 */ EXTERN int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix) MP_WUR; @@ -342,34 +328,34 @@ typedef struct TclTomMathStubs { int (*tclBN_epoch) (void) MP_WUR; /* 0 */ int (*tclBN_revision) (void) MP_WUR; /* 1 */ mp_err (*tclBN_mp_add) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 2 */ - mp_err (*tclBN_mp_add_d) (const mp_int *a, unsigned int b, mp_int *c) MP_WUR; /* 3 */ + mp_err (*tclBN_mp_add_d) (const mp_int *a, mp_digit b, mp_int *c) MP_WUR; /* 3 */ mp_err (*tclBN_mp_and) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 4 */ void (*tclBN_mp_clamp) (mp_int *a); /* 5 */ void (*tclBN_mp_clear) (mp_int *a); /* 6 */ void (*tclBN_mp_clear_multi) (mp_int *a, ...); /* 7 */ mp_ord (*tclBN_mp_cmp) (const mp_int *a, const mp_int *b) MP_WUR; /* 8 */ - mp_ord (*tclBN_mp_cmp_d) (const mp_int *a, unsigned int b) MP_WUR; /* 9 */ + mp_ord (*tclBN_mp_cmp_d) (const mp_int *a, mp_digit b) MP_WUR; /* 9 */ mp_ord (*tclBN_mp_cmp_mag) (const mp_int *a, const mp_int *b) MP_WUR; /* 10 */ mp_err (*tclBN_mp_copy) (const mp_int *a, mp_int *b) MP_WUR; /* 11 */ int (*tclBN_mp_count_bits) (const mp_int *a) MP_WUR; /* 12 */ mp_err (*tclBN_mp_div) (const mp_int *a, const mp_int *b, mp_int *q, mp_int *r) MP_WUR; /* 13 */ - mp_err (*tclBN_mp_div_d) (const mp_int *a, unsigned int b, mp_int *q, unsigned int *r) MP_WUR; /* 14 */ + mp_err (*tclBN_mp_div_d) (const mp_int *a, mp_digit b, mp_int *q, mp_digit *r) MP_WUR; /* 14 */ mp_err (*tclBN_mp_div_2) (const mp_int *a, mp_int *q) MP_WUR; /* 15 */ mp_err (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r) MP_WUR; /* 16 */ void (*reserved17)(void); void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */ - mp_err (*tclBN_mp_expt_u32) (const mp_int *a, unsigned int b, mp_int *c) MP_WUR; /* 19 */ + mp_err (*tclBN_mp_expt_u32) (const mp_int *a, uint32_t b, mp_int *c) MP_WUR; /* 19 */ mp_err (*tclBN_mp_grow) (mp_int *a, int size) MP_WUR; /* 20 */ mp_err (*tclBN_mp_init) (mp_int *a) MP_WUR; /* 21 */ mp_err (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b) MP_WUR; /* 22 */ mp_err (*tclBN_mp_init_multi) (mp_int *a, ...) MP_WUR; /* 23 */ - mp_err (*tclBN_mp_init_set) (mp_int *a, unsigned int b) MP_WUR; /* 24 */ + mp_err (*tclBN_mp_init_set) (mp_int *a, mp_digit b) MP_WUR; /* 24 */ mp_err (*tclBN_mp_init_size) (mp_int *a, int size) MP_WUR; /* 25 */ mp_err (*tclBN_mp_lshd) (mp_int *a, int shift) MP_WUR; /* 26 */ mp_err (*tclBN_mp_mod) (const mp_int *a, const mp_int *b, mp_int *r) MP_WUR; /* 27 */ mp_err (*tclBN_mp_mod_2d) (const mp_int *a, int b, mp_int *r) MP_WUR; /* 28 */ mp_err (*tclBN_mp_mul) (const mp_int *a, const mp_int *b, mp_int *p) MP_WUR; /* 29 */ - mp_err (*tclBN_mp_mul_d) (const mp_int *a, unsigned int b, mp_int *p) MP_WUR; /* 30 */ + mp_err (*tclBN_mp_mul_d) (const mp_int *a, mp_digit b, mp_int *p) MP_WUR; /* 30 */ mp_err (*tclBN_mp_mul_2) (const mp_int *a, mp_int *p) MP_WUR; /* 31 */ mp_err (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p) MP_WUR; /* 32 */ mp_err (*tclBN_mp_neg) (const mp_int *a, mp_int *b) MP_WUR; /* 33 */ @@ -382,7 +368,7 @@ typedef struct TclTomMathStubs { void (*reserved40)(void); mp_err (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b) MP_WUR; /* 41 */ mp_err (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 42 */ - mp_err (*tclBN_mp_sub_d) (const mp_int *a, unsigned int b, mp_int *c) MP_WUR; /* 43 */ + mp_err (*tclBN_mp_sub_d) (const mp_int *a, mp_digit b, mp_int *c) MP_WUR; /* 43 */ void (*reserved44)(void); void (*reserved45)(void); void (*reserved46)(void); @@ -418,7 +404,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 76 */ void (*reserved77)(void); int (*tclBN_mp_to_ubin) (const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) MP_WUR; /* 78 */ - mp_err (*tclBN_mp_div_ld) (const mp_int *a, uint64_t b, mp_int *q, uint64_t *r) MP_WUR; /* 79 */ + void (*reserved79)(void); int (*tclBN_mp_to_radix) (const mp_int *a, char *str, size_t maxlen, size_t *written, int radix) MP_WUR; /* 80 */ } TclTomMathStubs; @@ -565,8 +551,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; /* Slot 77 is reserved */ #define TclBN_mp_to_ubin \ (tclTomMathStubsPtr->tclBN_mp_to_ubin) /* 78 */ -#define TclBN_mp_div_ld \ - (tclTomMathStubsPtr->tclBN_mp_div_ld) /* 79 */ +/* Slot 79 is reserved */ #define TclBN_mp_to_radix \ (tclTomMathStubsPtr->tclBN_mp_to_radix) /* 80 */ @@ -574,55 +559,6 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; /* !END!: Do not edit above this line. */ -#if defined(USE_TCL_STUBS) -#undef mp_add_d -#define mp_add_d TclBN_mp_add_d -#undef mp_cmp_d -#define mp_cmp_d TclBN_mp_cmp_d -#undef mp_div_d -#ifdef MP_64BIT -#define mp_div_d TclBN_mp_div_ld -#else -#define mp_div_d TclBN_mp_div_d -#endif -#undef mp_sub_d -#define mp_sub_d TclBN_mp_sub_d -#undef mp_init_set -#define mp_init_set TclBN_mp_init_set -#undef mp_mul_d -#define mp_mul_d TclBN_mp_mul_d -#undef mp_set -#define mp_set TclBN_mp_set -#undef mp_expt_u32 -#define mp_expt_u32 TclBN_mp_expt_u32 -#endif /* USE_TCL_STUBS */ - -#define TclBNInitBignumFromLong(a,b) \ - do { \ - (a)->dp = NULL; \ - (void)mp_init_i64((a),(b)); \ - if ((a)->dp == NULL) { \ - Tcl_Panic("initialization failure in TclBNInitBignumFromLong"); \ - } \ - } while (0) -#undef TclBNInitBignumFromWideInt -#define TclBNInitBignumFromWideInt(a,b) \ - do { \ - (a)->dp = NULL; \ - (void)mp_init_i64((a),(b)); \ - if ((a)->dp == NULL) { \ - Tcl_Panic("initialization failure in TclBNInitBignumFromWideInt"); \ - } \ - } while (0) -#undef TclBNInitBignumFromWideUInt -#define TclBNInitBignumFromWideUInt(a,b) \ - do { \ - (a)->dp = NULL; \ - (void)mp_init_u64((a),(b)); \ - if ((a)->dp == NULL) { \ - Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt"); \ - } \ - } while (0) #undef mp_get_ll #define mp_get_ll(a) ((long long)mp_get_i64(a)) #undef mp_set_ll -- cgit v0.12 From be44843404a002a18aca9b059109c34cb538a8f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 13 Dec 2019 20:35:56 +0000 Subject: Fix [435acb846c]: libtommath - missing declarations --- generic/tclTomMathDecls.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 6716f9a..9a13a1a 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -56,6 +56,10 @@ # define MODULE_SCOPE extern #endif +MODULE_SCOPE mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b); +MODULE_SCOPE mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, mp_digit *r); + + /* Rename the global symbols in libtommath to avoid linkage conflicts */ #ifndef TCL_WITH_EXTERNAL_TOMMATH -- cgit v0.12 From f5a8aaadf8c1f3c677edfbdde0c7619089a37705 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 30 Dec 2019 21:00:09 +0000 Subject: Remove TclInitCompiledLocals(), internal routine marked deprecated in 8.5+. --- generic/tclInt.decls | 9 +++++---- generic/tclIntDecls.h | 9 +++------ generic/tclProc.c | 48 ------------------------------------------------ generic/tclStubInit.c | 2 +- 4 files changed, 9 insertions(+), 59 deletions(-) diff --git a/generic/tclInt.decls b/generic/tclInt.decls index bcdea6c..8b1b3a6 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -215,10 +215,11 @@ declare 46 { # Tcl_Obj *TclIncrVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, # Tcl_Obj *part2Ptr, long incrAmount, int part1NotParsed) #} -declare 50 { - void TclInitCompiledLocals(Tcl_Interp *interp, CallFrame *framePtr, - Namespace *nsPtr) -} +# Removed in 9.0: +#declare 50 { +# void TclInitCompiledLocals(Tcl_Interp *interp, CallFrame *framePtr, +# Namespace *nsPtr) +#} declare 51 { int TclInterpInit(Tcl_Interp *interp) } diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 260ef3e..580c959 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -142,9 +142,7 @@ EXTERN int TclInExit(void); /* Slot 47 is reserved */ /* Slot 48 is reserved */ /* Slot 49 is reserved */ -/* 50 */ -EXTERN void TclInitCompiledLocals(Tcl_Interp *interp, - CallFrame *framePtr, Namespace *nsPtr); +/* Slot 50 is reserved */ /* 51 */ EXTERN int TclInterpInit(Tcl_Interp *interp); /* Slot 52 is reserved */ @@ -638,7 +636,7 @@ typedef struct TclIntStubs { void (*reserved47)(void); void (*reserved48)(void); void (*reserved49)(void); - void (*tclInitCompiledLocals) (Tcl_Interp *interp, CallFrame *framePtr, Namespace *nsPtr); /* 50 */ + void (*reserved50)(void); int (*tclInterpInit) (Tcl_Interp *interp); /* 51 */ void (*reserved52)(void); int (*tclInvokeObjectCommand) (void *clientData, Tcl_Interp *interp, int argc, const char **argv); /* 53 */ @@ -937,8 +935,7 @@ extern const TclIntStubs *tclIntStubsPtr; /* Slot 47 is reserved */ /* Slot 48 is reserved */ /* Slot 49 is reserved */ -#define TclInitCompiledLocals \ - (tclIntStubsPtr->tclInitCompiledLocals) /* 50 */ +/* Slot 50 is reserved */ #define TclInterpInit \ (tclIntStubsPtr->tclInterpInit) /* 51 */ /* Slot 52 is reserved */ diff --git a/generic/tclProc.c b/generic/tclProc.c index ee57865..7aa553c 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1099,54 +1099,6 @@ ProcWrongNumArgs( /* *---------------------------------------------------------------------- * - * TclInitCompiledLocals -- - * - * This routine is invoked in order to initialize the compiled locals - * table for a new call frame. - * - * DEPRECATED: functionality has been inlined elsewhere; this function - * remains to insure binary compatibility with Itcl. - * - * Results: - * None. - * - * Side effects: - * May invoke various name resolvers in order to determine which - * variables are being referenced at runtime. - * - *---------------------------------------------------------------------- - */ - -void -TclInitCompiledLocals( - Tcl_Interp *interp, /* Current interpreter. */ - CallFrame *framePtr, /* Call frame to initialize. */ - Namespace *nsPtr) /* Pointer to current namespace. */ -{ - Var *varPtr = framePtr->compiledLocals; - Tcl_Obj *bodyPtr; - ByteCode *codePtr; - - bodyPtr = framePtr->procPtr->bodyPtr; - ByteCodeGetIntRep(bodyPtr, &tclByteCodeType, codePtr); - if (codePtr == NULL) { - Tcl_Panic("body object for proc attached to frame is not a byte code type"); - } - - if (framePtr->numCompiledLocals) { - if (!codePtr->localCachePtr) { - InitLocalCache(framePtr->procPtr) ; - } - framePtr->localCachePtr = codePtr->localCachePtr; - framePtr->localCachePtr->refCount++; - } - - InitResolvedLocals(interp, codePtr, varPtr, nsPtr); -} - -/* - *---------------------------------------------------------------------- - * * InitResolvedLocals -- * * This routine is invoked in order to initialize the compiled locals diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 8cae2f5..7250bd8 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -312,7 +312,7 @@ static const TclIntStubs tclIntStubs = { 0, /* 47 */ 0, /* 48 */ 0, /* 49 */ - TclInitCompiledLocals, /* 50 */ + 0, /* 50 */ TclInterpInit, /* 51 */ 0, /* 52 */ TclInvokeObjectCommand, /* 53 */ -- cgit v0.12 From fc63e758a4d1537762b5a86ee42f762547a4931a Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 13 Jan 2020 16:49:42 +0000 Subject: Implement TIP 559 --- doc/SetResult.3 | 12 +----------- generic/tcl.decls | 7 ++++--- generic/tclDecls.h | 8 +++----- generic/tclResult.c | 30 ------------------------------ generic/tclStubInit.c | 2 +- 5 files changed, 9 insertions(+), 50 deletions(-) diff --git a/doc/SetResult.3 b/doc/SetResult.3 index 07e2344..1355d6b 100644 --- a/doc/SetResult.3 +++ b/doc/SetResult.3 @@ -9,7 +9,7 @@ .so man.macros .BS .SH NAME -Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult, Tcl_TransferResult, Tcl_FreeResult \- manipulate Tcl result +Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult, Tcl_TransferResult \- manipulate Tcl result .SH SYNOPSIS .nf \fB#include \fR @@ -31,8 +31,6 @@ const char * \fBTcl_TransferResult\fR(\fIsourceInterp, code, targetInterp\fR) .sp \fBTcl_AppendElement\fR(\fIinterp, element\fR) -.sp -\fBTcl_FreeResult\fR(\fIinterp\fR) .SH ARGUMENTS .AS Tcl_FreeProc sourceInterp out .AP Tcl_Interp *interp out @@ -177,14 +175,6 @@ single character or ends in the characters .QW " {" ) then no space is added. -.PP -\fBTcl_FreeResult\fR performs part of the work -of \fBTcl_ResetResult\fR. -It frees up the memory associated with \fIinterp\fR's result. -It also sets \fIinterp->freeProc\fR to zero, but does not -change \fIinterp->result\fR or clear error state. -\fBTcl_FreeResult\fR is most commonly used when a procedure -is about to replace one result value with another. .SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT" .PP \fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how diff --git a/generic/tcl.decls b/generic/tcl.decls index f852601..98cddd5 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -540,9 +540,10 @@ declare 145 { declare 146 { int Tcl_Flush(Tcl_Channel chan) } -declare 147 { - void Tcl_FreeResult(Tcl_Interp *interp) -} +# Removed in 9.0, TIP 559 +#declare 147 { +# void Tcl_FreeResult(Tcl_Interp *interp) +#} declare 148 { int Tcl_GetAlias(Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, const char **targetCmdPtr, diff --git a/generic/tclDecls.h b/generic/tclDecls.h index be71893..d944676 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -434,8 +434,7 @@ EXTERN Tcl_HashEntry * Tcl_FirstHashEntry(Tcl_HashTable *tablePtr, Tcl_HashSearch *searchPtr); /* 146 */ EXTERN int Tcl_Flush(Tcl_Channel chan); -/* 147 */ -EXTERN void Tcl_FreeResult(Tcl_Interp *interp); +/* Slot 147 is reserved */ /* 148 */ EXTERN int Tcl_GetAlias(Tcl_Interp *interp, const char *slaveCmd, @@ -1941,7 +1940,7 @@ typedef struct TclStubs { void (*reserved144)(void); Tcl_HashEntry * (*tcl_FirstHashEntry) (Tcl_HashTable *tablePtr, Tcl_HashSearch *searchPtr); /* 145 */ int (*tcl_Flush) (Tcl_Channel chan); /* 146 */ - void (*tcl_FreeResult) (Tcl_Interp *interp); /* 147 */ + void (*reserved147)(void); int (*tcl_GetAlias) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, const char **targetCmdPtr, int *argcPtr, const char ***argvPtr); /* 148 */ int (*tcl_GetAliasObj) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, const char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv); /* 149 */ void * (*tcl_GetAssocData) (Tcl_Interp *interp, const char *name, Tcl_InterpDeleteProc **procPtr); /* 150 */ @@ -2754,8 +2753,7 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_FirstHashEntry) /* 145 */ #define Tcl_Flush \ (tclStubsPtr->tcl_Flush) /* 146 */ -#define Tcl_FreeResult \ - (tclStubsPtr->tcl_FreeResult) /* 147 */ +/* Slot 147 is reserved */ #define Tcl_GetAlias \ (tclStubsPtr->tcl_GetAlias) /* 148 */ #define Tcl_GetAliasObj \ diff --git a/generic/tclResult.c b/generic/tclResult.c index 3ca3c7b..69edd39 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -373,36 +373,6 @@ Tcl_AppendElement( /* *---------------------------------------------------------------------- * - * Tcl_FreeResult -- - * - * This function frees up the memory associated with an interpreter's - * result, resetting the interpreter's result object. Tcl_FreeResult is - * most commonly used when a function is about to replace one result - * value with another. - * - * Results: - * None. - * - * Side effects: - * Frees the memory associated with interp's result but does not change - * any part of the error dictionary (i.e., the errorinfo and errorcode - * remain the same). - * - *---------------------------------------------------------------------- - */ - -void -Tcl_FreeResult( - Tcl_Interp *interp)/* Interpreter for which to free result. */ -{ - Interp *iPtr = (Interp *) interp; - - ResetObjResult(iPtr); -} - -/* - *---------------------------------------------------------------------- - * * Tcl_ResetResult -- * * This function resets both the interpreter's string and object results. diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 01434b9..3ca9fe4 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -894,7 +894,7 @@ const TclStubs tclStubs = { 0, /* 144 */ Tcl_FirstHashEntry, /* 145 */ Tcl_Flush, /* 146 */ - Tcl_FreeResult, /* 147 */ + 0, /* 147 */ Tcl_GetAlias, /* 148 */ Tcl_GetAliasObj, /* 149 */ Tcl_GetAssocData, /* 150 */ -- cgit v0.12 From b77246e08bf5f354f35ac9a388296a3fcb5a2a95 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 21 Jan 2020 09:21:30 +0000 Subject: Enable test-cases stringObj-15.[5-8]: "nodep" restriction doesn't work in 9.0. --- tests/stringObj.test | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/stringObj.test b/tests/stringObj.test index 3779bca..8b10897 100644 --- a/tests/stringObj.test +++ b/tests/stringObj.test @@ -24,7 +24,6 @@ testConstraint testobj [llength [info commands testobj]] testConstraint testbytestring [llength [info commands testbytestring]] testConstraint testdstring [llength [info commands testdstring]] testConstraint tip389 [expr {[string length \U010000] == 2}] -testConstraint nodep [info exists tcl_precision] test stringObj-1.1 {string type registration} testobj { set t [testobj types] @@ -466,19 +465,19 @@ test stringObj-15.4 {Tcl_Append*ToObj: self appends} testobj { teststringobj set 1 foo teststringobj appendself 1 3 } foo -test stringObj-15.5 {Tcl_Append*ToObj: self appends} {testobj tip389 nodep} { +test stringObj-15.5 {Tcl_Append*ToObj: self appends} {testobj tip389} { teststringobj set 1 foo teststringobj appendself2 1 0 } foofoo -test stringObj-15.6 {Tcl_Append*ToObj: self appends} {testobj tip389 nodep} { +test stringObj-15.6 {Tcl_Append*ToObj: self appends} {testobj tip389} { teststringobj set 1 foo teststringobj appendself2 1 1 } foooo -test stringObj-15.7 {Tcl_Append*ToObj: self appends} {testobj tip389 nodep} { +test stringObj-15.7 {Tcl_Append*ToObj: self appends} {testobj tip389} { teststringobj set 1 foo teststringobj appendself2 1 2 } fooo -test stringObj-15.8 {Tcl_Append*ToObj: self appends} {testobj tip389 nodep} { +test stringObj-15.8 {Tcl_Append*ToObj: self appends} {testobj tip389} { teststringobj set 1 foo teststringobj appendself2 1 3 } foo -- cgit v0.12 From f4a42dff0150fceaeadfb3812a70c54f149e17ca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 1 Mar 2020 12:35:04 +0000 Subject: re-generate configure script (option -Wc++-compat was still missing) --- unix/configure | 10 +++++++++- win/configure | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/unix/configure b/unix/configure index 892288d..1ba1e5c 100755 --- a/unix/configure +++ b/unix/configure @@ -5036,7 +5036,15 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wsign-compare -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + case "${CC}" in + *++) + ;; + *) + CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement" + ;; + esac + else diff --git a/win/configure b/win/configure index c210d89..6ceae65 100755 --- a/win/configure +++ b/win/configure @@ -4196,7 +4196,7 @@ $as_echo "using shared flags" >&6; } CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wsign-compare -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= @@ -4205,7 +4205,7 @@ $as_echo "using shared flags" >&6; } CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format" ;; *) - CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement" + CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement" ;; esac -- cgit v0.12 From 72f5a0b42fd69b0ccad811c45ab2d2b265a67b63 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 11 Mar 2020 10:20:51 +0000 Subject: Put back dummy Tcl_DriverCloseProc/Tcl_DriverSeekProc (just defined as "void"). Needed to make Tk compile with C++ against 9.0 headers. --- generic/tcl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generic/tcl.h b/generic/tcl.h index 29f64bc..874f6e9 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1240,12 +1240,14 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData); */ typedef int (Tcl_DriverBlockModeProc) (void *instanceData, int mode); +typedef void Tcl_DriverCloseProc; typedef int (Tcl_DriverClose2Proc) (void *instanceData, Tcl_Interp *interp, int flags); typedef int (Tcl_DriverInputProc) (void *instanceData, char *buf, int toRead, int *errorCodePtr); typedef int (Tcl_DriverOutputProc) (void *instanceData, const char *buf, int toWrite, int *errorCodePtr); +typedef void Tcl_DriverSeekProc; typedef int (Tcl_DriverSetOptionProc) (void *instanceData, Tcl_Interp *interp, const char *optionName, const char *value); -- cgit v0.12 From b6f9e488f51114487c444153373a1b89728d76fd Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 25 Mar 2020 15:37:25 +0000 Subject: Fix for windows build (Windows doesn't have "%z" printf modifier) --- generic/tclBinary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 77258bb..7c41aab 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -473,7 +473,7 @@ TclGetBytesFromObj( Tcl_UtfToUniChar(nonbyte, &ch); Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "expected byte sequence but character %zu " + "expected byte sequence but character %" TCL_Z_MODIFIER "u " "was '%1s' (U+%04X)", baPtr->bad, nonbyte, ch)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "BYTES", NULL); } -- cgit v0.12 From ce51daca482df2b6dfe2f0433ec5366c9729666c Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 29 Mar 2020 21:47:12 +0000 Subject: Let the private, internal TclGetBytesFromObj handle size_t lengths --- generic/tclBinary.c | 36 ++++++++++++++++++++---------------- generic/tclInt.h | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 0a64e96..0e5b942 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -453,7 +453,7 @@ unsigned char * TclGetBytesFromObj( Tcl_Interp *interp, /* For error reporting */ Tcl_Obj *objPtr, /* Value to extract from */ - int *lengthPtr) /* If non-NULL, filled with length of the + size_t *lengthPtr) /* If non-NULL, filled with length of the * array of bytes in the ByteArray object. */ { ByteArray *baPtr; @@ -512,23 +512,27 @@ Tcl_GetByteArrayFromObj( int *lengthPtr) /* If non-NULL, filled with length of the * array of bytes in the ByteArray object. */ { - ByteArray *baPtr; - const Tcl_ObjIntRep *irPtr; - unsigned char *result = TclGetBytesFromObj(NULL, objPtr, lengthPtr); + size_t size; + unsigned char *result = TclGetBytesFromObj(NULL, objPtr, &size); - if (result) { - return result; - } + if (result == NULL) { + ByteArray *baPtr; + const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclByteArrayType); - irPtr = TclFetchIntRep(objPtr, &tclByteArrayType); - assert(irPtr != NULL); + assert(irPtr != NULL); - baPtr = GET_BYTEARRAY(irPtr); + baPtr = GET_BYTEARRAY(irPtr); + result = baPtr->bytes; + size = baPtr->used; + } if (lengthPtr != NULL) { - *lengthPtr = baPtr->used; + if (size > INT_MAX) { + Tcl_Panic("more bytes than Tcl_GetByteArrayFromObj can return"); + } + *lengthPtr = (int) size; } - return baPtr->bytes; + return result; } /* @@ -556,7 +560,7 @@ Tcl_GetByteArrayFromObj( unsigned char * Tcl_SetByteArrayLength( Tcl_Obj *objPtr, /* The ByteArray object. */ - size_t length) /* New length for internal byte array. */ + size_t length) /* New length for internal byte array. */ { ByteArray *byteArrayPtr; Tcl_ObjIntRep *irPtr; @@ -2698,7 +2702,7 @@ BinaryEncode64( unsigned char *data, *limit; int maxlen = 0; const char *wrapchar = "\n"; - int wrapcharlen = 1; + size_t wrapcharlen = 1; int i, index, size, outindex = 0, purewrap = 1; size_t offset, count = 0; enum { OPT_MAXLEN, OPT_WRAPCHAR }; @@ -3103,8 +3107,8 @@ BinaryDecode64( unsigned char *begin = NULL; unsigned char *cursor = NULL; int pure = 1, strict = 0; - int i, index, size, cut = 0; - int count = 0; + int i, index, cut = 0; + size_t size, count = 0; Tcl_UniChar ch; enum { OPT_STRICT }; static const char *const optStrings[] = { "-strict", NULL }; diff --git a/generic/tclInt.h b/generic/tclInt.h index 6ff11d3..a6635aa 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2958,7 +2958,7 @@ MODULE_SCOPE void TclFSUnloadTempFile(Tcl_LoadHandle loadHandle); MODULE_SCOPE int * TclGetAsyncReadyPtr(void); MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp); MODULE_SCOPE unsigned char * TclGetBytesFromObj(Tcl_Interp *interp, - Tcl_Obj *objPtr, int *lengthPtr); + Tcl_Obj *objPtr, size_t *lengthPtr); MODULE_SCOPE int TclGetChannelFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Channel *chanPtr, int *modePtr, int flags); -- cgit v0.12 From 2a007ddb5067d4496a8d1007a8a6ed5151bc7f5e Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 29 Mar 2020 22:10:28 +0000 Subject: Change of variables. --- generic/tclBinary.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 0e5b942..67183a5 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -512,27 +512,27 @@ Tcl_GetByteArrayFromObj( int *lengthPtr) /* If non-NULL, filled with length of the * array of bytes in the ByteArray object. */ { - size_t size; - unsigned char *result = TclGetBytesFromObj(NULL, objPtr, &size); + size_t numBytes; + unsigned char *bytes = TclGetBytesFromObj(NULL, objPtr, &numBytes); - if (result == NULL) { + if (bytes == NULL) { ByteArray *baPtr; const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclByteArrayType); assert(irPtr != NULL); baPtr = GET_BYTEARRAY(irPtr); - result = baPtr->bytes; - size = baPtr->used; + bytes = baPtr->bytes; + numBytes = baPtr->used; } if (lengthPtr != NULL) { - if (size > INT_MAX) { + if (numBytes > INT_MAX) { Tcl_Panic("more bytes than Tcl_GetByteArrayFromObj can return"); } - *lengthPtr = (int) size; + *lengthPtr = (int) numBytes; } - return result; + return bytes; } /* -- cgit v0.12 From 9e82ddc739533d80820c3d1d91f873b25132380a Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 30 Mar 2020 03:23:26 +0000 Subject: Adjustments for easier merging. --- generic/tclBinary.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 67183a5..0e22298 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -512,7 +512,7 @@ Tcl_GetByteArrayFromObj( int *lengthPtr) /* If non-NULL, filled with length of the * array of bytes in the ByteArray object. */ { - size_t numBytes; + size_t numBytes = 0; unsigned char *bytes = TclGetBytesFromObj(NULL, objPtr, &numBytes); if (bytes == NULL) { @@ -526,11 +526,19 @@ Tcl_GetByteArrayFromObj( numBytes = baPtr->used; } - if (lengthPtr != NULL) { + /* Macro TclGetByteArrayFromObj passes NULL for lengthPtr as + * a trick to get around changing size. */ + if (lengthPtr) { if (numBytes > INT_MAX) { - Tcl_Panic("more bytes than Tcl_GetByteArrayFromObj can return"); + /* Caller asked for an int length, but true length is outside + * the int range. This case will be developed out of existence + * in Tcl 9. As interim measure, fail. */ + + *lengthPtr = 0; + return NULL; + } else { + *lengthPtr = (int) numBytes; } - *lengthPtr = (int) numBytes; } return bytes; } -- cgit v0.12 From 998384d14959533914f0aa6cacaa0bd26a590ba2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 31 Mar 2020 07:09:46 +0000 Subject: Internal API simplifications: Don't use types like HINSTANCE/HMODULE any more, just void*. Has effect only on Win32 and Cygwin. --- generic/tclInt.decls | 8 ++++---- generic/tclIntPlatDecls.h | 12 ++++++------ generic/tclZipfs.c | 2 +- unix/tclSelectNotfy.c | 29 +++++++++++++++-------------- unix/tclUnixInit.c | 22 +++++++++++----------- unix/tclUnixPort.h | 3 --- win/tclWin32Dll.c | 2 +- win/tclWinError.c | 6 +++--- win/tclWinInit.c | 4 ++-- win/tclWinNotify.c | 6 +++--- win/tclWinSock.c | 4 ++-- 11 files changed, 48 insertions(+), 50 deletions(-) diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 82d9249..b9cec96 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -1082,11 +1082,11 @@ interface tclIntPlat # Windows specific functions declare 0 win { - void TclWinConvertError(DWORD errCode) + void TclWinConvertError(int errCode) } # Removed in 9.0: #declare 1 win { -# void TclWinConvertWSAError(DWORD errCode) +# void TclWinConvertWSAError(int errCode) #} # Removed in 9.0: #declare 2 win { @@ -1099,7 +1099,7 @@ declare 0 win { # char *optval, int *optlen) #} declare 4 win { - HINSTANCE TclWinGetTclInstance(void) + void *TclWinGetTclInstance(void) } # new for 8.4.20+/8.5.12+ Cygwin only declare 5 win { @@ -1177,7 +1177,7 @@ declare 19 win { TclFile TclpOpenFile(const char *fname, int mode) } declare 20 win { - void TclWinAddProcess(HANDLE hProcess, size_t id) + void TclWinAddProcess(void *hProcess, size_t id) } # Removed in 9.0: #declare 21 win { diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index fc6cd0b..87a25db 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -114,12 +114,12 @@ EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj, #endif /* UNIX */ #if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ -EXTERN void TclWinConvertError(DWORD errCode); +EXTERN void TclWinConvertError(int errCode); /* Slot 1 is reserved */ /* Slot 2 is reserved */ /* Slot 3 is reserved */ /* 4 */ -EXTERN HINSTANCE TclWinGetTclInstance(void); +EXTERN void * TclWinGetTclInstance(void); /* 5 */ EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); /* Slot 6 is reserved */ @@ -155,7 +155,7 @@ EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); /* 19 */ EXTERN TclFile TclpOpenFile(const char *fname, int mode); /* 20 */ -EXTERN void TclWinAddProcess(HANDLE hProcess, size_t id); +EXTERN void TclWinAddProcess(void *hProcess, size_t id); /* Slot 21 is reserved */ /* 22 */ EXTERN TclFile TclpCreateTempFile(const char *contents); @@ -285,11 +285,11 @@ typedef struct TclIntPlatStubs { int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */ #endif /* UNIX */ #if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ - void (*tclWinConvertError) (DWORD errCode); /* 0 */ + void (*tclWinConvertError) (int errCode); /* 0 */ void (*reserved1)(void); void (*reserved2)(void); void (*reserved3)(void); - HINSTANCE (*tclWinGetTclInstance) (void); /* 4 */ + void * (*tclWinGetTclInstance) (void); /* 4 */ int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 5 */ void (*reserved6)(void); void (*reserved7)(void); @@ -305,7 +305,7 @@ typedef struct TclIntPlatStubs { int (*tclUnixCopyFile) (const char *src, const char *dst, const Tcl_StatBuf *statBufPtr, int dontCopyAtts); /* 17 */ TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 18 */ TclFile (*tclpOpenFile) (const char *fname, int mode); /* 19 */ - void (*tclWinAddProcess) (HANDLE hProcess, size_t id); /* 20 */ + void (*tclWinAddProcess) (void *hProcess, size_t id); /* 20 */ void (*reserved21)(void); TclFile (*tclpCreateTempFile) (const char *contents); /* 22 */ void (*reserved23)(void); diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index aa68935..7398ab8 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3205,7 +3205,7 @@ TclZipfs_TclLibrary(void) */ #if defined(_WIN32) - hModule = TclWinGetTclInstance(); + hModule = (HMODULE)TclWinGetTclInstance(); GetModuleFileNameW(hModule, wName, MAX_PATH); WideCharToMultiByte(CP_UTF8, 0, wName, -1, dllName, sizeof(dllName), NULL, NULL); diff --git a/unix/tclSelectNotfy.c b/unix/tclSelectNotfy.c index 52b012a..8b19578 100644 --- a/unix/tclSelectNotfy.c +++ b/unix/tclSelectNotfy.c @@ -216,11 +216,12 @@ extern "C" { typedef struct { void *hwnd; /* Messaging window. */ unsigned int *message; /* Message payload. */ - int wParam; /* Event-specific "word" parameter. */ - int lParam; /* Event-specific "long" parameter. */ + size_t wParam; /* Event-specific "word" parameter. */ + size_t lParam; /* Event-specific "long" parameter. */ int time; /* Event timestamp. */ int x; /* Event location (where meaningful). */ int y; + int lPrivate; } MSG; typedef struct { @@ -232,7 +233,7 @@ typedef struct { void *hIcon; void *hCursor; void *hbrBackground; - void *lpszMenuName; + const void *lpszMenuName; const void *lpszClassName; } WNDCLASSW; @@ -243,14 +244,14 @@ extern void __stdcall CloseHandle(void *); extern void *__stdcall CreateEventW(void *, unsigned char, unsigned char, void *); extern void *__stdcall CreateWindowExW(void *, const void *, const void *, - DWORD, int, int, int, int, void *, void *, void *, + unsigned int, int, int, int, int, void *, void *, void *, void *); -extern DWORD __stdcall DefWindowProcW(void *, int, void *, void *); +extern unsigned int __stdcall DefWindowProcW(void *, int, void *, void *); extern unsigned char __stdcall DestroyWindow(void *); extern int __stdcall DispatchMessageW(const MSG *); extern unsigned char __stdcall GetMessageW(MSG *, void *, int, int); -extern void __stdcall MsgWaitForMultipleObjects(DWORD, void *, - unsigned char, DWORD, DWORD); +extern void __stdcall MsgWaitForMultipleObjects(unsigned int, void *, + unsigned char, unsigned int, unsigned int); extern unsigned char __stdcall PeekMessageW(MSG *, void *, int, int, int); extern unsigned char __stdcall PostMessageW(void *, unsigned int, void *, void *); @@ -264,7 +265,7 @@ extern unsigned char __stdcall TranslateMessage(const MSG *); */ static const wchar_t className[] = L"TclNotifier"; -static DWORD __stdcall NotifierProc(void *hwnd, unsigned int message, +static unsigned int __stdcall NotifierProc(void *hwnd, unsigned int message, void *wParam, void *lParam); #ifdef __cplusplus } @@ -322,7 +323,7 @@ Tcl_InitNotifier(void) RegisterClassW(&clazz); tsdPtr->hwnd = CreateWindowExW(NULL, clazz.lpszClassName, clazz.lpszClassName, 0, 0, 0, 0, 0, NULL, NULL, - TclWinGetTclInstance(), NULL); + clazz.hInstance, NULL); tsdPtr->event = CreateEventW(NULL, 1 /* manual */, 0 /* !signaled */, NULL); #else @@ -598,7 +599,7 @@ Tcl_DeleteFileHandler( #if defined(__CYGWIN__) -static DWORD __stdcall +static unsigned int __stdcall NotifierProc( void *hwnd, unsigned int message, @@ -649,6 +650,7 @@ Tcl_WaitForEvent( FileHandler *filePtr; int mask; Tcl_Time vTime; + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); #if TCL_THREADS int waitForFiles; # ifdef __CYGWIN__ @@ -664,7 +666,6 @@ Tcl_WaitForEvent( struct timeval timeout, *timeoutPtr; int numFound; #endif /* TCL_THREADS */ - ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); /* * Set up the timeout structure. Note that if there are no events to @@ -769,7 +770,7 @@ Tcl_WaitForEvent( if (!tsdPtr->eventReady) { #ifdef __CYGWIN__ if (!PeekMessageW(&msg, NULL, 0, 0, 0)) { - DWORD timeout; + unsigned int timeout; if (timePtr) { timeout = timePtr->sec * 1000 + timePtr->usec / 1000; @@ -804,12 +805,12 @@ Tcl_WaitForEvent( * Retrieve and dispatch the message. */ - DWORD result = GetMessageW(&msg, NULL, 0, 0); + unsigned int result = GetMessageW(&msg, NULL, 0, 0); if (result == 0) { PostQuitMessage(msg.wParam); /* What to do here? */ - } else if (result != (DWORD) -1) { + } else if (result != (unsigned int) -1) { TranslateMessage(&msg); DispatchMessageW(&msg); } diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 137747f..e6f44e7 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -54,29 +54,29 @@ static const char *const processors[NUMPROCESSORS] = { typedef struct { union { - DWORD dwOemId; + unsigned int dwOemId; struct { int wProcessorArchitecture; int wReserved; }; }; - DWORD dwPageSize; + unsigned int dwPageSize; void *lpMinimumApplicationAddress; void *lpMaximumApplicationAddress; void *dwActiveProcessorMask; - DWORD dwNumberOfProcessors; - DWORD dwProcessorType; - DWORD dwAllocationGranularity; + unsigned int dwNumberOfProcessors; + unsigned int dwProcessorType; + unsigned int dwAllocationGranularity; int wProcessorLevel; int wProcessorRevision; } SYSTEM_INFO; typedef struct { - DWORD dwOSVersionInfoSize; - DWORD dwMajorVersion; - DWORD dwMinorVersion; - DWORD dwBuildNumber; - DWORD dwPlatformId; + unsigned int dwOSVersionInfoSize; + unsigned int dwMajorVersion; + unsigned int dwMinorVersion; + unsigned int dwBuildNumber; + unsigned int dwPlatformId; wchar_t szCSDVersion[128]; } OSVERSIONINFOW; #endif @@ -873,7 +873,7 @@ TclpSetVariables( #ifdef __CYGWIN__ unameOK = 1; if (!osInfoInitialized) { - HANDLE handle = GetModuleHandleW(L"NTDLL"); + void *handle = GetModuleHandleW(L"NTDLL"); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index b3ad0bf..77426c8 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -90,11 +90,8 @@ typedef off_t Tcl_SeekOffset; extern "C" { #endif /* Make some symbols available without including */ -# define DWORD unsigned int # define CP_UTF8 65001 # define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004 -# define HANDLE void * -# define HINSTANCE void * # define SOCKET unsigned int # define WSAEWOULDBLOCK 10035 typedef unsigned short WCHAR; diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index de0ddad..737567b 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -152,7 +152,7 @@ DllMain( *---------------------------------------------------------------------- */ -HINSTANCE +void * TclWinGetTclInstance(void) { return hInstance; diff --git a/win/tclWinError.c b/win/tclWinError.c index fc07b3e..f93f000 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -349,11 +349,11 @@ static const unsigned char wsaErrorTable[] = { void TclWinConvertError( - DWORD errCode) /* Win32 error code. */ + int errCode) /* Win32 error code. */ { - if (errCode >= sizeof(errorTable)/sizeof(errorTable[0])) { + if ((unsigned)errCode >= sizeof(errorTable)/sizeof(errorTable[0])) { errCode -= WSAEWOULDBLOCK; - if (errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) { + if ((unsigned)errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) { Tcl_SetErrno(errorTable[1]); } else { Tcl_SetErrno(wsaErrorTable[errCode]); diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 122c4ae..7bd46cc 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -344,7 +344,7 @@ InitializeDefaultLibraryDir( size_t *lengthPtr, Tcl_Encoding *encodingPtr) { - HMODULE hModule = TclWinGetTclInstance(); + HMODULE hModule = (HMODULE)TclWinGetTclInstance(); WCHAR wName[MAX_PATH + LIBRARY_SIZE]; char name[(MAX_PATH + LIBRARY_SIZE) * 3]; char *end, *p; @@ -392,7 +392,7 @@ InitializeSourceLibraryDir( size_t *lengthPtr, Tcl_Encoding *encodingPtr) { - HMODULE hModule = TclWinGetTclInstance(); + HMODULE hModule = (HMODULE)TclWinGetTclInstance(); WCHAR wName[MAX_PATH + LIBRARY_SIZE]; char name[(MAX_PATH + LIBRARY_SIZE) * 3]; char *end, *p; diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c index 2ab4efa..022c7f4 100644 --- a/win/tclWinNotify.c +++ b/win/tclWinNotify.c @@ -103,7 +103,7 @@ Tcl_InitNotifier(void) clazz.style = 0; clazz.cbClsExtra = 0; clazz.cbWndExtra = 0; - clazz.hInstance = TclWinGetTclInstance(); + clazz.hInstance = (HINSTANCE)TclWinGetTclInstance(); clazz.hbrBackground = NULL; clazz.lpszMenuName = NULL; clazz.lpszClassName = className; @@ -195,7 +195,7 @@ Tcl_FinalizeNotifier( if (notifierCount) { notifierCount--; if (notifierCount == 0) { - UnregisterClassW(className, TclWinGetTclInstance()); + UnregisterClassW(className, (HINSTANCE)TclWinGetTclInstance()); } } LeaveCriticalSection(¬ifierMutex); @@ -360,7 +360,7 @@ Tcl_ServiceModeHook( if (mode == TCL_SERVICE_ALL && !tsdPtr->hwnd) { tsdPtr->hwnd = CreateWindowW(className, className, - WS_TILED, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(), + WS_TILED, 0, 0, 0, 0, NULL, NULL, (HINSTANCE)TclWinGetTclInstance(), NULL); /* diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 0bdb499..a02e846 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -2485,7 +2485,7 @@ InitSockets(void) windowClass.style = 0; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; - windowClass.hInstance = TclWinGetTclInstance(); + windowClass.hInstance = (HINSTANCE)TclWinGetTclInstance(); windowClass.hbrBackground = NULL; windowClass.lpszMenuName = NULL; windowClass.lpszClassName = className; @@ -2616,7 +2616,7 @@ SocketExitHandler( */ TclpFinalizeSockets(); - UnregisterClassW(className, TclWinGetTclInstance()); + UnregisterClassW(className, (HINSTANCE)TclWinGetTclInstance()); initialized = 0; Tcl_MutexUnlock(&socketMutex); } -- cgit v0.12 From 6e29f3da25b3a8130905e992528fda0b9c12f8e1 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 31 Mar 2020 16:21:11 +0000 Subject: Missed one int -> size_t in the merge. --- generic/tclBinary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index d013076..0e1e54e 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2879,7 +2879,7 @@ BinaryEncodeUu( objv[i + 1], &wrapcharlen); { const unsigned char *p = wrapchar; - int numBytes = wrapcharlen; + size_t numBytes = wrapcharlen; while (numBytes) { switch (*p) { -- cgit v0.12 From f47fbe763af41b982b9233bca58795cd34b2c259 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 6 Apr 2020 13:24:34 +0000 Subject: Fix build with --enable-symbols=mem --- generic/tclCkalloc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 6efef86..e37d0b8 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -20,7 +20,9 @@ #define FALSE 0 #define TRUE 1 +#undef Tcl_Alloc #undef Tcl_Free +#undef Tcl_Realloc #undef Tcl_AttemptAlloc #undef Tcl_AttemptRealloc @@ -690,7 +692,7 @@ Tcl_DbCkrealloc( if (copySize > memp->length) { copySize = memp->length; } - newPtr = Tcl_DbCkalloc(size, file, line); + newPtr = (char *)Tcl_DbCkalloc(size, file, line); memcpy(newPtr, ptr, copySize); Tcl_DbCkfree(ptr, file, line); return newPtr; @@ -721,7 +723,7 @@ Tcl_AttemptDbCkrealloc( if (copySize > memp->length) { copySize = memp->length; } - newPtr = Tcl_AttemptDbCkalloc(size, file, line); + newPtr = (char *)Tcl_AttemptDbCkalloc(size, file, line); if (newPtr == NULL) { return NULL; } @@ -734,6 +736,59 @@ Tcl_AttemptDbCkrealloc( /* *---------------------------------------------------------------------- * + * Tcl_Alloc, et al. -- + * + * These functions are defined in terms of the debugging versions when + * TCL_MEM_DEBUG is set. + * + * Results: + * Same as the debug versions. + * + * Side effects: + * Same as the debug versions. + * + *---------------------------------------------------------------------- + */ + +void * +Tcl_Alloc( + size_t size) +{ + return Tcl_DbCkalloc(size, "unknown", 0); +} + +void * +Tcl_AttemptAlloc( + size_t size) +{ + return Tcl_AttemptDbCkalloc(size, "unknown", 0); +} + +void +Tcl_Free( + void *ptr) +{ + Tcl_DbCkfree(ptr, "unknown", 0); +} + +void * +Tcl_Realloc( + void *ptr, + size_t size) +{ + return Tcl_DbCkrealloc(ptr, size, "unknown", 0); +} +void * +Tcl_AttemptRealloc( + void *ptr, + size_t size) +{ + return Tcl_AttemptDbCkrealloc(ptr, size, "unknown", 0); +} + +/* + *---------------------------------------------------------------------- + * * MemoryCmd -- * * Implements the Tcl "memory" command, which provides Tcl-level control @@ -992,7 +1047,6 @@ Tcl_InitMemory( *---------------------------------------------------------------------- */ -#undef Tcl_Alloc void * Tcl_Alloc( size_t size) @@ -1069,7 +1123,6 @@ Tcl_AttemptDbCkalloc( *---------------------------------------------------------------------- */ -#undef Tcl_Realloc void * Tcl_Realloc( void *ptr, @@ -1141,7 +1194,6 @@ Tcl_AttemptDbCkrealloc( *---------------------------------------------------------------------- */ -#undef Tcl_Free void Tcl_Free( void *ptr) -- cgit v0.12 From 3a2ad288cae5e522cfc2797e0d10c81746ed20d0 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 14 Apr 2020 15:57:08 +0000 Subject: Remove test not suitable for Tcl 9. --- tests/encoding.test | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/encoding.test b/tests/encoding.test index 5c1ea6c..f21fd0e 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -326,11 +326,6 @@ test encoding-15.3.b {UtfToUtfProc null character input} testbytestring { binary scan [testbytestring $y] H* z set z } 00 -test encoding-15.3.c {UtfToUtfProc null character input} { - set y [encoding convertfrom utf-8 [encoding convertto utf-8 \u0000]] - binary scan [encoding convertto identity $y] H* z - set z -} c080 test encoding-15.4 {UtfToUtfProc emoji character input} -body { set x \xED\xA0\xBD\xED\xB8\x82 set y [encoding convertfrom utf-8 \xED\xA0\xBD\xED\xB8\x82] -- cgit v0.12 From fc7ca4202ee105ad3bbd576d2a3bf2e5d5793825 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 20 Apr 2020 21:07:35 +0000 Subject: Change a few variables from type "int" to "size_t". Always test TCL_UTF_MAX for <= 3 or > 3, because that's the only 2 flavours we really have. --- generic/tclDisassemble.c | 2 +- generic/tclObj.c | 4 ++-- generic/tclUtf.c | 6 +++--- macosx/tclMacOSXFCmd.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 49904bd..85a17b0 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -832,7 +832,7 @@ UpdateStringOfInstName( if (inst > LAST_INST_OPCODE) { dst = Tcl_InitStringRep(objPtr, NULL, TCL_INTEGER_SPACE + 5); - TclOOM(dst, TCL_INTEGER_SPACE + 5); + TclOOM(dst, (size_t)TCL_INTEGER_SPACE + 5); sprintf(dst, "inst_%" TCL_Z_MODIFIER "u", inst); (void) Tcl_InitStringRep(objPtr, NULL, strlen(dst)); } else { diff --git a/generic/tclObj.c b/generic/tclObj.c index 7853507..8a628a7 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2381,7 +2381,7 @@ UpdateStringOfDouble( { char *dst = Tcl_InitStringRep(objPtr, NULL, TCL_DOUBLE_SPACE); - TclOOM(dst, TCL_DOUBLE_SPACE + 1); + TclOOM(dst, (size_t)TCL_DOUBLE_SPACE + 1); Tcl_PrintDouble(NULL, objPtr->internalRep.doubleValue, dst); (void) Tcl_InitStringRep(objPtr, NULL, strlen(dst)); @@ -2494,7 +2494,7 @@ UpdateStringOfInt( { char *dst = Tcl_InitStringRep( objPtr, NULL, TCL_INTEGER_SPACE); - TclOOM(dst, TCL_INTEGER_SPACE + 1); + TclOOM(dst, (size_t)TCL_INTEGER_SPACE + 1); (void) Tcl_InitStringRep(objPtr, NULL, TclFormatInt(dst, objPtr->internalRep.wideValue)); } diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 5b0c9e9..6e0a7db 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -344,7 +344,7 @@ Tcl_Char16ToUtfDString( * Tcl_UtfCharComplete() before calling this routine to ensure that * enough bytes remain in the string. * - * If TCL_UTF_MAX <= 4, special handling of Surrogate pairs is done: + * If TCL_UTF_MAX <= 3, special handling of Surrogate pairs is done: * For any UTF-8 string containing a character outside of the BMP, the * first call to this function will fill *chPtr with the high surrogate * and generate a return value of 1. Calling Tcl_UtfToUniChar again @@ -1031,13 +1031,13 @@ Tcl_UtfAtIndex( size_t index) /* The position of the desired character. */ { Tcl_UniChar ch = 0; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX <= 3 size_t len = 0; #endif if (index != TCL_INDEX_NONE) { while (index--) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX <= 3 src += (len = TclUtfToUniChar(src, &ch)); #else src += TclUtfToUniChar(src, &ch); diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c index 8dc3775..e00739a 100644 --- a/macosx/tclMacOSXFCmd.c +++ b/macosx/tclMacOSXFCmd.c @@ -693,7 +693,7 @@ UpdateStringOfOSType( Tcl_Obj *objPtr) /* OSType object whose string rep to * update. */ { - const int size = TCL_UTF_MAX * 4; + const size_t size = TCL_UTF_MAX * 4; char *dst = Tcl_InitStringRep(objPtr, NULL, size); OSType osType = (OSType) objPtr->internalRep.wideValue; int written = 0; -- cgit v0.12 From 4a86cf8b0011b3ea785b6e92ca8ab5aa5372a707 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 26 Apr 2020 15:30:12 +0000 Subject: Since Tcl_NumUtfChars() now can return a value of more that 32 bits .... --- generic/tclDisassemble.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 85a17b0..9cb899e 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -1194,10 +1194,10 @@ DisassembleByteCodeAsDicts( */ Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptfrom", -1), - Tcl_NewIntObj(Tcl_NumUtfChars(codePtr->source, + Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source, sourceOffset))); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptto", -1), - Tcl_NewIntObj(Tcl_NumUtfChars(codePtr->source, + Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source, sourceOffset + sourceLength - 1))); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("script", -1), Tcl_NewStringObj(codePtr->source+sourceOffset, sourceLength)); -- cgit v0.12 From 2e6739312916740bb0300654d3e97bde5a10112d Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 27 Apr 2020 16:10:54 +0000 Subject: [a444889cbe] Quick fix to satisfy Travis. Might revise later. --- tests/utf.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utf.test b/tests/utf.test index ad030f4..7a97db1 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -775,7 +775,7 @@ test utf-9.2 {Tcl_UtfAtIndex: index > 0} { test utf-9.3 {Tcl_UtfAtIndex: index = 0, Emoji} { string range \U1F600G 0 0 } "\U1F600" -test utf-9.4 {Tcl_UtfAtIndex: index > 0, Emoji} fullutf { +test utf-9.4 {Tcl_UtfAtIndex: index > 0, Emoji} ucs4 { string range \U1F600G 1 1 } {G} -- cgit v0.12 From fb50a7f7b52d70cb9a3f8b0225a988d5c83e92ef Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 6 Jun 2020 21:19:17 +0000 Subject: Fix Travis build for Windows in debug mode. --- win/tclWinPort.h | 1 + 1 file changed, 1 insertion(+) diff --git a/win/tclWinPort.h b/win/tclWinPort.h index c6ddf40..59ba138 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -485,6 +485,7 @@ typedef DWORD_PTR * PDWORD_PTR; #if defined(_MSC_VER) # pragma warning(disable:4146) # pragma warning(disable:4244) +# pragma warning(disable:4307) # if _MSC_VER >= 1400 # pragma warning(disable:4267) # pragma warning(disable:4996) -- cgit v0.12 From f2b9098a94578c0b0d0091a71f9a92231a1f5426 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 8 Jun 2020 20:02:28 +0000 Subject: Still ... need to disable C4305 on Win32 (32-bit only) --- win/tclWinPort.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win/tclWinPort.h b/win/tclWinPort.h index c6ddf40..4f39e63 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -485,6 +485,9 @@ typedef DWORD_PTR * PDWORD_PTR; #if defined(_MSC_VER) # pragma warning(disable:4146) # pragma warning(disable:4244) +#if !defined(_WIN64) +# pragma warning(disable:4305) +#endif # if _MSC_VER >= 1400 # pragma warning(disable:4267) # pragma warning(disable:4996) -- cgit v0.12 From 97399b2494ad5212668ee6daac2929a4d48cee3f Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 19 Jun 2020 06:06:07 +0000 Subject: Correct man page per [ad8df845fef2c76d95b9f1aaa4815f3b23d4c472] --- doc/lset.n | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/lset.n b/doc/lset.n index afc721f..fbcf7e4 100644 --- a/doc/lset.n +++ b/doc/lset.n @@ -116,6 +116,8 @@ The indicated return value also becomes the new value of \fIx\fR \fBlset\fR x {2 1} j \fI\(-> {a b c} {d e f} {g j i}\fR \fBlset\fR x {2 3} j + \fI\(-> {a b c} {d e f} {g h i j}\fR +\fBlset\fR x {2 4} j \fI\(-> list index out of range\fR .CE .PP -- cgit v0.12 From 326bd29be7c2d61536c5eaba30da96d47973c529 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 6 Jul 2020 00:22:26 +0000 Subject: Clarify index order --- doc/lsearch.n | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lsearch.n b/doc/lsearch.n index c5dc98f..72c91dc 100644 --- a/doc/lsearch.n +++ b/doc/lsearch.n @@ -65,8 +65,8 @@ These options may be given with all matching styles. . Changes the result to be the list of all matching indices (or all matching values if \fB\-inline\fR is specified as well.) If indices are returned, the -indices will be in numeric order. If values are returned, the order of the -values will be the order of those values within the input \fIlist\fR. +indices will be in ascending numeric order. If values are returned, the order +of the values will be the order of those values within the input \fIlist\fR. .TP \fB\-inline\fR . -- cgit v0.12 -- cgit v0.12 From 0d59960edfba62674a912819c0328b91a02beb29 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 11:22:37 +0000 Subject: Add example files for use in tests/safe.test; add tests of the files themselves. --- tests/auto0/auto1/file1.tcl | 3 + tests/auto0/auto1/package1.tcl | 5 ++ tests/auto0/auto1/pkgIndex.tcl | 11 +++ tests/auto0/auto1/tclIndex | 9 +++ tests/auto0/auto2/file2.tcl | 3 + tests/auto0/auto2/package2.tcl | 5 ++ tests/auto0/auto2/pkgIndex.tcl | 11 +++ tests/auto0/auto2/tclIndex | 9 +++ tests/auto0/modules/mod1/test1-1.0.tm | 5 ++ tests/auto0/modules/mod2/test2-2.0.tm | 5 ++ tests/auto0/modules/test0-0.5.tm | 5 ++ tests/safe.test | 123 ++++++++++++++++++++++++++++++++++ 12 files changed, 194 insertions(+) create mode 100644 tests/auto0/auto1/file1.tcl create mode 100644 tests/auto0/auto1/package1.tcl create mode 100644 tests/auto0/auto1/pkgIndex.tcl create mode 100644 tests/auto0/auto1/tclIndex create mode 100644 tests/auto0/auto2/file2.tcl create mode 100644 tests/auto0/auto2/package2.tcl create mode 100644 tests/auto0/auto2/pkgIndex.tcl create mode 100644 tests/auto0/auto2/tclIndex create mode 100644 tests/auto0/modules/mod1/test1-1.0.tm create mode 100644 tests/auto0/modules/mod2/test2-2.0.tm create mode 100644 tests/auto0/modules/test0-0.5.tm diff --git a/tests/auto0/auto1/file1.tcl b/tests/auto0/auto1/file1.tcl new file mode 100644 index 0000000..bd8b92b --- /dev/null +++ b/tests/auto0/auto1/file1.tcl @@ -0,0 +1,3 @@ +proc report1 {args} { + return ok1 +} diff --git a/tests/auto0/auto1/package1.tcl b/tests/auto0/auto1/package1.tcl new file mode 100644 index 0000000..32d7c56 --- /dev/null +++ b/tests/auto0/auto1/package1.tcl @@ -0,0 +1,5 @@ +proc HeresPackage1 {args} { + return OK1 +} + +package provide SafeTestPackage1 1.2.3 diff --git a/tests/auto0/auto1/pkgIndex.tcl b/tests/auto0/auto1/pkgIndex.tcl new file mode 100644 index 0000000..babb6d5 --- /dev/null +++ b/tests/auto0/auto1/pkgIndex.tcl @@ -0,0 +1,11 @@ +# Tcl package index file, version 1.1 +# This file is generated by the "pkg_mkIndex" command +# and sourced either when an application starts up or +# by a "package unknown" script. It invokes the +# "package ifneeded" command to set up package-related +# information so that packages will be loaded automatically +# in response to "package require" commands. When this +# script is sourced, the variable $dir must contain the +# full path name of this file's directory. + +package ifneeded SafeTestPackage1 1.2.3 [list source [file join $dir package1.tcl]] diff --git a/tests/auto0/auto1/tclIndex b/tests/auto0/auto1/tclIndex new file mode 100644 index 0000000..bbfa6d4 --- /dev/null +++ b/tests/auto0/auto1/tclIndex @@ -0,0 +1,9 @@ +# Tcl autoload index file, version 2.0 +# This file is generated by the "auto_mkindex" command +# and sourced to set up indexing information for one or +# more commands. Typically each line is a command that +# sets an element in the auto_index array, where the +# element name is the name of a command and the value is +# a script that loads the command. + +set auto_index(report1) [list source [file join $dir file1.tcl]] diff --git a/tests/auto0/auto2/file2.tcl b/tests/auto0/auto2/file2.tcl new file mode 100644 index 0000000..5bc622f --- /dev/null +++ b/tests/auto0/auto2/file2.tcl @@ -0,0 +1,3 @@ +proc report2 {args} { + return ok2 +} diff --git a/tests/auto0/auto2/package2.tcl b/tests/auto0/auto2/package2.tcl new file mode 100644 index 0000000..61774df --- /dev/null +++ b/tests/auto0/auto2/package2.tcl @@ -0,0 +1,5 @@ +proc HeresPackage2 {args} { + return OK2 +} + +package provide SafeTestPackage2 2.3.4 diff --git a/tests/auto0/auto2/pkgIndex.tcl b/tests/auto0/auto2/pkgIndex.tcl new file mode 100644 index 0000000..1022691 --- /dev/null +++ b/tests/auto0/auto2/pkgIndex.tcl @@ -0,0 +1,11 @@ +# Tcl package index file, version 1.1 +# This file is generated by the "pkg_mkIndex" command +# and sourced either when an application starts up or +# by a "package unknown" script. It invokes the +# "package ifneeded" command to set up package-related +# information so that packages will be loaded automatically +# in response to "package require" commands. When this +# script is sourced, the variable $dir must contain the +# full path name of this file's directory. + +package ifneeded SafeTestPackage2 2.3.4 [list source [file join $dir package2.tcl]] diff --git a/tests/auto0/auto2/tclIndex b/tests/auto0/auto2/tclIndex new file mode 100644 index 0000000..9cd2a74 --- /dev/null +++ b/tests/auto0/auto2/tclIndex @@ -0,0 +1,9 @@ +# Tcl autoload index file, version 2.0 +# This file is generated by the "auto_mkindex" command +# and sourced to set up indexing information for one or +# more commands. Typically each line is a command that +# sets an element in the auto_index array, where the +# element name is the name of a command and the value is +# a script that loads the command. + +set auto_index(report2) [list source [file join $dir file2.tcl]] diff --git a/tests/auto0/modules/mod1/test1-1.0.tm b/tests/auto0/modules/mod1/test1-1.0.tm new file mode 100644 index 0000000..927fa6f --- /dev/null +++ b/tests/auto0/modules/mod1/test1-1.0.tm @@ -0,0 +1,5 @@ +namespace eval mod1::test1 {} + +proc mod1::test1::try1 args { + return res1 +} diff --git a/tests/auto0/modules/mod2/test2-2.0.tm b/tests/auto0/modules/mod2/test2-2.0.tm new file mode 100644 index 0000000..b5cd45b --- /dev/null +++ b/tests/auto0/modules/mod2/test2-2.0.tm @@ -0,0 +1,5 @@ +namespace eval mod2::test2 {} + +proc mod2::test2::try2 args { + return res2 +} diff --git a/tests/auto0/modules/test0-0.5.tm b/tests/auto0/modules/test0-0.5.tm new file mode 100644 index 0000000..19f3613 --- /dev/null +++ b/tests/auto0/modules/test0-0.5.tm @@ -0,0 +1,5 @@ +namespace eval test0 {} + +proc test0::try0 args { + return res0 +} diff --git a/tests/safe.test b/tests/safe.test index 11ad2a9..71fe0fb 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -24,6 +24,8 @@ foreach i [interp slaves] { set saveAutoPath $::auto_path set ::auto_path [info library] +set TestsDir [file normalize [file dirname [info script]]] + # Force actual loading of the safe package because we use un exported (and # thus un-autoindexed) APIs in this test result arguments: catch {safe::interpConfigure} @@ -179,6 +181,126 @@ test safe-6.3 {test safe interpreters knowledge of the world} { # More test should be added to check that hostname, nameofexecutable, aren't # leaking infos, but they still do... +# Tests 7.0* test the example files before using them to test safe interpreters. + +test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0 auto1] [file join $TestsDir auto0 auto2] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {0 ok1 0 ok2} + +test safe-7.0b {example tclIndex commands, negative test in master interpreter} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} + +test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} + +test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} + +test safe-7.0e {example modules packages, test in master interpreter, replace path} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} + +test safe-7.0f {example modules packages, test in master interpreter, append to path} -setup { + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} + # high level general test test safe-7.1 {tests that everything works at high level} -body { set i [safe::interpCreate] @@ -833,6 +955,7 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -result {} set ::auto_path $saveAutoPath +unset saveAutoPath TestsDir # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 2c1750c78f0c5c36008d4043f099ef2485d96de4 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 11:43:52 +0000 Subject: Add new tests to tests/safe.test. --- tests/safe.test | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 544 insertions(+) diff --git a/tests/safe.test b/tests/safe.test index 71fe0fb..3ff9e62 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -527,6 +527,550 @@ test safe-9.6 {interpConfigure widget like behaviour} -body { safe::interpConfigure $i] } -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} +test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { + # this test shall work, believed equivalent to 9.6 + set i [safe::interpCreate \ + -noStatics \ + -nestedLoadOk \ + -deleteHook {foo bar} \ + ] + + safe::interpConfigure $i -accessPath /foo/bar + set a [safe::interpConfigure $i] + set b [safe::interpConfigure $i -aCCess] + set c [safe::interpConfigure $i -nested] + set d [safe::interpConfigure $i -statics] + set e [safe::interpConfigure $i -DEL] + safe::interpConfigure $i -accessPath /blah -statics 1 + set f [safe::interpConfigure $i] + safe::interpConfigure $i -deleteHook toto -nosta -nested 0 + set g [safe::interpConfigure $i] + + list $a $b $c $d $e $f $g +} -cleanup { + safe::interpDelete $i +} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} + +test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + + # Load and run the commands. + # This guarantees the test will pass even if the tokens are swapped. + set code1 [catch {interp eval $i {report1}} msg1] + set code2 [catch {interp eval $i {report2}} msg2] + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto2] \ + [file join $TestsDir auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}" + +test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + + # Do not load the commands. With the tokens swapped, the test + # will pass only if the Safe Base has called auto_reset. + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto2] \ + [file join $TestsDir auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load and run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}" + +test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { +} -body { + # For complete correspondence to safe-9.10opt, include auto0 in access path. + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0] \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}. + # This would have no effect because the records in Pkg of these directories + # were from access as children of {$p(:1:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0] \ + [file join $TestsDir auto0 auto2] \ + [file join $TestsDir auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ + $code5 $msg5 $code6 $msg6 + +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:2:)} {\$p(:3:)} {\$p(:3:)} {\$p(:2:)} 0 1.2.3 0 2.3.4\ + {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + 0 OK1 0 OK2" + +test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto2] \ + [file join $TestsDir auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ + $code5 $msg5 $code6 $msg6 +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + 0 OK1 0 OK2" + +test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library] + + # Inspect. + set confB [safe::interpConfigure $i] + set code4 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]} path4] + set code5 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]} path5] + + # Try to load the packages. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] + set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] + + list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ + 1 {* not found in access path} 1 {*} 1 {*}\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" + +test safe-9.20 {check module loading} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]*}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" + +test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Load pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/auto1 \ + $TestsDir/auto0/auto2 \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" + +test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/auto1 \ + $TestsDir/auto0/auto2 \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" + +test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Refresh stale pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 + +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/auto1 \ + $TestsDir/auto0/auto2 \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" + +test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $TestsDir auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $TestsDir auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $TestsDir/auto0/auto1 \ + $TestsDir/auto0/auto2 \ + $TestsDir/auto0/modules \ + $TestsDir/auto0/modules/mod1 \ + $TestsDir/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" + + catch {teststaticpkg Safepkg1 0 0} test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { set i [safe::interpCreate] -- cgit v0.12 From c256107a5c50a4ffa13d226f245f25cf4ccc311f Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 11:49:46 +0000 Subject: Bugfix in library/safe.tcl for doreset (auto_reset); pass test safe-9.9 --- library/safe.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 3429b9e..7ed6b94 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -192,10 +192,10 @@ proc ::safe::interpConfigure {args} { # Get the current (and not the default) values of whatever has # not been given: if {![::tcl::OptProcArgGiven -accessPath]} { - set doreset 1 + set doreset 0 set accessPath $state(access_path) } else { - set doreset 0 + set doreset 1 } if { ![::tcl::OptProcArgGiven -statics] -- cgit v0.12 From 9c9af976ae17ba173df40300467589554956e8f2 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:09:47 +0000 Subject: Bugfix in library/safe.tcl - when auto_reset, also reload pkgIndex.tcl data; pass tests safe-9.10, safe-9.11 --- library/safe.tcl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/safe.tcl b/library/safe.tcl index 7ed6b94..deefa33 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -225,6 +225,14 @@ proc ::safe::interpConfigure {args} { } else { Log $slave "successful auto_reset" NOTICE } + # Wherever possible, refresh package data. + # - Ideally [package ifneeded $pkg $ver {}] would clear the + # stale data from the interpreter, but instead it sets a + # nonsense empty script. + # - We cannot purge stale package data, but we can overwrite + # it where we have fresh data. Any remaining stale data will + # do no harm but the error messages may be cryptic. + ::interp eval $slave [list catch {package require NOEXIST}] } } } -- cgit v0.12 From af4b36c13d6d8cbcdf5798b5b12dd996b484d8a8 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:13:07 +0000 Subject: Bugfix in library/safe.tcl - remove impossible error message in safe::interpFindInAccessPath; pass test safe-9.12 --- library/safe.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/safe.tcl b/library/safe.tcl index deefa33..838f65f 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -404,7 +404,7 @@ proc ::safe::interpFindInAccessPath {slave path} { namespace upvar ::safe S$slave state if {![dict exists $state(access_path,remap) $path]} { - return -code error "$path not found in access path $access_path" + return -code error "$path not found in access path" } return [dict get $state(access_path,remap) $path] -- cgit v0.12 From cca23e5286ec6f14dd7c62275cc409419f2a6d3c Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:25:10 +0000 Subject: Bugfix in library/safe.tcl - only add tm roots to tcl::tm::list; pass test safe-9.20 --- library/safe.tcl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/safe.tcl b/library/safe.tcl index 838f65f..d31ca63 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -352,6 +352,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { } set morepaths [::tcl::tm::list] + set firstpass 1 while {[llength $morepaths]} { set addpaths $morepaths set morepaths {} @@ -360,6 +361,12 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Prevent the addition of dirs on the tm list to the # result if they are already known. if {[dict exists $remap_access_path $dir]} { + if {$firstpass} { + # $dir is in [::tcl::tm::list] and belongs in the slave_tm_path. + # Later passes handle subdirectories, which belong in the + # access path but not in the module path. + lappend slave_tm_path [dict get $remap_access_path $dir] + } continue } @@ -369,7 +376,12 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { lappend map_access_path $token $dir lappend remap_access_path $dir $token lappend norm_access_path [file normalize $dir] - lappend slave_tm_path $token + if {$firstpass} { + # $dir is in [::tcl::tm::list] and belongs in the slave_tm_path. + # Later passes handle subdirectories, which belong in the + # access path but not in the module path. + lappend slave_tm_path $token + } incr i # [Bug 2854929] @@ -380,6 +392,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # subdirectories. lappend morepaths {*}[glob -nocomplain -directory $dir -type d *] } + set firstpass 0 } set state(access_path) $access_path -- cgit v0.12 From f0a97b5c716346e60173644010e1d201bea8e690 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:32:08 +0000 Subject: Bugfix in library/safe.tcl - interpConfigure use revised value of tcl::tm::list; pass tests safe-9.21, safe-9.22 --- library/safe.tcl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/safe.tcl b/library/safe.tcl index d31ca63..4d22cbe 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -225,6 +225,14 @@ proc ::safe::interpConfigure {args} { } else { Log $slave "successful auto_reset" NOTICE } + + # Sync the paths used to search for Tcl modules. + ::interp eval $slave {tcl::tm::path remove {*}[tcl::tm::list]} + if {[llength $state(tm_path_slave)] > 0} { + ::interp eval $slave [list \ + ::tcl::tm::add {*}[lreverse $state(tm_path_slave)]] + } + # Wherever possible, refresh package data. # - Ideally [package ifneeded $pkg $ver {}] would clear the # stale data from the interpreter, but instead it sets a -- cgit v0.12 From 12ba446acbcd70856603aeeffb90fc425be58e02 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:37:16 +0000 Subject: Bugfix in library/tm.tcl - in a safe interp ::tcl::tm::UnknownHandler should always use the freshest "package ifneeded"; pass test safe-9.23 --- library/tm.tcl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/tm.tcl b/library/tm.tcl index 1802bb9..3861532 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -238,12 +238,16 @@ proc ::tcl::tm::UnknownHandler {original name args} { continue } - if {[package ifneeded $pkgname $pkgversion] ne {}} { + if { ([package ifneeded $pkgname $pkgversion] ne {}) + && (![interp issafe]) + } { # There's already a provide script registered for # this version of this package. Since all units of # code claiming to be the same version of the same # package ought to be identical, just stick with # the one we already have. + # This does not apply to Safe Base interpreters because + # the token-to-directory mapping may have changed. continue } -- cgit v0.12 From 4c326aa381e14ad6cdef2060e7f0a6328b970699 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 12:52:53 +0000 Subject: Bugfix in library/safe.tcl - when auto_reset, also reload module data; pass test safe-9.24 --- library/safe.tcl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 4d22cbe..30b045e 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -217,7 +217,7 @@ proc ::safe::interpConfigure {args} { set deleteHook $state(cleanupHook) } # we can now reconfigure : - InterpSetConfig $slave $accessPath $statics $nested $deleteHook + set slave_tm_rel [InterpSetConfig $slave $accessPath $statics $nested $deleteHook] # auto_reset the slave (to completly synch the new access_path) if {$doreset} { if {[catch {::interp eval $slave {auto_reset}} msg]} { @@ -233,7 +233,7 @@ proc ::safe::interpConfigure {args} { ::tcl::tm::add {*}[lreverse $state(tm_path_slave)]] } - # Wherever possible, refresh package data. + # Wherever possible, refresh package/module data. # - Ideally [package ifneeded $pkg $ver {}] would clear the # stale data from the interpreter, but instead it sets a # nonsense empty script. @@ -241,6 +241,10 @@ proc ::safe::interpConfigure {args} { # it where we have fresh data. Any remaining stale data will # do no harm but the error messages may be cryptic. ::interp eval $slave [list catch {package require NOEXIST}] + foreach rel $slave_tm_rel { + set cmd [list package require [string map {/ ::} $rel]::NOEXIST] + ::interp eval $slave [list catch $cmd] + } } } } @@ -348,6 +352,8 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { set map_access_path {} set remap_access_path {} set slave_tm_path {} + set slave_tm_roots {} + set slave_tm_rel {} set i 0 foreach dir $access_path { @@ -374,6 +380,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Later passes handle subdirectories, which belong in the # access path but not in the module path. lappend slave_tm_path [dict get $remap_access_path $dir] + lappend slave_tm_roots [file normalize $dir] [file normalize $dir] } continue } @@ -389,6 +396,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Later passes handle subdirectories, which belong in the # access path but not in the module path. lappend slave_tm_path $token + lappend slave_tm_roots [file normalize $dir] [file normalize $dir] } incr i @@ -399,6 +407,14 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # 'platform/shell-X.tm', i.e arbitrarily deep # subdirectories. lappend morepaths {*}[glob -nocomplain -directory $dir -type d *] + foreach sub [glob -nocomplain -directory $dir -type d *] { + lappend slave_tm_roots [file normalize $sub] [dict get $slave_tm_roots $dir] + set lenny [string length [dict get $slave_tm_roots $dir]] + set relpath [string range [file normalize $sub] $lenny+1 end] + if {$relpath ni $slave_tm_rel} { + lappend slave_tm_rel $relpath + } + } } set firstpass 0 } @@ -414,6 +430,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { set state(cleanupHook) $deletehook SyncAccessPath $slave + return $slave_tm_rel } # -- cgit v0.12 From 7169e0abe0053715354bdb1f7e2ecec9199e9691 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 14:55:28 +0000 Subject: Add tests to tests/safe.test --- tests/safe.test | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 3ff9e62..c70d9b1 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -9,6 +9,7 @@ # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. +# PURGE SyncExists AutoPathSync package require Tcl 8.5- @@ -302,7 +303,25 @@ test safe-7.0f {example modules packages, test in master interpreter, append to } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} # high level general test -test safe-7.1 {tests that everything works at high level} -body { +# Use example packages not http1.0 +test safe-7.1 {tests that everything works at high level} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0] + set i [safe::interpCreate] + set ::auto_path $tmpAutoPath +} -body { + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a slave works like in the master) + set v [interp eval $i {package require SafeTestPackage1}] + # no error shall occur: + interp eval $i {HeresPackage1} + set v +} -cleanup { + safe::interpDelete $i +} -match glob -result 1.2.3 +# high level general test +test safe-7.1http {tests that everything works at high level, uses http 2} -body { set i [safe::interpCreate] # no error shall occur: # (because the default access_path shall include 1st level sub dirs so @@ -313,7 +332,27 @@ test safe-7.1 {tests that everything works at high level} -body { safe::interpDelete $i set v } -match glob -result 2.* -test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -body { +test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + # should add as p* (not p2 if master has a module path) + set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] + # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level + # provided deep path) + list $token1 $token2 $token3 \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ + [safe::interpConfigure $i]\ + [safe::interpDelete $i] +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1\ + {can't find package SafeTestPackage1}\ + {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ + -statics 0 -nested 1 -deleteHook {}} {}" +test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] @@ -331,6 +370,36 @@ test safe-7.3 {check that safe subinterpreters work} { set j [safe::interpCreate [list $i x]] list [interp eval $j {join {o k} ""}] [safe::interpDelete $i] [interp exists $j] } {ok {} 0} +test safe-7.4 {tests specific path and positive search} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] + # this time, unlike test safe-7.2, SafeTestPackage1 should be found + list $token1 $token2 \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ + [safe::interpConfigure $i]\ + [safe::interpDelete $i] + # Note that the glob match elides directories (those from the module path) + # other than the first and last in the access path. +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ + {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ + -statics 0 -nested 1 -deleteHook {}} {}" +test safe-7.4http {tests specific path and positive search, uses http1.0} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p1 + set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] + # this time, unlike test safe-7.2, http should be found + list $token1 $token2 \ + [catch {interp eval $i {package require http 1}} msg] $msg \ + [safe::interpConfigure $i]\ + [safe::interpDelete $i] +} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.0 {-accessPath {[list $tcl_library *$tcl_library/http1.0]} -statics 0 -nested 1 -deleteHook {}} {}" # test source control on file name set i "a" -- cgit v0.12 From 26cf086c2c3bbb88a608e5c24767c065f5763d8a Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 14:57:44 +0000 Subject: Comments only. --- tests/safe.test | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/safe.test b/tests/safe.test index c70d9b1..0f40c36 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -9,7 +9,6 @@ # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -# PURGE SyncExists AutoPathSync package require Tcl 8.5- -- cgit v0.12 -- cgit v0.12 From 7141714e0b598c51f7bda601937fb5e1160e9332 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 17:36:16 +0000 Subject: safe.test - use opt instead of http for tests with stock packages; tests work whether and how opt is installed; add tests 9.10opt, 9.12opt --- tests/safe.test | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 151 insertions(+), 18 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index be52ff4..e99e3f7 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -24,6 +24,58 @@ foreach i [interp slaves] { set saveAutoPath $::auto_path set ::auto_path [info library] +# The defunct package http 1.0 was convenient for testing package loading. +# - Replaced here with tests using example packages provided in subdirectory +# auto0 of the tests directory, which are independent of any changes +# made to the packages provided with Tcl. +# - These are tests 7.1 7.2 7.4 9.10 9.12 +# - Tests 7.0[a-f] test the example packages themselves before they +# are used to test Safe Base interpreters. +# - Alternatively use packages opt and (from cookiejar) tcl::idna. +# - These alternative tests have suffix "opt". +# - These are 7.[124]opt, 9.1[02]opt +# - Tests 7.[124]opt, 9.1[02]opt use "package require opt". +# - Tests 9.1[02]opt also use "package require tcl::idna". +# +# When using package opt for testing positive/negative package search: +# - The directory location and the error message depend on whether +# and how the package is installed. + +# Error message for tests 7.2opt for "package require opt". +if {[string match *zipfs:/* [info library]]} { + # pkgIndex.tcl is in [info library] + # file to be sourced is in [info library]/opt* + set pkgOptErrMsg {permission denied} +} else { + # pkgIndex.tcl and file to be sourced are + # both in [info library]/opt* + set pkgOptErrMsg {can't find package opt} +} + +# Directory of opt for tests 7.4opt, 9.10opt, 9.12opt +# for "package require opt". +if {[file exists [file join [info library] opt0.4]]} { + # Installed files in lib8.7/opt0.4 + set pkgOptDir opt0.4 +} elseif {[file exists [file join [info library] opt]]} { + # Installed files in zipfs, or source files used by "make test" + set pkgOptDir opt +} else { + error {cannot find opt library} +} + +# Directory of cookiejar for tests 9.10opt, 9.12opt +# for "package require tcl::idna". +if {[file exists [file join [info library] cookiejar0.2]]} { + # Installed files in lib8.7/cookiejar0.2 + set pkgJarDir cookiejar0.2 +} elseif {[file exists [file join [info library] cookiejar]]} { + # Installed files in zipfs, or source files used by "make test" + set pkgJarDir cookiejar +} else { + error {cannot find cookiejar library} +} + set TestsDir [file normalize [file dirname [info script]]] # Force actual loading of the safe package because we use un exported (and @@ -320,17 +372,19 @@ test safe-7.1 {tests that everything works at high level} -setup { safe::interpDelete $i } -match glob -result 1.2.3 # high level general test -test safe-7.1http {tests that everything works at high level, uses http 2} -body { +test safe-7.1opt {tests that everything works at high level, uses pkg opt} -setup { set i [safe::interpCreate] +} -body { # no error shall occur: # (because the default access_path shall include 1st level sub dirs so # package require in a slave works like in the master) - set v [interp eval $i {package require http 2}] + set v [interp eval $i {package require opt}] # no error shall occur: - interp eval $i {http::config} - safe::interpDelete $i + interp eval $i {::tcl::Lempty {a list}} set v -} -match glob -result 2.* +} -cleanup { + safe::interpDelete $i +} -match glob -result 0.4.* test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -351,19 +405,23 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { {can't find package SafeTestPackage1}\ {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ -statics 0 -nested 1 -deleteHook {}} {}" -test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { +test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { +} -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 + # should add as p* (not p1 if master has a module path) set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - # an error shall occur (http is not anymore in the secure 0-level + # an error shall occur (opt is not anymore in the secure 0-level # provided deep path) list $token1 $token2 \ - [catch {interp eval $i {package require http 1}} msg] $msg \ + [catch {interp eval $i {package require opt}} msg] $msg \ [safe::interpConfigure $i]\ [safe::interpDelete $i] -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 1 {can't find package http 1} {-accessPath {[list $tcl_library */dummy/unixlike/test/path]} -statics 0 -nested 1 -deleteHook {}} {}" +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} 1 {$pkgOptErrMsg}\ + {-accessPath {[list $tcl_library */dummy/unixlike/test/path]}\ + -statics 0 -nested 1 -deleteHook {}} {}" test safe-7.3 {check that safe subinterpreters work} { set i [safe::interpCreate] set j [safe::interpCreate [list $i x]] @@ -387,18 +445,24 @@ test safe-7.4 {tests specific path and positive search} -setup { } -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ -statics 0 -nested 1 -deleteHook {}} {}" -test safe-7.4http {tests specific path and positive search, uses http1.0} -constraints needs_http1.0 -body { +test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup { +} -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 - set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] - # this time, unlike test safe-7.2, http should be found + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i [file join [info library] $pkgOptDir]] + # this time, unlike test safe-7.2opt, opt should be found list $token1 $token2 \ - [catch {interp eval $i {package require http 1}} msg] $msg \ + [catch {interp eval $i {package require opt}} msg] $msg \ [safe::interpConfigure $i]\ [safe::interpDelete $i] -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.0 {-accessPath {[list $tcl_library *$tcl_library/http1.0]} -statics 0 -nested 1 -deleteHook {}} {}" + # Note that the glob match elides directories (those from the module path) + # other than the first and last in the access path. +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 0.4.*\ + {-accessPath {[list $tcl_library *$tcl_library/$pkgOptDir]}\ + -statics 0 -nested 1 -deleteHook {}} {}" # test source control on file name set i "a" @@ -748,7 +812,45 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}\ 0 OK1 0 OK2" +test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $tcl_library $pkgOptDir] \ + [file join $tcl_library $pkgJarDir]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + # This has no effect because the records in Pkg of these directories were from access as children of {$p(:0:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $tcl_library $pkgJarDir] \ + [file join $tcl_library $pkgOptDir]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path4 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require tcl::idna}} msg3] + set code4 [catch {interp eval $i {package require opt}} msg4] + set code5 [catch {interp eval $i {::tcl::Lempty {a list}}} msg5] + set code6 [catch {interp eval $i {::tcl::idna::IDNAencode example.com}} msg6] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 \ + $confA $confB $code5 $msg5 $code6 $msg6 +} -cleanup { +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.* 0 0.4.*\ + {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $tcl_library/$pkgJarDir $tcl_library/$pkgOptDir]*}\ + -statics 1 -nested 0 -deleteHook {}} 0 0 0 example.com" test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -789,7 +891,6 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}\ 0 OK1 0 OK2" - test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -824,7 +925,39 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" +test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $tcl_library $pkgOptDir] \ + [file join $tcl_library $pkgJarDir]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library] + + # Inspect. + set confB [safe::interpConfigure $i] + set code4 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]} path4] + set code5 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]} path5] + + # Try to load the packages. + set code3 [catch {interp eval $i {package require opt}} msg3] + set code6 [catch {interp eval $i {package require tcl::idna}} msg6] + + list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB +} -cleanup { +} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ + 1 {* not found in access path} 1 {*} 1 {*}\ + {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" test safe-9.20 {check module loading} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1563,7 +1696,7 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -result {} set ::auto_path $saveAutoPath -unset saveAutoPath TestsDir +unset pkgOptErrMsg pkgOptDir pkgJarDir saveAutoPath TestsDir # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 7e2905fd746b15cae860819c4b882f30b6d1c659 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 13 Jul 2020 18:14:33 +0000 Subject: safe.test - add zipfile and tests of loading files from zipfs --- tests/auto-files.zip | Bin 0 -> 4447 bytes tests/safe.test | 696 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 684 insertions(+), 12 deletions(-) create mode 100644 tests/auto-files.zip diff --git a/tests/auto-files.zip b/tests/auto-files.zip new file mode 100644 index 0000000..b8bdf88 Binary files /dev/null and b/tests/auto-files.zip differ diff --git a/tests/safe.test b/tests/safe.test index e99e3f7..98584fd 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -77,6 +77,8 @@ if {[file exists [file join [info library] cookiejar0.2]]} { } set TestsDir [file normalize [file dirname [info script]]] +set ZipMountPoint [zipfs root]auto-files +zipfs mount $ZipMountPoint [file join $TestsDir auto-files.zip] # Force actual loading of the safe package because we use un exported (and # thus un-autoindexed) APIs in this test result arguments: @@ -249,7 +251,20 @@ test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { set ::auto_path $tmpAutoPath auto_reset } -match glob -result {0 ok1 0 ok2} - +test safe-7.0az {example tclIndex commands, test in master interpreter; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {0 ok1 0 ok2} test safe-7.0b {example tclIndex commands, negative test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -264,7 +279,20 @@ test safe-7.0b {example tclIndex commands, negative test in master interpreter} set ::auto_path $tmpAutoPath auto_reset } -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} - +test safe-7.0bz {example tclIndex commands, negative test in master interpreter; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -283,7 +311,24 @@ test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} +test safe-7.0cz {example pkgIndex.tcl packages, test in master interpreter, child directories; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] \ @@ -303,7 +348,25 @@ test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} +test safe-7.0dz {example pkgIndex.tcl packages, test in master interpreter, main directories; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} test safe-7.0e {example modules packages, test in master interpreter, replace path} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -331,7 +394,33 @@ test safe-7.0e {example modules packages, test in master interpreter, replace pa catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} +test safe-7.0ez {example modules packages, test in master interpreter, replace path; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} test safe-7.0f {example modules packages, test in master interpreter, append to path} -setup { tcl::tm::path add [file join $TestsDir auto0 modules] } -body { @@ -352,6 +441,26 @@ test safe-7.0f {example modules packages, test in master interpreter, append to catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} +test safe-7.0fz {example modules packages, test in master interpreter, append to path; zipfs} -setup { + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} # high level general test # Use example packages not http1.0 @@ -372,6 +481,24 @@ test safe-7.1 {tests that everything works at high level} -setup { safe::interpDelete $i } -match glob -result 1.2.3 # high level general test +# Use zipped example packages not tcl8.x/opt +test safe-7.1z {tests that everything works at high level; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $TestsDir auto0] + set i [safe::interpCreate] + set ::auto_path $tmpAutoPath +} -body { + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a slave works like in the master) + set v [interp eval $i {package require SafeTestPackage1}] + # no error shall occur: + interp eval $i {HeresPackage1} + set v +} -cleanup { + safe::interpDelete $i +} -match glob -result 1.2.3 +# high level general test test safe-7.1opt {tests that everything works at high level, uses pkg opt} -setup { set i [safe::interpCreate] } -body { @@ -405,6 +532,26 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { {can't find package SafeTestPackage1}\ {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ -statics 0 -nested 1 -deleteHook {}} {}" +test safe-7.2z {tests specific path and interpFind/AddToAccessPath; zipfs} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + # should add as p* (not p2 if master has a module path) + set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] + # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level + # provided deep path) + list $token1 $token2 $token3 \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ + [safe::interpConfigure $i]\ + [safe::interpDelete $i] +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1\ + {can't find package SafeTestPackage1}\ + {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ + -statics 0 -nested 1 -deleteHook {}} {}" test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -445,6 +592,24 @@ test safe-7.4 {tests specific path and positive search} -setup { } -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ -statics 0 -nested 1 -deleteHook {}} {}" +test safe-7.4z {tests specific path and positive search; zipfs} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] + # this time, unlike test safe-7.2z, SafeTestPackage1 should be found + list $token1 $token2 \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ + [safe::interpConfigure $i]\ + [safe::interpDelete $i] + # Note that the glob match elides directories (those from the module path) + # other than the first and last in the access path. +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ + {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ + -statics 0 -nested 1 -deleteHook {}} {}" test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -724,7 +889,47 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}" +test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset); zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + # Load and run the commands. + # This guarantees the test will pass even if the tokens are swapped. + set code1 [catch {interp eval $i {report1}} msg1] + set code2 [catch {interp eval $i {report2}} msg2] + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}" test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -764,7 +969,45 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}" +test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset); zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + + # Do not load the commands. With the tokens swapped, the test + # will pass only if the Safe Base has called auto_reset. + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load and run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}" test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. @@ -812,6 +1055,53 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}\ 0 OK1 0 OK2" +test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement; zipfs} -setup { +} -body { + # For complete correspondence to safe-9.10opt, include auto0 in access path. + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0] \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}. + # This would have no effect because the records in Pkg of these directories + # were from access as children of {$p(:1:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0] \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ + $code5 $msg5 $code6 $msg6 + +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:2:)} {\$p(:3:)} {\$p(:3:)} {\$p(:2:)} 0 1.2.3 0 2.3.4\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0 $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0 $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + 0 OK1 0 OK2" test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -846,6 +1136,7 @@ test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 \ $confA $confB $code5 $msg5 $code6 $msg6 } -cleanup { + safe::interpDelete $i } -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.* 0 0.4.*\ {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ -statics 1 -nested 0 -deleteHook {}}\ @@ -859,21 +1150,61 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un # Inspect. set confA [safe::interpConfigure $i] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto2] \ + [file join $TestsDir auto0 auto1]] + + # Inspect. + set confB [safe::interpConfigure $i] + set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ + $code5 $msg5 $code6 $msg6 +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + 0 OK1 0 OK2" +test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0; zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] # Load pkgIndex.tcl data. catch {interp eval $i {package require NOEXIST}} # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto2] \ - [file join $TestsDir auto0 auto1]] + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] # Inspect. set confB [safe::interpConfigure $i] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] # Try to load the packages and run a command from each one. set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] @@ -886,9 +1217,9 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un } -cleanup { safe::interpDelete $i } -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}\ 0 OK1 0 OK2" test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { @@ -925,6 +1256,40 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" +test safe-9.12z {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed; zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + + # Inspect. + set confA [safe::interpConfigure $i] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library] + + # Inspect. + set confB [safe::interpConfigure $i] + set code4 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]} path4] + set code5 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]} path5] + + # Try to load the packages. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] + set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] + + list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB +} -cleanup { + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ + 1 {* not found in access path} 1 {*} 1 {*}\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ + -statics 1 -nested 0 -deleteHook {}}\ + {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -953,6 +1318,7 @@ test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB } -cleanup { + safe::interpDelete $i } -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ 1 {* not found in access path} 1 {*} 1 {*}\ {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ @@ -997,7 +1363,45 @@ test safe-9.20 {check module loading} -setup { $TestsDir/auto0/modules/mod2]*}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" +test safe-9.20z {check module loading; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + list $path0 $path1 $path2 -- $modsA -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]*}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1065,7 +1469,73 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st $TestsDir/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" +test safe-9.21z {interpConfigure change the access path; check module loading; stale data case 1; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Load pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/auto1 \ + $ZipMountPoint/auto0/auto2 \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1128,7 +1598,68 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st $TestsDir/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" +test safe-9.22z {interpConfigure change the access path; check module loading; stale data case 0; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/auto1 \ + $ZipMountPoint/auto0/auto2 \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1202,7 +1733,79 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st $TestsDir/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" +test safe-9.23z {interpConfigure change the access path; check module loading; stale data case 3; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Refresh stale pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/auto1 \ + $ZipMountPoint/auto0/auto2 \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1270,7 +1873,73 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st $TestsDir/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" +test safe-9.24z {interpConfigure change the access path; check module loading; stale data case 2 (worst case); zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + + # Inspect. + set confB [safe::interpConfigure $i] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ + {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + {-accessPath {[list $tcl_library \ + $ZipMountPoint/auto0/auto1 \ + $ZipMountPoint/auto0/auto2 \ + $ZipMountPoint/auto0/modules \ + $ZipMountPoint/auto0/modules/mod1 \ + $ZipMountPoint/auto0/modules/mod2]}\ + -statics 1 -nested 0 -deleteHook {}} --\ + res0 res1 res2" catch {teststaticpkg Safepkg1 0 0} test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { @@ -1694,9 +2363,12 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -cleanup { safe::interpDelete $i } -result {} - + +puts stderr [interp slaves] + set ::auto_path $saveAutoPath -unset pkgOptErrMsg pkgOptDir pkgJarDir saveAutoPath TestsDir +zipfs unmount ${ZipMountPoint} +unset pkgOptErrMsg pkgOptDir pkgJarDir saveAutoPath TestsDir ZipMountPoint # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 5e45a1d39a08b7172d872e54720fa033bafc4dd9 Mon Sep 17 00:00:00 2001 From: kjnash Date: Tue, 14 Jul 2020 15:45:31 +0000 Subject: Remove diagnostic puts --- tests/safe.test | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 98584fd..6838201 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -2363,9 +2363,7 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -cleanup { safe::interpDelete $i } -result {} - -puts stderr [interp slaves] - + set ::auto_path $saveAutoPath zipfs unmount ${ZipMountPoint} unset pkgOptErrMsg pkgOptDir pkgJarDir saveAutoPath TestsDir ZipMountPoint -- cgit v0.12 From c14dbae8ad115c63cccc32ca0fee7a5c355edbe5 Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 15 Jul 2020 13:22:54 +0000 Subject: Bugfix in library/safe.tcl - when deleting a safe interpreter, delete its sub-interpreters cleanly; pass revised test safe-7.3 --- library/safe.tcl | 11 +++++++++++ tests/safe.test | 12 ++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 30b045e..68d4b21 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -593,6 +593,17 @@ proc ::safe::interpDelete {slave} { namespace upvar ::safe S$slave state + # When an interpreter is deleted with [interp delete], any sub-interpreters + # are deleted automatically, but this leaves behind their data in the Safe + # Base. To clean up properly, we call safe::interpDelete recursively on each + # Safe Base sub-interpreter, so each one is deleted cleanly and not by + # the automatic mechanism built into [interp delete]. + foreach sub [interp slaves $slave] { + if {[info exists ::safe::S[list $slave $sub]]} { + ::safe::interpDelete [list $slave $sub] + } + } + # If the slave has a cleanup hook registered, call it. Check the # existance because we might be called to delete an interp which has # not been registered with us at all diff --git a/tests/safe.test b/tests/safe.test index 0f40c36..6b55ef1 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -365,10 +365,18 @@ test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http [safe::interpDelete $i] } -match glob -result "{\$p(:0:)} {\$p(:*:)} 1 {can't find package http 1} {-accessPath {[list $tcl_library */dummy/unixlike/test/path]} -statics 0 -nested 1 -deleteHook {}} {}" test safe-7.3 {check that safe subinterpreters work} { + set g [interp slaves] + if {$g ne {}} { + append g { -- residue of an earlier test} + } + set h [info vars ::safe::S*] + if {$h ne {}} { + append h { -- residue of an earlier test} + } set i [safe::interpCreate] set j [safe::interpCreate [list $i x]] - list [interp eval $j {join {o k} ""}] [safe::interpDelete $i] [interp exists $j] -} {ok {} 0} + list $g $h [interp eval $j {join {o k} ""}] [safe::interpDelete $i] [interp exists $j] [info vars ::safe::S*] +} {{} {} ok {} 0 {}} test safe-7.4 {tests specific path and positive search} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] -- cgit v0.12 From 69fdd85b744c7f463d6731dff11db373df7e33f6 Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 15 Jul 2020 17:03:47 +0000 Subject: Bugfix in library/safe.tcl - AliasGlob passes -join to glob inappropriately; pass new test safe-13.7a --- library/safe.tcl | 6 +++++- tests/safe.test | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 68d4b21..82a2780 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -769,11 +769,15 @@ proc ::safe::AliasGlob {slave args} { while {$at < [llength $args]} { switch -glob -- [set opt [lindex $args $at]] { - -nocomplain - -- - -join - -tails { + -nocomplain - -- - -tails { lappend cmd $opt set got($opt) 1 incr at } + -join { + set got($opt) 1 + incr at + } -types - -type { lappend cmd -types [lindex $args [incr at]] incr at diff --git a/tests/safe.test b/tests/safe.test index 6b55ef1..c250400 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -1354,6 +1354,15 @@ proc buildEnvironment {filename} { set testdir2 [makeDirectory deletemetoo $testdir] set testfile [makeFile {} $filename $testdir2] } +proc buildEnvironment2 {filename} { + upvar 1 testdir testdir testdir2 testdir2 testfile testfile + upvar 1 testdir3 testdir3 testfile2 testfile2 + set testdir [makeDirectory deletethisdir] + set testdir2 [makeDirectory deletemetoo $testdir] + set testfile [makeFile {} $filename $testdir2] + set testdir3 [makeDirectory deleteme $testdir] + set testfile2 [makeFile {} $filename $testdir3] +} #### New tests for Safe base glob, with patches @ Bug 2964715 test safe-13.1 {glob is restricted [Bug 2964715]} -setup { set i [safe::interpCreate] @@ -1425,7 +1434,7 @@ test safe-13.6 {as 13.4 but test silent failure when result is outside access_pa safe::interpDelete $i removeDirectory $testdir } -result {} -test safe-13.7 {mimic the glob call by tclPkgUnknown which gives a deliberate error in a safe interpreter [Bug 2964715]} -setup { +test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug 2964715]} -setup { set i [safe::interpCreate] buildEnvironment pkgIndex.tcl } -body { @@ -1437,9 +1446,25 @@ test safe-13.7 {mimic the glob call by tclPkgUnknown which gives a deliberate er safe::interpDelete $i removeDirectory $testdir } -result {{EXPECTED/deletemetoo/pkgIndex.tcl}} -# Note the extra {} around the result above; that's *expected* because of the -# format of virtual path roots. -test safe-13.8 {mimic the glob call by tclPkgUnknown without the deliberate error that is specific to pkgIndex.tcl [Bug 2964715]} -setup { +# Note the extra {} around the result above; that's *expected* because the +# tokenized paths require delimitation in the list returned by glob; the +# braces remain after the token is replaced by EXPECTED. +test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { + set i [safe::interpCreate] + buildEnvironment2 pkgIndex.tcl +} -body { + set safeTD [::safe::interpAddToAccessPath $i $testdir] + ::safe::interpAddToAccessPath $i $testdir2 + ::safe::interpAddToAccessPath $i $testdir3 + lsort [string map [list $safeTD EXPECTED] [$i eval [list \ + glob -directory $safeTD -join * pkgIndex.tcl]]] +} -cleanup { + safe::interpDelete $i + removeDirectory $testdir +} -result {EXPECTED/deleteme/pkgIndex.tcl EXPECTED/deletemetoo/pkgIndex.tcl} +# Cf safe-13.7 - this time there's no extra {} around the result; the list +# operation lsort removed it. +test safe-13.8 {mimic the glob call by tclPkgUnknown without the special treatment that is specific to pkgIndex.tcl [Bug 2964715]} -setup { set i [safe::interpCreate] buildEnvironment notIndex.tcl } -body { @@ -1477,6 +1502,7 @@ test safe-13.10 {as 13.8 but test silent failure when result is outside access_p removeDirectory $testdir } -result {} rename buildEnvironment {} +rename buildEnvironment2 {} #### Test for the module path test safe-14.1 {Check that module path is the same as in the master interpreter [Bug 2964715]} -setup { -- cgit v0.12 From 79214905a2153e60fdf993173f37afcc2b2e80d8 Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 15 Jul 2020 23:11:46 +0000 Subject: Bugfix tests/safe.test. Harden tests safe-9.20 to safe-9.24 against indeterminate order of glob matches. Audit use of glob and tcl::tm in modified tests for cases with multiple matches. Simplify test comparison patterns. --- library/safe.tcl | 5 +- tests/safe.test | 307 +++++++++++++++++++++++++++---------------------------- 2 files changed, 154 insertions(+), 158 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 82a2780..74aee87 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -406,8 +406,9 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # 'platform::shell', which translate into # 'platform/shell-X.tm', i.e arbitrarily deep # subdirectories. - lappend morepaths {*}[glob -nocomplain -directory $dir -type d *] - foreach sub [glob -nocomplain -directory $dir -type d *] { + set next [glob -nocomplain -directory $dir -type d *] + lappend morepaths {*}$next + foreach sub $next { lappend slave_tm_roots [file normalize $sub] [dict get $slave_tm_roots $dir] set lenny [string length [dict get $slave_tm_roots $dir]] set relpath [string range [file normalize $sub] $lenny+1 end] diff --git a/tests/safe.test b/tests/safe.test index c250400..69da9d2 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -25,8 +25,24 @@ set saveAutoPath $::auto_path set ::auto_path [info library] set TestsDir [file normalize [file dirname [info script]]] +set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] -# Force actual loading of the safe package because we use un exported (and +proc mapList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + return $listOut +} +proc mapAndSortList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + lsort $listOut +} + +# Force actual loading of the safe package because we use un-exported (and # thus un-autoindexed) APIs in this test result arguments: catch {safe::interpConfigure} @@ -340,30 +356,32 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] # should add as p* (not p2 if master has a module path) set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level # provided deep path) - list $token1 $token2 $token3 \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] + list $token1 $token2 $token3 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] } -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1\ - {can't find package SafeTestPackage1}\ - {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ - -statics 0 -nested 1 -deleteHook {}} {}" +} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ + 1 {can't find package SafeTestPackage1} --\ + {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p1 set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # an error shall occur (http is not anymore in the secure 0-level # provided deep path) - list $token1 $token2 \ - [catch {interp eval $i {package require http 1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 1 {can't find package http 1} {-accessPath {[list $tcl_library */dummy/unixlike/test/path]} -statics 0 -nested 1 -deleteHook {}} {}" + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ + {TCLLIB */dummy/unixlike/test/path} -- {}} test safe-7.3 {check that safe subinterpreters work} { set g [interp slaves] if {$g ne {}} { @@ -384,29 +402,30 @@ test safe-7.4 {tests specific path and positive search} -setup { set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p* (not p1 if master has a module path) set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # this time, unlike test safe-7.2, SafeTestPackage1 should be found - list $token1 $token2 \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] + list $token1 $token2 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] # Note that the glob match elides directories (those from the module path) # other than the first and last in the access path. } -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ - {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ - -statics 0 -nested 1 -deleteHook {}} {}" +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ + {TCLLIB * TESTSDIR/auto0/auto1} -- {}} test safe-7.4http {tests specific path and positive search, uses http1.0} -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p1 set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # this time, unlike test safe-7.2, http should be found - list $token1 $token2 \ - [catch {interp eval $i {package require http 1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.0 {-accessPath {[list $tcl_library *$tcl_library/http1.0]} -statics 0 -nested 1 -deleteHook {}} {}" + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}} # test source control on file name set i "a" @@ -632,9 +651,9 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -653,6 +672,7 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -660,23 +680,21 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec set code3 [catch {interp eval $i {report1}} msg3] set code4 [catch {interp eval $i {report2}} msg4] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ + {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -693,6 +711,7 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -700,14 +719,13 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec set code3 [catch {interp eval $i {report1}} msg3] set code4 [catch {interp eval $i {report2}} msg4] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 ok1 0 ok2 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ + {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { @@ -719,6 +737,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -736,6 +755,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -745,17 +765,14 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ - $code5 $msg5 $code6 $msg6 - + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:2:)} {\$p(:3:)} {\$p(:3:)} {\$p(:2:)} 0 1.2.3 0 2.3.4\ - {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - 0 OK1 0 OK2" +} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\ + {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ + {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { @@ -765,6 +782,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -778,6 +796,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -787,25 +806,23 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -- \ $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - 0 OK1 0 OK2" - +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 1.2.3 0 2.3.4 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ + {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] @@ -817,6 +834,7 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set code4 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]} path4] set code5 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]} path5] @@ -824,15 +842,12 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] - list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ - 1 {* not found in access path} 1 {*} 1 {*}\ - {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" - +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ + 1 {* not found in access path} -- 1 1 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} -- {TCLLIB*}} test safe-9.20 {check module loading} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -844,6 +859,7 @@ test safe-9.20 {check module loading} -setup { # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -857,22 +873,27 @@ test safe-9.20 {check module loading} -setup { set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]*}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" - + {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ + TESTSDIR/auto0/modules/mod2} -- res0 res1 res2} +# - The command safe::InterpSetConfig adds the master's [tcl::tm::list] in +# tokenized form to the slave's access path, and then adds all the +# descendants, discovered recursively by using glob. +# - The order of the directories in the list returned by glob is system-dependent, +# and therefore this is true also for (a) the order of token assignment to +# descendants of the [tcl::tm::list] roots; and (b) the order of those same +# directories in the access path. Both those things must be sorted before +# comparing with expected results. The test is therefore not totally strict, +# but will notice missing or surplus directories. test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -884,6 +905,7 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -897,6 +919,7 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -915,8 +938,8 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] @@ -924,23 +947,15 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/auto1 \ - $TestsDir/auto0/auto2 \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" - + {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ + TESTSDIR/auto0/modules/mod2} --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ + TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -952,6 +967,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -965,6 +981,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -978,8 +995,8 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] @@ -987,23 +1004,15 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/auto1 \ - $TestsDir/auto0/auto2 \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" - + {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ + TESTSDIR/auto0/modules/mod2} --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ + TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1015,6 +1024,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -1033,6 +1043,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -1051,8 +1062,8 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 } -cleanup { @@ -1061,23 +1072,15 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/auto1 \ - $TestsDir/auto0/auto2 \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" - + {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ + TESTSDIR/auto0/modules/mod2} --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ + TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1089,6 +1092,7 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -1107,6 +1111,7 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] @@ -1120,8 +1125,8 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] @@ -1129,23 +1134,15 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $TestsDir/auto0/auto1 \ - $TestsDir/auto0/auto2 \ - $TestsDir/auto0/modules \ - $TestsDir/auto0/modules/mod1 \ - $TestsDir/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" - + {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ + TESTSDIR/auto0/modules/mod2} --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ + TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. catch {teststaticpkg Safepkg1 0 0} test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { @@ -1440,15 +1437,12 @@ test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug } -body { set safeTD [::safe::interpAddToAccessPath $i $testdir] ::safe::interpAddToAccessPath $i $testdir2 - string map [list $safeTD EXPECTED] [$i eval [list \ + mapList [list $safeTD EXPECTED] [$i eval [list \ glob -directory $safeTD -join * pkgIndex.tcl]] } -cleanup { safe::interpDelete $i removeDirectory $testdir -} -result {{EXPECTED/deletemetoo/pkgIndex.tcl}} -# Note the extra {} around the result above; that's *expected* because the -# tokenized paths require delimitation in the list returned by glob; the -# braces remain after the token is replaced by EXPECTED. +} -result {EXPECTED/deletemetoo/pkgIndex.tcl} test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { set i [safe::interpCreate] buildEnvironment2 pkgIndex.tcl @@ -1456,14 +1450,12 @@ test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with set safeTD [::safe::interpAddToAccessPath $i $testdir] ::safe::interpAddToAccessPath $i $testdir2 ::safe::interpAddToAccessPath $i $testdir3 - lsort [string map [list $safeTD EXPECTED] [$i eval [list \ - glob -directory $safeTD -join * pkgIndex.tcl]]] + mapAndSortList [list $safeTD EXPECTED] [$i eval [list \ + glob -directory $safeTD -join * pkgIndex.tcl]] } -cleanup { safe::interpDelete $i removeDirectory $testdir } -result {EXPECTED/deleteme/pkgIndex.tcl EXPECTED/deletemetoo/pkgIndex.tcl} -# Cf safe-13.7 - this time there's no extra {} around the result; the list -# operation lsort removed it. test safe-13.8 {mimic the glob call by tclPkgUnknown without the special treatment that is specific to pkgIndex.tcl [Bug 2964715]} -setup { set i [safe::interpCreate] buildEnvironment notIndex.tcl @@ -1601,7 +1593,10 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -result {} set ::auto_path $saveAutoPath -unset saveAutoPath TestsDir +unset saveAutoPath TestsDir PathMapp +rename mapList {} +rename mapAndSortList {} + # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From d44da35f2c661a2a7ae6bfd016778f34d65162b0 Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 16 Jul 2020 12:17:59 +0000 Subject: Remove diagnostic spaces --- tests/safe.test | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 6cbcdf8..56cf013 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -530,7 +530,7 @@ test safe-7.1opt {tests that everything works at high level, uses pkg opt} -setu } -cleanup { safe::interpDelete $i } -match glob -result 0.4.* - test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { +test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) @@ -587,7 +587,7 @@ test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg o } -cleanup { } -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package opt} --\ {TCLLIB */dummy/unixlike/test/path} -- {}} - test safe-7.3 {check that safe subinterpreters work} { +test safe-7.3 {check that safe subinterpreters work} { set g [interp slaves] if {$g ne {}} { append g { -- residue of an earlier test} @@ -600,7 +600,7 @@ test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg o set j [safe::interpCreate [list $i x]] list $g $h [interp eval $j {join {o k} ""}] [safe::interpDelete $i] [interp exists $j] [info vars ::safe::S*] } {{} {} ok {} 0 {}} - test safe-7.4 {tests specific path and positive search} -setup { +test safe-7.4 {tests specific path and positive search} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) @@ -831,7 +831,7 @@ test safe-9.4 {dual specification of statics} { test safe-9.5 {dual specification of nested} -returnCodes error -body { safe::interpCreate -nested 0 -nestedload } -result {conflicting values given for -nested and -nestedLoadOk} - test safe-9.6 {interpConfigure widget like behaviour} -body { +test safe-9.6 {interpConfigure widget like behaviour} -body { # this test shall work, don't try to "fix it" unless you *really* know what # you are doing (ie you are me :p) -- dl list [set i [safe::interpCreate \ @@ -850,7 +850,7 @@ test safe-9.5 {dual specification of nested} -returnCodes error -body { safe::interpConfigure $i] } -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} - test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { +test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { # this test shall work, believed equivalent to 9.6 set i [safe::interpCreate \ -noStatics \ @@ -874,7 +874,7 @@ test safe-9.5 {dual specification of nested} -returnCodes error -body { safe::interpDelete $i } -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} - test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { +test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -956,7 +956,7 @@ test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffe -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}" - test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { +test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1035,7 +1035,7 @@ test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffe -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}" - test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { +test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -1169,7 +1169,7 @@ test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library $tcl_library/$pkgJarDir $tcl_library/$pkgOptDir]*}\ -statics 1 -nested 0 -deleteHook {}} 0 0 0 example.com" - test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { +test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1250,7 +1250,7 @@ test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages u {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ -statics 1 -nested 0 -deleteHook {}}\ 0 OK1 0 OK2" - test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { +test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1351,7 +1351,7 @@ test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ -statics 1 -nested 0 -deleteHook {}}\ {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" - test safe-9.20 {check module loading} -setup { +test safe-9.20 {check module loading} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -1436,7 +1436,7 @@ test safe-9.20z {check module loading; zipfs} -setup { $ZipMountPoint/auto0/modules/mod2]*}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" - test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { +test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -1565,7 +1565,7 @@ test safe-9.21z {interpConfigure change the access path; check module loading; s $ZipMountPoint/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" - test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { +test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -1684,7 +1684,7 @@ test safe-9.22z {interpConfigure change the access path; check module loading; s $ZipMountPoint/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" - test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { +test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -1825,7 +1825,7 @@ test safe-9.23z {interpConfigure change the access path; check module loading; s $ZipMountPoint/auto0/modules/mod2]}\ -statics 1 -nested 0 -deleteHook {}} --\ res0 res1 res2" - test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { +test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -2239,7 +2239,7 @@ test safe-13.6 {as 13.4 but test silent failure when result is outside access_pa safe::interpDelete $i removeDirectory $testdir } -result {} - test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug 2964715]} -setup { +test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug 2964715]} -setup { set i [safe::interpCreate] buildEnvironment pkgIndex.tcl } -body { @@ -2251,7 +2251,7 @@ test safe-13.6 {as 13.4 but test silent failure when result is outside access_pa safe::interpDelete $i removeDirectory $testdir } -result {EXPECTED/deletemetoo/pkgIndex.tcl} - test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { +test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { set i [safe::interpCreate] buildEnvironment2 pkgIndex.tcl } -body { -- cgit v0.12 From 18560d970e2d150d0082bd99455bae5c8caa238a Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 16 Jul 2020 15:47:39 +0000 Subject: Bugfix tests/safe.test (as in safe-bugfixes-8-6). Harden tests safe-9.20z to safe-9.24z against indeterminate order of glob matches. Audit use of glob and tcl::tm in modified tests for cases with multiple matches. Simplify test comparison patterns. --- tests/safe.test | 322 +++++++++++++++++++++++++------------------------------- 1 file changed, 145 insertions(+), 177 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 56cf013..4195ebb 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -80,8 +80,10 @@ set TestsDir [file normalize [file dirname [info script]]] set ZipMountPoint [zipfs root]auto-files zipfs mount $ZipMountPoint [file join $TestsDir auto-files.zip] -set TestsDir [file normalize [file dirname [info script]]] -set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] +set PathMapp {} +lappend PathMapp [file join [info library] $pkgOptDir] TCLLIB/OPTDIR +lappend PathMapp [file join [info library] $pkgJarDir] TCLLIB/JARDIR +lappend PathMapp $tcl_library TCLLIB $TestsDir TESTSDIR $ZipMountPoint ZIPDIR proc mapList {map listIn} { set listOut {} @@ -338,7 +340,6 @@ test safe-7.0cz {example pkgIndex.tcl packages, test in master interpreter, chil set code4 [catch {package require SafeTestPackage2} msg4] set code5 [catch HeresPackage1 msg5] set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 } -cleanup { set ::auto_path $tmpAutoPath @@ -376,7 +377,6 @@ test safe-7.0dz {example pkgIndex.tcl packages, test in master interpreter, main set code4 [catch {package require SafeTestPackage2} msg4] set code5 [catch HeresPackage1 msg5] set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 } -cleanup { set ::auto_path $tmpAutoPath @@ -426,7 +426,6 @@ test safe-7.0ez {example modules packages, test in master interpreter, replace p set out0 [test0::try0] set out1 [mod1::test1::try1] set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] @@ -469,7 +468,6 @@ test safe-7.0fz {example modules packages, test in master interpreter, append to set out0 [test0::try0] set out1 [mod1::test1::try1] set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] @@ -559,17 +557,17 @@ test safe-7.2z {tests specific path and interpFind/AddToAccessPath; zipfs} -setu set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] # should add as p* (not p2 if master has a module path) set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level # provided deep path) - list $token1 $token2 $token3 \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] -} -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1\ - {can't find package SafeTestPackage1}\ - {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\ - -statics 0 -nested 1 -deleteHook {}} {}" + list $token1 $token2 $token3 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -cleanup { +} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ + 1 {can't find package SafeTestPackage1} --\ + {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -625,17 +623,17 @@ test safe-7.4z {tests specific path and positive search; zipfs} -setup { set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p* (not p1 if master has a module path) set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] - # this time, unlike test safe-7.2z, SafeTestPackage1 should be found - list $token1 $token2 \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # this time, unlike test safe-7.2, SafeTestPackage1 should be found + list $token1 $token2 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] # Note that the glob match elides directories (those from the module path) # other than the first and last in the access path. } -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\ - {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\ - -statics 0 -nested 1 -deleteHook {}} {}" +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ + {TCLLIB * TESTSDIR/auto0/auto1} -- {}} test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -643,17 +641,17 @@ test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p* (not p1 if master has a module path) set token2 [safe::interpAddToAccessPath $i [file join [info library] $pkgOptDir]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] # this time, unlike test safe-7.2opt, opt should be found - list $token1 $token2 \ - [catch {interp eval $i {package require opt}} msg] $msg \ - [safe::interpConfigure $i]\ - [safe::interpDelete $i] + list $token1 $token2 -- \ + [catch {interp eval $i {package require opt}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] # Note that the glob match elides directories (those from the module path) # other than the first and last in the access path. } -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 0.4.*\ - {-accessPath {[list $tcl_library *$tcl_library/$pkgOptDir]}\ - -statics 0 -nested 1 -deleteHook {}} {}" +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 0.4.* --\ + {TCLLIB * TCLLIB/OPTDIR} -- {}} # test source control on file name set i "a" @@ -920,9 +918,9 @@ test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffe set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -938,9 +936,9 @@ test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffe safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto2] \ [file join $ZipMountPoint auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -948,14 +946,13 @@ test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffe set code3 [catch {interp eval $i {report1}} msg3] set code4 [catch {interp eval $i {report2}} msg4] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} + test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -1001,9 +998,9 @@ test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffe set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1017,9 +1014,9 @@ test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffe safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto2] \ [file join $ZipMountPoint auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1027,14 +1024,13 @@ test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffe set code3 [catch {interp eval $i {report1}} msg3] set code4 [catch {interp eval $i {report2}} msg4] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 ok1 0 ok2 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. @@ -1081,7 +1077,6 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} - test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement; zipfs} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. @@ -1089,9 +1084,9 @@ test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages u [file join $ZipMountPoint auto0] \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1106,9 +1101,9 @@ test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages u [file join $ZipMountPoint auto0] \ [file join $ZipMountPoint auto0 auto2] \ [file join $ZipMountPoint auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1118,25 +1113,22 @@ test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages u set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ - $code5 $msg5 $code6 $msg6 - + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:2:)} {\$p(:3:)} {\$p(:3:)} {\$p(:2:)} 0 1.2.3 0 2.3.4\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0 $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0 $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - 0 OK1 0 OK2" +} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\ + {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $tcl_library $pkgOptDir] \ [file join $tcl_library $pkgJarDir]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] @@ -1148,9 +1140,9 @@ test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $tcl_library $pkgJarDir] \ [file join $tcl_library $pkgOptDir]] - # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] set path4 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] @@ -1160,15 +1152,14 @@ test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages set code5 [catch {interp eval $i {::tcl::Lempty {a list}}} msg5] set code6 [catch {interp eval $i {::tcl::idna::IDNAencode example.com}} msg6] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 \ - $confA $confB $code5 $msg5 $code6 $msg6 + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.* 0 0.4.*\ - {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $tcl_library/$pkgJarDir $tcl_library/$pkgOptDir]*}\ - -statics 1 -nested 0 -deleteHook {}} 0 0 0 example.com" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 1.* 0 0.4.* --\ + {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} --\ + {TCLLIB TCLLIB/JARDIR TCLLIB/OPTDIR*} --\ + 0 0 0 example.com} test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -1215,9 +1206,9 @@ test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages u set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1228,9 +1219,9 @@ test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages u safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto2] \ [file join $ZipMountPoint auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1240,16 +1231,15 @@ test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages u set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \ - $code5 $msg5 $code6 $msg6 + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto2 $ZipMountPoint/auto0/auto1]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - 0 OK1 0 OK2" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 1.2.3 0 2.3.4 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -1288,9 +1278,9 @@ test safe-9.12z {interpConfigure change the access path; pkgIndex.tcl packages f set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] @@ -1302,6 +1292,7 @@ test safe-9.12z {interpConfigure change the access path; pkgIndex.tcl packages f # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set code4 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]} path4] set code5 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]} path5] @@ -1309,22 +1300,21 @@ test safe-9.12z {interpConfigure change the access path; pkgIndex.tcl packages f set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] - list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ + $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ - 1 {* not found in access path} 1 {*} 1 {*}\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/auto1 $ZipMountPoint/auto0/auto2]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ + 1 {* not found in access path} -- 1 1 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB*}} test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $tcl_library $pkgOptDir] \ [file join $tcl_library $pkgJarDir]]] - # Inspect. set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] @@ -1336,6 +1326,7 @@ test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages # Inspect. set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] set code4 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]} path4] set code5 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]} path5] @@ -1343,14 +1334,13 @@ test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages set code3 [catch {interp eval $i {package require opt}} msg3] set code6 [catch {interp eval $i {package require tcl::idna}} msg6] - list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ + $mappA -- $mappB } -cleanup { safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\ - 1 {* not found in access path} 1 {*} 1 {*}\ - {-accessPath {[list $tcl_library $tcl_library/$pkgOptDir $tcl_library/$pkgJarDir]*}\ - -statics 1 -nested 0 -deleteHook {}}\ - {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}" +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ + 1 {* not found in access path} -- 1 1 --\ + {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} -- {TCLLIB*}} test safe-9.20 {check module loading} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1408,6 +1398,7 @@ test safe-9.20z {check module loading; zipfs} -setup { # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1421,21 +1412,19 @@ test safe-9.20z {check module loading; zipfs} -setup { set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]*}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} -- res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1509,6 +1498,7 @@ test safe-9.21z {interpConfigure change the access path; check module loading; s # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1519,9 +1509,9 @@ test safe-9.21z {interpConfigure change the access path; check module loading; s safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1540,31 +1530,25 @@ test safe-9.21z {interpConfigure change the access path; check module loading; s set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/auto1 \ - $ZipMountPoint/auto0/auto2 \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1633,6 +1617,7 @@ test safe-9.22z {interpConfigure change the access path; check module loading; s # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1643,9 +1628,9 @@ test safe-9.22z {interpConfigure change the access path; check module loading; s safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1659,31 +1644,25 @@ test safe-9.22z {interpConfigure change the access path; check module loading; s set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/auto1 \ - $ZipMountPoint/auto0/auto2 \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1763,6 +1742,7 @@ test safe-9.23z {interpConfigure change the access path; check module loading; s # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1778,9 +1758,9 @@ test safe-9.23z {interpConfigure change the access path; check module loading; s safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1799,32 +1779,25 @@ test safe-9.23z {interpConfigure change the access path; check module loading; s set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ - $out0 $out1 $out2 - + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/auto1 \ - $ZipMountPoint/auto0/auto2 \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1887,7 +1860,6 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ res0 res1 res2} # See comments on lsort after test safe-9.20. - test safe-9.24z {interpConfigure change the access path; check module loading; stale data case 2 (worst case); zipfs} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -1899,6 +1871,7 @@ test safe-9.24z {interpConfigure change the access path; check module loading; s # Inspect. set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] set modsA [interp eval $i {tcl::tm::path list}] set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1914,9 +1887,9 @@ test safe-9.24z {interpConfigure change the access path; check module loading; s safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $ZipMountPoint auto0 auto1] \ [file join $ZipMountPoint auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] set modsB [interp eval $i {tcl::tm::path list}] set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] @@ -1930,31 +1903,25 @@ test safe-9.24z {interpConfigure change the access path; check module loading; s set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $ZipMountPoint auto0 modules] foreach path [lreverse $oldTm] { tcl::tm::path add $path } safe::interpDelete $i -} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\ - {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\ +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ 0 0.5 0 1.0 0 2.0 --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - {-accessPath {[list $tcl_library \ - $ZipMountPoint/auto0/auto1 \ - $ZipMountPoint/auto0/auto2 \ - $ZipMountPoint/auto0/modules \ - $ZipMountPoint/auto0/modules/mod1 \ - $ZipMountPoint/auto0/modules/mod2]}\ - -statics 1 -nested 0 -deleteHook {}} --\ - res0 res1 res2" + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-9.20. catch {teststaticpkg Safepkg1 0 0} test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { @@ -2264,6 +2231,7 @@ test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with safe::interpDelete $i removeDirectory $testdir } -result {EXPECTED/deleteme/pkgIndex.tcl EXPECTED/deletemetoo/pkgIndex.tcl} +# See comments on lsort after test safe-9.20. test safe-13.8 {mimic the glob call by tclPkgUnknown without the special treatment that is specific to pkgIndex.tcl [Bug 2964715]} -setup { set i [safe::interpCreate] buildEnvironment notIndex.tcl -- cgit v0.12 From 7d6a2292b530eb21168b734c6dcf292c9927ad08 Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 16 Jul 2020 15:55:19 +0000 Subject: Amend tests safe-7.[124]z so they look for packages in the mounted zipfile --- tests/safe.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 4195ebb..b71a720 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -500,7 +500,7 @@ test safe-7.1 {tests that everything works at high level} -setup { # Use zipped example packages not tcl8.x/opt test safe-7.1z {tests that everything works at high level; zipfs} -setup { set tmpAutoPath $::auto_path - lappend ::auto_path [file join $TestsDir auto0] + lappend ::auto_path [file join $ZipMountPoint auto0] set i [safe::interpCreate] set ::auto_path $tmpAutoPath } -body { @@ -556,7 +556,7 @@ test safe-7.2z {tests specific path and interpFind/AddToAccessPath; zipfs} -setu # should add as p* (not p1 if master has a module path) set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] # should add as p* (not p2 if master has a module path) - set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] + set token3 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0]] set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level @@ -567,7 +567,7 @@ test safe-7.2z {tests specific path and interpFind/AddToAccessPath; zipfs} -setu } -cleanup { } -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ 1 {can't find package SafeTestPackage1} --\ - {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} + {TCLLIB */dummy/unixlike/test/path ZIPDIR/auto0} -- {}} test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -622,7 +622,7 @@ test safe-7.4z {tests specific path and positive search; zipfs} -setup { # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] # should add as p* (not p1 if master has a module path) - set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] + set token2 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0 auto1]] set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] # this time, unlike test safe-7.2, SafeTestPackage1 should be found @@ -633,7 +633,7 @@ test safe-7.4z {tests specific path and positive search; zipfs} -setup { # other than the first and last in the access path. } -cleanup { } -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ - {TCLLIB * TESTSDIR/auto0/auto1} -- {}} + {TCLLIB * ZIPDIR/auto0/auto1} -- {}} test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] -- cgit v0.12 From 85bdb7cb8e43af0938b1c7f5013daa6b170bd5d4 Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 16 Jul 2020 17:29:04 +0000 Subject: Fix error in merging safe.test with safe-bugfixes-8-6 commit d065e8c73d --- tests/safe.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index b71a720..e9ec7df 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -583,8 +583,8 @@ test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg o [catch {interp eval $i {package require opt}} msg] $msg -- \ $mappA -- [safe::interpDelete $i] } -cleanup { -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package opt} --\ - {TCLLIB */dummy/unixlike/test/path} -- {}} +} -match glob -result "{\$p(:0:)} {\$p(:*:)} -- 1 {$pkgOptErrMsg} --\ + {TCLLIB */dummy/unixlike/test/path} -- {}" test safe-7.3 {check that safe subinterpreters work} { set g [interp slaves] if {$g ne {}} { -- cgit v0.12 From 9598926f42bd5ffbd6c7e9b7022f39382e8d29b8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 17 Jul 2020 10:42:29 +0000 Subject: New TIP #581 implementation --- doc/CrtAlias.3 | 29 ++++++++++++++++++++++++++++- doc/interp.n | 6 ++++++ generic/tclDecls.h | 3 +++ generic/tclIntDecls.h | 2 ++ generic/tclInterp.c | 5 +++-- tests/interp.test | 8 ++++---- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/doc/CrtAlias.3 b/doc/CrtAlias.3 index 72912bc..f9c912d 100644 --- a/doc/CrtAlias.3 +++ b/doc/CrtAlias.3 @@ -8,7 +8,7 @@ .so man.macros .BS .SH NAME -Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetMaster, Tcl_GetInterpPath, Tcl_CreateAlias, Tcl_CreateAliasObj, Tcl_GetAlias, Tcl_GetAliasObj, Tcl_ExposeCommand, Tcl_HideCommand \- manage multiple Tcl interpreters, aliases and hidden commands +Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateChild, Tcl_CreateSlave, Tcl_GetChild, Tcl_GetSlave, Tcl_GetParent, Tcl_GetMaster, Tcl_GetInterpPath, Tcl_CreateAlias, Tcl_CreateAliasObj, Tcl_GetAlias, Tcl_GetAliasObj, Tcl_ExposeCommand, Tcl_HideCommand \- manage multiple Tcl interpreters, aliases and hidden commands .SH SYNOPSIS .nf \fB#include \fR @@ -19,12 +19,27 @@ int int \fBTcl_MakeSafe\fR(\fIinterp\fR) .sp +.VS "TIP 581" +Tcl_Interp * +\fBTcl_CreateChild\fR(\fIinterp, name, isSafe\fR) +.VE "TIP 581" +.sp Tcl_Interp * \fBTcl_CreateSlave\fR(\fIinterp, name, isSafe\fR) .sp +.VS "TIP 581" +Tcl_Interp * +\fBTcl_GetChild\fR(\fIinterp, name\fR) +.VE "TIP 581" +.sp Tcl_Interp * \fBTcl_GetSlave\fR(\fIinterp, name\fR) .sp +.VS "TIP 581" +Tcl_Interp * +\fBTcl_GetParent\fR(\fIinterp\fR) +.VE "TIP 581" +.sp Tcl_Interp * \fBTcl_GetMaster\fR(\fIinterp\fR) .sp @@ -133,6 +148,10 @@ slave in which Tcl code has access only to set of Tcl commands defined as see the manual entry for the Tcl \fBinterp\fR command for details. If the creation of the new slave interpreter failed, \fBNULL\fR is returned. .PP +.VS "TIP 581" +\fBTcl_CreateChild\fR is a synonym for \fBTcl_CreateSlave\fR. +.VE "TIP 581" +.PP \fBTcl_IsSafe\fR returns \fB1\fR if \fIinterp\fR is .QW safe (was created with the \fBTCL_SAFE_INTERPRETER\fR flag specified), @@ -154,10 +173,18 @@ may be a better choice, since it creates interpreters in a known-safe state. \fIinterp\fR. The slave interpreter is identified by \fIslaveName\fR. If no such slave interpreter exists, \fBNULL\fR is returned. .PP +.VS "TIP 581" +\fBTcl_GetChild\fR is a synonym for \fBTcl_GetSlave\fR. +.VE "TIP 581" +.PP \fBTcl_GetMaster\fR returns a pointer to the master interpreter of \fIinterp\fR. If \fIinterp\fR has no master (it is a top-level interpreter) then \fBNULL\fR is returned. .PP +.VS "TIP 581" +\fBTcl_GetParent\fR is a synonym for \fBTcl_GetMaster\fR. +.VE "TIP 581" +.PP \fBTcl_GetInterpPath\fR stores in the result of \fIaskingInterp\fR the relative path between \fIaskingInterp\fR and \fIslaveInterp\fR; \fIslaveInterp\fR must be a slave of \fIaskingInterp\fR. If the computation diff --git a/doc/interp.n b/doc/interp.n index 9fcd055..9f975d0 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -377,6 +377,12 @@ Returns a Tcl list of the names of all the slave interpreters associated with the interpreter identified by \fIpath\fR. If \fIpath\fR is omitted, the invoking interpreter is used. .TP +.VS "TIP 581" +\fBinterp\fR \fBchildren\fR ?\fIpath\fR? +. +Synonym for . \fBinterp\fR \fBslaves\fR ?\fIpath\fR? +.VE "TIP 581" +.TP \fBinterp\fR \fBtarget\fR \fIpath alias\fR . Returns a Tcl list describing the target interpreter for an alias. The diff --git a/generic/tclDecls.h b/generic/tclDecls.h index e341731..e0854d6 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -3974,5 +3974,8 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_GlobalEvalObj #define Tcl_GlobalEvalObj(interp,objPtr) \ Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL) +#define Tcl_CreateChild Tcl_CreateSlave +#define Tcl_GetChild Tcl_GetSlave +#define Tcl_GetParent Tcl_GetMaster #endif /* _TCLDECLS */ diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 7560d11..ffe0e17 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -1422,4 +1422,6 @@ extern const TclIntStubs *tclIntStubsPtr; #undef TclCopyChannelOld #undef TclSockMinimumBuffersOld +#define TclSetChildCancelFlags TclSetSlaveCancelFlags + #endif /* _TCLINTDECLS */ diff --git a/generic/tclInterp.c b/generic/tclInterp.c index ac66324..6e99913 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -611,7 +611,7 @@ NRInterpCmd( int index; static const char *const options[] = { "alias", "aliases", "bgerror", "cancel", - "create", "debug", "delete", + "children", "create", "debug", "delete", "eval", "exists", "expose", "hide", "hidden", "issafe", "invokehidden", "limit", "marktrusted", "recursionlimit", @@ -620,7 +620,7 @@ NRInterpCmd( }; enum option { OPT_ALIAS, OPT_ALIASES, OPT_BGERROR, OPT_CANCEL, - OPT_CREATE, OPT_DEBUG, OPT_DELETE, + OPT_CHILDREN, OPT_CREATE, OPT_DEBUG, OPT_DELETE, OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, OPT_HIDE, OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHID, OPT_LIMIT, OPT_MARKTRUSTED,OPT_RECLIMIT, @@ -1008,6 +1008,7 @@ NRInterpCmd( return TCL_ERROR; } return SlaveRecursionLimit(interp, slaveInterp, objc - 3, objv + 3); + case OPT_CHILDREN: case OPT_SLAVES: { InterpInfo *iiPtr; Tcl_Obj *resultPtr; diff --git a/tests/interp.test b/tests/interp.test index 5b7b157..df94678 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -32,7 +32,7 @@ test interp-1.1 {options for interp command} -returnCodes error -body { } -result {wrong # args: should be "interp cmd ?arg ...?"} test interp-1.2 {options for interp command} -returnCodes error -body { interp frobox -} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.3 {options for interp command} { interp delete } "" @@ -50,13 +50,13 @@ test interp-1.6 {options for interp command} -returnCodes error -body { } -result {wrong # args: should be "interp slaves ?path?"} test interp-1.7 {options for interp command} -returnCodes error -body { interp hello -} -result {bad option "hello": must be alias, aliases, bgerror, cancel, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.8 {options for interp command} -returnCodes error -body { interp -froboz -} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.9 {options for interp command} -returnCodes error -body { interp -froboz -safe -} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.10 {options for interp command} -returnCodes error -body { interp target } -result {wrong # args: should be "interp target path alias"} -- cgit v0.12 From 651f71edfd77b66fd1e585154b7f4390e6df2b6f Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 04:12:08 +0000 Subject: Tidying tests/safe.test --- tests/safe.test | 128 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index dbcd2cc..2683b9c 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -21,9 +21,8 @@ foreach i [interp slaves] { interp delete $i } -set saveAutoPath $::auto_path +set SaveAutoPath $::auto_path set ::auto_path [info library] - set TestsDir [file normalize [file dirname [info script]]] set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] @@ -194,6 +193,7 @@ test safe-6.3 {test safe interpreters knowledge of the world} { lsort $r } {byteOrder engine pathSeparator platform pointerSize wordSize} +rename SafeEval {} # More test should be added to check that hostname, nameofexecutable, aren't # leaking infos, but they still do... @@ -213,7 +213,6 @@ test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { set ::auto_path $tmpAutoPath auto_reset } -match glob -result {0 ok1 0 ok2} - test safe-7.0b {example tclIndex commands, negative test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -228,7 +227,6 @@ test safe-7.0b {example tclIndex commands, negative test in master interpreter} set ::auto_path $tmpAutoPath auto_reset } -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} - test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -238,7 +236,6 @@ test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child set code4 [catch {package require SafeTestPackage2} msg4] set code5 [catch HeresPackage1 msg5] set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 } -cleanup { set ::auto_path $tmpAutoPath @@ -247,7 +244,6 @@ test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} - test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] \ @@ -258,7 +254,6 @@ test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main set code4 [catch {package require SafeTestPackage2} msg4] set code5 [catch HeresPackage1 msg5] set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 } -cleanup { set ::auto_path $tmpAutoPath @@ -267,7 +262,6 @@ test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} - test safe-7.0e {example modules packages, test in master interpreter, replace path} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { @@ -282,7 +276,6 @@ test safe-7.0e {example modules packages, test in master interpreter, replace pa set out0 [test0::try0] set out1 [mod1::test1::try1] set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] @@ -295,7 +288,6 @@ test safe-7.0e {example modules packages, test in master interpreter, replace pa catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} - test safe-7.0f {example modules packages, test in master interpreter, append to path} -setup { tcl::tm::path add [file join $TestsDir auto0 modules] } -body { @@ -306,7 +298,6 @@ test safe-7.0f {example modules packages, test in master interpreter, append to set out0 [test0::try0] set out1 [mod1::test1::try1] set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] @@ -393,7 +384,8 @@ test safe-7.3 {check that safe subinterpreters work} { } set i [safe::interpCreate] set j [safe::interpCreate [list $i x]] - list $g $h [interp eval $j {join {o k} ""}] [safe::interpDelete $i] [interp exists $j] [info vars ::safe::S*] + list $g $h [interp eval $j {join {o k} ""}] [safe::interpDelete $i] \ + [interp exists $j] [info vars ::safe::S*] } {{} {} ok {} 0 {}} test safe-7.4 {tests specific path and positive search} -setup { } -body { @@ -428,24 +420,28 @@ test safe-7.4http {tests specific path and positive search, uses http1.0} -body } -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.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 $i eval {source} } -returnCodes error -cleanup { safe::interpDelete $i + unset 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 $i eval {source a b c d e} } -returnCodes error -cleanup { safe::interpDelete $i + unset 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} @@ -456,10 +452,12 @@ test safe-8.3 {safe source control on file} -setup { list [catch {$i eval {source .}} msg] $msg $log } -cleanup { safe::setLogCmd $prevlog - unset log safe::interpDelete $i + rename safe-test-log {} + unset i log } -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} @@ -470,10 +468,12 @@ test safe-8.4 {safe source control on file} -setup { list [catch {$i eval {source /abc/def}} msg] $msg $log } -cleanup { safe::setLogCmd $prevlog - unset log safe::interpDelete $i + rename safe-test-log {} + unset i log } -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} @@ -488,10 +488,12 @@ test safe-8.5 {safe source control on file} -setup { } msg] $msg $log } -cleanup { safe::setLogCmd $prevlog - unset log safe::interpDelete $i + rename safe-test-log {} + unset i log } -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} @@ -504,10 +506,12 @@ test safe-8.6 {safe source control on file} -setup { } msg] $msg $log } -cleanup { safe::setLogCmd $prevlog - unset log safe::interpDelete $i + rename safe-test-log {} + unset i log } -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} @@ -522,14 +526,16 @@ test safe-8.7 {safe source control on file} -setup { } msg] $msg $log } -cleanup { safe::setLogCmd $prevlog - unset log safe::interpDelete $i + rename safe-test-log {} + unset i log } -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} emptyTest { # Disabled this test. It was only useful for long unsupported # Mac OS 9 systems. [Bug 860a9f1945] } {} test safe-8.9 {safe source and return} -setup { + set i "a" set returnScript [makeFile {return "ok"} return.tcl] catch {safe::interpDelete $i} } -body { @@ -539,8 +545,10 @@ test safe-8.9 {safe source and return} -setup { } -cleanup { catch {safe::interpDelete $i} removeFile $returnScript + unset i } -result ok test safe-8.10 {safe source and return} -setup { + set i "a" set returnScript [makeFile {return -level 2 "ok"} return.tcl] catch {safe::interpDelete $i} } -body { @@ -553,10 +561,11 @@ test safe-8.10 {safe source and return} -setup { } -cleanup { catch {safe::interpDelete $i} removeFile $returnScript + unset i } -result ok -set i "a" test safe-9.1 {safe interps' deleteHook} -setup { + set i "a" catch {safe::interpDelete $i} set res {} } -body { @@ -569,8 +578,12 @@ test safe-9.1 {safe interps' deleteHook} -setup { } safe::interpCreate $i -deleteHook "testDelHook arg1 arg2" list [interp eval $i exit] $res +} -cleanup { + catch {rename testDelHook {}} + unset i 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 {} @@ -591,7 +604,9 @@ test safe-9.2 {safe interps' error in deleteHook} -setup { list [safe::interpDelete $i] $res $log } -cleanup { safe::setLogCmd $prevlog - unset log + catch {rename testDelHook {}} + rename safe-test-log {} + unset i log res } -result {{} {arg1 arg2 a} {{NOTICE for slave a : About to delete} {ERROR for slave a : Delete hook error (being catched)} {NOTICE for slave a : Deleted}}} test safe-9.3 {dual specification of statics} -returnCodes error -body { safe::interpCreate -stat true -nostat @@ -620,16 +635,18 @@ test safe-9.6 {interpConfigure widget like behaviour} -body { safe::interpConfigure $i]\ [safe::interpConfigure $i -deleteHook toto -nosta -nested 0 safe::interpConfigure $i] -} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} - +} -cleanup { + safe::interpDelete $i +} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}}\ + {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}}\ + {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}}\ + {-accessPath * -statics 0 -nested 0 -deleteHook toto}} test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { # this test shall work, believed equivalent to 9.6 set i [safe::interpCreate \ -noStatics \ -nestedLoadOk \ - -deleteHook {foo bar} \ - ] - + -deleteHook {foo bar}] safe::interpConfigure $i -accessPath /foo/bar set a [safe::interpConfigure $i] set b [safe::interpConfigure $i -aCCess] @@ -644,8 +661,11 @@ test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { list $a $b $c $d $e $f $g } -cleanup { safe::interpDelete $i -} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} - + unset -nocomplain a b c d e f g i +} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}}\ + {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}}\ + {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}}\ + {-accessPath * -statics 0 -nested 0 -deleteHook toto}} test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -669,7 +689,6 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto2] \ [file join $TestsDir auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] set mappB [mapList $PathMapp [dict get $confB -accessPath]] @@ -686,7 +705,6 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} - test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -708,7 +726,6 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto2] \ [file join $TestsDir auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] set mappB [mapList $PathMapp [dict get $confB -accessPath]] @@ -726,7 +743,6 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} - test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. @@ -734,7 +750,6 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un [file join $TestsDir auto0] \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] @@ -752,7 +767,6 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un [file join $TestsDir auto0] \ [file join $TestsDir auto0 auto2] \ [file join $TestsDir auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] set mappB [mapList $PathMapp [dict get $confB -accessPath]] @@ -773,13 +787,11 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} - test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]]] - # Inspect. set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] @@ -793,7 +805,6 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto2] \ [file join $TestsDir auto0 auto1]] - # Inspect. set confB [safe::interpConfigure $i] set mappB [mapList $PathMapp [dict get $confB -accessPath]] @@ -806,8 +817,9 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -- \ - $code5 $msg5 $code6 $msg6 + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- \ + $code5 $msg5 $code6 $msg6 } -cleanup { safe::interpDelete $i } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ @@ -842,7 +854,8 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] - list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- $mappA -- $mappB + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ + $mappA -- $mappB } -cleanup { safe::interpDelete $i } -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ @@ -916,7 +929,6 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] @@ -938,9 +950,10 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] foreach path [lreverse $oldTm] { @@ -978,7 +991,6 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] @@ -995,9 +1007,10 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] foreach path [lreverse $oldTm] { @@ -1040,7 +1053,6 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] @@ -1062,10 +1074,10 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 - + list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] foreach path [lreverse $oldTm] { @@ -1108,7 +1120,6 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st safe::interpConfigure $i -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2]] - # Inspect. set confB [safe::interpConfigure $i] set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] @@ -1125,9 +1136,10 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 } -cleanup { tcl::tm::path remove [file join $TestsDir auto0 modules] foreach path [lreverse $oldTm] { @@ -1593,8 +1605,8 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { safe::interpDelete $i } -result {} -set ::auto_path $saveAutoPath -unset saveAutoPath TestsDir PathMapp +set ::auto_path $SaveAutoPath +unset SaveAutoPath TestsDir PathMapp rename mapList {} rename mapAndSortList {} -- cgit v0.12 From 2a52ff28dd5deb1dc6fde4f0fdbbb85aa6b4efe3 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 12:53:53 +0000 Subject: Remove code block in ::safe::AliasGlob that no longer serves a useful purpose. --- library/safe.tcl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 74aee87..e645085 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -792,13 +792,6 @@ proc ::safe::AliasGlob {slave args} { set virtualdir [lindex $args [incr at]] incr at } - pkgIndex.tcl { - # Oops, this is globbing a subdirectory in regular package - # search. That is not wanted. Abort, handler does catch - # already (because glob was not defined before). See - # package.tcl, lines 484ff in tclPkgUnknown. - return -code error "unknown command glob" - } -* { Log $slave "Safe base rejecting glob option '$opt'" return -code error "Safe base rejecting glob option '$opt'" -- cgit v0.12 From a300508fee9c27bc2ea2bf95a19d7007dcd26424 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 13:09:25 +0000 Subject: Remove unused code for *.tm from ::safe::AliasGlob. --- library/safe.tcl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index e645085..843255a 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -831,8 +831,7 @@ proc ::safe::AliasGlob {slave args} { } elseif {[string match ~* $thedir]} { set thedir ./$thedir } - if {$thedir eq "*" && - ($thefile eq "pkgIndex.tcl" || $thefile eq "*.tm")} { + if {($thedir eq "*") && ($thefile eq "pkgIndex.tcl")} { set mapped 0 foreach d [glob -directory [TranslatePath $slave $virtualdir] \ -types d -tails *] { -- cgit v0.12 From 690f2c283978a046e78664a1070c5c0bf5ddf67f Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 13:18:48 +0000 Subject: Bugfix argument combination -- and -directory in ::safe::AliasGlob. --- library/safe.tcl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/safe.tcl b/library/safe.tcl index 843255a..410a5c1 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -815,7 +815,11 @@ proc ::safe::AliasGlob {slave args} { if {$got(-nocomplain)} return return -code error "permission denied" } - lappend cmd -directory $dir + if {$got(--)} { + set cmd [linsert $cmd end-1 -directory $dir] + } else { + lappend cmd -directory $dir + } } # Apply the -join semantics ourselves -- cgit v0.12 From 6310c709d39e30dcefc165aa242973e919d86134 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 13:22:31 +0000 Subject: Update comments about safe interpreters in library/tm.tcl and library/package.tcl so they agree with code --- library/package.tcl | 10 +++++++--- library/tm.tcl | 11 ++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/library/package.tcl b/library/package.tcl index 44e3b28..d6280ae 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -479,9 +479,12 @@ proc tclPkgUnknown {name args} { } set tclSeenPath($dir) 1 - # we can't use glob in safe interps, so enclose the following in a - # catch statement, where we get the pkgIndex files out of the - # subdirectories + # Get the pkgIndex.tcl files in subdirectories of auto_path directories. + # - Safe Base interpreters have a restricted "glob" command that + # works in this case. + # - The "catch" was essential when there was no safe glob and every + # call in a safe interp failed; it is retained only for corner + # cases in which the eventual call to glob returns an error. catch { foreach file [glob -directory $dir -join -nocomplain \ * pkgIndex.tcl] { @@ -585,6 +588,7 @@ proc tcl::MacOSXPkgUnknown {original name args} { set tclSeenPath($dir) 1 # get the pkgIndex files out of the subdirectories + # Safe interpreters do not use tcl::MacOSXPkgUnknown - see init.tcl. foreach file [glob -directory $dir -join -nocomplain \ * Resources Scripts pkgIndex.tcl] { set dir [file dirname $file] diff --git a/library/tm.tcl b/library/tm.tcl index 0ed3f1a..c60084c 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -212,11 +212,12 @@ proc ::tcl::tm::UnknownHandler {original name args} { } set strip [llength [file split $path]] - # We can't use glob in safe interps, so enclose the following in a - # catch statement, where we get the module files out of the - # subdirectories. In other words, Tcl Modules are not-functional - # in such an interpreter. This is the same as for the command - # "tclPkgUnknown", i.e. the search for regular packages. + # Get the module files out of the subdirectories. + # - Safe Base interpreters have a restricted "glob" command that + # works in this case. + # - The "catch" was essential when there was no safe glob and every + # call in a safe interp failed; it is retained only for corner + # cases in which the eventual call to glob returns an error. catch { # We always look for _all_ possible modules in the current -- cgit v0.12 From 201d01f9da1f2fb006cc4c0fc265e552cf9c2703 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 17:51:27 +0000 Subject: Add explanatory comments to safe::AliasGlob --- library/safe.tcl | 33 +++++++++++++++++++++++++++++++-- tests/safe.test | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 410a5c1..da6523c 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -822,19 +822,27 @@ proc ::safe::AliasGlob {slave args} { } } - # Apply the -join semantics ourselves + # Apply the -join semantics ourselves. if {$got(-join)} { set args [lreplace $args $at end [join [lrange $args $at end] "/"]] } - # Process remaining pattern arguments + # Process the pattern arguments. If we've done a join there is only one + # pattern argument. + set firstPattern [llength $cmd] foreach opt [lrange $args $at end] { if {![regexp $dirPartRE $opt -> thedir thefile]} { set thedir . + # The *.tm search comes here. } elseif {[string match ~* $thedir]} { set thedir ./$thedir } + # "Special" treatment for (joined) argument {*/pkgIndex.tcl}. + # Do the expansion of "*" here, and filter out any directories that are + # not in the access path. The outcome is to lappend to cmd a path of + # the form $virtualdir/subdir/pkgIndex.tcl for each subdirectory subdir, + # after removing any subdir that are not in the access path. if {($thedir eq "*") && ($thefile eq "pkgIndex.tcl")} { set mapped 0 foreach d [glob -directory [TranslatePath $slave $virtualdir] \ @@ -847,7 +855,19 @@ proc ::safe::AliasGlob {slave args} { } } if {$mapped} continue + # Don't [continue] if */pkgIndex.tcl has no matches in the access + # path. The pattern will now receive the same treatment as a + # "non-special" pattern (and will fail because it includes a "*" in + # the directory name). } + # Any directory pattern that is not an exact (i.e. non-glob) match to a + # directory in the access path will be rejected here. + # - Rejections include any directory pattern that has glob matching + # patterns "*", "?", backslashes, braces or square brackets, (UNLESS + # it corresponds to a genuine directory name AND that directory is in + # the access path). + # - The only "special matching characters" that remain in patterns for + # processing by glob are in the filename tail. try { DirInAccessPath $slave [TranslatePath $slave \ [file join $virtualdir $thedir]] @@ -865,8 +885,17 @@ proc ::safe::AliasGlob {slave args} { return } try { + # >>>>>>>>>> HERE'S THE CALL TO SAFE INTERP GLOB <<<<<<<<<< + # - Pattern arguments added to cmd have NOT been translated from tokens. + # Only the virtualdir is translated (to dir). + # - In the pkgIndex.tcl case, there is no "*" in the pattern arguments, + # which are a list of names each with tail pkgIndex.tcl. The purpose + # of the call to glob is to remove the names for which the file does + # not exist. set entries [::interp invokehidden $slave glob {*}$cmd] } on error msg { + # This is the only place that a call with -nocomplain and no invalid + # "dash-options" can return an error. Log $slave $msg return -code error "script error" } diff --git a/tests/safe.test b/tests/safe.test index 2683b9c..9e90236 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -1572,6 +1572,7 @@ test safe-16.1 {Bug 3529949: defang ~ in paths} -setup { } -cleanup { safe::interpDelete $i set env(HOME) $savedHOME + unset savedHOME } -result {./~} test safe-16.2 {Bug 3529949: defang ~user in paths} -setup { set i [safe::interpCreate] @@ -1581,6 +1582,7 @@ test safe-16.2 {Bug 3529949: defang ~user in paths} -setup { "file join \[file dirname ~$user\] \[file tail ~$user\]"] } -cleanup { safe::interpDelete $i + unset user } -result {./~USER} test safe-16.3 {Bug 3529949: defang ~ in globs} -setup { set syntheticHOME [makeDirectory foo] @@ -1595,6 +1597,7 @@ test safe-16.3 {Bug 3529949: defang ~ in globs} -setup { safe::interpDelete $i set env(HOME) $savedHOME removeDirectory $syntheticHOME + unset savedHOME syntheticHOME } -result {} test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { set i [safe::interpCreate] @@ -1604,6 +1607,52 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { } -cleanup { safe::interpDelete $i } -result {} +test safe-16.5 {Bug 3529949: defang ~ in paths used by AliasGlob (1)} -setup { + set savedHOME $env(HOME) + set env(HOME) /foo/bar + set i [safe::interpCreate] +} -body { + $i eval { + set d [format %c 126] + file join {$p(:0:)} $d + } +} -cleanup { + safe::interpDelete $i + set env(HOME) $savedHOME + unset savedHOME +} -result {~} +test safe-16.6 {Bug 3529949: defang ~ in paths used by AliasGlob (2)} -setup { + set savedHOME $env(HOME) + set env(HOME) /foo/bar + set i [safe::interpCreate] +} -body { + $i eval { + set d [format %c 126] + file join {$p(:0:)/foo/bar} $d + } +} -cleanup { + safe::interpDelete $i + set env(HOME) $savedHOME + unset savedHOME +} -result {~} +test safe-16.7 {Bug 3529949: defang ~user in paths used by AliasGlob (1)} -setup { + set i [safe::interpCreate] + set user $tcl_platform(user) +} -body { + string map [list $user USER] [$i eval [list file join {$p(:0:)} ~$user]] +} -cleanup { + safe::interpDelete $i + unset user +} -result {~USER} +test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup { + set i [safe::interpCreate] + set user $tcl_platform(user) +} -body { + string map [list $user USER] [$i eval [list file join {$p(:0:)/foo/bar} ~$user]] +} -cleanup { + safe::interpDelete $i + unset user +} -result {~USER} set ::auto_path $SaveAutoPath unset SaveAutoPath TestsDir PathMapp -- cgit v0.12 From d12eb85c8fe92ca27b4f03950a447068c2418cb8 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 18:06:30 +0000 Subject: Simplify case analysis in safe::AliasGlob --- library/safe.tcl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/safe.tcl b/library/safe.tcl index da6523c..f0a14a3 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -820,6 +820,13 @@ proc ::safe::AliasGlob {slave args} { } else { lappend cmd -directory $dir } + } else { + # The code after this "if ... else" block would conspire to return with + # no results in this case, if it were allowed to proceed. Instead, + # return now and reduce the number of cases to be considered later. + Log $slave {option -directory must be supplied} + if {$got(-nocomplain)} return + return -code error "permission denied" } # Apply the -join semantics ourselves. -- cgit v0.12 From a541a7be4cbbd4b2e5cca7ff65b98010dc224929 Mon Sep 17 00:00:00 2001 From: kjnash Date: Sat, 18 Jul 2020 18:51:53 +0000 Subject: Remove an old fix for ~ expansion in safe::AliasGlob that is now fixed by other means --- library/safe.tcl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index f0a14a3..4540be3 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -842,8 +842,6 @@ proc ::safe::AliasGlob {slave args} { if {![regexp $dirPartRE $opt -> thedir thefile]} { set thedir . # The *.tm search comes here. - } elseif {[string match ~* $thedir]} { - set thedir ./$thedir } # "Special" treatment for (joined) argument {*/pkgIndex.tcl}. # Do the expansion of "*" here, and filter out any directories that are @@ -875,6 +873,12 @@ proc ::safe::AliasGlob {slave args} { # the access path). # - The only "special matching characters" that remain in patterns for # processing by glob are in the filename tail. + # - [file join $anything ~${foo}] is ~${foo}, which is not an exact + # match to any directory in the access path. Hence directory patterns + # that begin with "~" are rejected here. Tests safe-16.[5-8] check + # that "file join" remains as required and does not expand ~${foo}. + # - Bug [3529949] relates to unwanted expansion of ~${foo} and this is + # how the present code avoids the bug. All tests safe-16.* relate. try { DirInAccessPath $slave [TranslatePath $slave \ [file join $virtualdir $thedir]] -- cgit v0.12 From e6a9f22409462ec90bb2009619173c4228809317 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 20 Jul 2020 22:32:28 +0000 Subject: File tests/safe.test - rearrange tests - move tests of command/package loading that use Tcl files to new file tests/safe-stock86.test; renumber tests 9.8+ and add test 9.8 to replace old 5.1; move tests 7.0* to 5.*. --- tests/safe-stock86.test | 116 ++++++++++++++++++++++++++++++++ tests/safe.test | 172 ++++++++++++++++++++++-------------------------- 2 files changed, 193 insertions(+), 95 deletions(-) create mode 100644 tests/safe-stock86.test diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test new file mode 100644 index 0000000..2fbe108 --- /dev/null +++ b/tests/safe-stock86.test @@ -0,0 +1,116 @@ +# safe-stock86.test -- +# +# This file contains tests for safe Tcl that were previously in the file +# safe.test, and use files and packages of stock Tcl 8.6 to perform the tests. +# These files may be changed or disappear in future revisions of Tcl, for +# example package http 1.0 will be removed from Tcl 8.7. +# +# The tests are replaced in safe.tcl with tests that use files provided in the +# tests directory. Test numbering is for comparison with similar tests in +# safe.test. +# +# Sourcing this file into tcl runs the tests and generates output for errors. +# No output means no errors were found. +# +# Copyright (c) 1995-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +package require Tcl 8.5- + +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest 2 + namespace import -force ::tcltest::* +} + +foreach i [interp slaves] { + interp delete $i +} + +set SaveAutoPath $::auto_path +set ::auto_path [info library] +set TestsDir [file normalize [file dirname [info script]]] +set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] + +proc mapList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + return $listOut +} + +# Force actual loading of the safe package because we use un-exported (and +# thus un-autoindexed) APIs in this test result arguments: +catch {safe::interpConfigure} + +# testing that nested and statics do what is advertised (we use a static +# package - Tcltest - but it might be absent if we're in standard tclsh) + +testConstraint TcltestPackage [expr {![catch {package require Tcltest}]}] + +# high level general test +test safe-stock86-7.1 {tests that everything works at high level, uses http 2} -body { + set i [safe::interpCreate] + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a slave works like in the master) + set v [interp eval $i {package require http 2}] + # no error shall occur: + interp eval $i {http::config} + safe::interpDelete $i + set v +} -match glob -result 2.* +test safe-stock86-7.2 {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p1 + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # an error shall occur (http is not anymore in the secure 0-level + # provided deep path) + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ + {TCLLIB */dummy/unixlike/test/path} -- {}} +test safe-stock86-7.4 {tests specific path and positive search, uses http1.0} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p1 + set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # this time, unlike test safe-stock86-7.2, http should be found + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}} + +# The following test checks whether the definition of tcl_endOfWord can be +# obtained from auto_loading. It was previously test "safe-5.1". +test safe-stock86-9.8 {test auto-loading in safe interpreters, was test 5.1} -setup { + catch {safe::interpDelete a} + safe::interpCreate a +} -body { + interp eval a {tcl_endOfWord "" 0} +} -cleanup { + safe::interpDelete a +} -result -1 + +set ::auto_path $SaveAutoPath +unset SaveAutoPath TestsDir PathMapp +rename mapList {} + +# cleanup +::tcltest::cleanupTests +return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/safe.test b/tests/safe.test index 9e90236..3511625 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -4,6 +4,17 @@ # using safe interpreters. Sourcing this file into tcl runs the tests and # generates output for errors. No output means no errors were found. # +# The package http 1.0 is convenient for testing package loading, but will soon +# be removed. +# - Tests that use http are replaced here with tests that use example packages +# provided in subdirectory auto0 of the tests directory, which are independent +# of any changes made to the packages provided with Tcl itself. +# - These are tests 7.1 7.2 7.4 9.11 9.13 +# - Tests 5.* test the example packages themselves before they +# are used to test Safe Base interpreters. +# - Alternative tests using stock packages of Tcl 8.6 are in file +# safe-stock86.test. +# # Copyright (c) 1995-1996 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # @@ -155,51 +166,11 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup { a eval exit } -result "" -# The following test checks whether the definition of tcl_endOfWord can be -# obtained from auto_loading. - -test safe-5.1 {test auto-loading in safe interpreters} -setup { - catch {safe::interpDelete a} - safe::interpCreate a -} -body { - interp eval a {tcl_endOfWord "" 0} -} -cleanup { - safe::interpDelete a -} -result -1 - -# test safe interps 'information leak' -proc SafeEval {script} { - # Helper procedure that ensures the safe interp is cleaned up even if - # there is a failure in the script. - set SafeInterp [interp create -safe] - catch {$SafeInterp eval $script} msg opts - interp delete $SafeInterp - return -options $opts $msg -} +# The old test "safe-5.1" has been moved to "safe-stock86-9.8". +# A replacement test using example files is "safe-9.8". +# Tests 5.* test the example files before using them to test safe interpreters. -test safe-6.1 {test safe interpreters knowledge of the world} { - lsort [SafeEval {info globals}] -} {tcl_interactive tcl_patchLevel tcl_platform tcl_version} -test safe-6.2 {test safe interpreters knowledge of the world} { - SafeEval {info script} -} {} -test safe-6.3 {test safe interpreters knowledge of the world} { - set r [SafeEval {array names tcl_platform}] - # If running a windows-debug shell, remove the "debug" element from r. - if {[testConstraint win]} { - set r [lsearch -all -inline -not -exact $r "debug"] - } - set r [lsearch -all -inline -not -exact $r "threaded"] - lsort $r -} {byteOrder engine pathSeparator platform pointerSize wordSize} - -rename SafeEval {} -# More test should be added to check that hostname, nameofexecutable, aren't -# leaking infos, but they still do... - -# Tests 7.0* test the example files before using them to test safe interpreters. - -test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { +test safe-5.1 {example tclIndex commands, test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] [file join $TestsDir auto0 auto2] } -body { @@ -213,7 +184,7 @@ test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { set ::auto_path $tmpAutoPath auto_reset } -match glob -result {0 ok1 0 ok2} -test safe-7.0b {example tclIndex commands, negative test in master interpreter} -setup { +test safe-5.2 {example tclIndex commands, negative test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -227,7 +198,7 @@ test safe-7.0b {example tclIndex commands, negative test in master interpreter} set ::auto_path $tmpAutoPath auto_reset } -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} -test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { +test safe-5.3 {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -244,7 +215,7 @@ test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { +test safe-5.4 {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2] @@ -262,7 +233,7 @@ test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0e {example modules packages, test in master interpreter, replace path} -setup { +test safe-5.5 {example modules packages, test in master interpreter, replace path} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -288,7 +259,7 @@ test safe-7.0e {example modules packages, test in master interpreter, replace pa catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} -test safe-7.0f {example modules packages, test in master interpreter, append to path} -setup { +test safe-5.6 {example modules packages, test in master interpreter, append to path} -setup { tcl::tm::path add [file join $TestsDir auto0 modules] } -body { # Try to load the modules and run a command from each one. @@ -308,6 +279,37 @@ test safe-7.0f {example modules packages, test in master interpreter, append to catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} + +# test safe interps 'information leak' +proc SafeEval {script} { + # Helper procedure that ensures the safe interp is cleaned up even if + # there is a failure in the script. + set SafeInterp [interp create -safe] + catch {$SafeInterp eval $script} msg opts + interp delete $SafeInterp + return -options $opts $msg +} + +test safe-6.1 {test safe interpreters knowledge of the world} { + lsort [SafeEval {info globals}] +} {tcl_interactive tcl_patchLevel tcl_platform tcl_version} +test safe-6.2 {test safe interpreters knowledge of the world} { + SafeEval {info script} +} {} +test safe-6.3 {test safe interpreters knowledge of the world} { + set r [SafeEval {array names tcl_platform}] + # If running a windows-debug shell, remove the "debug" element from r. + if {[testConstraint win]} { + set r [lsearch -all -inline -not -exact $r "debug"] + } + set r [lsearch -all -inline -not -exact $r "threaded"] + lsort $r +} {byteOrder engine pathSeparator platform pointerSize wordSize} + +rename SafeEval {} +# More test should be added to check that hostname, nameofexecutable, aren't +# leaking infos, but they still do... + # high level general test # Use example packages not http1.0 test safe-7.1 {tests that everything works at high level} -setup { @@ -326,18 +328,6 @@ test safe-7.1 {tests that everything works at high level} -setup { } -cleanup { safe::interpDelete $i } -match glob -result 1.2.3 -# high level general test -test safe-7.1http {tests that everything works at high level, uses http 2} -body { - set i [safe::interpCreate] - # no error shall occur: - # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the master) - set v [interp eval $i {package require http 2}] - # no error shall occur: - interp eval $i {http::config} - safe::interpDelete $i - set v -} -match glob -result 2.* test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -358,21 +348,6 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ 1 {can't find package SafeTestPackage1} --\ {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} -test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 - set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # an error shall occur (http is not anymore in the secure 0-level - # provided deep path) - list $token1 $token2 -- \ - [catch {interp eval $i {package require http 1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ - {TCLLIB */dummy/unixlike/test/path} -- {}} test safe-7.3 {check that safe subinterpreters work} { set g [interp slaves] if {$g ne {}} { @@ -405,19 +380,6 @@ test safe-7.4 {tests specific path and positive search} -setup { } -cleanup { } -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ {TCLLIB * TESTSDIR/auto0/auto1} -- {}} -test safe-7.4http {tests specific path and positive search, uses http1.0} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 - set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # this time, unlike test safe-7.2, http should be found - list $token1 $token2 -- \ - [catch {interp eval $i {package require http 1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}} # test source control on file name test safe-8.1 {safe source control on file} -setup { @@ -666,7 +628,27 @@ test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}}\ {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}}\ {-accessPath * -statics 0 -nested 0 -deleteHook toto}} -test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { +test safe-9.8 {test autoloading commands indexed in tclIndex files} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load and run the commands. + set code1 [catch {interp eval $i {report1}} msg1] + set code2 [catch {interp eval $i {report2}} msg2] + + list $path1 $path2 -- $code1 $msg1 $code2 $msg2 -- $mappA +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 0 ok1 0 ok2 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*}} +test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -705,7 +687,7 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} -test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { +test safe-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -743,7 +725,7 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} -test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { +test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -787,7 +769,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} -test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { +test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -827,7 +809,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} -test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { +test safe-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1455,7 +1437,7 @@ test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug safe::interpDelete $i removeDirectory $testdir } -result {EXPECTED/deletemetoo/pkgIndex.tcl} -test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { +test safe-13.7.1 {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { set i [safe::interpCreate] buildEnvironment2 pkgIndex.tcl } -body { -- cgit v0.12 From 51449d078f688627b42b0c8ced040cc8b5197ca2 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 20 Jul 2020 22:57:42 +0000 Subject: File tests/safe.test - rearrange tests - move tests of command/package loading that use Tcl files to new file tests/safe-stock87.test; move tests of zipfs compatibility to new file tests/safe-zipfs.test; renumber tests 9.8+ and add test 9.8 to replace old 5.1; move tests 7.0* to 5.*; reverse merge error (duplicate code). --- tests/safe-stock87.test | 255 ++++++++ tests/safe-zipfs.test | 729 +++++++++++++++++++++++ tests/safe.test | 1487 +++-------------------------------------------- 3 files changed, 1063 insertions(+), 1408 deletions(-) create mode 100644 tests/safe-stock87.test create mode 100644 tests/safe-zipfs.test diff --git a/tests/safe-stock87.test b/tests/safe-stock87.test new file mode 100644 index 0000000..3ba1558 --- /dev/null +++ b/tests/safe-stock87.test @@ -0,0 +1,255 @@ +# safe-stock87.test -- +# +# This file contains tests for safe Tcl that were previously in the file +# safe.test, and use files and packages of stock Tcl 8.7 to perform the tests. +# These files may be changed or disappear in future revisions of Tcl, for +# example package opt will eventually be removed. +# +# The tests are replaced in safe.tcl with tests that use files provided in the +# tests directory. Test numbering is for comparison with similar tests in +# safe.test. +# +# Sourcing this file into tcl runs the tests and generates output for errors. +# No output means no errors were found. +# +# The defunct package http 1.0 was convenient for testing package loading. +# - This file, safe-stock87.test, uses packages opt and (from cookiejar) +# tcl::idna to provide alternative tests based on stock Tcl packages. +# - These are tests 7.1 7.2 7.4 9.11 9.13 +# - Tests 7.[124], 9.1[13] use "package require opt". +# - Tests 9.1[13] also use "package require tcl::idna". +# - The corresponding tests in safe.test use example packages provided in +# subdirectory auto0 of the tests directory, which are independent of any +# changes made to the packages provided with Tcl. +# +# Copyright (c) 1995-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +package require Tcl 8.5- + +if {"::tcltest" ni [namespace children]} { + package require tcltest 2 + namespace import -force ::tcltest::* +} + +foreach i [interp slaves] { + interp delete $i +} + +# When using package opt for testing positive/negative package search: +# - The directory location and the error message depend on whether +# and how the package is installed. + +# Error message for test 7.2 for "package require opt". +if {[string match *zipfs:/* [info library]]} { + # pkgIndex.tcl is in [info library] + # file to be sourced is in [info library]/opt* + set pkgOptErrMsg {permission denied} +} else { + # pkgIndex.tcl and file to be sourced are + # both in [info library]/opt* + set pkgOptErrMsg {can't find package opt} +} + +# Directory of opt for tests 7.4, 9.10, 9.12 for "package require opt". +if {[file exists [file join [info library] opt0.4]]} { + # Installed files in lib8.7/opt0.4 + set pkgOptDir opt0.4 +} elseif {[file exists [file join [info library] opt]]} { + # Installed files in zipfs, or source files used by "make test" + set pkgOptDir opt +} else { + error {cannot find opt library} +} + +# Directory of cookiejar for tests 9.10, 9.12 for "package require tcl::idna". +if {[file exists [file join [info library] cookiejar0.2]]} { + # Installed files in lib8.7/cookiejar0.2 + set pkgJarDir cookiejar0.2 +} elseif {[file exists [file join [info library] cookiejar]]} { + # Installed files in zipfs, or source files used by "make test" + set pkgJarDir cookiejar +} else { + error {cannot find cookiejar library} +} + +set SaveAutoPath $::auto_path +set ::auto_path [info library] +set TestsDir [file normalize [file dirname [info script]]] +set PathMapp {} +lappend PathMapp [file join [info library] $pkgOptDir] TCLLIB/OPTDIR +lappend PathMapp [file join [info library] $pkgJarDir] TCLLIB/JARDIR +lappend PathMapp $tcl_library TCLLIB $TestsDir TESTSDIR + +proc mapList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + return $listOut +} +proc mapAndSortList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + lsort $listOut +} + +# Force actual loading of the safe package because we use un-exported (and +# thus un-autoindexed) APIs in this test result arguments: +catch {safe::interpConfigure} + +# testing that nested and statics do what is advertised (we use a static +# package - Tcltest - but it might be absent if we're in standard tclsh) + +testConstraint TcltestPackage [expr {![catch {package require Tcltest}]}] + +# high level general test +test safe-stock87-7.1 {tests that everything works at high level, uses pkg opt} -setup { + set i [safe::interpCreate] +} -body { + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a slave works like in the master) + set v [interp eval $i {package require opt}] + # no error shall occur: + interp eval $i {::tcl::Lempty {a list}} + set v +} -cleanup { + safe::interpDelete $i +} -match glob -result 0.4.* +test safe-stock87-7.2 {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + # an error shall occur (opt is not anymore in the secure 0-level + # provided deep path) + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + list $token1 $token2 -- \ + [catch {interp eval $i {package require opt}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -cleanup { +} -match glob -result "{\$p(:0:)} {\$p(:*:)} -- 1 {$pkgOptErrMsg} --\ + {TCLLIB */dummy/unixlike/test/path} -- {}" +test safe-stock87-7.4 {tests specific path and positive search, uses pkg opt} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i [file join [info library] $pkgOptDir]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # this time, unlike test safe-stock87-7.2, opt should be found + list $token1 $token2 -- \ + [catch {interp eval $i {package require opt}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] + # Note that the glob match elides directories (those from the module path) + # other than the first and last in the access path. +} -cleanup { +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 0.4.* --\ + {TCLLIB * TCLLIB/OPTDIR} -- {}} + +# The following test checks whether the definition of tcl_endOfWord can be +# obtained from auto_loading. It was previously test "safe-5.1". +test safe-stock87-9.8 {test auto-loading in safe interpreters, was safe-5.1} -setup { + catch {safe::interpDelete a} + safe::interpCreate a +} -body { + interp eval a {tcl_endOfWord "" 0} +} -cleanup { + safe::interpDelete a +} -result -1 +test safe-stock87-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $tcl_library $pkgOptDir] \ + [file join $tcl_library $pkgJarDir]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + # This has no effect because the records in Pkg of these directories were from access as children of {$p(:0:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $tcl_library $pkgJarDir] \ + [file join $tcl_library $pkgOptDir]] + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set path3 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path4 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require tcl::idna}} msg3] + set code4 [catch {interp eval $i {package require opt}} msg4] + set code5 [catch {interp eval $i {::tcl::Lempty {a list}}} msg5] + set code6 [catch {interp eval $i {::tcl::idna::IDNAencode example.com}} msg6] + + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 1.* 0 0.4.* --\ + {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} --\ + {TCLLIB TCLLIB/JARDIR TCLLIB/OPTDIR*} --\ + 0 0 0 example.com} +test safe-stock87-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $tcl_library $pkgOptDir] \ + [file join $tcl_library $pkgJarDir]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] + set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library] + + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set code4 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]} path4] + set code5 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]} path5] + + # Try to load the packages. + set code3 [catch {interp eval $i {package require opt}} msg3] + set code6 [catch {interp eval $i {package require tcl::idna}} msg6] + + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ + $mappA -- $mappB +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ + 1 {* not found in access path} -- 1 1 --\ + {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} -- {TCLLIB*}} + +set ::auto_path $SaveAutoPath +unset pkgOptErrMsg pkgOptDir pkgJarDir SaveAutoPath TestsDir PathMapp +rename mapList {} +rename mapAndSortList {} +# cleanup +::tcltest::cleanupTests +return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/safe-zipfs.test b/tests/safe-zipfs.test new file mode 100644 index 0000000..1f110d1 --- /dev/null +++ b/tests/safe-zipfs.test @@ -0,0 +1,729 @@ +# safe-zipfs.test -- +# +# This file contains tests for safe Tcl that test its compatibility with the +# zipfs facilities introduced in Tcl 8.7. Test numbering is for comparison +# with similar tests in safe.test that do not use the zipfs file system. +# +# Sourcing this file into tcl runs the tests and generates output for errors. +# No output means no errors were found. +# +# Copyright (c) 1995-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +package require Tcl 8.5- + +if {"::tcltest" ni [namespace children]} { + package require tcltest 2 + namespace import -force ::tcltest::* +} + +foreach i [interp slaves] { + interp delete $i +} + +set SaveAutoPath $::auto_path +set ::auto_path [info library] +set TestsDir [file normalize [file dirname [info script]]] + +set ZipMountPoint [zipfs root]auto-files +zipfs mount $ZipMountPoint [file join $TestsDir auto-files.zip] + +set PathMapp {} +lappend PathMapp $tcl_library TCLLIB $TestsDir TESTSDIR $ZipMountPoint ZIPDIR + +proc mapList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + return $listOut +} +proc mapAndSortList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + lsort $listOut +} + +# Force actual loading of the safe package because we use un-exported (and +# thus un-autoindexed) APIs in this test result arguments: +catch {safe::interpConfigure} + +# testing that nested and statics do what is advertised (we use a static +# package - Tcltest - but it might be absent if we're in standard tclsh) + +testConstraint TcltestPackage [expr {![catch {package require Tcltest}]}] + +# Tests 5.* test the example files before using them to test safe interpreters. + +test safe-zipfs-5.1 {example tclIndex commands, test in master interpreter; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {0 ok1 0 ok2} +test safe-zipfs-5.2 {example tclIndex commands, negative test in master interpreter; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0] +} -body { + # Try to load the commands. + set code3 [catch report1 msg3] + set code4 [catch report2 msg4] + list $code3 $msg3 $code4 $msg4 +} -cleanup { + catch {rename report1 {}} + catch {rename report2 {}} + set ::auto_path $tmpAutoPath + auto_reset +} -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} +test safe-zipfs-5.3 {example pkgIndex.tcl packages, test in master interpreter, child directories; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} +test safe-zipfs-5.4 {example pkgIndex.tcl packages, test in master interpreter, main directories; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2] +} -body { + # Try to load the packages and run a command from each one. + set code3 [catch {package require SafeTestPackage1} msg3] + set code4 [catch {package require SafeTestPackage2} msg4] + set code5 [catch HeresPackage1 msg5] + set code6 [catch HeresPackage2 msg6] + list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 +} -cleanup { + set ::auto_path $tmpAutoPath + catch {package forget SafeTestPackage1} + catch {package forget SafeTestPackage2} + catch {rename HeresPackage1 {}} + catch {rename HeresPackage2 {}} +} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} +test safe-zipfs-5.5 {example modules packages, test in master interpreter, replace path; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} +test safe-zipfs-5.6 {example modules packages, test in master interpreter, append to path; zipfs} -setup { + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + # Try to load the modules and run a command from each one. + set code0 [catch {package require test0} msg0] + set code1 [catch {package require mod1::test1} msg1] + set code2 [catch {package require mod2::test2} msg2] + set out0 [test0::try0] + set out1 [mod1::test1::try1] + set out2 [mod2::test2::try2] + list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + catch {package forget test0} + catch {package forget mod1::test1} + catch {package forget mod2::test2} + catch {namespace delete ::test0} + catch {namespace delete ::mod1} +} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} + +# high level general test +# Use zipped example packages not tcl8.x/opt +test safe-zipfs-7.1 {tests that everything works at high level; zipfs} -setup { + set tmpAutoPath $::auto_path + lappend ::auto_path [file join $ZipMountPoint auto0] + set i [safe::interpCreate] + set ::auto_path $tmpAutoPath +} -body { + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a slave works like in the master) + set v [interp eval $i {package require SafeTestPackage1}] + # no error shall occur: + interp eval $i {HeresPackage1} + set v +} -cleanup { + safe::interpDelete $i +} -match glob -result 1.2.3 +test safe-zipfs-7.2 {tests specific path and interpFind/AddToAccessPath; zipfs} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + # should add as p* (not p2 if master has a module path) + set token3 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level + # provided deep path) + list $token1 $token2 $token3 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -cleanup { +} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ + 1 {can't find package SafeTestPackage1} --\ + {TCLLIB */dummy/unixlike/test/path ZIPDIR/auto0} -- {}} +test safe-zipfs-7.4 {tests specific path and positive search; zipfs} -setup { +} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p* (not p1 if master has a module path) + set token2 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # this time, unlike test safe-zipfs-7.2, SafeTestPackage1 should be found + list $token1 $token2 -- \ + [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] + # Note that the glob match elides directories (those from the module path) + # other than the first and last in the access path. +} -cleanup { +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ + {TCLLIB * ZIPDIR/auto0/auto1} -- {}} + +test safe-zipfs-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset); zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + + # Load and run the commands. + # This guarantees the test will pass even if the tokens are swapped. + set code1 [catch {interp eval $i {report1}} msg1] + set code2 [catch {interp eval $i {report2}} msg2] + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} +test safe-zipfs-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset); zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} + + # Do not load the commands. With the tokens swapped, the test + # will pass only if the Safe Base has called auto_reset. + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load and run the commands. + set code3 [catch {interp eval $i {report1}} msg3] + set code4 [catch {interp eval $i {report2}} msg4] + + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 ok1 0 ok2 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} +test safe-zipfs-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement; zipfs} -setup { +} -body { + # For complete correspondence to safe-stock87-9.11, include auto0 in access path. + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0] \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}. + # This would have no effect because the records in Pkg of these directories + # were from access as children of {$p(:1:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0] \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\ + {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} +test safe-zipfs-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0; zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto2] \ + [file join $ZipMountPoint auto0 auto1]] + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Try to load the packages and run a command from each one. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] + set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] + set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] + set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] + + list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ + $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ + 0 1.2.3 0 2.3.4 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ + {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ + 0 OK1 0 OK2} +test safe-zipfs-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed; zipfs} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] + + # Load pkgIndex.tcl data. + catch {interp eval $i {package require NOEXIST}} + + # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. + safe::interpConfigure $i -accessPath [list $tcl_library] + + # Inspect. + set confB [safe::interpConfigure $i] + set mappB [mapList $PathMapp [dict get $confB -accessPath]] + set code4 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]} path4] + set code5 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]} path5] + + # Try to load the packages. + set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] + set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] + + list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ + $mappA -- $mappB +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ + 1 {* not found in access path} -- 1 1 --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB*}} +test safe-zipfs-9.20 {check module loading; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} -- res0 res1 res2} +# - The command safe::InterpSetConfig adds the master's [tcl::tm::list] in +# tokenized form to the slave's access path, and then adds all the +# descendants, discovered recursively by using glob. +# - The order of the directories in the list returned by glob is system-dependent, +# and therefore this is true also for (a) the order of token assignment to +# descendants of the [tcl::tm::list] roots; and (b) the order of those same +# directories in the access path. Both those things must be sorted before +# comparing with expected results. The test is therefore not totally strict, +# but will notice missing or surplus directories. +test safe-zipfs-9.21 {interpConfigure change the access path; check module loading; stale data case 1; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + # Inspect. + set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Load pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-zipfs-9.20. +test safe-zipfs-9.22 {interpConfigure change the access path; check module loading; stale data case 0; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + # Inspect. + set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-zipfs-9.20. +test safe-zipfs-9.23 {interpConfigure change the access path; check module loading; stale data case 3; zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + # Inspect. + set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Refresh stale pkg data. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-zipfs-9.20. +test safe-zipfs-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case); zipfs} -setup { + set oldTm [tcl::tm::path list] + foreach path $oldTm { + tcl::tm::path remove $path + } + tcl::tm::path add [file join $ZipMountPoint auto0 modules] +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library]] + + # Inspect. + set confA [safe::interpConfigure $i] + set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] + set modsA [interp eval $i {tcl::tm::path list}] + set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Force the interpreter to acquire pkg data which will soon become stale. + catch {interp eval $i {package require NOEXIST}} + catch {interp eval $i {package require mod1::NOEXIST}} + catch {interp eval $i {package require mod2::NOEXIST}} + + # Add to access path. + # This injects more tokens, pushing modules to higher token numbers. + safe::interpConfigure $i -accessPath [list $tcl_library \ + [file join $ZipMountPoint auto0 auto1] \ + [file join $ZipMountPoint auto0 auto2]] + # Inspect. + set confB [safe::interpConfigure $i] + set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] + set modsB [interp eval $i {tcl::tm::path list}] + set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] + set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] + set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] + + # Try to load the packages and run a command from each one. + set code0 [catch {interp eval $i {package require test0}} msg0] + set code1 [catch {interp eval $i {package require mod1::test1}} msg1] + set code2 [catch {interp eval $i {package require mod2::test2}} msg2] + set out0 [interp eval $i {test0::try0}] + set out1 [interp eval $i {mod1::test1::try1}] + set out2 [interp eval $i {mod2::test2::try2}] + + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ + [lsort [list $path3 $path4 $path5]] -- $modsB -- \ + $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ + $out0 $out1 $out2 +} -cleanup { + tcl::tm::path remove [file join $ZipMountPoint auto0 modules] + foreach path [lreverse $oldTm] { + tcl::tm::path add $path + } + safe::interpDelete $i +} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ + {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ + 0 0.5 0 1.0 0 2.0 --\ + {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ + ZIPDIR/auto0/modules/mod2} --\ + {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ + ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ + res0 res1 res2} +# See comments on lsort after test safe-zipfs-9.20. + +set ::auto_path $SaveAutoPath +zipfs unmount ${ZipMountPoint} +unset SaveAutoPath TestsDir ZipMountPoint PathMapp +rename mapList {} +rename mapAndSortList {} +# cleanup +::tcltest::cleanupTests +return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/safe.test b/tests/safe.test index be29a8d..4157596 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -4,6 +4,16 @@ # using safe interpreters. Sourcing this file into tcl runs the tests and # generates output for errors. No output means no errors were found. # +# The defunct package http 1.0 was convenient for testing package loading. +# - Tests that used http are replaced here with tests that use example packages +# provided in subdirectory auto0 of the tests directory, which are independent +# of any changes made to the packages provided with Tcl itself. +# - These are tests 7.1 7.2 7.4 9.11 9.13 +# - Tests 5.* test the example packages themselves before they +# are used to test Safe Base interpreters. +# - Alternative tests using stock packages of Tcl 8.7 are in file +# safe-stock87.test. +# # Copyright (c) 1995-1996 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # @@ -26,67 +36,6 @@ set ::auto_path [info library] set TestsDir [file normalize [file dirname [info script]]] set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] -# The defunct package http 1.0 was convenient for testing package loading. -# - Replaced here with tests using example packages provided in subdirectory -# auto0 of the tests directory, which are independent of any changes -# made to the packages provided with Tcl. -# - These are tests 7.1 7.2 7.4 9.10 9.12 -# - Tests 7.0[a-f] test the example packages themselves before they -# are used to test Safe Base interpreters. -# - Alternatively use packages opt and (from cookiejar) tcl::idna. -# - These alternative tests have suffix "opt". -# - These are 7.[124]opt, 9.1[02]opt -# - Tests 7.[124]opt, 9.1[02]opt use "package require opt". -# - Tests 9.1[02]opt also use "package require tcl::idna". -# -# When using package opt for testing positive/negative package search: -# - The directory location and the error message depend on whether -# and how the package is installed. - -# Error message for tests 7.2opt for "package require opt". -if {[string match *zipfs:/* [info library]]} { - # pkgIndex.tcl is in [info library] - # file to be sourced is in [info library]/opt* - set pkgOptErrMsg {permission denied} -} else { - # pkgIndex.tcl and file to be sourced are - # both in [info library]/opt* - set pkgOptErrMsg {can't find package opt} -} - -# Directory of opt for tests 7.4opt, 9.10opt, 9.12opt -# for "package require opt". -if {[file exists [file join [info library] opt0.4]]} { - # Installed files in lib8.7/opt0.4 - set pkgOptDir opt0.4 -} elseif {[file exists [file join [info library] opt]]} { - # Installed files in zipfs, or source files used by "make test" - set pkgOptDir opt -} else { - error {cannot find opt library} -} - -# Directory of cookiejar for tests 9.10opt, 9.12opt -# for "package require tcl::idna". -if {[file exists [file join [info library] cookiejar0.2]]} { - # Installed files in lib8.7/cookiejar0.2 - set pkgJarDir cookiejar0.2 -} elseif {[file exists [file join [info library] cookiejar]]} { - # Installed files in zipfs, or source files used by "make test" - set pkgJarDir cookiejar -} else { - error {cannot find cookiejar library} -} - -set TestsDir [file normalize [file dirname [info script]]] -set ZipMountPoint [zipfs root]auto-files -zipfs mount $ZipMountPoint [file join $TestsDir auto-files.zip] - -set PathMapp {} -lappend PathMapp [file join [info library] $pkgOptDir] TCLLIB/OPTDIR -lappend PathMapp [file join [info library] $pkgJarDir] TCLLIB/JARDIR -lappend PathMapp $tcl_library TCLLIB $TestsDir TESTSDIR $ZipMountPoint ZIPDIR - proc mapList {map listIn} { set listOut {} foreach element $listIn { @@ -216,51 +165,11 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup { a eval exit } -result "" -# The following test checks whether the definition of tcl_endOfWord can be -# obtained from auto_loading. - -test safe-5.1 {test auto-loading in safe interpreters} -setup { - catch {safe::interpDelete a} - safe::interpCreate a -} -body { - interp eval a {tcl_endOfWord "" 0} -} -cleanup { - safe::interpDelete a -} -result -1 - -# test safe interps 'information leak' -proc SafeEval {script} { - # Helper procedure that ensures the safe interp is cleaned up even if - # there is a failure in the script. - set SafeInterp [interp create -safe] - catch {$SafeInterp eval $script} msg opts - interp delete $SafeInterp - return -options $opts $msg -} - -test safe-6.1 {test safe interpreters knowledge of the world} { - lsort [SafeEval {info globals}] -} {tcl_interactive tcl_patchLevel tcl_platform tcl_version} -test safe-6.2 {test safe interpreters knowledge of the world} { - SafeEval {info script} -} {} -test safe-6.3 {test safe interpreters knowledge of the world} { - set r [SafeEval {array names tcl_platform}] - # If running a windows-debug shell, remove the "debug" element from r. - if {[testConstraint win]} { - set r [lsearch -all -inline -not -exact $r "debug"] - } - set r [lsearch -all -inline -not -exact $r "threaded"] - lsort $r -} {byteOrder engine pathSeparator platform pointerSize wordSize} - -rename SafeEval {} -# More test should be added to check that hostname, nameofexecutable, aren't -# leaking infos, but they still do... - -# Tests 7.0* test the example files before using them to test safe interpreters. +# The old test "safe-5.1" has been moved to "safe-stock87-9.8". +# A replacement test using example files is "safe-9.8". +# Tests 5.* test the example files before using them to test safe interpreters. -test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { +test safe-5.1 {example tclIndex commands, test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] [file join $TestsDir auto0 auto2] } -body { @@ -274,21 +183,7 @@ test safe-7.0a {example tclIndex commands, test in master interpreter} -setup { set ::auto_path $tmpAutoPath auto_reset } -match glob -result {0 ok1 0 ok2} -test safe-7.0az {example tclIndex commands, test in master interpreter; zipfs} -setup { - set tmpAutoPath $::auto_path - lappend ::auto_path [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2] -} -body { - # Try to load the commands. - set code3 [catch report1 msg3] - set code4 [catch report2 msg4] - list $code3 $msg3 $code4 $msg4 -} -cleanup { - catch {rename report1 {}} - catch {rename report2 {}} - set ::auto_path $tmpAutoPath - auto_reset -} -match glob -result {0 ok1 0 ok2} -test safe-7.0b {example tclIndex commands, negative test in master interpreter} -setup { +test safe-5.2 {example tclIndex commands, negative test in master interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -302,21 +197,7 @@ test safe-7.0b {example tclIndex commands, negative test in master interpreter} set ::auto_path $tmpAutoPath auto_reset } -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} -test safe-7.0bz {example tclIndex commands, negative test in master interpreter; zipfs} -setup { - set tmpAutoPath $::auto_path - lappend ::auto_path [file join $ZipMountPoint auto0] -} -body { - # Try to load the commands. - set code3 [catch report1 msg3] - set code4 [catch report2 msg4] - list $code3 $msg3 $code4 $msg4 -} -cleanup { - catch {rename report1 {}} - catch {rename report2 {}} - set ::auto_path $tmpAutoPath - auto_reset -} -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} -test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { +test safe-5.3 {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -333,24 +214,7 @@ test safe-7.0c {example pkgIndex.tcl packages, test in master interpreter, child catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0cz {example pkgIndex.tcl packages, test in master interpreter, child directories; zipfs} -setup { - set tmpAutoPath $::auto_path - lappend ::auto_path [file join $ZipMountPoint auto0] -} -body { - # Try to load the packages and run a command from each one. - set code3 [catch {package require SafeTestPackage1} msg3] - set code4 [catch {package require SafeTestPackage2} msg4] - set code5 [catch HeresPackage1 msg5] - set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 -} -cleanup { - set ::auto_path $tmpAutoPath - catch {package forget SafeTestPackage1} - catch {package forget SafeTestPackage2} - catch {rename HeresPackage1 {}} - catch {rename HeresPackage2 {}} -} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { +test safe-5.4 {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2] @@ -368,25 +232,7 @@ test safe-7.0d {example pkgIndex.tcl packages, test in master interpreter, main catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0dz {example pkgIndex.tcl packages, test in master interpreter, main directories; zipfs} -setup { - set tmpAutoPath $::auto_path - lappend ::auto_path [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2] -} -body { - # Try to load the packages and run a command from each one. - set code3 [catch {package require SafeTestPackage1} msg3] - set code4 [catch {package require SafeTestPackage2} msg4] - set code5 [catch HeresPackage1 msg5] - set code6 [catch HeresPackage2 msg6] - list $code3 $msg3 $code4 $msg4 $code5 $msg5 $code6 $msg6 -} -cleanup { - set ::auto_path $tmpAutoPath - catch {package forget SafeTestPackage1} - catch {package forget SafeTestPackage2} - catch {rename HeresPackage1 {}} - catch {rename HeresPackage2 {}} -} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-7.0e {example modules packages, test in master interpreter, replace path} -setup { +test safe-5.5 {example modules packages, test in master interpreter, replace path} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -412,33 +258,7 @@ test safe-7.0e {example modules packages, test in master interpreter, replace pa catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} -test safe-7.0ez {example modules packages, test in master interpreter, replace path; zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - # Try to load the modules and run a command from each one. - set code0 [catch {package require test0} msg0] - set code1 [catch {package require mod1::test1} msg1] - set code2 [catch {package require mod2::test2} msg2] - set out0 [test0::try0] - set out1 [mod1::test1::try1] - set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - catch {package forget test0} - catch {package forget mod1::test1} - catch {package forget mod2::test2} - catch {namespace delete ::test0} - catch {namespace delete ::mod1} -} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} -test safe-7.0f {example modules packages, test in master interpreter, append to path} -setup { +test safe-5.6 {example modules packages, test in master interpreter, append to path} -setup { tcl::tm::path add [file join $TestsDir auto0 modules] } -body { # Try to load the modules and run a command from each one. @@ -457,25 +277,37 @@ test safe-7.0f {example modules packages, test in master interpreter, append to catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} -test safe-7.0fz {example modules packages, test in master interpreter, append to path; zipfs} -setup { - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - # Try to load the modules and run a command from each one. - set code0 [catch {package require test0} msg0] - set code1 [catch {package require mod1::test1} msg1] - set code2 [catch {package require mod2::test2} msg2] - set out0 [test0::try0] - set out1 [mod1::test1::try1] - set out2 [mod2::test2::try2] - list $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - catch {package forget test0} - catch {package forget mod1::test1} - catch {package forget mod2::test2} - catch {namespace delete ::test0} - catch {namespace delete ::mod1} -} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} + + +# test safe interps 'information leak' +proc SafeEval {script} { + # Helper procedure that ensures the safe interp is cleaned up even if + # there is a failure in the script. + set SafeInterp [interp create -safe] + catch {$SafeInterp eval $script} msg opts + interp delete $SafeInterp + return -options $opts $msg +} + +test safe-6.1 {test safe interpreters knowledge of the world} { + lsort [SafeEval {info globals}] +} {tcl_interactive tcl_patchLevel tcl_platform tcl_version} +test safe-6.2 {test safe interpreters knowledge of the world} { + SafeEval {info script} +} {} +test safe-6.3 {test safe interpreters knowledge of the world} { + set r [SafeEval {array names tcl_platform}] + # If running a windows-debug shell, remove the "debug" element from r. + if {[testConstraint win]} { + set r [lsearch -all -inline -not -exact $r "debug"] + } + set r [lsearch -all -inline -not -exact $r "threaded"] + lsort $r +} {byteOrder engine pathSeparator platform pointerSize wordSize} + +rename SafeEval {} +# More test should be added to check that hostname, nameofexecutable, aren't +# leaking infos, but they still do... # high level general test # Use example packages not http1.0 @@ -495,38 +327,6 @@ test safe-7.1 {tests that everything works at high level} -setup { } -cleanup { safe::interpDelete $i } -match glob -result 1.2.3 -# high level general test -# Use zipped example packages not tcl8.x/opt -test safe-7.1z {tests that everything works at high level; zipfs} -setup { - set tmpAutoPath $::auto_path - lappend ::auto_path [file join $ZipMountPoint auto0] - set i [safe::interpCreate] - set ::auto_path $tmpAutoPath -} -body { - # no error shall occur: - # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the master) - set v [interp eval $i {package require SafeTestPackage1}] - # no error shall occur: - interp eval $i {HeresPackage1} - set v -} -cleanup { - safe::interpDelete $i -} -match glob -result 1.2.3 -# high level general test -test safe-7.1opt {tests that everything works at high level, uses pkg opt} -setup { - set i [safe::interpCreate] -} -body { - # no error shall occur: - # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the master) - set v [interp eval $i {package require opt}] - # no error shall occur: - interp eval $i {::tcl::Lempty {a list}} - set v -} -cleanup { - safe::interpDelete $i -} -match glob -result 0.4.* test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] @@ -547,43 +347,6 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { } -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ 1 {can't find package SafeTestPackage1} --\ {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} -test safe-7.2z {tests specific path and interpFind/AddToAccessPath; zipfs} -setup { -} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) - set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - # should add as p* (not p2 if master has a module path) - set token3 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0]] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level - # provided deep path) - list $token1 $token2 $token3 -- \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -cleanup { -} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\ - 1 {can't find package SafeTestPackage1} --\ - {TCLLIB */dummy/unixlike/test/path ZIPDIR/auto0} -- {}} -test safe-7.2opt {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup { -} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) - set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - # an error shall occur (opt is not anymore in the secure 0-level - # provided deep path) - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - list $token1 $token2 -- \ - [catch {interp eval $i {package require opt}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -cleanup { -} -match glob -result "{\$p(:0:)} {\$p(:*:)} -- 1 {$pkgOptErrMsg} --\ - {TCLLIB */dummy/unixlike/test/path} -- {}" test safe-7.3 {check that safe subinterpreters work} { set g [interp slaves] if {$g ne {}} { @@ -616,42 +379,6 @@ test safe-7.4 {tests specific path and positive search} -setup { } -cleanup { } -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ {TCLLIB * TESTSDIR/auto0/auto1} -- {}} -test safe-7.4z {tests specific path and positive search; zipfs} -setup { -} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) - set token2 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # this time, unlike test safe-7.2, SafeTestPackage1 should be found - list $token1 $token2 -- \ - [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] - # Note that the glob match elides directories (those from the module path) - # other than the first and last in the access path. -} -cleanup { -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\ - {TCLLIB * ZIPDIR/auto0/auto1} -- {}} -test safe-7.4opt {tests specific path and positive search, uses pkg opt} -setup { -} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) - set token2 [safe::interpAddToAccessPath $i [file join [info library] $pkgOptDir]] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # this time, unlike test safe-7.2opt, opt should be found - list $token1 $token2 -- \ - [catch {interp eval $i {package require opt}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] - # Note that the glob match elides directories (those from the module path) - # other than the first and last in the access path. -} -cleanup { -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 0.4.* --\ - {TCLLIB * TCLLIB/OPTDIR} -- {}} # test source control on file name test safe-8.1 {safe source control on file} -setup { @@ -900,7 +627,7 @@ test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}}\ {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}}\ {-accessPath * -statics 0 -nested 0 -deleteHook toto}} -test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { +test safe-9.8 {test autoloading commands indexed in tclIndex files} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -911,8 +638,28 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - # Load auto_load data. - interp eval $i {catch nonExistentCommand} + # Load and run the commands. + set code1 [catch {interp eval $i {report1}} msg1] + set code2 [catch {interp eval $i {report2}} msg2] + + list $path1 $path2 -- $code1 $msg1 $code2 $msg2 -- $mappA +} -cleanup { + safe::interpDelete $i +} -match glob -result {{$p(:1:)} {$p(:2:)} -- 0 ok1 0 ok2 --\ + {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*}} +test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { +} -body { + set i [safe::interpCreate -accessPath [list $tcl_library \ + [file join $TestsDir auto0 auto1] \ + [file join $TestsDir auto0 auto2]]] + # Inspect. + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] + set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] + + # Load auto_load data. + interp eval $i {catch nonExistentCommand} # Load and run the commands. # This guarantees the test will pass even if the tokens are swapped. @@ -939,7 +686,7 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} -test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { +test safe-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -977,7 +724,7 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec 0 ok1 0 ok2 --\ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} -test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { +test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { } -body { # For complete correspondence to safe-9.10opt, include auto0 in access path. set i [safe::interpCreate -accessPath [list $tcl_library \ @@ -1021,7 +768,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} -test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { +test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1061,7 +808,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ 0 OK1 0 OK2} -test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { +test safe-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { } -body { set i [safe::interpCreate -accessPath [list $tcl_library \ [file join $TestsDir auto0 auto1] \ @@ -1390,1081 +1137,6 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st res0 res1 res2} # See comments on lsort after test safe-9.20. -test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body { - # this test shall work, believed equivalent to 9.6 - set i [safe::interpCreate \ - -noStatics \ - -nestedLoadOk \ - -deleteHook {foo bar} \ - ] - - safe::interpConfigure $i -accessPath /foo/bar - set a [safe::interpConfigure $i] - set b [safe::interpConfigure $i -aCCess] - set c [safe::interpConfigure $i -nested] - set d [safe::interpConfigure $i -statics] - set e [safe::interpConfigure $i -DEL] - safe::interpConfigure $i -accessPath /blah -statics 1 - set f [safe::interpConfigure $i] - safe::interpConfigure $i -deleteHook toto -nosta -nested 0 - set g [safe::interpConfigure $i] - - list $a $b $c $d $e $f $g -} -cleanup { - safe::interpDelete $i -} -match glob -result {{-accessPath * -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath * -statics 0 -nested 0 -deleteHook toto}} - -test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load auto_load data. - interp eval $i {catch nonExistentCommand} - - # Load and run the commands. - # This guarantees the test will pass even if the tokens are swapped. - set code1 [catch {interp eval $i {report1}} msg1] - set code2 [catch {interp eval $i {report2}} msg2] - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto2] \ - [file join $TestsDir auto0 auto1]] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Run the commands. - set code3 [catch {interp eval $i {report1}} msg3] - set code4 [catch {interp eval $i {report2}} msg4] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ - {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} - -test safe-9.8z {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset); zipfs} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load auto_load data. - interp eval $i {catch nonExistentCommand} - - # Load and run the commands. - # This guarantees the test will pass even if the tokens are swapped. - set code1 [catch {interp eval $i {report1}} msg1] - set code2 [catch {interp eval $i {report2}} msg2] - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto2] \ - [file join $ZipMountPoint auto0 auto1]] - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Run the commands. - set code3 [catch {interp eval $i {report1}} msg3] - set code4 [catch {interp eval $i {report2}} msg4] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ - {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} - -test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load auto_load data. - interp eval $i {catch nonExistentCommand} - - # Do not load the commands. With the tokens swapped, the test - # will pass only if the Safe Base has called auto_reset. - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto2] \ - [file join $TestsDir auto0 auto1]] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load and run the commands. - set code3 [catch {interp eval $i {report1}} msg3] - set code4 [catch {interp eval $i {report2}} msg4] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ - 0 ok1 0 ok2 --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ - {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}} - -test safe-9.9z {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset); zipfs} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load auto_load data. - interp eval $i {catch nonExistentCommand} - - # Do not load the commands. With the tokens swapped, the test - # will pass only if the Safe Base has called auto_reset. - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto2] \ - [file join $ZipMountPoint auto0 auto1]] - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load and run the commands. - set code3 [catch {interp eval $i {report1}} msg3] - set code4 [catch {interp eval $i {report2}} msg4] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ - 0 ok1 0 ok2 --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ - {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}} -test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup { -} -body { - # For complete correspondence to safe-9.10opt, include auto0 in access path. - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $TestsDir auto0] \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]]] - - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}. - # This would have no effect because the records in Pkg of these directories - # were from access as children of {$p(:1:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0] \ - [file join $TestsDir auto0 auto2] \ - [file join $TestsDir auto0 auto1]] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Try to load the packages and run a command from each one. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] - set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] - set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] - set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ - $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\ - {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ - {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ - 0 OK1 0 OK2} -test safe-9.10z {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement; zipfs} -setup { -} -body { - # For complete correspondence to safe-9.10opt, include auto0 in access path. - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0] \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}. - # This would have no effect because the records in Pkg of these directories - # were from access as children of {$p(:1:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0] \ - [file join $ZipMountPoint auto0 auto2] \ - [file join $ZipMountPoint auto0 auto1]] - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Try to load the packages and run a command from each one. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] - set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] - set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] - set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ - $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\ - {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ - {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ - 0 OK1 0 OK2} -test safe-9.10opt {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $tcl_library $pkgOptDir] \ - [file join $tcl_library $pkgJarDir]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] - set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - # This has no effect because the records in Pkg of these directories were from access as children of {$p(:0:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $tcl_library $pkgJarDir] \ - [file join $tcl_library $pkgOptDir]] - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] - set path4 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] - - # Try to load the packages and run a command from each one. - set code3 [catch {interp eval $i {package require tcl::idna}} msg3] - set code4 [catch {interp eval $i {package require opt}} msg4] - set code5 [catch {interp eval $i {::tcl::Lempty {a list}}} msg5] - set code6 [catch {interp eval $i {::tcl::idna::IDNAencode example.com}} msg6] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ - $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 1.* 0 0.4.* --\ - {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} --\ - {TCLLIB TCLLIB/JARDIR TCLLIB/OPTDIR*} --\ - 0 0 0 example.com} -test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]]] - - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto2] \ - [file join $TestsDir auto0 auto1]] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Try to load the packages and run a command from each one. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] - set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] - set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] - set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -- \ - $code5 $msg5 $code6 $msg6 -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ - 0 1.2.3 0 2.3.4 --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\ - {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\ - 0 OK1 0 OK2} -test safe-9.11z {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0; zipfs} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto2] \ - [file join $ZipMountPoint auto0 auto1]] - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Try to load the packages and run a command from each one. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3] - set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4] - set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5] - set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6] - - list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \ - $mappA -- $mappB -- $code5 $msg5 $code6 $msg6 -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\ - 0 1.2.3 0 2.3.4 --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\ - {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\ - 0 OK1 0 OK2} -test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set code4 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]} path4] - set code5 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]} path5] - - # Try to load the packages. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] - set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] - - list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ - 1 {* not found in access path} -- 1 1 --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} -- {TCLLIB*}} -test safe-9.12z {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed; zipfs} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set code4 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto1]} path4] - set code5 [catch {::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 auto2]} path5] - - # Try to load the packages. - set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3] - set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6] - - list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ - $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ - 1 {* not found in access path} -- 1 1 --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB*}} -test safe-9.12opt {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup { -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library \ - [file join $tcl_library $pkgOptDir] \ - [file join $tcl_library $pkgJarDir]]] - # Inspect. - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - set path1 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]] - set path2 [::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]] - - # Load pkgIndex.tcl data. - catch {interp eval $i {package require NOEXIST}} - - # Limit access path. Remove tokens {$p(:1:)} and {$p(:2:)}. - safe::interpConfigure $i -accessPath [list $tcl_library] - - # Inspect. - set confB [safe::interpConfigure $i] - set mappB [mapList $PathMapp [dict get $confB -accessPath]] - set code4 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgOptDir]} path4] - set code5 [catch {::safe::interpFindInAccessPath $i [file join $tcl_library $pkgJarDir]} path5] - - # Try to load the packages. - set code3 [catch {interp eval $i {package require opt}} msg3] - set code6 [catch {interp eval $i {package require tcl::idna}} msg6] - - list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- \ - $mappA -- $mappB -} -cleanup { - safe::interpDelete $i -} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\ - 1 {* not found in access path} -- 1 1 --\ - {TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} -- {TCLLIB*}} -test safe-9.20 {check module loading} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $TestsDir auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $TestsDir auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ - TESTSDIR/auto0/modules/mod2} -- res0 res1 res2} -# - The command safe::InterpSetConfig adds the master's [tcl::tm::list] in -# tokenized form to the slave's access path, and then adds all the -# descendants, discovered recursively by using glob. -# - The order of the directories in the list returned by glob is system-dependent, -# and therefore this is true also for (a) the order of token assignment to -# descendants of the [tcl::tm::list] roots; and (b) the order of those same -# directories in the access path. Both those things must be sorted before -# comparing with expected results. The test is therefore not totally strict, -# but will notice missing or surplus directories. -test safe-9.20z {check module loading; zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ - ZIPDIR/auto0/modules/mod2} -- res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $TestsDir auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]] - - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Load pkg data. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $TestsDir auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ - TESTSDIR/auto0/modules/mod2} --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ - TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.21z {interpConfigure change the access path; check module loading; stale data case 1; zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]] - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Load pkg data. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ - ZIPDIR/auto0/modules/mod2} --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ - ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $TestsDir auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]] - - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $TestsDir auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ - TESTSDIR/auto0/modules/mod2} --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ - TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.22z {interpConfigure change the access path; check module loading; stale data case 0; zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]] - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ - ZIPDIR/auto0/modules/mod2} --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ - ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $TestsDir auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Force the interpreter to acquire pkg data which will soon become stale. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]] - - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Refresh stale pkg data. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 - -} -cleanup { - tcl::tm::path remove [file join $TestsDir auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ - TESTSDIR/auto0/modules/mod2} --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ - TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.23z {interpConfigure change the access path; check module loading; stale data case 3; zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Force the interpreter to acquire pkg data which will soon become stale. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]] - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Refresh stale pkg data. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ - ZIPDIR/auto0/modules/mod2} --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ - ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $TestsDir auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Force the interpreter to acquire pkg data which will soon become stale. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $TestsDir auto0 auto1] \ - [file join $TestsDir auto0 auto2]] - - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $TestsDir auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ - TESTSDIR/auto0/modules/mod2} --\ - {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\ - TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. -test safe-9.24z {interpConfigure change the access path; check module loading; stale data case 2 (worst case); zipfs} -setup { - set oldTm [tcl::tm::path list] - foreach path $oldTm { - tcl::tm::path remove $path - } - tcl::tm::path add [file join $ZipMountPoint auto0 modules] -} -body { - set i [safe::interpCreate -accessPath [list $tcl_library]] - - # Inspect. - set confA [safe::interpConfigure $i] - set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]] - set modsA [interp eval $i {tcl::tm::path list}] - set path0 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path1 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path2 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Force the interpreter to acquire pkg data which will soon become stale. - catch {interp eval $i {package require NOEXIST}} - catch {interp eval $i {package require mod1::NOEXIST}} - catch {interp eval $i {package require mod2::NOEXIST}} - - # Add to access path. - # This injects more tokens, pushing modules to higher token numbers. - safe::interpConfigure $i -accessPath [list $tcl_library \ - [file join $ZipMountPoint auto0 auto1] \ - [file join $ZipMountPoint auto0 auto2]] - # Inspect. - set confB [safe::interpConfigure $i] - set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]] - set modsB [interp eval $i {tcl::tm::path list}] - set path3 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules]] - set path4 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod1]] - set path5 [::safe::interpFindInAccessPath $i [file join $ZipMountPoint auto0 modules mod2]] - - # Try to load the packages and run a command from each one. - set code0 [catch {interp eval $i {package require test0}} msg0] - set code1 [catch {interp eval $i {package require mod1::test1}} msg1] - set code2 [catch {interp eval $i {package require mod2::test2}} msg2] - set out0 [interp eval $i {test0::try0}] - set out1 [interp eval $i {mod1::test1::try1}] - set out2 [interp eval $i {mod2::test2::try2}] - - list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ - [lsort [list $path3 $path4 $path5]] -- $modsB -- \ - $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ - $out0 $out1 $out2 -} -cleanup { - tcl::tm::path remove [file join $ZipMountPoint auto0 modules] - foreach path [lreverse $oldTm] { - tcl::tm::path add $path - } - safe::interpDelete $i -} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\ - {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\ - 0 0.5 0 1.0 0 2.0 --\ - {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\ - ZIPDIR/auto0/modules/mod2} --\ - {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\ - ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\ - res0 res1 res2} -# See comments on lsort after test safe-9.20. - catch {teststaticpkg Safepkg1 0 0} test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { set i [safe::interpCreate] @@ -2760,7 +1432,7 @@ test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug safe::interpDelete $i removeDirectory $testdir } -result {EXPECTED/deletemetoo/pkgIndex.tcl} -test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { +test safe-13.7.1 {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup { set i [safe::interpCreate] buildEnvironment2 pkgIndex.tcl } -body { @@ -2960,8 +1632,7 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup } -result {~USER} set ::auto_path $SaveAutoPath -zipfs unmount ${ZipMountPoint} -unset pkgOptErrMsg pkgOptDir pkgJarDir SaveAutoPath TestsDir ZipMountPoint PathMapp +unset SaveAutoPath TestsDir PathMapp rename mapList {} rename mapAndSortList {} # cleanup -- cgit v0.12 From 204434e4d41bb9e07b48d28331a6a63206dc36dd Mon Sep 17 00:00:00 2001 From: kjnash Date: Tue, 21 Jul 2020 03:59:35 +0000 Subject: Use suitable -errorcode in safe::AliasSource if file does not exist or is unreadable. Fixes bug f3ba57600d. --- library/safe.tcl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 4540be3..9b8a04f 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -968,12 +968,15 @@ proc ::safe::AliasSource {slave args} { return -code error "permission denied" } - # do the checks on the filename : + # Check that the filename exists and is readable. If it is not, deliver + # this -errorcode so that caller in tclPkgUnknown does not write a message + # to tclLog. Has no effect on other callers of ::source, which are in + # "package ifneeded" scripts. if {[catch { CheckFileName $slave $realfile } msg]} { Log $slave "$realfile:$msg" - return -code error $msg + return -code error -errorcode {POSIX EACCES} $msg } # Passed all the tests, lets source it. Note that we do this all manually -- cgit v0.12 From 14cfbc651c24aa44c83023e8bba2781d322b230f Mon Sep 17 00:00:00 2001 From: kjnash Date: Tue, 21 Jul 2020 17:25:03 +0000 Subject: Adapt Safe Base for interpreter names with namespace separators. Add a test and revise safe(n). Fixes bug [693851]. --- doc/safe.n | 10 +++++- library/safe.tcl | 92 +++++++++++++++++++++++++++++++++++++++++++++----------- tests/safe.test | 17 +++++++++++ 3 files changed, 100 insertions(+), 19 deletions(-) diff --git a/doc/safe.n b/doc/safe.n index b39f2c2..7ddb182 100644 --- a/doc/safe.n +++ b/doc/safe.n @@ -72,11 +72,19 @@ See the \fBOPTIONS\fR section below for a description of the optional arguments. If the \fIslave\fR argument is omitted, a name will be generated. \fB::safe::interpCreate\fR always returns the interpreter name. +.sp +The interpreter name \fIslave\fR may include namespace separators, +but may not have leading or trailing namespace separators, or excess +colon characters in namespace separators. The interpreter name is +qualified relative to the global namespace ::, not the namespace in which +the \fB::safe::interpCreate\fR command is evaluated. .TP \fB::safe::interpInit\fR \fIslave\fR ?\fIoptions...\fR? This command is similar to \fBinterpCreate\fR except it that does not create the safe interpreter. \fIslave\fR must have been created by some -other means, like \fBinterp create\fR \fB\-safe\fR. +other means, like \fBinterp create\fR \fB\-safe\fR. The interpreter +name \fIslave\fR may include namespace separators, subject to the same +restrictions as for \fBinterpCreate\fR. .TP \fB::safe::interpConfigure\fR \fIslave\fR ?\fIoptions...\fR? If no \fIoptions\fR are given, returns the settings for all options for the diff --git a/library/safe.tcl b/library/safe.tcl index 9b8a04f..6b531be 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -79,6 +79,7 @@ proc ::safe::InterpNested {} { # Interface/entry point function and front end for "Create" proc ::safe::interpCreate {args} { set Args [::tcl::OptKeyParse ::safe::interpCreate $args] + RejectExcessColons $slave InterpCreate $slave $accessPath \ [InterpStatics] [InterpNested] $deleteHook } @@ -88,13 +89,14 @@ proc ::safe::interpInit {args} { if {![::interp exists $slave]} { return -code error "\"$slave\" is not an interpreter" } + RejectExcessColons $slave InterpInit $slave $accessPath \ [InterpStatics] [InterpNested] $deleteHook } # Check that the given slave is "one of us" proc ::safe::CheckInterp {slave} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {![info exists state] || ![::interp exists $slave]} { return -code error \ "\"$slave\" is not an interpreter managed by ::safe::" @@ -123,7 +125,7 @@ proc ::safe::interpConfigure {args} { # checks for the "-help" option. set Args [::tcl::OptKeyParse ::safe::interpIC $args] CheckInterp $slave - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state return [join [list \ [list -accessPath $state(access_path)] \ @@ -146,7 +148,7 @@ proc ::safe::interpConfigure {args} { return -code error [::tcl::OptFlagUsage $desc $arg] } CheckInterp $slave - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state set item [::tcl::OptCurDesc $desc] set name [::tcl::OptName $item] @@ -187,7 +189,7 @@ proc ::safe::interpConfigure {args} { # create did set Args [::tcl::OptKeyParse ::safe::interpIC $args] CheckInterp $slave - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state # Get the current (and not the default) values of whatever has # not been given: @@ -284,8 +286,10 @@ proc ::safe::InterpCreate { deletehook } { # Create the slave. + # If evaluated in ::safe, the interpreter command for foo is ::foo; + # but for foo::bar is safe::foo::bar. So evaluate in :: instead. if {$slave ne ""} { - ::interp create -safe $slave + namespace eval :: [list ::interp create -safe $slave] } else { # empty argument: generate slave name set slave [::interp create -safe] @@ -338,7 +342,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { Log $slave "Setting accessPath=($access_path) staticsok=$staticsok\ nestedok=$nestedok deletehook=($deletehook)" NOTICE - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state # clear old autopath if it existed # build new one @@ -440,7 +444,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Search for a real directory and returns its virtual Id (including the # "$") proc ::safe::interpFindInAccessPath {slave path} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {![dict exists $state(access_path,remap) $path]} { return -code error "$path not found in access path" @@ -456,7 +460,7 @@ proc ::safe::interpFindInAccessPath {slave path} { proc ::safe::interpAddToAccessPath {slave path} { # first check if the directory is already in there # (inlined interpFindInAccessPath). - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {[dict exists $state(access_path,remap) $path]} { return [dict get $state(access_path,remap) $path] @@ -555,7 +559,7 @@ proc ::safe::InterpInit { # Sync the paths used to search for Tcl modules. This can be done only # now, after tm.tcl was loaded. - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {[llength $state(tm_path_slave)] > 0} { ::interp eval $slave [list \ ::tcl::tm::add {*}[lreverse $state(tm_path_slave)]] @@ -592,7 +596,7 @@ proc ::safe::AddSubDirs {pathList} { proc ::safe::interpDelete {slave} { Log $slave "About to delete" NOTICE - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state # When an interpreter is deleted with [interp delete], any sub-interpreters # are deleted automatically, but this leaves behind their data in the Safe @@ -600,7 +604,7 @@ proc ::safe::interpDelete {slave} { # Safe Base sub-interpreter, so each one is deleted cleanly and not by # the automatic mechanism built into [interp delete]. foreach sub [interp slaves $slave] { - if {[info exists ::safe::S[list $slave $sub]]} { + if {[info exists ::safe::[VarName [list $slave $sub]]]} { ::safe::interpDelete [list $slave $sub] } } @@ -675,7 +679,7 @@ proc ::safe::setLogCmd {args} { # tcl_library to the first token of the virtual path. # proc ::safe::SyncAccessPath {slave} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state set slave_access_path $state(access_path,slave) ::interp eval $slave [list set auto_path $slave_access_path] @@ -702,7 +706,7 @@ proc ::safe::PathToken {n} { # translate virtual path into real path # proc ::safe::TranslatePath {slave path} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state # somehow strip the namespaces 'functionality' out (the danger is that # we would strip valid macintosh "../" queries... : @@ -1021,7 +1025,7 @@ proc ::safe::AliasLoad {slave file args} { # package name (can be empty if file is not). set package [lindex $args 0] - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state # Determine where to load. load use a relative interp path and {} # means self, so we can directly and safely use passed arg. @@ -1083,7 +1087,7 @@ proc ::safe::AliasLoad {slave file args} { # the security here relies on "file dirname" answering the proper # result... needs checking ? proc ::safe::FileInAccessPath {slave file} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state set access_path $state(access_path) if {[file isdirectory $file]} { @@ -1095,14 +1099,14 @@ proc ::safe::FileInAccessPath {slave file} { # potential pathname anomalies. set norm_parent [file normalize $parent] - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {$norm_parent ni $state(access_path,norm)} { return -code error "\"$file\": not in access_path" } } proc ::safe::DirInAccessPath {slave dir} { - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state set access_path $state(access_path) if {[file isfile $dir]} { @@ -1113,7 +1117,7 @@ proc ::safe::DirInAccessPath {slave dir} { # potential pathname anomalies. set norm_dir [file normalize $dir] - namespace upvar ::safe S$slave state + namespace upvar ::safe [VarName $slave] state if {$norm_dir ni $state(access_path,norm)} { return -code error "\"$dir\": not in access_path" } @@ -1154,6 +1158,58 @@ proc ::safe::AliasExeName {slave} { return "" } +# ------------------------------------------------------------------------------ +# Using Interpreter Names with Namespace Qualifiers +# ------------------------------------------------------------------------------ +# (1) We wish to preserve compatibility with existing code, in which Safe Base +# interpreter names have no namespace qualifiers. +# (2) safe::interpCreate and the rest of the Safe Base previously could not +# accept namespace qualifiers in an interpreter name. +# (3) The interp command will accept namespace qualifiers in an interpreter +# name, but accepts distinct interpreters that will have the same command +# name (e.g. foo, ::foo, and :::foo) (bug 66c2e8c974). +# (4) To satisfy these constraints, Safe Base interpreter names will be fully +# qualified namespace names with no excess colons and with the leading "::" +# omitted. +# (5) Trailing "::" implies a namespace tail {}, which interp reads as {{}}. +# Reject such names. +# (6) We could: +# (a) EITHER reject usable but non-compliant names (e.g. excess colons) in +# interpCreate, interpInit; +# (b) OR accept such names and then translate to a compliant name in every +# command. +# The problem with (b) is that the user will expect to use the name with the +# interp command and will find that it is not recognised. +# E.g "interpCreate ::foo" creates interpreter "foo", and the user's name +# "::foo" works with all the Safe Base commands, but "interp eval ::foo" +# fails. +# So we choose (a). +# (7) The command +# namespace upvar ::safe S$slave state +# becomes +# namespace upvar ::safe [VarName $slave] state +# ------------------------------------------------------------------------------ + +proc ::safe::RejectExcessColons {slave} { + set stripped [regsub -all -- {:::*} $slave ::] + if {[string range $stripped end-1 end] eq {::}} { + return -code error {interpreter name must not end in "::"} + } + if {$stripped ne $slave} { + set msg {interpreter name has excess colons in namespace separators} + return -code error $msg + } + if {[string range $stripped 0 1] eq {::}} { + return -code error {interpreter name must not begin "::"} + } + return +} + +proc ::safe::VarName {slave} { + # return S$slave + return S[string map {:: @N @ @A} $slave] +} + proc ::safe::Setup {} { #### # diff --git a/tests/safe.test b/tests/safe.test index 3511625..1415b09 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -362,6 +362,23 @@ test safe-7.3 {check that safe subinterpreters work} { list $g $h [interp eval $j {join {o k} ""}] [safe::interpDelete $i] \ [interp exists $j] [info vars ::safe::S*] } {{} {} ok {} 0 {}} +test safe-7.3.1 {check that safe subinterpreters work with namespace names} -setup { +} -body { + set g [interp slaves] + if {$g ne {}} { + append g { -- residue of an earlier test} + } + set h [info vars ::safe::S*] + if {$h ne {}} { + append h { -- residue of an earlier test} + } + set i [safe::interpCreate foo::bar] + set j [safe::interpCreate [list $i hello::world]] + list $g $h [interp eval $j {join {o k} ""}] \ + [foo::bar eval {hello::world eval {join {o k} ""}}] \ + [safe::interpDelete $i] \ + [interp exists $j] [info vars ::safe::S*] +} -match glob -result {{} {} ok ok {} 0 {}} test safe-7.4 {tests specific path and positive search} -setup { } -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] -- cgit v0.12 From 720183a9af204a0db0d0211ea410609891ebd9d6 Mon Sep 17 00:00:00 2001 From: kjnash Date: Tue, 21 Jul 2020 17:34:03 +0000 Subject: In ::safe::interpFindInAccessPath, ::safe::interpAddToAccessPath, add a check that the interpreter belongs to the Safe Base. Add comments on why this is not done for ::safe::interpDelete. --- library/safe.tcl | 8 +++++++- tests/safe.test | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/safe.tcl b/library/safe.tcl index 6b531be..3e8c2c6 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -444,6 +444,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Search for a real directory and returns its virtual Id (including the # "$") proc ::safe::interpFindInAccessPath {slave path} { + CheckInterp $slave namespace upvar ::safe [VarName $slave] state if {![dict exists $state(access_path,remap) $path]} { @@ -460,6 +461,7 @@ proc ::safe::interpFindInAccessPath {slave path} { proc ::safe::interpAddToAccessPath {slave path} { # first check if the directory is already in there # (inlined interpFindInAccessPath). + CheckInterp $slave namespace upvar ::safe [VarName $slave] state if {[dict exists $state(access_path,remap) $path]} { @@ -591,11 +593,15 @@ proc ::safe::AddSubDirs {pathList} { } # This procedure deletes a safe slave managed by Safe Tcl and cleans up -# associated state: +# associated state. +# - The command will also delete non-Safe-Base interpreters. +# - This is regrettable, but to avoid breaking existing code this should be +# amended at the next major revision by uncommenting "CheckInterp". proc ::safe::interpDelete {slave} { Log $slave "About to delete" NOTICE + # CheckInterp $slave namespace upvar ::safe [VarName $slave] state # When an interpreter is deleted with [interp delete], any sub-interpreters diff --git a/tests/safe.test b/tests/safe.test index 1415b09..f6d1826 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -94,6 +94,8 @@ test safe-2.2 {creating interpreters, should have no aliases} -setup { a aliases } -cleanup { safe::interpDelete a + # This (ab)use of safe::interpDelete to delete non-Safe-Base interpreters + # is regrettable and should be removed at the next major revision. } -result "" test safe-2.3 {creating safe interpreters, should have no unexpected aliases} -setup { catch {safe::interpDelete a} @@ -143,6 +145,8 @@ test safe-4.1 {safe::interpDelete} -setup { } -body { interp create a safe::interpDelete a + # This (ab)use of safe::interpDelete to delete non-Safe-Base interpreters + # is regrettable and should be removed at the next major revision. } -result "" test safe-4.2 {safe::interpDelete, indirectly} -setup { catch {safe::interpDelete a} @@ -150,6 +154,8 @@ test safe-4.2 {safe::interpDelete, indirectly} -setup { interp create a a alias exit safe::interpDelete a a eval exit + # This (ab)use of safe::interpDelete to delete non-Safe-Base interpreters + # is regrettable and should be removed at the next major revision. } -result "" test safe-4.5 {safe::interpDelete} -setup { catch {safe::interpDelete a} -- cgit v0.12 From 7f6ef9991b5e56cb237fd047aa75c1c012014a3a Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 22 Jul 2020 19:07:30 +0000 Subject: Whitespace changes only. --- tests/safe.test | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index f6d1826..bcb33d7 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -285,7 +285,6 @@ test safe-5.6 {example modules packages, test in master interpreter, append to p catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} - # test safe interps 'information leak' proc SafeEval {script} { # Helper procedure that ensures the safe interp is cleaned up even if @@ -317,7 +316,7 @@ rename SafeEval {} # leaking infos, but they still do... # high level general test -# Use example packages not http1.0 +# Use example packages not http1.0 etc test safe-7.1 {tests that everything works at high level} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -1012,7 +1011,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ [lsort [list $path3 $path4 $path5]] -- $modsB -- \ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 @@ -1079,7 +1078,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ [lsort [list $path3 $path4 $path5]] -- $modsB -- \ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 @@ -1543,7 +1542,7 @@ test safe-15.1 {safe file ensemble does not surprise code} -setup { unset -nocomplain msg interp delete $i } -result {1 {a b c} 1 {a b c} 1 {invalid command name "file"} 1 0 {a b c} 1 {not allowed to invoke subcommand isdirectory of file}} -test safe-15.1.1 {safe file ensemble does not surprise code} -setup { +test safe-15.2 {safe file ensemble does not surprise code} -setup { set i [interp create -safe] } -body { set result [expr {"file" in [interp hidden $i]}] @@ -1659,12 +1658,11 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup unset user } -result {~USER} +# cleanup set ::auto_path $SaveAutoPath unset SaveAutoPath TestsDir PathMapp rename mapList {} rename mapAndSortList {} - -# cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 9684712f82b11fe000a70daea51504e068baba80 Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 22 Jul 2020 19:26:32 +0000 Subject: Whitespace and comment changes only. --- tests/safe-zipfs.test | 4 ++-- tests/safe.test | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/safe-zipfs.test b/tests/safe-zipfs.test index 1f110d1..ed473ca 100644 --- a/tests/safe-zipfs.test +++ b/tests/safe-zipfs.test @@ -170,7 +170,7 @@ test safe-zipfs-5.6 {example modules packages, test in master interpreter, appen } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} # high level general test -# Use zipped example packages not tcl8.x/opt +# Use zipped example packages not http1.0 etc test safe-zipfs-7.1 {tests that everything works at high level; zipfs} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $ZipMountPoint auto0] @@ -715,12 +715,12 @@ test safe-zipfs-9.24 {interpConfigure change the access path; check module loadi res0 res1 res2} # See comments on lsort after test safe-zipfs-9.20. +# cleanup set ::auto_path $SaveAutoPath zipfs unmount ${ZipMountPoint} unset SaveAutoPath TestsDir ZipMountPoint PathMapp rename mapList {} rename mapAndSortList {} -# cleanup ::tcltest::cleanupTests return diff --git a/tests/safe.test b/tests/safe.test index f196d97..3dd965e 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -284,7 +284,6 @@ test safe-5.6 {example modules packages, test in master interpreter, append to p catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} - # test safe interps 'information leak' proc SafeEval {script} { # Helper procedure that ensures the safe interp is cleaned up even if @@ -316,7 +315,7 @@ rename SafeEval {} # leaking infos, but they still do... # high level general test -# Use example packages not http1.0 +# Use example packages not http1.0 etc test safe-7.1 {tests that everything works at high level} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] @@ -1011,7 +1010,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ [lsort [list $path3 $path4 $path5]] -- $modsB -- \ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 @@ -1078,7 +1077,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st set out1 [interp eval $i {mod1::test1::try1}] set out2 [interp eval $i {mod2::test2::try2}] - list [lsort [list $path0 $path1 $path2]] -- $modsA --\ + list [lsort [list $path0 $path1 $path2]] -- $modsA -- \ [lsort [list $path3 $path4 $path5]] -- $modsB -- \ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \ $out0 $out1 $out2 @@ -1654,11 +1653,11 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup unset user } -result {~USER} +# cleanup set ::auto_path $SaveAutoPath unset SaveAutoPath TestsDir PathMapp rename mapList {} rename mapAndSortList {} -# cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 0e59966ac59400d43816bc360c74e5b9dfb49493 Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 23 Jul 2020 13:26:02 +0000 Subject: Improvements to removal of stale package data - bugfix for 1f63efa537 and 319e438f7f --- library/safe.tcl | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index 3e8c2c6..1c46978 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -219,7 +219,7 @@ proc ::safe::interpConfigure {args} { set deleteHook $state(cleanupHook) } # we can now reconfigure : - set slave_tm_rel [InterpSetConfig $slave $accessPath $statics $nested $deleteHook] + InterpSetConfig $slave $accessPath $statics $nested $deleteHook # auto_reset the slave (to completly synch the new access_path) if {$doreset} { if {[catch {::interp eval $slave {auto_reset}} msg]} { @@ -235,19 +235,18 @@ proc ::safe::interpConfigure {args} { ::tcl::tm::add {*}[lreverse $state(tm_path_slave)]] } - # Wherever possible, refresh package/module data. - # - Ideally [package ifneeded $pkg $ver {}] would clear the - # stale data from the interpreter, but instead it sets a - # nonsense empty script. - # - We cannot purge stale package data, but we can overwrite - # it where we have fresh data. Any remaining stale data will - # do no harm but the error messages may be cryptic. - ::interp eval $slave [list catch {package require NOEXIST}] - foreach rel $slave_tm_rel { - set cmd [list package require [string map {/ ::} $rel]::NOEXIST] - ::interp eval $slave [list catch $cmd] + # Remove stale "package ifneeded" data for non-loaded packages. + # - Not for loaded packages, because "package forget" erases + # data from "package provide" as well as "package ifneeded". + # - This is OK because the script cannot reload any version of + # the package unless it first does "package forget". + foreach pkg [::interp eval $slave {package names}] { + if {[::interp eval $slave [list package provide $pkg]] eq ""} { + ::interp eval $slave [list package forget $pkg] + } } } + return } } } @@ -356,8 +355,6 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { set map_access_path {} set remap_access_path {} set slave_tm_path {} - set slave_tm_roots {} - set slave_tm_rel {} set i 0 foreach dir $access_path { @@ -384,7 +381,6 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Later passes handle subdirectories, which belong in the # access path but not in the module path. lappend slave_tm_path [dict get $remap_access_path $dir] - lappend slave_tm_roots [file normalize $dir] [file normalize $dir] } continue } @@ -400,7 +396,6 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # Later passes handle subdirectories, which belong in the # access path but not in the module path. lappend slave_tm_path $token - lappend slave_tm_roots [file normalize $dir] [file normalize $dir] } incr i @@ -410,16 +405,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # 'platform::shell', which translate into # 'platform/shell-X.tm', i.e arbitrarily deep # subdirectories. - set next [glob -nocomplain -directory $dir -type d *] - lappend morepaths {*}$next - foreach sub $next { - lappend slave_tm_roots [file normalize $sub] [dict get $slave_tm_roots $dir] - set lenny [string length [dict get $slave_tm_roots $dir]] - set relpath [string range [file normalize $sub] $lenny+1 end] - if {$relpath ni $slave_tm_rel} { - lappend slave_tm_rel $relpath - } - } + lappend morepaths {*}[glob -nocomplain -directory $dir -type d *] } set firstpass 0 } @@ -435,7 +421,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { set state(cleanupHook) $deletehook SyncAccessPath $slave - return $slave_tm_rel + return } # -- cgit v0.12 -- cgit v0.12 From cc21b0be2ad2d9c16af8d9dbdf188110479ebfc7 Mon Sep 17 00:00:00 2001 From: kjnash Date: Wed, 12 Aug 2020 09:20:56 +0000 Subject: Bugfixes to the earlier fix of bug cb0373bb33, which broke HTTP/1.0 transactions in which the server indicates neither a Content-Length nor that it will close the socket on completion ("Connection: close"). The HTTP/1.1 rule is that the response header "Connection", if absent, must default to "keep-alive"; but this rule does not apply to HTTP/1.0. Add test http11-3.4 and bump version to 2.9.4. --- library/http/http.tcl | 40 ++++++++++++++++++++++++++++------------ library/http/pkgIndex.tcl | 2 +- tests/http11.test | 27 +++++++++++++++++++++++++++ tests/httpd11.tcl | 13 +++++++++++-- unix/Makefile.in | 4 ++-- win/Makefile.in | 4 ++-- 6 files changed, 71 insertions(+), 19 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index f9ec8ca..8b5d686 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -11,7 +11,7 @@ package require Tcl 8.6- # Keep this in sync with pkgIndex.tcl and with the install directories in # Makefiles -package provide http 2.9.3 +package provide http 2.9.4 namespace eval http { # Allow resourcing to not clobber existing data @@ -966,6 +966,18 @@ proc http::geturl {url args} { set state(-pipeline) $http(-pipeline) } + # We cannot handle chunked encodings with -handler, so force HTTP/1.0 + # until we can manage this. + if {[info exists state(-handler)]} { + set state(-protocol) 1.0 + } + + # RFC 7320 A.1 - HTTP/1.0 Keep-Alive is problematic. We do not support it. + if {$state(-protocol) eq "1.0"} { + set state(connection) close + set state(-keepalive) 0 + } + # See if we are supposed to use a previously opened channel. # - In principle, ANY call to http::geturl could use a previously opened # channel if it is available - the "Connection: keep-alive" header is a @@ -1338,11 +1350,6 @@ proc http::Connected {token proto phost srvurl} { if {[info exists state(-method)] && ($state(-method) ne "")} { set how $state(-method) } - # We cannot handle chunked encodings with -handler, so force HTTP/1.0 - # until we can manage this. - if {[info exists state(-handler)]} { - set state(-protocol) 1.0 - } set accept_types_seen 0 Log ^B$tk begin sending request - token $token @@ -1361,7 +1368,7 @@ proc http::Connected {token proto phost srvurl} { puts $sock "Host: $host:$port" } puts $sock "User-Agent: $http(-useragent)" - if {($state(-protocol) >= 1.0) && $state(-keepalive)} { + if {($state(-protocol) > 1.0) && $state(-keepalive)} { # Send this header, because a 1.1 server is not compelled to treat # this as the default. puts $sock "Connection: keep-alive" @@ -1369,9 +1376,17 @@ proc http::Connected {token proto phost srvurl} { if {($state(-protocol) > 1.0) && !$state(-keepalive)} { puts $sock "Connection: close" ;# RFC2616 sec 8.1.2.1 } - if {[info exists phost] && ($phost ne "") && $state(-keepalive)} { - puts $sock "Proxy-Connection: Keep-Alive" - } + if {($state(-protocol) < 1.1)} { + # RFC7230 A.1 + # Some server implementations of HTTP/1.0 have a faulty + # implementation of RFC 2068 Keep-Alive. + # Don't leave this to chance. + # For HTTP/1.0 we have already "set state(connection) close" + # and "state(-keepalive) 0". + puts $sock "Connection: close" + } + # RFC7230 A.1 - "clients are encouraged not to send the + # Proxy-Connection header field in any requests" set accept_encoding_seen 0 set content_type_seen 0 dict for {key value} $state(-headers) { @@ -2702,15 +2717,16 @@ proc http::Event {sock token} { # therefore "keep-alive". set tmpHeader keep-alive } else { - set tmpHeader keep-alive + set tmpResult keep-alive set tmpCsl [split $tmpHeader ,] # Optional whitespace either side of separator. foreach el $tmpCsl { if {[string trim $el] eq {close}} { - set tmpHeader close + set tmpResult close break } } + set tmpHeader $tmpResult } set state(connection) $tmpHeader } diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl index 43cd86b..1cc8f46 100644 --- a/library/http/pkgIndex.tcl +++ b/library/http/pkgIndex.tcl @@ -1,2 +1,2 @@ if {![package vsatisfies [package provide Tcl] 8.6-]} {return} -package ifneeded http 2.9.3 [list tclPkgSetup $dir http 2.9.3 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] +package ifneeded http 2.9.4 [list tclPkgSetup $dir http 2.9.4 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] diff --git a/tests/http11.test b/tests/http11.test index 762788e..240bfef 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -626,6 +626,33 @@ test http11-3.3 "-handler,keepalive,chunked" -setup { halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} +# http11-3.4 +# This test is a blatant attempt to confuse the client by instructing the server +# to send neither "Connection: close" nor "Content-Length" when in non-chunked +# mode. +# The client has no way to know the response-body is complete unless the +# server signals this by closing the connection. +# In an HTTP/1.1 response the absence of "Connection: close" means +# "Connection: keep-alive", i.e. the server will keep the connection +# open. In HTTP/1.0 this is not the case, and this is a test that +# the Tcl client assumes "Connection: close" by default in HTTP/1.0. +test http11-3.4 "-handler,close,identity; HTTP/1.0 server does not send Connection: close header or Content-Length" -setup { + variable httpd [create_httpd] + set testdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1&nosendclose=any \ + -timeout 10000 -handler [namespace code [list handler testdata]]] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length $testdata]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain testdata + halt_httpd +} -result {ok {HTTP/1.0 200 OK} ok {} {} {} 0} + test http11-4.0 "normal post request" -setup { variable httpd [create_httpd] } -body { diff --git a/tests/httpd11.tcl b/tests/httpd11.tcl index 7880494..0b02319 100644 --- a/tests/httpd11.tcl +++ b/tests/httpd11.tcl @@ -170,14 +170,19 @@ proc Service {chan addr port} { set close 1 } + set nosendclose 0 foreach pair [split $query &] { if {[scan $pair {%[^=]=%s} key val] != 2} {set val ""} switch -exact -- $key { + nosendclose {set nosendclose 1} close {set close 1 ; set transfer 0} transfer {set transfer $val} content-type {set type $val} } } + if {$protocol eq "HTTP/1.1"} { + set nosendclose 0 + } chan configure $chan -buffering line -encoding iso8859-1 -translation crlf Puts $chan "$protocol $code" @@ -186,12 +191,16 @@ proc Service {chan addr port} { if {$req eq "POST"} { Puts $chan [format "x-query-length: %d" [string length $query]] } - if {$close} { + if {$close && (!$nosendclose)} { Puts $chan "connection: close" } Puts $chan "x-requested-encodings: [dict get? $meta accept-encoding]" - if {$encoding eq "identity"} { + if {$encoding eq "identity" && (!$nosendclose)} { Puts $chan "content-length: [string length $data]" + } elseif {$encoding eq "identity"} { + # This is a blatant attempt to confuse the client by sending neither + # "Connection: close" nor "Content-Length" when in non-chunked mode. + # See test http11-3.4. } else { Puts $chan "content-encoding: $encoding" } diff --git a/unix/Makefile.in b/unix/Makefile.in index 3e0dd1e..07ce3b7 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -944,8 +944,8 @@ install-libraries: libraries do \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)/http1.0"; \ done; - @echo "Installing package http 2.9.3 as a Tcl Module"; - @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.3.tm"; + @echo "Installing package http 2.9.4 as a Tcl Module"; + @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.4.tm"; @echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/"; @for i in $(TOP_DIR)/library/opt/*.tcl ; \ do \ diff --git a/win/Makefile.in b/win/Makefile.in index 7c0db47..110f7bf 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -719,8 +719,8 @@ install-libraries: libraries install-tzdata install-msgs do \ $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/http1.0"; \ done; - @echo "Installing package http 2.9.3 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.3.tm"; + @echo "Installing package http 2.9.4 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.4.tm"; @echo "Installing library opt0.4 directory"; @for j in $(ROOT_DIR)/library/opt/*.tcl; \ do \ -- cgit v0.12 From f78ef1eea29afd567e722620db2fbfe19400a154 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 21 Aug 2020 12:28:26 +0000 Subject: Fix [43b434812a]: Tcl 9.0 uses stat64() but not struct stat64 on Linux i686 --- generic/tcl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generic/tcl.h b/generic/tcl.h index d6de75d..1da4df8 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -325,6 +325,8 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; struct {long long tv_sec;} st_mtim; struct {long long tv_sec;} st_ctim; } Tcl_StatBuf; +#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) + typedef struct stat64 Tcl_StatBuf; #else typedef struct stat Tcl_StatBuf; #endif -- cgit v0.12 From 591c90cd3e7e44d16dc721a6b3d7a66c6746c2eb Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 21 Aug 2020 13:59:13 +0000 Subject: Suppress tests that fail starting with OSX Mojave. --- tests/socket.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/socket.test b/tests/socket.test index 3544dd9..469367a 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -199,6 +199,8 @@ if {[testConstraint doTestsWithRemoteServer]} { } } +testConstraint notOSX [string compare $::tcl_platform(os) Darwin] + test socket-1.1 {arg parsing for socket command} {socket} { list [catch {socket -server} msg] $msg } {1 {no argument given for -server option}} @@ -816,7 +818,7 @@ test socket-4.2 {byte order problems, socket numbers, htons} {socket} { } ok test socket-5.1 {byte order problems, socket numbers, htons} \ - {socket unix notRoot} { + {socket unix notRoot notOSX} { set x {couldn't open socket: not owner} if {![catch {socket -server dodo 0x1} msg]} { set x {htons problem, should be disallowed, are you running as SU?} @@ -833,7 +835,7 @@ test socket-5.2 {byte order problems, socket numbers, htons} {socket} { set x } {couldn't open socket: port number too high} test socket-5.3 {byte order problems, socket numbers, htons} \ - {socket unix notRoot} { + {socket unix notRoot notOSX} { set x {couldn't open socket: not owner} if {![catch {socket -server dodo 21} msg]} { set x {htons problem, should be disallowed, are you running as SU?} -- cgit v0.12 From b2d5b24a704988578dfaa93e7cead7428be9ccbc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Aug 2020 07:57:04 +0000 Subject: Upgrade Travis build from bionic to focal --- .travis.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05c2f6a..dd86769 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,48 +14,48 @@ jobs: # Testing on Linux with various compilers - name: "Linux/GCC/Shared" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - name: "Linux/GCC/Shared: UTF_MAX=4" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT=CFLAGS=-DTCL_UTF_MAX=4 - name: "Linux/GCC/Shared: UTF_MAX=5" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT=CFLAGS=-DTCL_UTF_MAX=5 - name: "Linux/GCC/Shared: UTF_MAX=6" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT=CFLAGS=-DTCL_UTF_MAX=6 - name: "Linux/GCC/Static" os: linux - dist: bionic + dist: focal compiler: gcc env: - CFGOPT="--disable-shared" - BUILD_DIR=unix - name: "Linux/GCC/Debug" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" - name: "Linux/GCC/Mem-Debug" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix @@ -63,7 +63,7 @@ jobs: # Older versions of GCC... - name: "Linux/GCC 7/Shared" os: linux - dist: bionic + dist: focal compiler: gcc-7 addons: apt: @@ -75,7 +75,7 @@ jobs: - BUILD_DIR=unix - name: "Linux/GCC 6/Shared" os: linux - dist: bionic + dist: focal compiler: gcc-6 addons: apt: @@ -87,7 +87,7 @@ jobs: - BUILD_DIR=unix - name: "Linux/GCC 5/Shared" os: linux - dist: bionic + dist: focal compiler: gcc-5 addons: apt: @@ -100,27 +100,27 @@ jobs: # Clang - name: "Linux/Clang/Shared" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - name: "Linux/Clang/Static" os: linux - dist: bionic + dist: focal compiler: clang env: - CFGOPT="--disable-shared" - BUILD_DIR=unix - name: "Linux/Clang/Debug" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" - name: "Linux/Clang/Mem-Debug" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix @@ -174,7 +174,7 @@ jobs: # Doesn't run tests because wine is only an imperfect Windows emulation - name: "Linux-cross-Windows/GCC/Shared/no test" os: linux - dist: bionic + dist: focal compiler: x86_64-w64-mingw32-gcc env: - BUILD_DIR=win @@ -188,7 +188,7 @@ jobs: # Doesn't run tests because wine is only an imperfect Windows emulation - name: "Linux-cross-Windows-32/GCC/Shared/no test" os: linux - dist: bionic + dist: focal compiler: i686-w64-mingw32-gcc env: - BUILD_DIR=win -- cgit v0.12 From 5f4ef0229dcf7281043e2ece43b807f55ae0c461 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Aug 2020 10:19:49 +0000 Subject: Backport improvemenets in .gitignore .fossil-settings/ignore-glob and win/nmakehlp.c --- .fossil-settings/ignore-glob | 4 ++ .gitignore | 3 + win/nmakehlp.c | 131 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 13 deletions(-) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index eca9bcd..651d616 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -1,9 +1,12 @@ *.a *.dll *.dylib +*.dylib.E *.exe *.exp +*.la *.lib +*.lo *.o *.obj *.pdb @@ -61,4 +64,5 @@ win/*.manifest win/pkgs/* win/coffbase.txt win/tcl.hpj +win/nmakehlp.out win/nmhlp-out.txt diff --git a/.gitignore b/.gitignore index 701419b..33579cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.bundle *.dll *.dylib +*.dylib.E *.exe *.exp *.lib @@ -14,6 +15,7 @@ .fslckout Makefile Tcl-Info.plist +Tclsh-Info.plist autom4te.cache config.cache config.log @@ -59,4 +61,5 @@ win/*.manifest win/pkgs/* win/coffbase.txt win/tcl.hpj +win/nmakehlp.out win/nmhlp-out.txt diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 821d00b..7536ede 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -14,13 +14,8 @@ #define _CRT_SECURE_NO_DEPRECATE #include -#define NO_SHLWAPI_GDI -#define NO_SHLWAPI_STREAM -#define NO_SHLWAPI_REG -#include #pragma comment (lib, "user32.lib") #pragma comment (lib, "kernel32.lib") -#pragma comment (lib, "shlwapi.lib") #include #include @@ -46,6 +41,7 @@ static int CheckForLinkerFeature(const char **options, int count); static int IsIn(const char *string, const char *substring); static int SubstituteFile(const char *substs, const char *filename); static int QualifyPath(const char *path); +static int LocateDependency(const char *keyfile); static const char *GetVersionFromFile(const char *filename, const char *match, int numdots); static DWORD WINAPI ReadFromPipe(LPVOID args); @@ -171,6 +167,18 @@ main( return 2; } return QualifyPath(argv[2]); + + case 'L': + if (argc != 3) { + chars = snprintf(msg, sizeof(msg) - 1, + "usage: %s -L keypath\n" + "Emit the fully qualified path of directory containing keypath\n" + "exitcodes: 0 == success, 1 == not found, 2 == error\n", argv[0]); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, + &dwWritten, NULL); + return 2; + } + return LocateDependency(argv[2]); } } chars = snprintf(msg, sizeof(msg) - 1, @@ -635,7 +643,7 @@ SubstituteFile( } /* debug: dump the list */ -#ifdef _DEBUG +#ifndef NDEBUG { int n = 0; list_item_t *p = NULL; @@ -675,6 +683,17 @@ SubstituteFile( return 0; } +BOOL FileExists(LPCTSTR szPath) +{ +#ifndef INVALID_FILE_ATTRIBUTES + #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +#endif + DWORD pathAttr = GetFileAttributes(szPath); + return (pathAttr != INVALID_FILE_ATTRIBUTES && + !(pathAttr & FILE_ATTRIBUTE_DIRECTORY)); +} + + /* * QualifyPath -- * @@ -688,18 +707,104 @@ QualifyPath( const char *szPath) { char szCwd[MAX_PATH + 1]; - char szTmp[MAX_PATH + 1]; - char *p; - GetCurrentDirectory(MAX_PATH, szCwd); - while ((p = strchr(szPath, '/')) && *p) - *p = '\\'; - PathCombine(szTmp, szCwd, szPath); - PathCanonicalize(szCwd, szTmp); + + GetFullPathName(szPath, sizeof(szCwd)-1, szCwd, NULL); printf("%s\n", szCwd); return 0; } /* + * Implements LocateDependency for a single directory. See that command + * for an explanation. + * Returns 0 if found after printing the directory. + * Returns 1 if not found but no errors. + * Returns 2 on any kind of error + * Basically, these are used as exit codes for the process. + */ +static int LocateDependencyHelper(const char *dir, const char *keypath) +{ + HANDLE hSearch; + char path[MAX_PATH+1]; + int dirlen, keylen, ret; + WIN32_FIND_DATA finfo; + + if (dir == NULL || keypath == NULL) + return 2; /* Have no real error reporting mechanism into nmake */ + dirlen = strlen(dir); + if ((dirlen + 3) > sizeof(path)) + return 2; + strncpy(path, dir, dirlen); + strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ + keylen = strlen(keypath); + +#if 0 /* This function is not available in Visual C++ 6 */ + /* + * Use numerics 0 -> FindExInfoStandard, + * 1 -> FindExSearchLimitToDirectories, + * as these are not defined in Visual C++ 6 + */ + hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0); +#else + hSearch = FindFirstFile(path, &finfo); +#endif + if (hSearch == INVALID_HANDLE_VALUE) + return 1; /* Not found */ + + /* Loop through all subdirs checking if the keypath is under there */ + ret = 1; /* Assume not found */ + do { + int sublen; + /* + * We need to check it is a directory despite the + * FindExSearchLimitToDirectories in the above call. See SDK docs + */ + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + continue; + sublen = strlen(finfo.cFileName); + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + continue; /* Path does not fit, assume not matched */ + strncpy(path+dirlen+1, finfo.cFileName, sublen); + path[dirlen+1+sublen] = '\\'; + strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); + if (FileExists(path)) { + /* Found a match, print to stdout */ + path[dirlen+1+sublen] = '\0'; + QualifyPath(path); + ret = 0; + break; + } + } while (FindNextFile(hSearch, &finfo)); + FindClose(hSearch); + return ret; +} + +/* + * LocateDependency -- + * + * Locates a dependency for a package. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. + * The search path for the package directory is currently only + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. + */ +static int LocateDependency(const char *keypath) +{ + int i, ret; + static const char *paths[] = {"..", "..\\..", "..\\..\\.."}; + + for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { + ret = LocateDependencyHelper(paths[i], keypath); + if (ret == 0) + return ret; + } + return ret; +} + + +/* * Local variables: * mode: c * c-basic-offset: 4 -- cgit v0.12 -- cgit v0.12 From 06a30a3a2acfa22ae71c137e7abb28e61748f496 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 24 Aug 2020 14:28:22 +0000 Subject: Fix for http bug c2dc1da315. Add tests. Add detail about -handler to http(n). Bump version to 2.9.5. --- doc/http.n | 4 ++ library/http/http.tcl | 46 +++++++++++- library/http/pkgIndex.tcl | 2 +- tests/http11.test | 178 ++++++++++++++++++++++++++++++++++++++++++++++ unix/Makefile.in | 4 +- win/Makefile.in | 4 +- 6 files changed, 231 insertions(+), 7 deletions(-) diff --git a/doc/http.n b/doc/http.n index e8c8c90..26bf943 100644 --- a/doc/http.n +++ b/doc/http.n @@ -250,6 +250,10 @@ proc httpHandlerCallback {socket token} { return $nbytes } .CE +.PP +The \fBhttp::geturl\fR code for the \fB-handler\fR option is not compatible with either compression or chunked transfer-encoding. If \fB-handler\fR is specified, then to work around these issues \fBhttp::geturl\fR will reduce the HTTP protocol to 1.0, and override the \fB-zip\fR option (i.e. it will not send the header "\fBAccept-Encoding: gzip,deflate,compress\fR"). +.PP +If options \fB-handler\fR and \fB-channel\fR are used together, the handler is responsible for copying the data from the HTTP socket to the specified channel. The name of the channel is available to the handler as element \fB-channel\fR of the token array. .RE .TP \fB\-headers\fR \fIkeyvaluelist\fR diff --git a/library/http/http.tcl b/library/http/http.tcl index 8b5d686..9d3e5ca 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -11,7 +11,7 @@ package require Tcl 8.6- # Keep this in sync with pkgIndex.tcl and with the install directories in # Makefiles -package provide http 2.9.4 +package provide http 2.9.5 namespace eval http { # Allow resourcing to not clobber existing data @@ -1646,9 +1646,51 @@ proc http::ReceiveResponse {token} { Log ^D$tk begin receiving response - token $token coroutine ${token}EventCoroutine http::Event $sock $token - fileevent $sock readable ${token}EventCoroutine + if {[info exists state(-handler)] || [info exists state(-progress)]} { + fileevent $sock readable [list http::EventGateway $sock $token] + } else { + fileevent $sock readable ${token}EventCoroutine + } + return } + +# http::EventGateway +# +# Bug [c2dc1da315]. +# - Recursive launch of the coroutine can occur if a -handler or -progress +# callback is used, and the callback command enters the event loop. +# - To prevent this, the fileevent "binding" is disabled while the +# coroutine is in flight. +# - If a recursive call occurs despite these precautions, it is not +# trapped and discarded here, because it is better to report it as a +# bug. +# - Although this solution is believed to be sufficiently general, it is +# used only if -handler or -progress is specified. In other cases, +# the coroutine is called directly. + +proc http::EventGateway {sock token} { + variable $token + upvar 0 $token state + fileevent $sock readable {} + catch {${token}EventCoroutine} res opts + if {[info commands ${token}EventCoroutine] ne {}} { + # The coroutine can be deleted by completion (a non-yield return), by + # http::Finish (when there is a premature end to the transaction), by + # http::reset or http::cleanup, or if the caller set option -channel + # but not option -handler: in the last case reading from the socket is + # now managed by commands ::http::Copy*, http::ReceiveChunked, and + # http::make-transformation-chunked. + # + # Catch in case the coroutine has closed the socket. + catch {fileevent $sock readable [list http::EventGateway $sock $token]} + } + + # If there was an error, re-throw it. + return -options $opts $res +} + + # http::NextPipelinedWrite # # - Connecting a socket to a token for writing is done by this command and by diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl index 1cc8f46..74c4841 100644 --- a/library/http/pkgIndex.tcl +++ b/library/http/pkgIndex.tcl @@ -1,2 +1,2 @@ if {![package vsatisfies [package provide Tcl] 8.6-]} {return} -package ifneeded http 2.9.4 [list tclPkgSetup $dir http 2.9.4 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] +package ifneeded http 2.9.5 [list tclPkgSetup $dir http 2.9.5 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] diff --git a/tests/http11.test b/tests/http11.test index 240bfef..989b00f 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -280,6 +280,20 @@ test http11-1.13 "normal, 1.1 and keepalive as server default, no zip" -setup { # ------------------------------------------------------------------------- +proc progress {var token total current} { + upvar #0 $var log + set log [list $current $total] + return +} + +proc progressPause {var token total current} { + upvar #0 $var log + set log [list $current $total] + after 100 set ::WaitHere 0 + vwait ::WaitHere + return +} + test http11-2.0 "-channel" -setup { variable httpd [create_httpd] set chan [open [makeFile {} testfile.tmp] wb+] @@ -376,6 +390,58 @@ test http11-2.4 "-channel,encoding identity" -setup { halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {} chunked} +test http11-2.4.1 "-channel,encoding identity with -progress" -setup { + variable httpd [create_httpd] + set chan [open [makeFile {} testfile.tmp] wb+] + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html \ + -timeout 5000 -channel $chan \ + -headers {accept-encoding identity} \ + -progress [namespace code [list progress logdata]]] + + http::wait $tok + seek $chan 0 + set data [read $chan] + list [http::status $tok] [http::code $tok] [check_crc $tok $data]\ + [meta $tok connection] [meta $tok content-encoding]\ + [meta $tok transfer-encoding] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length $data]}] +} -cleanup { + http::cleanup $tok + close $chan + removeFile testfile.tmp + halt_httpd + unset -nocomplain logdata data +} -result {ok {HTTP/1.1 200 OK} ok close {} chunked 0 0} + +test http11-2.4.2 "-channel,encoding identity with -progress progressPause enters event loop" -constraints knownBug -setup { + variable httpd [create_httpd] + set chan [open [makeFile {} testfile.tmp] wb+] + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html \ + -timeout 5000 -channel $chan \ + -headers {accept-encoding identity} \ + -progress [namespace code [list progressPause logdata]]] + + http::wait $tok + seek $chan 0 + set data [read $chan] + list [http::status $tok] [http::code $tok] [check_crc $tok $data]\ + [meta $tok connection] [meta $tok content-encoding]\ + [meta $tok transfer-encoding] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length $data]}] +} -cleanup { + http::cleanup $tok + close $chan + removeFile testfile.tmp + halt_httpd + unset -nocomplain logdata data ::WaitHere +} -result {ok {HTTP/1.1 200 OK} ok close {} chunked 0 0} + test http11-2.5 "-channel,encoding unsupported" -setup { variable httpd [create_httpd] set chan [open [makeFile {} testfile.tmp] wb+] @@ -555,6 +621,16 @@ proc handler {var sock token} { return [string length $chunk] } +proc handlerPause {var sock token} { + upvar #0 $var data + set chunk [read $sock] + append data $chunk + #::http::Log "handler read [string length $chunk] ([chan configure $sock -buffersize])" + after 100 set ::WaitHere 0 + vwait ::WaitHere + return [string length $chunk] +} + test http11-3.0 "-handler,close,identity" -setup { variable httpd [create_httpd] set testdata "" @@ -653,6 +729,108 @@ test http11-3.4 "-handler,close,identity; HTTP/1.0 server does not send Connecti halt_httpd } -result {ok {HTTP/1.0 200 OK} ok {} {} {} 0} +# It is not forbidden for a handler to enter the event loop. +test http11-3.5 "-handler,close,identity as http11-3.0 but handlerPause enters event loop" -setup { + variable httpd [create_httpd] + set testdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \ + -timeout 10000 -handler [namespace code [list handlerPause testdata]]] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length $testdata]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain testdata ::WaitHere + halt_httpd +} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} + +test http11-3.6 "-handler,close,identity as http11-3.0 but with -progress" -setup { + variable httpd [create_httpd] + set testdata "" + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \ + -timeout 10000 -handler [namespace code [list handler testdata]] \ + -progress [namespace code [list progress logdata]]] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length $testdata]}] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length $testdata]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain testdata logdata ::WaitHere + halt_httpd +} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} + +test http11-3.7 "-handler,close,identity as http11-3.0 but with -progress progressPause enters event loop" -setup { + variable httpd [create_httpd] + set testdata "" + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \ + -timeout 10000 -handler [namespace code [list handler testdata]] \ + -progress [namespace code [list progressPause logdata]]] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length $testdata]}] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length $testdata]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain testdata logdata ::WaitHere + halt_httpd +} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} + +test http11-3.8 "close,identity no -handler but with -progress" -setup { + variable httpd [create_httpd] + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \ + -timeout 10000 \ + -progress [namespace code [list progress logdata]] \ + -headers {accept-encoding {}}] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length [http::data $tok]]}] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain logdata ::WaitHere + halt_httpd +} -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} + +test http11-3.9 "close,identity no -handler but with -progress progressPause enters event loop" -setup { + variable httpd [create_httpd] + set logdata "" +} -body { + set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \ + -timeout 10000 \ + -progress [namespace code [list progressPause logdata]] \ + -headers {accept-encoding {}}] + http::wait $tok + list [http::status $tok] [http::code $tok] [check_crc $tok]\ + [meta $tok connection] [meta $tok content-encoding] \ + [meta $tok transfer-encoding] \ + [expr {[file size testdoc.html]-[string length [http::data $tok]]}] \ + [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ + [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] +} -cleanup { + http::cleanup $tok + unset -nocomplain logdata ::WaitHere + halt_httpd +} -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} + test http11-4.0 "normal post request" -setup { variable httpd [create_httpd] } -body { diff --git a/unix/Makefile.in b/unix/Makefile.in index 07ce3b7..87f0844 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -944,8 +944,8 @@ install-libraries: libraries do \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)/http1.0"; \ done; - @echo "Installing package http 2.9.4 as a Tcl Module"; - @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.4.tm"; + @echo "Installing package http 2.9.5 as a Tcl Module"; + @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.5.tm"; @echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/"; @for i in $(TOP_DIR)/library/opt/*.tcl ; \ do \ diff --git a/win/Makefile.in b/win/Makefile.in index 110f7bf..dee6656 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -719,8 +719,8 @@ install-libraries: libraries install-tzdata install-msgs do \ $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/http1.0"; \ done; - @echo "Installing package http 2.9.4 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.4.tm"; + @echo "Installing package http 2.9.5 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/http/http.tcl "$(MODULE_INSTALL_DIR)/8.6/http-2.9.5.tm"; @echo "Installing library opt0.4 directory"; @for j in $(ROOT_DIR)/library/opt/*.tcl; \ do \ -- cgit v0.12 From 171bea3624e84c0fe616ac8bef5d7e8138bdc359 Mon Sep 17 00:00:00 2001 From: kjnash Date: Mon, 24 Aug 2020 14:35:37 +0000 Subject: Try another Travis build --- tests/safe-stock86.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test index 2fbe108..ccfdd3f 100644 --- a/tests/safe-stock86.test +++ b/tests/safe-stock86.test @@ -2,8 +2,8 @@ # # This file contains tests for safe Tcl that were previously in the file # safe.test, and use files and packages of stock Tcl 8.6 to perform the tests. -# These files may be changed or disappear in future revisions of Tcl, for -# example package http 1.0 will be removed from Tcl 8.7. +# These files may be changed or disappear in future revisions of Tcl, +# for example package http 1.0 will be removed from Tcl 8.7. # # The tests are replaced in safe.tcl with tests that use files provided in the # tests directory. Test numbering is for comparison with similar tests in -- cgit v0.12 From 0d23451993cbdb14bcb0cef73c5db4a979a23648 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Aug 2020 09:42:37 +0000 Subject: Keep gcc-5 and gcc-6 builds on "bionic", because "focal" doesn't have these --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd86769..ad3f03a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ jobs: - BUILD_DIR=unix - name: "Linux/GCC 6/Shared" os: linux - dist: focal + dist: bionic compiler: gcc-6 addons: apt: @@ -87,7 +87,7 @@ jobs: - BUILD_DIR=unix - name: "Linux/GCC 5/Shared" os: linux - dist: focal + dist: bionic compiler: gcc-5 addons: apt: -- cgit v0.12 From 7cb8eb7218804199155464c4441c47b8a2fbf677 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Aug 2020 16:09:04 +0000 Subject: Add test-case util-9.59, which demonstrates bug [b5777d3d32] --- tests/util.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/util.test b/tests/util.test index b516a0e..03fa9fe 100644 --- a/tests/util.test +++ b/tests/util.test @@ -818,6 +818,9 @@ test util-9.57 {Tcl_GetIntForIndex} { test util-9.58 {Tcl_GetIntForIndex} -body { string index abcd end--0x8000000000000000 } -result {} +test util-9.59 {Tcl_GetIntForIndex} { + string index abcd 0-0x10000000000000000 +} {} test util-10.1 {Tcl_PrintDouble - rounding} {ieeeFloatingPoint} { convertDouble 0x0000000000000000 -- cgit v0.12 From 43d2fdc86c454dc83a6fe24125d0fd1188cc1bfa Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Aug 2020 14:52:42 +0000 Subject: Testcase chan-io-50.1 still fails sometimes on MacOSX. So put same measures in place as in io-50.1. See: [f586089a2b] --- tests/chanio.test | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 66f4a30..10f3624 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -6380,12 +6380,16 @@ test chan-io-50.1 {testing handler deletion} -setup { set f [open $path(test1) w] chan close $f set f [open $path(test1) r] + variable z not_called + set timer [after 50 lappend z timeout] + testservicemode 0 testchannelevent $f add readable [namespace code { variable z called testchannelevent $f delete 0 }] - variable z not_called - update + testservicemode 1 + vwait z + after cancel $timer set z } -cleanup { chan close $f -- cgit v0.12 From 3b1ca15e0739a1650dbc9c0de1429299326078ee Mon Sep 17 00:00:00 2001 From: kjnash Date: Thu, 27 Aug 2020 15:50:24 +0000 Subject: Provide error message if failed load does not. --- library/safe.tcl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/safe.tcl b/library/safe.tcl index 1c46978..c0a5dc6 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -1068,6 +1068,13 @@ proc ::safe::AliasLoad {slave file args} { try { return [::interp invokehidden $slave load $file $package $target] } on error msg { + # Some packages return no error message. + set msg0 "Load of binary library for package $package failed" + if {$msg eq {}} { + set msg $msg0 + } else { + set msg "$msg0: $msg" + } Log $slave $msg return -code error $msg } -- cgit v0.12 From 953e3ea89962393c4b65866feb0f3d38f4bc8b14 Mon Sep 17 00:00:00 2001 From: kjnash Date: Fri, 28 Aug 2020 01:03:23 +0000 Subject: Update safe.test for new error message. --- library/safe.tcl | 2 +- tests/safe.test | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/safe.tcl b/library/safe.tcl index c0a5dc6..352b302 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -1069,7 +1069,7 @@ proc ::safe::AliasLoad {slave file args} { return [::interp invokehidden $slave load $file $package $target] } on error msg { # Some packages return no error message. - set msg0 "Load of binary library for package $package failed" + set msg0 "load of binary library for package $package failed" if {$msg eq {}} { set msg $msg0 } else { diff --git a/tests/safe.test b/tests/safe.test index bcb33d7..eba6057 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -1167,7 +1167,7 @@ test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup { interp eval $i {load {} Safepkg1} } -returnCodes error -cleanup { safe::interpDelete $i -} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure} +} -result {load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure} test safe-10.1.1 {testing statics loading} -constraints TcltestPackage -setup { set i [safe::interpCreate] } -body { @@ -1176,7 +1176,7 @@ test safe-10.1.1 {testing statics loading} -constraints TcltestPackage -setup { } -returnCodes ok -cleanup { unset -nocomplain m o safe::interpDelete $i -} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure +} -result {load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure invoked from within "load {} Safepkg1" invoked from within @@ -1199,7 +1199,7 @@ test safe-10.4 {testing nested statics loading / -nestedloadok} -constraints Tcl interp eval $i {interp create x; load {} Safepkg1 x} } -returnCodes error -cleanup { safe::interpDelete $i -} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure} +} -result {load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure} test safe-10.4.1 {testing nested statics loading / -nestedloadok} -constraints TcltestPackage -body { set i [safe::interpCreate -nestedloadok] catch {interp eval $i {interp create x; load {} Safepkg1 x}} m o @@ -1207,7 +1207,7 @@ test safe-10.4.1 {testing nested statics loading / -nestedloadok} -constraints T } -returnCodes ok -cleanup { unset -nocomplain m o safe::interpDelete $i -} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure +} -result {load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure invoked from within "load {} Safepkg1 x" invoked from within -- cgit v0.12 From 18dfd2c4666607dc76ff1b647f114b5f7947312f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 28 Aug 2020 10:03:46 +0000 Subject: Missing testConstraint in socket.test --- tests/socket.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/socket.test b/tests/socket.test index 1c1a89d..66a1bf1 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -291,6 +291,9 @@ proc getPort sock { lindex [fconfigure $sock -sockname] 2 } +# Some tests in this file are known to hang *occasionally* on OSX; stop the +# worst offenders. +testConstraint notOSX [expr {$::tcl_platform(os) ne "Darwin"}] # ---------------------------------------------------------------------- -- cgit v0.12 From 4af0efa4cb10780f9c7d391eb66fe1c3367872d2 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 28 Aug 2020 14:02:50 +0000 Subject: tests/regexp.test: added missing test that cover indices if running on string containing multi-byte utf-8 chars (de/ru, byte offsets != char offsets) --- tests/regexp.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/regexp.test b/tests/regexp.test index 362f425..99113ce 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -156,6 +156,10 @@ test regexp-3.7 {getting substrings back from regexp} { set foo 1; set f2 1; set f3 1; set f4 1 list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4 } {1 {1 2} {1 1} {-1 -1} {2 2}} +test regexp-3.8 {-indices by multi-byte utf-8} { + regexp -inline -indices {(\w+)-(\w+)} \ + "gr\u00FC\u00DF-\u043F\u0440\u0438\u0432\u0435\u0442" +} {{0 10} {0 3} {5 10}} test regexp-4.1 {-nocase option to regexp} { regexp -nocase foo abcFOo -- cgit v0.12 From be42098b827423520078e2cb5150275a3a8540e2 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 28 Aug 2020 15:01:23 +0000 Subject: tests/regexp.test: more tests for -indices by multi-byte utf-8 (considering -start position now) --- tests/regexp.test | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/regexp.test b/tests/regexp.test index 99113ce..d2bdf7b 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -156,10 +156,17 @@ test regexp-3.7 {getting substrings back from regexp} { set foo 1; set f2 1; set f3 1; set f4 1 list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4 } {1 {1 2} {1 1} {-1 -1} {2 2}} -test regexp-3.8 {-indices by multi-byte utf-8} { +test regexp-3.8a {-indices by multi-byte utf-8} { regexp -inline -indices {(\w+)-(\w+)} \ "gr\u00FC\u00DF-\u043F\u0440\u0438\u0432\u0435\u0442" } {{0 10} {0 3} {5 10}} +test regexp-3.8b {-indices by multi-byte utf-8, from -start position} { + list\ + [regexp -inline -indices -start 3 {(\w+)-(\w+)} \ + "gr\u00FC\u00DF-\u043F\u0440\u0438\u0432\u0435\u0442"] \ + [regexp -inline -indices -start 4 {(\w+)-(\w+)} \ + "gr\u00FC\u00DF-\u043F\u0440\u0438\u0432\u0435\u0442"] +} {{{3 10} {3 3} {5 10}} {}} test regexp-4.1 {-nocase option to regexp} { regexp -nocase foo abcFOo -- cgit v0.12 From 3b621e98a7961f0e76c85c64d11a24c1d8c68a34 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 30 Aug 2020 14:12:18 +0000 Subject: Disable textcase safe-stock86-7.4, because http 1 is no longer present in the Tcl 8.7 distribution --- tests/safe-stock86.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test index ccfdd3f..72e9d34 100644 --- a/tests/safe-stock86.test +++ b/tests/safe-stock86.test @@ -78,7 +78,8 @@ test safe-stock86-7.2 {tests specific path and interpFind/AddToAccessPath, uses $mappA -- [safe::interpDelete $i] } -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ {TCLLIB */dummy/unixlike/test/path} -- {}} -test safe-stock86-7.4 {tests specific path and positive search, uses http1.0} -body { +# Disable because http 1 is no longer present in the Tcl 8.7 distribution. +test safe-stock86-7.4 {tests specific path and positive search, uses http1.0} -constraints nonPortable -body { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] -- cgit v0.12 From 6c69cf8504626ca091607ff500979c1f738cefb1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 31 Aug 2020 13:12:01 +0000 Subject: opt package: Change comment. 0.4.7 -> 0.4.8. More Master -> Parent and Slave -> Child changes in (internal) library and test-cases --- library/auto.tcl | 2 +- library/clock.tcl | 4 ++-- library/opt/optparse.tcl | 6 +++--- library/opt/pkgIndex.tcl | 2 +- library/package.tcl | 2 +- library/safe.tcl | 14 ++++++------- tests/interp.test | 52 +++++++++++++++++++++++------------------------ tests/opt.test | 2 +- tests/safe-stock86.test | 4 ++-- tests/safe.test | 30 +++++++++++++-------------- tools/checkLibraryDoc.tcl | 1 + tools/tcltk-man2html.tcl | 1 + 12 files changed, 61 insertions(+), 59 deletions(-) diff --git a/library/auto.tcl b/library/auto.tcl index a7a8979..27173df 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -377,7 +377,7 @@ proc auto_mkindex_parser::mkindex {file} { # auto_mkindex_parser::hook command # # Registers a Tcl command to evaluate when initializing the slave interpreter -# used by the mkindex parser. The command is evaluated in the master +# used by the mkindex parser. The command is evaluated in the parent # interpreter, and can use the variable auto_mkindex_parser::parser to get to # the slave diff --git a/library/clock.tcl b/library/clock.tcl index 49dfdbe..2e42a98 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -3304,7 +3304,7 @@ proc ::tcl::clock::LoadTimeZoneFile { fileName } { return } - # Since an unsafe interp uses the [clock] command in the master, this code + # Since an unsafe interp uses the [clock] command in the parent, this code # is security sensitive. Make sure that the path name cannot escape the # given directory. @@ -3344,7 +3344,7 @@ proc ::tcl::clock::LoadTimeZoneFile { fileName } { proc ::tcl::clock::LoadZoneinfoFile { fileName } { variable ZoneinfoPaths - # Since an unsafe interp uses the [clock] command in the master, this code + # Since an unsafe interp uses the [clock] command in the parent, this code # is security sensitive. Make sure that the path name cannot escape the # given directory. diff --git a/library/opt/optparse.tcl b/library/opt/optparse.tcl index c8946fd..1639379 100644 --- a/library/opt/optparse.tcl +++ b/library/opt/optparse.tcl @@ -11,7 +11,7 @@ package require Tcl 8.5- # When this version number changes, update the pkgIndex.tcl file # and the install directory in the Makefiles. -package provide opt 0.4.7 +package provide opt 0.4.8 namespace eval ::tcl { @@ -44,8 +44,8 @@ namespace eval ::tcl { {-intflag 7} {-weirdflag "help string"} {-noStatics "Not ok to load static packages"} - {-nestedloading1 true "OK to load into nested slaves"} - {-nestedloading2 -boolean true "OK to load into nested slaves"} + {-nestedloading1 true "OK to load into nested children"} + {-nestedloading2 -boolean true "OK to load into nested children"} {-libsOK -choice {Tk SybTcl} "List of packages that can be loaded"} {-precision -int 12 "Number of digits of precision"} diff --git a/library/opt/pkgIndex.tcl b/library/opt/pkgIndex.tcl index daf9aa9..23e118c 100644 --- a/library/opt/pkgIndex.tcl +++ b/library/opt/pkgIndex.tcl @@ -9,4 +9,4 @@ # full path name of this file's directory. if {![package vsatisfies [package provide Tcl] 8.5-]} {return} -package ifneeded opt 0.4.7 [list source [file join $dir optparse.tcl]] +package ifneeded opt 0.4.8 [list source [file join $dir optparse.tcl]] diff --git a/library/package.tcl b/library/package.tcl index d6280ae..4a73346 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -237,7 +237,7 @@ proc pkg_mkIndex {args} { $c eval [list set ::tcl::file $file] $c eval [list set ::tcl::direct $direct] - # Download needed procedures into the slave because we've just deleted + # Download needed procedures into the child because we've just deleted # the unknown procedure. This doesn't handle procedures with default # arguments. diff --git a/library/safe.tcl b/library/safe.tcl index 352b302..96177d5 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -2,7 +2,7 @@ # # This file provide a safe loading/sourcing mechanism for safe interpreters. # It implements a virtual path mecanism to hide the real pathnames from the -# slave. It runs in a master interpreter and sets up data structure and +# slave. It runs in a parent interpreter and sets up data structure and # aliases that will be invoked when used from a slave interpreter. # # See the safe.n man page for details. @@ -20,7 +20,7 @@ # # Needed utilities package -package require opt 0.4.7 +package require opt 0.4.8 # Create the safe namespace namespace eval ::safe { @@ -270,7 +270,7 @@ proc ::safe::interpConfigure {args} { # Optional Arguments : # + slave name : if empty, generated name will be used # + access_path: path list controlling where load/source can occur, -# if empty: the master auto_path will be used. +# if empty: the parent auto_path will be used. # + staticsok : flag, if 0 :no static package can be loaded (load {} Xxx) # if 1 :static packages are ok. # + nestedok: flag, if 0 :no loading to sub-sub interps (load xx xx sub) @@ -302,7 +302,7 @@ proc ::safe::InterpCreate { # # InterpSetConfig (was setAccessPath) : # Sets up slave virtual auto_path and corresponding structure within -# the master. Also sets the tcl_library in the slave to be the first +# the parent. Also sets the tcl_library in the slave to be the first # directory in the path. # NB: If you change the path after the slave has been initialized you # probably need to call "auto_reset" in the slave in order that it gets @@ -595,7 +595,7 @@ proc ::safe::interpDelete {slave} { # Base. To clean up properly, we call safe::interpDelete recursively on each # Safe Base sub-interpreter, so each one is deleted cleanly and not by # the automatic mechanism built into [interp delete]. - foreach sub [interp slaves $slave] { + foreach sub [interp children $slave] { if {[info exists ::safe::[VarName [list $slave $sub]]]} { ::safe::interpDelete [list $slave $sub] } @@ -667,7 +667,7 @@ proc ::safe::setLogCmd {args} { # ------------------- END OF PUBLIC METHODS ------------ # -# Sets the slave auto_path to the master recorded value. Also sets +# Sets the slave auto_path to the parent recorded value. Also sets # tcl_library to the first token of the virtual path. # proc ::safe::SyncAccessPath {slave} { @@ -1081,7 +1081,7 @@ proc ::safe::AliasLoad {slave file args} { } # FileInAccessPath raises an error if the file is not found in the list of -# directories contained in the (master side recorded) slave's access path. +# directories contained in the (parent side recorded) slave's access path. # the security here relies on "file dirname" answering the proper # result... needs checking ? diff --git a/tests/interp.test b/tests/interp.test index df94678..3fe8c67 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -22,7 +22,7 @@ testConstraint testinterpdelete [llength [info commands testinterpdelete]] set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source tcl:encoding:dirs tcl:file:atime tcl:file:attributes tcl:file:copy tcl:file:delete tcl:file:dirname tcl:file:executable tcl:file:exists tcl:file:extension tcl:file:isdirectory tcl:file:isfile tcl:file:link tcl:file:lstat tcl:file:mkdir tcl:file:mtime tcl:file:nativename tcl:file:normalize tcl:file:owned tcl:file:readable tcl:file:readlink tcl:file:rename tcl:file:rootname tcl:file:size tcl:file:stat tcl:file:tail tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable unload} -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } @@ -46,8 +46,8 @@ test interp-1.5 {options for interp command} -returnCodes error -body { # test interp-0.6 was removed # test interp-1.6 {options for interp command} -returnCodes error -body { - interp slaves foo bar zop -} -result {wrong # args: should be "interp slaves ?path?"} + interp children foo bar zop +} -result {wrong # args: should be "interp children ?path?"} test interp-1.7 {options for interp command} -returnCodes error -body { interp hello } -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} @@ -120,45 +120,45 @@ test interp-2.13 {correct default when no $path arg is given} -body { interp create -- } -match regexp -result {interp[0-9]+} -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } -# Part 2: Testing "interp slaves" and "interp exists" -test interp-3.1 {testing interp exists and interp slaves} { - interp slaves +# Part 2: Testing "interp children" and "interp exists" +test interp-3.1 {testing interp exists and interp children} { + interp children } "" -test interp-3.2 {testing interp exists and interp slaves} { +test interp-3.2 {testing interp exists and interp children} { interp create a interp exists a } 1 -test interp-3.3 {testing interp exists and interp slaves} { +test interp-3.3 {testing interp exists and interp children} { interp exists nonexistent } 0 -test interp-3.4 {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.5 {testing interp exists and interp slaves} -body { +test interp-3.4 {testing interp exists and interp children} -body { + interp children a b c +} -returnCodes error -result {wrong # args: should be "interp children ?path?"} +test interp-3.5 {testing interp exists and interp children} -body { interp exists a b c } -returnCodes error -result {wrong # args: should be "interp exists ?path?"} -test interp-3.6 {testing interp exists and interp slaves} { +test interp-3.6 {testing interp exists and interp children} { interp exists } 1 -test interp-3.7 {testing interp exists and interp slaves} -setup { +test interp-3.7 {testing interp exists and interp children} -setup { catch {interp create a} } -body { - interp slaves + interp children } -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} -setup { +test interp-3.8 {testing interp exists and interp children} -body { + interp children a b c +} -returnCodes error -result {wrong # args: should be "interp children ?path?"} +test interp-3.9 {testing interp exists and interp children} -setup { catch {interp create a} } -body { interp create {a a2} -safe - expr {"a2" in [interp slaves a]} + expr {"a2" in [interp children a]} } -result 1 -test interp-3.10 {testing interp exists and interp slaves} -setup { +test interp-3.10 {testing interp exists and interp children} -setup { catch {interp create a} catch {interp create {a a2}} } -body { @@ -186,7 +186,7 @@ test interp-4.5 {testing interp delete} { interp create a interp create {a x1} interp delete {a x1} - expr {"x1" in [interp slaves a]} + expr {"x1" in [interp children a]} } 0 test interp-4.6 {testing interp delete} { interp create c1 @@ -203,14 +203,14 @@ test interp-4.8 {testing interp delete} -returnCodes error -body { interp delete {} } -result {cannot delete the current interpreter} -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } # Part 4: Consistency checking - all nondeleted interpreters should be # there: test interp-5.1 {testing consistency} { - interp slaves + interp children } "" test interp-5.2 {testing consistency} { interp exists a @@ -3667,7 +3667,7 @@ test interp-38.8 {interp debug basic setup} -body { # cleanup unset -nocomplain hidden_cmds -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } ::tcltest::cleanupTests diff --git a/tests/opt.test b/tests/opt.test index 14a6e04..7ed25b5 100644 --- a/tests/opt.test +++ b/tests/opt.test @@ -17,7 +17,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { } # the package we are going to test -package require opt 0.4.7 +package require opt 0.4.8 # we are using implementation specifics to test the package diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test index ccfdd3f..3f20d77 100644 --- a/tests/safe-stock86.test +++ b/tests/safe-stock86.test @@ -25,7 +25,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { namespace import -force ::tcltest::* } -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } @@ -56,7 +56,7 @@ test safe-stock86-7.1 {tests that everything works at high level, uses http 2} - set i [safe::interpCreate] # no error shall occur: # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the master) + # package require in a slave works like in the parent) set v [interp eval $i {package require http 2}] # no error shall occur: interp eval $i {http::config} diff --git a/tests/safe.test b/tests/safe.test index eba6057..217200c 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -28,7 +28,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { namespace import -force ::tcltest::* } -foreach i [interp slaves] { +foreach i [interp children] { interp delete $i } @@ -176,7 +176,7 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup { # A replacement test using example files is "safe-9.8". # Tests 5.* test the example files before using them to test safe interpreters. -test safe-5.1 {example tclIndex commands, test in master interpreter} -setup { +test safe-5.1 {example tclIndex commands, test in parent interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] [file join $TestsDir auto0 auto2] } -body { @@ -190,7 +190,7 @@ test safe-5.1 {example tclIndex commands, test in master interpreter} -setup { set ::auto_path $tmpAutoPath auto_reset } -match glob -result {0 ok1 0 ok2} -test safe-5.2 {example tclIndex commands, negative test in master interpreter} -setup { +test safe-5.2 {example tclIndex commands, negative test in parent interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -204,7 +204,7 @@ test safe-5.2 {example tclIndex commands, negative test in master interpreter} - set ::auto_path $tmpAutoPath auto_reset } -match glob -result {1 {invalid command name "report1"} 1 {invalid command name "report2"}} -test safe-5.3 {example pkgIndex.tcl packages, test in master interpreter, child directories} -setup { +test safe-5.3 {example pkgIndex.tcl packages, test in parent interpreter, child directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0] } -body { @@ -221,7 +221,7 @@ test safe-5.3 {example pkgIndex.tcl packages, test in master interpreter, child catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-5.4 {example pkgIndex.tcl packages, test in master interpreter, main directories} -setup { +test safe-5.4 {example pkgIndex.tcl packages, test in parent interpreter, main directories} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] \ [file join $TestsDir auto0 auto2] @@ -239,7 +239,7 @@ test safe-5.4 {example pkgIndex.tcl packages, test in master interpreter, main d catch {rename HeresPackage1 {}} catch {rename HeresPackage2 {}} } -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2} -test safe-5.5 {example modules packages, test in master interpreter, replace path} -setup { +test safe-5.5 {example modules packages, test in parent interpreter, replace path} -setup { set oldTm [tcl::tm::path list] foreach path $oldTm { tcl::tm::path remove $path @@ -265,7 +265,7 @@ test safe-5.5 {example modules packages, test in master interpreter, replace pat catch {namespace delete ::test0} catch {namespace delete ::mod1} } -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2} -test safe-5.6 {example modules packages, test in master interpreter, append to path} -setup { +test safe-5.6 {example modules packages, test in parent interpreter, append to path} -setup { tcl::tm::path add [file join $TestsDir auto0 modules] } -body { # Try to load the modules and run a command from each one. @@ -325,7 +325,7 @@ test safe-7.1 {tests that everything works at high level} -setup { } -body { # no error shall occur: # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the master) + # package require in a child works like in the parent) set v [interp eval $i {package require SafeTestPackage1}] # no error shall occur: interp eval $i {HeresPackage1} @@ -338,9 +338,9 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) + # should add as p* (not p1 if parent has a module path) set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - # should add as p* (not p2 if master has a module path) + # should add as p* (not p2 if parent has a module path) set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]] set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] @@ -354,7 +354,7 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup { 1 {can't find package SafeTestPackage1} --\ {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}} test safe-7.3 {check that safe subinterpreters work} { - set g [interp slaves] + set g [interp children] if {$g ne {}} { append g { -- residue of an earlier test} } @@ -369,7 +369,7 @@ test safe-7.3 {check that safe subinterpreters work} { } {{} {} ok {} 0 {}} test safe-7.3.1 {check that safe subinterpreters work with namespace names} -setup { } -body { - set g [interp slaves] + set g [interp children] if {$g ne {}} { append g { -- residue of an earlier test} } @@ -389,7 +389,7 @@ test safe-7.4 {tests specific path and positive search} -setup { set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] # should not add anything (p0) set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p* (not p1 if master has a module path) + # should add as p* (not p1 if parent has a module path) set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]] set confA [safe::interpConfigure $i] set mappA [mapList $PathMapp [dict get $confA -accessPath]] @@ -902,7 +902,7 @@ test safe-9.20 {check module loading} -setup { 0 0.5 0 1.0 0 2.0 --\ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ TESTSDIR/auto0/modules/mod2} -- res0 res1 res2} -# - The command safe::InterpSetConfig adds the master's [tcl::tm::list] in +# - The command safe::InterpSetConfig adds the parent's [tcl::tm::list] in # tokenized form to the slave's access path, and then adds all the # descendants, discovered recursively by using glob. # - The order of the directories in the list returned by glob is system-dependent, @@ -1514,7 +1514,7 @@ rename buildEnvironment {} rename buildEnvironment2 {} #### Test for the module path -test safe-14.1 {Check that module path is the same as in the master interpreter [Bug 2964715]} -setup { +test safe-14.1 {Check that module path is the same as in the parent interpreter [Bug 2964715]} -setup { set i [safe::interpCreate] } -body { set tm {} diff --git a/tools/checkLibraryDoc.tcl b/tools/checkLibraryDoc.tcl index 6d147ac..d560b98 100755 --- a/tools/checkLibraryDoc.tcl +++ b/tools/checkLibraryDoc.tcl @@ -69,6 +69,7 @@ set StructList { Tk_GeomMgr \ Tk_Image \ Tk_ImageMaster \ + Tk_ImageModel \ Tk_ImageType \ Tk_Item \ Tk_ItemType \ diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index d607905..a7231f7 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -557,6 +557,7 @@ array set remap_link_target { Tk_Font Tk_GetFont Tk_Image Tk_GetImage Tk_ImageMaster Tk_GetImage + Tk_ImageModel Tk_GetImage Tk_ItemType Tk_CreateItemType Tk_Justify Tk_GetJustify Ttk_Theme Ttk_GetTheme -- cgit v0.12 From 6b0b7154f13dc5d47830ef1daaea80c791504f8a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 1 Sep 2020 09:11:28 +0000 Subject: Eliminate eol-spacing --- tools/encoding/Makefile | 12 ++++++------ tools/encoding/big5.txt | 14 +++++++------- tools/encoding/jis0212.txt | 4 ++-- tools/encoding/ksc5601.txt | 6 +++--- tools/encoding/macCentEuro.txt | 2 +- tools/encoding/macCroatian.txt | 2 +- tools/encoding/macCyrillic.txt | 2 +- tools/encoding/macGreek.txt | 2 +- tools/encoding/macIceland.txt | 2 +- tools/encoding/macRoman.txt | 2 +- tools/encoding/macTurkish.txt | 2 +- tools/encoding/shiftjis.txt | 2 +- tools/encoding/tis-620.txt | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/encoding/Makefile b/tools/encoding/Makefile index 4c10673..361239e 100644 --- a/tools/encoding/Makefile +++ b/tools/encoding/Makefile @@ -1,5 +1,5 @@ # -# This file is a Makefile to compile all the encoding files. +# This file is a Makefile to compile all the encoding files. # # Run "make" to compile all the encoding files (*.txt,*.esc) into the # format that Tcl can use (*.enc). It is your responsibility to move the @@ -26,16 +26,16 @@ # specifically excludes the right to re-distribute this file directly # to third parties or other organizations whether for profit or not. # -# In other words: Don't put this file on the Internet. People who want to +# In other words: Don't put this file on the Internet. People who want to # get it over the Internet should do so directly from ftp://unicode.org. They # can therefore be assured of getting the most recent and accurate version. # #---------------------------------------------------------------------------- # # The txt2enc program built by this makefile is used to compile individual -# .txt files into .enc files, the format that Tcl understands for encoding +# .txt files into .enc files, the format that Tcl understands for encoding # files. This compilation to a different format is allowed by the above -# restriction. +# restriction. # # The files shiftjis.txt and jis0208.txt were modified from the original # ones provided on the Unicode CD. The double-width backslash character @@ -53,7 +53,7 @@ # SCCS: @(#) Makefile 1.1 98/01/28 11:41:36 # -EUC_ENCODINGS = euc-cn.txt euc-kr.txt euc-jp.txt +EUC_ENCODINGS = euc-cn.txt euc-kr.txt euc-jp.txt encodings: clean txt2enc $(EUC_ENCODINGS) @echo Compiling encoding files. @@ -69,7 +69,7 @@ encodings: clean txt2enc $(EUC_ENCODINGS) echo $$enc; \ ./txt2enc -e 0 -u 1 $$p > $$enc; \ done - @echo + @echo @echo Compiling special versions of encoding files. @for p in ascii.txt; do \ enc=`echo $$p | sed 's/\..*$$/\.enc/'`; \ diff --git a/tools/encoding/big5.txt b/tools/encoding/big5.txt index 5cc9e81..f21484a 100644 --- a/tools/encoding/big5.txt +++ b/tools/encoding/big5.txt @@ -41,7 +41,7 @@ # BIG5 characters map into Unicode. # # WARNING! It is currently impossible to provide round-trip compatibility -# between BIG5 and Unicode. +# between BIG5 and Unicode. # # A number of characters are not currently mapped because # of conflicts with other mappings. They are as follows: @@ -58,8 +58,8 @@ # # We currently map all of these characters to U+FFFD REPLACEMENT CHARACTER. # It is also possible to map these characters to their duplicates, or to -# the user zone. -# +# the user zone. +# # Notes: # # 1. In addition to the above, there is some uncertainty about the @@ -72,13 +72,13 @@ # 0xA3BC. This character occurs within the Big Five block of tone marks # for bopomofo and is intended to be the tone mark for the first tone in # Mandarin Chinese. We have selected the mapping U+02C9 MODIFIER LETTER -# MACRON (Mandarin Chinese first tone) to reflect this semantic. +# MACRON (Mandarin Chinese first tone) to reflect this semantic. # However, because bopomofo uses the absense of a tone mark to indicate # the first Mandarin tone, most implementations of Big Five represent # this character with a blank space, and so a mapping such as U+2003 EM SPACE -# might be preferred. -# -# +# might be preferred. +# +# # # Format: Three tab-separated columns # Column #1 is the BIG5 code (in hex as 0xXXXX) diff --git a/tools/encoding/jis0212.txt b/tools/encoding/jis0212.txt index b6d4cb2..316d28e 100644 --- a/tools/encoding/jis0212.txt +++ b/tools/encoding/jis0212.txt @@ -61,7 +61,7 @@ # # 1. JIS X 0212 apparently unified the following two symbols # into a single character at 0x2922: -# +# # LATIN CAPITAL LETTER D WITH STROKE # LATIN CAPITAL LETTER ETH # @@ -71,7 +71,7 @@ # 0x2922 and 0x2942 are intended to be a capital/small pair. # Consequently, in the Unicode mapping, 0x2922 is treated as # LATIN CAPITAL LETTER D WITH STROKE. -# +# 0x222F 0x02D8 # BREVE 0x2230 0x02C7 # CARON (Mandarin Chinese third tone) 0x2231 0x00B8 # CEDILLA diff --git a/tools/encoding/ksc5601.txt b/tools/encoding/ksc5601.txt index 5c6e7dc..c5a6dd1 100644 --- a/tools/encoding/ksc5601.txt +++ b/tools/encoding/ksc5601.txt @@ -5,7 +5,7 @@ # BUT the mapping table between UHC(Microsoft Unified Hangul Code) # and Unicode 2.0. Hence, in this pacakge, I renamed it as UHC.TXT # -# The Unix command used is +# The Unix command used is # egrep '^0x' < KSC5601.TXT | \ # egrep -v '^0x([8-9]...|A0..|..[4-9].|..A0)' | perl tab.pl # @@ -26,8 +26,8 @@ # Column #3 : the Unicode name (following a comment sign, '#') # The number of characters enumerated in this table is 8824, the # as listed in KS C 5601-987 -# -# +# +# # The entries are in KS C 5601-1987 order # You can use the following algorithms to convert the hex form # of KS C 5601 to other forms diff --git a/tools/encoding/macCentEuro.txt b/tools/encoding/macCentEuro.txt index e6507d6..bf424c1 100644 --- a/tools/encoding/macCentEuro.txt +++ b/tools/encoding/macCentEuro.txt @@ -34,7 +34,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macCroatian.txt b/tools/encoding/macCroatian.txt index 2d66b6d..538eda3 100644 --- a/tools/encoding/macCroatian.txt +++ b/tools/encoding/macCroatian.txt @@ -36,7 +36,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macCyrillic.txt b/tools/encoding/macCyrillic.txt index b58bb83..695dade 100644 --- a/tools/encoding/macCyrillic.txt +++ b/tools/encoding/macCyrillic.txt @@ -37,7 +37,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macGreek.txt b/tools/encoding/macGreek.txt index 28b6ea8..9783259 100644 --- a/tools/encoding/macGreek.txt +++ b/tools/encoding/macGreek.txt @@ -35,7 +35,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macIceland.txt b/tools/encoding/macIceland.txt index d28bd9d..0a0b27b 100644 --- a/tools/encoding/macIceland.txt +++ b/tools/encoding/macIceland.txt @@ -37,7 +37,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macRoman.txt b/tools/encoding/macRoman.txt index 8821f3b..7ddcf8d 100644 --- a/tools/encoding/macRoman.txt +++ b/tools/encoding/macRoman.txt @@ -41,7 +41,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/macTurkish.txt b/tools/encoding/macTurkish.txt index 7b143e0..4a1ddab 100644 --- a/tools/encoding/macTurkish.txt +++ b/tools/encoding/macTurkish.txt @@ -34,7 +34,7 @@ # Apple makes no warranty or representation, either express or # implied, with respect to these tables, their quality, accuracy, or # fitness for a particular purpose. In no event will Apple be liable -# for direct, indirect, special, incidental, or consequential damages +# for direct, indirect, special, incidental, or consequential damages # resulting from any defect or inaccuracy in this document or the # accompanying tables. # diff --git a/tools/encoding/shiftjis.txt b/tools/encoding/shiftjis.txt index 7db99ab..b616f85 100644 --- a/tools/encoding/shiftjis.txt +++ b/tools/encoding/shiftjis.txt @@ -47,7 +47,7 @@ # There is an alternative order some people might be preferred, # where all the entries are in order of the top (or only) byte. # This alternate order can be generated from the one given here -# by a simple sort. +# by a simple sort. # # The kanji mappings are a normative part of ISO/IEC 10646. The # non-kanji mappings are provisional, pending definition of diff --git a/tools/encoding/tis-620.txt b/tools/encoding/tis-620.txt index d3656c5..8243d81 100644 --- a/tools/encoding/tis-620.txt +++ b/tools/encoding/tis-620.txt @@ -176,7 +176,7 @@ 0xA8 0x0E08 #THAI CHARACTER CHO CHAN 0xA9 0x0E09 #THAI CHARACTER CHO CHING 0xAA 0x0E0A #THAI CHARACTER CHO CHANG -0xAB 0x0E0B #THAI CHARACTER SO SO +0xAB 0x0E0B #THAI CHARACTER SO SO 0xAC 0x0E0C #THAI CHARACTER CHO CHOE 0xAD 0x0E0D #THAI CHARACTER YO YING 0xAE 0x0E0E #THAI CHARACTER DO CHADA -- cgit v0.12 From 724de352e37dd0fe795024353378cd662593b4a6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 1 Sep 2020 09:15:11 +0000 Subject: Many more internal master/slave -> parent/child renamings --- generic/regexec.c | 2 +- generic/tclBasic.c | 6 +- generic/tclClock.c | 2 +- generic/tclInterp.c | 1076 +++++++++++++++++++++++----------------------- generic/tclLoad.c | 8 +- generic/tclOO.c | 2 +- generic/tclOOInfo.c | 2 +- generic/tclOOInt.h | 4 +- generic/tclParse.c | 2 +- generic/tclTest.c | 16 +- library/auto.tcl | 12 +- tests/appendComp.test | 6 +- tests/autoMkindex.test | 18 +- tests/basic.test | 28 +- tests/cmdAH.test | 2 +- tests/compExpr.test | 6 +- tests/coroutine.test | 24 +- tests/env.test | 4 +- tests/execute.test | 104 ++--- tests/http.test | 2 +- tests/httpold.test | 2 +- tests/interp.test | 494 ++++++++++----------- tests/io.test | 6 +- tests/ioCmd.test | 4 +- tests/ioTrans.test | 6 +- tests/load.test | 2 +- tests/namespace.test | 92 ++-- tests/oo.test | 32 +- tests/parse.test | 20 +- tests/pkgMkIndex.test | 24 +- tests/proc.test | 12 +- tests/resolver.test | 2 +- tests/safe-stock86.test | 2 +- tests/subst.test | 16 +- tests/tcltest.test | 136 +++--- tests/thread.test | 4 +- tests/timer.test | 12 +- tests/trace.test | 10 +- tests/var.test | 18 +- tools/tcltk-man2html.tcl | 1 + unix/Makefile.in | 6 +- win/rules.vc | 6 +- 42 files changed, 1117 insertions(+), 1116 deletions(-) diff --git a/generic/regexec.c b/generic/regexec.c index f174420..d0d5680 100644 --- a/generic/regexec.c +++ b/generic/regexec.c @@ -73,7 +73,7 @@ struct dfa { chr *lastnopr; /* location of last cache-flushed NOPROGRESS */ struct sset *search; /* replacement-search-pointer memory */ int cptsmalloced; /* were the areas individually malloced? */ - char *mallocarea; /* self, or master malloced area, or NULL */ + char *mallocarea; /* self, or malloced area, or NULL */ }; #define WORK 1 /* number of work bitvectors needed */ diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 124702c..8b3a1b2 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -3444,7 +3444,7 @@ CancelEvalProc( TclSetCancelFlags(iPtr, cancelInfo->flags | CANCELED); /* - * Now, we must set the script cancellation flags on all the slave + * Now, we must set the script cancellation flags on all the child * interpreters belonging to this one. */ @@ -3967,7 +3967,7 @@ TclResetCancellation( * Tcl_Canceled -- * * Check if the script in progress has been canceled, i.e., - * Tcl_CancelEval was called for this interpreter or any of its master + * Tcl_CancelEval was called for this interpreter or any of its parent * interpreters. * * Results: @@ -5047,7 +5047,7 @@ TclEvalEx( * the embedded command, which is refered to * by 'script'. The 'clNextOuter' refers to * the current entry in the table of - * continuation lines in this "master script", + * continuation lines in this "main script", * and the character offsets are relative to * the 'outerScript' as well. * diff --git a/generic/tclClock.c b/generic/tclClock.c index 01058f5..f02e219 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -263,7 +263,7 @@ TclClockInit( }; /* - * Safe interps get [::clock] as alias to a master, so do not need their + * Safe interps get [::clock] as alias to a parent, so do not need their * own copies of the support routines. */ diff --git a/generic/tclInterp.c b/generic/tclInterp.c index a222cae..80c2534 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -27,34 +27,34 @@ struct Target; /* * struct Alias: * - * Stores information about an alias. Is stored in the slave interpreter and - * used by the source command to find the target command in the master when + * Stores information about an alias. Is stored in the child interpreter and + * used by the source command to find the target command in the parent when * the source command is invoked. */ typedef struct Alias { - Tcl_Obj *token; /* Token for the alias command in the slave + Tcl_Obj *token; /* Token for the alias command in the child * interp. This used to be the command name in - * the slave when the alias was first + * the child when the alias was first * created. */ Tcl_Interp *targetInterp; /* Interp in which target command will be * invoked. */ - Tcl_Command slaveCmd; /* Source command in slave interpreter, bound + Tcl_Command childCmd; /* Source command in child interpreter, bound * to command that invokes the target command * in the target interpreter. */ Tcl_HashEntry *aliasEntryPtr; - /* Entry for the alias hash table in slave. + /* Entry for the alias hash table in child. * This is used by alias deletion to remove - * the alias from the slave interpreter alias + * the alias from the child interpreter alias * table. */ - struct Target *targetPtr; /* Entry for target command in master. This is - * used in the master interpreter to map back + struct Target *targetPtr; /* Entry for target command in parent. This is + * used in the parent interpreter to map back * from the target command to aliases * redirecting to it. */ int objc; /* Count of Tcl_Obj in the prefix of the * target command to be invoked in the target * interpreter. Additional arguments specified - * when calling the alias in the slave interp + * when calling the alias in the child interp * will be appended to the prefix before the * command is invoked. */ Tcl_Obj *objPtr; /* The first actual prefix object - the target @@ -66,45 +66,45 @@ typedef struct Alias { /* * - * struct Slave: + * struct Child: * - * Used by the "interp" command to record and find information about slave - * interpreters. Maps from a command name in the master to information about a - * slave interpreter, e.g. what aliases are defined in it. + * Used by the "interp" command to record and find information about child + * interpreters. Maps from a command name in the parent to information about a + * child interpreter, e.g. what aliases are defined in it. */ -typedef struct Slave { - Tcl_Interp *masterInterp; /* Master interpreter for this slave. */ - Tcl_HashEntry *slaveEntryPtr; - /* Hash entry in masters slave table for this - * slave interpreter. Used to find this - * record, and used when deleting the slave - * interpreter to delete it from the master's +typedef struct Child { + Tcl_Interp *parentInterp; /* Parent interpreter for this child. */ + Tcl_HashEntry *childEntryPtr; + /* Hash entry in parents child table for this + * child interpreter. Used to find this + * record, and used when deleting the child + * interpreter to delete it from the parent's * table. */ - Tcl_Interp *slaveInterp; /* The slave interpreter. */ + Tcl_Interp *childInterp; /* The child interpreter. */ Tcl_Command interpCmd; /* Interpreter object command. */ Tcl_HashTable aliasTable; /* Table which maps from names of commands in - * slave interpreter to struct Alias defined + * child interpreter to struct Alias defined * below. */ -} Slave; +} Child; /* * struct Target: * - * Maps from master interpreter commands back to the source commands in slave + * Maps from parent interpreter commands back to the source commands in child * interpreters. This is needed because aliases can be created between sibling * interpreters and must be deleted when the target interpreter is deleted. In * case they would not be deleted the source interpreter would be left with a - * "dangling pointer". One such record is stored in the Master record of the - * master interpreter with the master for each alias which directs to a - * command in the master. These records are used to remove the source command - * for an from a slave if/when the master is deleted. They are organized in a - * doubly-linked list attached to the master interpreter. + * "dangling pointer". One such record is stored in the Parent record of the + * parent interpreter with the parent for each alias which directs to a + * command in the parent. These records are used to remove the source command + * for an from a child if/when the parent is deleted. They are organized in a + * doubly-linked list attached to the parent interpreter. */ typedef struct Target { - Tcl_Command slaveCmd; /* Command for alias in slave interp. */ - Tcl_Interp *slaveInterp; /* Slave Interpreter. */ + Tcl_Command childCmd; /* Command for alias in child interp. */ + Tcl_Interp *childInterp; /* Child Interpreter. */ struct Target *nextPtr; /* Next in list of target records, or NULL if * at the end of the list of targets. */ struct Target *prevPtr; /* Previous in list of target records, or NULL @@ -112,43 +112,43 @@ typedef struct Target { } Target; /* - * struct Master: + * struct Parent: * - * This record is used for two purposes: First, slaveTable (a hashtable) maps - * from names of commands to slave interpreters. This hashtable is used to - * store information about slave interpreters of this interpreter, to map over - * all slaves, etc. The second purpose is to store information about all - * aliases in slaves (or siblings) which direct to target commands in this + * This record is used for two purposes: First, childTable (a hashtable) maps + * from names of commands to child interpreters. This hashtable is used to + * store information about child interpreters of this interpreter, to map over + * all children, etc. The second purpose is to store information about all + * aliases in children (or siblings) which direct to target commands in this * interpreter (using the targetsPtr doubly-linked list). * * NB: the flags field in the interp structure, used with SAFE_INTERP mask * denotes whether the interpreter is safe or not. Safe interpreters have - * restricted functionality, can only create safe slave interpreters and can + * restricted functionality, can only create safe child interpreters and can * only load safe extensions. */ -typedef struct Master { - Tcl_HashTable slaveTable; /* Hash table for slave interpreters. Maps - * from command names to Slave records. */ +typedef struct Parent { + Tcl_HashTable childTable; /* Hash table for child interpreters. Maps + * from command names to Child records. */ Target *targetsPtr; /* The head of a doubly-linked list of all the * target records which denote aliases from - * slaves or sibling interpreters that direct + * children or sibling interpreters that direct * to commands in this interpreter. This list * is used to remove dangling pointers from - * the slave (or sibling) interpreters when + * the child (or sibling) interpreters when * this interpreter is deleted. */ -} Master; +} Parent; /* - * The following structure keeps track of all the Master and Slave information + * The following structure keeps track of all the Parent and Child information * on a per-interp basis. */ typedef struct InterpInfo { - Master master; /* Keeps track of all interps for which this - * interp is the Master. */ - Slave slave; /* Information necessary for this interp to - * function as a slave. */ + Parent parent; /* Keeps track of all interps for which this + * interp is the Parent. */ + Child child; /* Information necessary for this interp to + * function as a child. */ } InterpInfo; /* @@ -214,14 +214,14 @@ struct LimitHandler { */ static int AliasCreate(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, Tcl_Interp *masterInterp, + Tcl_Interp *childInterp, Tcl_Interp *parentInterp, Tcl_Obj *namePtr, Tcl_Obj *targetPtr, int objc, Tcl_Obj *const objv[]); static int AliasDelete(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, Tcl_Obj *namePtr); + Tcl_Interp *childInterp, Tcl_Obj *namePtr); static int AliasDescribe(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, Tcl_Obj *objPtr); -static int AliasList(Tcl_Interp *interp, Tcl_Interp *slaveInterp); + Tcl_Interp *childInterp, Tcl_Obj *objPtr); +static int AliasList(Tcl_Interp *interp, Tcl_Interp *childInterp); static int AliasObjCmd(ClientData dummy, Tcl_Interp *currentInterp, int objc, Tcl_Obj *const objv[]); @@ -234,43 +234,43 @@ static Tcl_Interp * GetInterp2(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void InterpInfoDeleteProc(ClientData clientData, Tcl_Interp *interp); -static int SlaveBgerror(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, int objc, +static int ChildBgerror(Tcl_Interp *interp, + Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static Tcl_Interp * SlaveCreate(Tcl_Interp *interp, Tcl_Obj *pathPtr, +static Tcl_Interp * ChildCreate(Tcl_Interp *interp, Tcl_Obj *pathPtr, int safe); -static int SlaveDebugCmd(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, +static int ChildDebugCmd(Tcl_Interp *interp, + Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static int SlaveEval(Tcl_Interp *interp, Tcl_Interp *slaveInterp, +static int ChildEval(Tcl_Interp *interp, Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static int SlaveExpose(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, int objc, +static int ChildExpose(Tcl_Interp *interp, + Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static int SlaveHide(Tcl_Interp *interp, Tcl_Interp *slaveInterp, +static int ChildHide(Tcl_Interp *interp, Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static int SlaveHidden(Tcl_Interp *interp, - Tcl_Interp *slaveInterp); -static int SlaveInvokeHidden(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, +static int ChildHidden(Tcl_Interp *interp, + Tcl_Interp *childInterp); +static int ChildInvokeHidden(Tcl_Interp *interp, + Tcl_Interp *childInterp, const char *namespaceName, int objc, Tcl_Obj *const objv[]); -static int SlaveMarkTrusted(Tcl_Interp *interp, - Tcl_Interp *slaveInterp); -static int SlaveObjCmd(ClientData dummy, Tcl_Interp *interp, +static int ChildMarkTrusted(Tcl_Interp *interp, + Tcl_Interp *childInterp); +static int ChildObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static void SlaveObjCmdDeleteProc(ClientData clientData); -static int SlaveRecursionLimit(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, int objc, +static void ChildObjCmdDeleteProc(ClientData clientData); +static int ChildRecursionLimit(Tcl_Interp *interp, + Tcl_Interp *childInterp, int objc, Tcl_Obj *const objv[]); -static int SlaveCommandLimitCmd(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, int consumedObjc, +static int ChildCommandLimitCmd(Tcl_Interp *interp, + Tcl_Interp *childInterp, int consumedObjc, int objc, Tcl_Obj *const objv[]); -static int SlaveTimeLimitCmd(Tcl_Interp *interp, - Tcl_Interp *slaveInterp, int consumedObjc, +static int ChildTimeLimitCmd(Tcl_Interp *interp, + Tcl_Interp *childInterp, int consumedObjc, int objc, Tcl_Obj *const objv[]); -static void InheritLimitsFromMaster(Tcl_Interp *slaveInterp, - Tcl_Interp *masterInterp); +static void InheritLimitsFromParent(Tcl_Interp *childInterp, + Tcl_Interp *parentInterp); static void SetScriptLimitCallback(Tcl_Interp *interp, int type, Tcl_Interp *targetInterp, Tcl_Obj *scriptObj); static void CallScriptLimitCallback(ClientData clientData, @@ -283,7 +283,7 @@ static void TimeLimitCallback(ClientData clientData); /* NRE enabling */ static Tcl_NRPostProc NRPostInvokeHidden; static Tcl_ObjCmdProc NRInterpCmd; -static Tcl_ObjCmdProc NRSlaveCmd; +static Tcl_ObjCmdProc NRChildCmd; /* @@ -452,7 +452,7 @@ Tcl_Init( * * TclInterpInit -- * - * Initializes the invoking interpreter for using the master, slave and + * Initializes the invoking interpreter for using the parent, child and * safe interp facilities. This is called from inside Tcl_CreateInterp(). * * Results: @@ -470,22 +470,22 @@ TclInterpInit( Tcl_Interp *interp) /* Interpreter to initialize. */ { InterpInfo *interpInfoPtr; - Master *masterPtr; - Slave *slavePtr; + Parent *parentPtr; + Child *childPtr; interpInfoPtr = ckalloc(sizeof(InterpInfo)); ((Interp *) interp)->interpInfo = interpInfoPtr; - masterPtr = &interpInfoPtr->master; - Tcl_InitHashTable(&masterPtr->slaveTable, TCL_STRING_KEYS); - masterPtr->targetsPtr = NULL; + parentPtr = &interpInfoPtr->parent; + Tcl_InitHashTable(&parentPtr->childTable, TCL_STRING_KEYS); + parentPtr->targetsPtr = NULL; - slavePtr = &interpInfoPtr->slave; - slavePtr->masterInterp = NULL; - slavePtr->slaveEntryPtr = NULL; - slavePtr->slaveInterp = interp; - slavePtr->interpCmd = NULL; - Tcl_InitHashTable(&slavePtr->aliasTable, TCL_STRING_KEYS); + childPtr = &interpInfoPtr->child; + childPtr->parentInterp = NULL; + childPtr->childEntryPtr = NULL; + childPtr->childInterp = interp; + childPtr->interpCmd = NULL; + Tcl_InitHashTable(&childPtr->aliasTable, TCL_STRING_KEYS); Tcl_NRCreateCommand(interp, "interp", Tcl_InterpObjCmd, NRInterpCmd, NULL, NULL); @@ -500,7 +500,7 @@ TclInterpInit( * InterpInfoDeleteProc -- * * Invoked when an interpreter is being deleted. It releases all storage - * used by the master/slave/safe interpreter facilities. + * used by the parent/child/safe interpreter facilities. * * Results: * None. @@ -515,11 +515,11 @@ static void InterpInfoDeleteProc( ClientData clientData, /* Ignored. */ Tcl_Interp *interp) /* Interp being deleted. All commands for - * slave interps should already be deleted. */ + * child interps should already be deleted. */ { InterpInfo *interpInfoPtr; - Slave *slavePtr; - Master *masterPtr; + Child *childPtr; + Parent *parentPtr; Target *targetPtr; interpInfoPtr = (InterpInfo *) ((Interp *) interp)->interpInfo; @@ -528,11 +528,11 @@ InterpInfoDeleteProc( * There shouldn't be any commands left. */ - masterPtr = &interpInfoPtr->master; - if (masterPtr->slaveTable.numEntries != 0) { + parentPtr = &interpInfoPtr->parent; + if (parentPtr->childTable.numEntries != 0) { Tcl_Panic("InterpInfoDeleteProc: still exist commands"); } - Tcl_DeleteHashTable(&masterPtr->slaveTable); + Tcl_DeleteHashTable(&parentPtr->childTable); /* * Tell any interps that have aliases to this interp that they should @@ -540,35 +540,35 @@ InterpInfoDeleteProc( * have removed the target record already. */ - for (targetPtr = masterPtr->targetsPtr; targetPtr != NULL; ) { + for (targetPtr = parentPtr->targetsPtr; targetPtr != NULL; ) { Target *tmpPtr = targetPtr->nextPtr; - Tcl_DeleteCommandFromToken(targetPtr->slaveInterp, - targetPtr->slaveCmd); + Tcl_DeleteCommandFromToken(targetPtr->childInterp, + targetPtr->childCmd); targetPtr = tmpPtr; } - slavePtr = &interpInfoPtr->slave; - if (slavePtr->interpCmd != NULL) { + childPtr = &interpInfoPtr->child; + if (childPtr->interpCmd != NULL) { /* * Tcl_DeleteInterp() was called on this interpreter, rather "interp - * delete" or the equivalent deletion of the command in the master. + * delete" or the equivalent deletion of the command in the parent. * First ensure that the cleanup callback doesn't try to delete the * interp again. */ - slavePtr->slaveInterp = NULL; - Tcl_DeleteCommandFromToken(slavePtr->masterInterp, - slavePtr->interpCmd); + childPtr->childInterp = NULL; + Tcl_DeleteCommandFromToken(childPtr->parentInterp, + childPtr->interpCmd); } /* * There shouldn't be any aliases left. */ - if (slavePtr->aliasTable.numEntries != 0) { + if (childPtr->aliasTable.numEntries != 0) { Tcl_Panic("InterpInfoDeleteProc: still exist aliases"); } - Tcl_DeleteHashTable(&slavePtr->aliasTable); + Tcl_DeleteHashTable(&childPtr->aliasTable); ckfree(interpInfoPtr); } @@ -607,7 +607,7 @@ NRInterpCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tcl_Interp *slaveInterp; + Tcl_Interp *childInterp; int index; static const char *const options[] = { "alias", "aliases", "bgerror", "cancel", @@ -637,7 +637,7 @@ NRInterpCmd( } switch ((enum option) index) { case OPT_ALIAS: { - Tcl_Interp *masterInterp; + Tcl_Interp *parentInterp; if (objc < 4) { aliasArgs: @@ -645,43 +645,43 @@ NRInterpCmd( "slavePath slaveCmd ?masterPath masterCmd? ?arg ...?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } if (objc == 4) { - return AliasDescribe(interp, slaveInterp, objv[3]); + return AliasDescribe(interp, childInterp, objv[3]); } if ((objc == 5) && (TclGetString(objv[4])[0] == '\0')) { - return AliasDelete(interp, slaveInterp, objv[3]); + return AliasDelete(interp, childInterp, objv[3]); } if (objc > 5) { - masterInterp = GetInterp(interp, objv[4]); - if (masterInterp == NULL) { + parentInterp = GetInterp(interp, objv[4]); + if (parentInterp == NULL) { return TCL_ERROR; } - return AliasCreate(interp, slaveInterp, masterInterp, objv[3], + return AliasCreate(interp, childInterp, parentInterp, objv[3], objv[5], objc - 6, objv + 6); } goto aliasArgs; } case OPT_ALIASES: - slaveInterp = GetInterp2(interp, objc, objv); - if (slaveInterp == NULL) { + childInterp = GetInterp2(interp, objc, objv); + if (childInterp == NULL) { return TCL_ERROR; } - return AliasList(interp, slaveInterp); + return AliasList(interp, childInterp); case OPT_BGERROR: if (objc != 3 && objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "path ?cmdPrefix?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveBgerror(interp, slaveInterp, objc - 3, objv + 3); + return ChildBgerror(interp, childInterp, objc - 3, objv + 3); case OPT_CANCEL: { int i, flags; Tcl_Obj *resultObjPtr; @@ -725,18 +725,18 @@ NRInterpCmd( } /* - * Did they specify a slave interp to cancel the script in progress + * Did they specify a child interp to cancel the script in progress * in? If not, use the current interp. */ if (i < objc) { - slaveInterp = GetInterp(interp, objv[i]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[i]); + if (childInterp == NULL) { return TCL_ERROR; } i++; } else { - slaveInterp = interp; + childInterp = interp; } if (i < objc) { @@ -752,11 +752,11 @@ NRInterpCmd( resultObjPtr = NULL; } - return Tcl_CancelEval(slaveInterp, resultObjPtr, 0, flags); + return Tcl_CancelEval(childInterp, resultObjPtr, 0, flags); } case OPT_CREATE: { int i, last, safe; - Tcl_Obj *slavePtr; + Tcl_Obj *childPtr; char buf[16 + TCL_INTEGER_SPACE]; static const char *const createOptions[] = { "-safe", "--", NULL @@ -771,7 +771,7 @@ NRInterpCmd( * Weird historical rules: "-safe" is accepted at the end, too. */ - slavePtr = NULL; + childPtr = NULL; last = 0; for (i = 2; i < objc; i++) { if ((last == 0) && (Tcl_GetString(objv[i])[0] == '-')) { @@ -786,21 +786,21 @@ NRInterpCmd( i++; last = 1; } - if (slavePtr != NULL) { + if (childPtr != NULL) { Tcl_WrongNumArgs(interp, 2, objv, "?-safe? ?--? ?path?"); return TCL_ERROR; } if (i < objc) { - slavePtr = objv[i]; + childPtr = objv[i]; } } buf[0] = '\0'; - if (slavePtr == NULL) { + if (childPtr == NULL) { /* * Create an anonymous interpreter -- we choose its name and the * name of the command. We check that the command name that we use * for the interpreter does not collide with an existing command - * in the master interpreter. + * in the parent interpreter. */ for (i = 0; ; i++) { @@ -811,15 +811,15 @@ NRInterpCmd( break; } } - slavePtr = Tcl_NewStringObj(buf, -1); + childPtr = Tcl_NewStringObj(buf, -1); } - if (SlaveCreate(interp, slavePtr, safe) == NULL) { + if (ChildCreate(interp, childPtr, safe) == NULL) { if (buf[0] != '\0') { - Tcl_DecrRefCount(slavePtr); + Tcl_DecrRefCount(childPtr); } return TCL_ERROR; } - Tcl_SetObjResult(interp, slavePtr); + Tcl_SetObjResult(interp, childPtr); return TCL_OK; } case OPT_DEBUG: /* TIP #378 */ @@ -831,29 +831,29 @@ NRInterpCmd( Tcl_WrongNumArgs(interp, 2, objv, "path ?-frame ?bool??"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveDebugCmd(interp, slaveInterp, objc - 3, objv + 3); + return ChildDebugCmd(interp, childInterp, objc - 3, objv + 3); case OPT_DELETE: { int i; InterpInfo *iiPtr; for (i = 2; i < objc; i++) { - slaveInterp = GetInterp(interp, objv[i]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[i]); + if (childInterp == NULL) { return TCL_ERROR; - } else if (slaveInterp == interp) { + } else if (childInterp == interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "cannot delete the current interpreter", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "DELETESELF", NULL); return TCL_ERROR; } - iiPtr = (InterpInfo *) ((Interp *) slaveInterp)->interpInfo; - Tcl_DeleteCommandFromToken(iiPtr->slave.masterInterp, - iiPtr->slave.interpCmd); + iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo; + Tcl_DeleteCommandFromToken(iiPtr->child.parentInterp, + iiPtr->child.interpCmd); } return TCL_OK; } @@ -862,16 +862,16 @@ NRInterpCmd( Tcl_WrongNumArgs(interp, 2, objv, "path arg ?arg ...?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveEval(interp, slaveInterp, objc - 3, objv + 3); + return ChildEval(interp, childInterp, objc - 3, objv + 3); case OPT_EXISTS: { int exists = 1; - slaveInterp = GetInterp2(interp, objc, objv); - if (slaveInterp == NULL) { + childInterp = GetInterp2(interp, objc, objv); + if (childInterp == NULL) { if (objc > 3) { return TCL_ERROR; } @@ -886,33 +886,33 @@ NRInterpCmd( Tcl_WrongNumArgs(interp, 2, objv, "path hiddenCmdName ?cmdName?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveExpose(interp, slaveInterp, objc - 3, objv + 3); + return ChildExpose(interp, childInterp, objc - 3, objv + 3); case OPT_HIDE: if ((objc < 4) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "path cmdName ?hiddenCmdName?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveHide(interp, slaveInterp, objc - 3, objv + 3); + return ChildHide(interp, childInterp, objc - 3, objv + 3); case OPT_HIDDEN: - slaveInterp = GetInterp2(interp, objc, objv); - if (slaveInterp == NULL) { + childInterp = GetInterp2(interp, objc, objv); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveHidden(interp, slaveInterp); + return ChildHidden(interp, childInterp); case OPT_ISSAFE: - slaveInterp = GetInterp2(interp, objc, objv); - if (slaveInterp == NULL) { + childInterp = GetInterp2(interp, objc, objv); + if (childInterp == NULL) { return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(Tcl_IsSafe(slaveInterp))); + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(Tcl_IsSafe(childInterp))); return TCL_OK; case OPT_INVOKEHID: { int i; @@ -951,11 +951,11 @@ NRInterpCmd( "path ?-namespace ns? ?-global? ?--? cmd ?arg ..?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveInvokeHidden(interp, slaveInterp, namespaceName, objc - i, + return ChildInvokeHidden(interp, childInterp, namespaceName, objc - i, objv + i); } case OPT_LIMIT: { @@ -972,8 +972,8 @@ NRInterpCmd( "path limitType ?-option value ...?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[3], limitTypes, "limit type", 0, @@ -982,9 +982,9 @@ NRInterpCmd( } switch ((enum LimitTypes) limitType) { case LIMIT_TYPE_COMMANDS: - return SlaveCommandLimitCmd(interp, slaveInterp, 4, objc,objv); + return ChildCommandLimitCmd(interp, childInterp, 4, objc,objv); case LIMIT_TYPE_TIME: - return SlaveTimeLimitCmd(interp, slaveInterp, 4, objc, objv); + return ChildTimeLimitCmd(interp, childInterp, 4, objc, objv); } } break; @@ -993,21 +993,21 @@ NRInterpCmd( Tcl_WrongNumArgs(interp, 2, objv, "path"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveMarkTrusted(interp, slaveInterp); + return ChildMarkTrusted(interp, childInterp); case OPT_RECLIMIT: if (objc != 3 && objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "path ?newlimit?"); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } - return SlaveRecursionLimit(interp, slaveInterp, objc - 3, objv + 3); + return ChildRecursionLimit(interp, childInterp, objc - 3, objv + 3); case OPT_CHILDREN: case OPT_SLAVES: { InterpInfo *iiPtr; @@ -1016,15 +1016,15 @@ NRInterpCmd( Tcl_HashSearch hashSearch; char *string; - slaveInterp = GetInterp2(interp, objc, objv); - if (slaveInterp == NULL) { + childInterp = GetInterp2(interp, objc, objv); + if (childInterp == NULL) { return TCL_ERROR; } - iiPtr = (InterpInfo *) ((Interp *) slaveInterp)->interpInfo; + iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo; resultPtr = Tcl_NewObj(); - hPtr = Tcl_FirstHashEntry(&iiPtr->master.slaveTable, &hashSearch); + hPtr = Tcl_FirstHashEntry(&iiPtr->parent.childTable, &hashSearch); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hashSearch)) { - string = Tcl_GetHashKey(&iiPtr->master.slaveTable, hPtr); + string = Tcl_GetHashKey(&iiPtr->parent.childTable, hPtr); Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(string, -1)); } @@ -1033,35 +1033,35 @@ NRInterpCmd( } case OPT_TRANSFER: case OPT_SHARE: { - Tcl_Interp *masterInterp; /* The master of the slave. */ + Tcl_Interp *parentInterp; /* The parent of the child. */ Tcl_Channel chan; if (objc != 5) { Tcl_WrongNumArgs(interp, 2, objv, "srcPath channelId destPath"); return TCL_ERROR; } - masterInterp = GetInterp(interp, objv[2]); - if (masterInterp == NULL) { + parentInterp = GetInterp(interp, objv[2]); + if (parentInterp == NULL) { return TCL_ERROR; } - chan = Tcl_GetChannel(masterInterp, TclGetString(objv[3]), NULL); + chan = Tcl_GetChannel(parentInterp, TclGetString(objv[3]), NULL); if (chan == NULL) { - Tcl_TransferResult(masterInterp, TCL_OK, interp); + Tcl_TransferResult(parentInterp, TCL_OK, interp); return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[4]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[4]); + if (childInterp == NULL) { return TCL_ERROR; } - Tcl_RegisterChannel(slaveInterp, chan); + Tcl_RegisterChannel(childInterp, chan); if (index == OPT_TRANSFER) { /* * When transferring, as opposed to sharing, we must unhitch the * channel from the interpreter where it started. */ - if (Tcl_UnregisterChannel(masterInterp, chan) != TCL_OK) { - Tcl_TransferResult(masterInterp, TCL_OK, interp); + if (Tcl_UnregisterChannel(parentInterp, chan) != TCL_OK) { + Tcl_TransferResult(parentInterp, TCL_OK, interp); return TCL_ERROR; } } @@ -1078,15 +1078,15 @@ NRInterpCmd( return TCL_ERROR; } - slaveInterp = GetInterp(interp, objv[2]); - if (slaveInterp == NULL) { + childInterp = GetInterp(interp, objv[2]); + if (childInterp == NULL) { return TCL_ERROR; } aliasName = TclGetString(objv[3]); - iiPtr = (InterpInfo *) ((Interp *) slaveInterp)->interpInfo; - hPtr = Tcl_FindHashEntry(&iiPtr->slave.aliasTable, aliasName); + iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo; + hPtr = Tcl_FindHashEntry(&iiPtr->child.aliasTable, aliasName); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "alias \"%s\" in path \"%s\" not found", @@ -1159,46 +1159,46 @@ GetInterp2( * A standard Tcl result. * * Side effects: - * Creates a new alias, manipulates the result field of slaveInterp. + * Creates a new alias, manipulates the result field of childInterp. * *---------------------------------------------------------------------- */ int Tcl_CreateAlias( - Tcl_Interp *slaveInterp, /* Interpreter for source command. */ - const char *slaveCmd, /* Command to install in slave. */ + Tcl_Interp *childInterp, /* Interpreter for source command. */ + const char *childCmd, /* Command to install in child. */ Tcl_Interp *targetInterp, /* Interpreter for target command. */ const char *targetCmd, /* Name of target command. */ int argc, /* How many additional arguments? */ const char *const *argv) /* These are the additional args. */ { - Tcl_Obj *slaveObjPtr, *targetObjPtr; + Tcl_Obj *childObjPtr, *targetObjPtr; Tcl_Obj **objv; int i; int result; - objv = TclStackAlloc(slaveInterp, (unsigned) sizeof(Tcl_Obj *) * argc); + objv = TclStackAlloc(childInterp, (unsigned) sizeof(Tcl_Obj *) * argc); for (i = 0; i < argc; i++) { objv[i] = Tcl_NewStringObj(argv[i], -1); Tcl_IncrRefCount(objv[i]); } - slaveObjPtr = Tcl_NewStringObj(slaveCmd, -1); - Tcl_IncrRefCount(slaveObjPtr); + childObjPtr = Tcl_NewStringObj(childCmd, -1); + Tcl_IncrRefCount(childObjPtr); targetObjPtr = Tcl_NewStringObj(targetCmd, -1); Tcl_IncrRefCount(targetObjPtr); - result = AliasCreate(slaveInterp, slaveInterp, targetInterp, slaveObjPtr, + result = AliasCreate(childInterp, childInterp, targetInterp, childObjPtr, targetObjPtr, argc, objv); for (i = 0; i < argc; i++) { Tcl_DecrRefCount(objv[i]); } - TclStackFree(slaveInterp, objv); + TclStackFree(childInterp, objv); Tcl_DecrRefCount(targetObjPtr); - Tcl_DecrRefCount(slaveObjPtr); + Tcl_DecrRefCount(childObjPtr); return result; } @@ -1221,26 +1221,26 @@ Tcl_CreateAlias( int Tcl_CreateAliasObj( - Tcl_Interp *slaveInterp, /* Interpreter for source command. */ - const char *slaveCmd, /* Command to install in slave. */ + Tcl_Interp *childInterp, /* Interpreter for source command. */ + const char *childCmd, /* Command to install in child. */ Tcl_Interp *targetInterp, /* Interpreter for target command. */ const char *targetCmd, /* Name of target command. */ int objc, /* How many additional arguments? */ Tcl_Obj *const objv[]) /* Argument vector. */ { - Tcl_Obj *slaveObjPtr, *targetObjPtr; + Tcl_Obj *childObjPtr, *targetObjPtr; int result; - slaveObjPtr = Tcl_NewStringObj(slaveCmd, -1); - Tcl_IncrRefCount(slaveObjPtr); + childObjPtr = Tcl_NewStringObj(childCmd, -1); + Tcl_IncrRefCount(childObjPtr); targetObjPtr = Tcl_NewStringObj(targetCmd, -1); Tcl_IncrRefCount(targetObjPtr); - result = AliasCreate(slaveInterp, slaveInterp, targetInterp, slaveObjPtr, + result = AliasCreate(childInterp, childInterp, targetInterp, childObjPtr, targetObjPtr, objc, objv); - Tcl_DecrRefCount(slaveObjPtr); + Tcl_DecrRefCount(childObjPtr); Tcl_DecrRefCount(targetObjPtr); return result; } @@ -1277,7 +1277,7 @@ Tcl_GetAlias( int i, objc; Tcl_Obj **objv; - hPtr = Tcl_FindHashEntry(&iiPtr->slave.aliasTable, aliasName); + hPtr = Tcl_FindHashEntry(&iiPtr->child.aliasTable, aliasName); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "alias \"%s\" not found", aliasName)); @@ -1339,7 +1339,7 @@ Tcl_GetAliasObj( int objc; Tcl_Obj **objv; - hPtr = Tcl_FindHashEntry(&iiPtr->slave.aliasTable, aliasName); + hPtr = Tcl_FindHashEntry(&iiPtr->child.aliasTable, aliasName); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "alias \"%s\" not found", aliasName)); @@ -1426,7 +1426,7 @@ TclPreventAliasLoop( if (Tcl_InterpDeleted(nextAliasPtr->targetInterp)) { /* - * The slave interpreter can be deleted while creating the alias. + * The child interpreter can be deleted while creating the alias. * [Bug #641195] */ @@ -1480,7 +1480,7 @@ TclPreventAliasLoop( * * Side effects: * An alias command is created and entered into the alias table for the - * slave interpreter. + * child interpreter. * *---------------------------------------------------------------------- */ @@ -1488,9 +1488,9 @@ TclPreventAliasLoop( static int AliasCreate( Tcl_Interp *interp, /* Interp for error reporting. */ - Tcl_Interp *slaveInterp, /* Interp where alias cmd will live or from + Tcl_Interp *childInterp, /* Interp where alias cmd will live or from * which alias will be deleted. */ - Tcl_Interp *masterInterp, /* Interp in which target command will be + Tcl_Interp *parentInterp, /* Interp in which target command will be * invoked. */ Tcl_Obj *namePtr, /* Name of alias cmd. */ Tcl_Obj *targetNamePtr, /* Name of target cmd. */ @@ -1500,15 +1500,15 @@ AliasCreate( Alias *aliasPtr; Tcl_HashEntry *hPtr; Target *targetPtr; - Slave *slavePtr; - Master *masterPtr; + Child *childPtr; + Parent *parentPtr; Tcl_Obj **prefv; int isNew, i; aliasPtr = ckalloc(sizeof(Alias) + objc * sizeof(Tcl_Obj *)); aliasPtr->token = namePtr; Tcl_IncrRefCount(aliasPtr->token); - aliasPtr->targetInterp = masterInterp; + aliasPtr->targetInterp = parentInterp; aliasPtr->objc = objc + 1; prefv = &aliasPtr->objPtr; @@ -1520,21 +1520,21 @@ AliasCreate( Tcl_IncrRefCount(objv[i]); } - Tcl_Preserve(slaveInterp); - Tcl_Preserve(masterInterp); + Tcl_Preserve(childInterp); + Tcl_Preserve(parentInterp); - if (slaveInterp == masterInterp) { - aliasPtr->slaveCmd = Tcl_NRCreateCommand(slaveInterp, + if (childInterp == parentInterp) { + aliasPtr->childCmd = Tcl_NRCreateCommand(childInterp, TclGetString(namePtr), AliasObjCmd, AliasNRCmd, aliasPtr, AliasObjCmdDeleteProc); } else { - aliasPtr->slaveCmd = Tcl_CreateObjCommand(slaveInterp, + aliasPtr->childCmd = Tcl_CreateObjCommand(childInterp, TclGetString(namePtr), AliasObjCmd, aliasPtr, AliasObjCmdDeleteProc); } - if (TclPreventAliasLoop(interp, slaveInterp, - aliasPtr->slaveCmd) != TCL_OK) { + if (TclPreventAliasLoop(interp, childInterp, + aliasPtr->childCmd) != TCL_OK) { /* * Found an alias loop! The last call to Tcl_CreateObjCommand made the * alias point to itself. Delete the command and its alias record. Be @@ -1550,11 +1550,11 @@ AliasCreate( Tcl_DecrRefCount(objv[i]); } - cmdPtr = (Command *) aliasPtr->slaveCmd; + cmdPtr = (Command *) aliasPtr->childCmd; cmdPtr->clientData = NULL; cmdPtr->deleteProc = NULL; cmdPtr->deleteData = NULL; - Tcl_DeleteCommandFromToken(slaveInterp, aliasPtr->slaveCmd); + Tcl_DeleteCommandFromToken(childInterp, aliasPtr->childCmd); ckfree(aliasPtr); @@ -1562,8 +1562,8 @@ AliasCreate( * The result was already set by TclPreventAliasLoop. */ - Tcl_Release(slaveInterp); - Tcl_Release(masterInterp); + Tcl_Release(childInterp); + Tcl_Release(parentInterp); return TCL_ERROR; } @@ -1571,13 +1571,13 @@ AliasCreate( * Make an entry in the alias table. If it already exists, retry. */ - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; while (1) { Tcl_Obj *newToken; const char *string; string = TclGetString(aliasPtr->token); - hPtr = Tcl_CreateHashEntry(&slavePtr->aliasTable, string, &isNew); + hPtr = Tcl_CreateHashEntry(&childPtr->aliasTable, string, &isNew); if (isNew != 0) { break; } @@ -1614,22 +1614,22 @@ AliasCreate( */ targetPtr = ckalloc(sizeof(Target)); - targetPtr->slaveCmd = aliasPtr->slaveCmd; - targetPtr->slaveInterp = slaveInterp; + targetPtr->childCmd = aliasPtr->childCmd; + targetPtr->childInterp = childInterp; - masterPtr = &((InterpInfo*) ((Interp*) masterInterp)->interpInfo)->master; - targetPtr->nextPtr = masterPtr->targetsPtr; + parentPtr = &((InterpInfo*) ((Interp*) parentInterp)->interpInfo)->parent; + targetPtr->nextPtr = parentPtr->targetsPtr; targetPtr->prevPtr = NULL; - if (masterPtr->targetsPtr != NULL) { - masterPtr->targetsPtr->prevPtr = targetPtr; + if (parentPtr->targetsPtr != NULL) { + parentPtr->targetsPtr->prevPtr = targetPtr; } - masterPtr->targetsPtr = targetPtr; + parentPtr->targetsPtr = targetPtr; aliasPtr->targetPtr = targetPtr; Tcl_SetObjResult(interp, aliasPtr->token); - Tcl_Release(slaveInterp); - Tcl_Release(masterInterp); + Tcl_Release(childInterp); + Tcl_Release(parentInterp); return TCL_OK; } @@ -1638,13 +1638,13 @@ AliasCreate( * * AliasDelete -- * - * Deletes the given alias from the slave interpreter given. + * Deletes the given alias from the child interpreter given. * * Results: * A standard Tcl result. * * Side effects: - * Deletes the alias from the slave interpreter. + * Deletes the alias from the child interpreter. * *---------------------------------------------------------------------- */ @@ -1652,21 +1652,21 @@ AliasCreate( static int AliasDelete( Tcl_Interp *interp, /* Interpreter for result & errors. */ - Tcl_Interp *slaveInterp, /* Interpreter containing alias. */ + Tcl_Interp *childInterp, /* Interpreter containing alias. */ Tcl_Obj *namePtr) /* Name of alias to delete. */ { - Slave *slavePtr; + Child *childPtr; Alias *aliasPtr; Tcl_HashEntry *hPtr; /* - * If the alias has been renamed in the slave, the master can still use + * If the alias has been renamed in the child, the parent can still use * the original name (with which it was created) to find the alias to * delete it. */ - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; - hPtr = Tcl_FindHashEntry(&slavePtr->aliasTable, TclGetString(namePtr)); + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; + hPtr = Tcl_FindHashEntry(&childPtr->aliasTable, TclGetString(namePtr)); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "alias \"%s\" not found", TclGetString(namePtr))); @@ -1675,7 +1675,7 @@ AliasDelete( return TCL_ERROR; } aliasPtr = Tcl_GetHashValue(hPtr); - Tcl_DeleteCommandFromToken(slaveInterp, aliasPtr->slaveCmd); + Tcl_DeleteCommandFromToken(childInterp, aliasPtr->childCmd); return TCL_OK; } @@ -1700,22 +1700,22 @@ AliasDelete( static int AliasDescribe( Tcl_Interp *interp, /* Interpreter for result & errors. */ - Tcl_Interp *slaveInterp, /* Interpreter containing alias. */ + Tcl_Interp *childInterp, /* Interpreter containing alias. */ Tcl_Obj *namePtr) /* Name of alias to describe. */ { - Slave *slavePtr; + Child *childPtr; Tcl_HashEntry *hPtr; Alias *aliasPtr; Tcl_Obj *prefixPtr; /* - * If the alias has been renamed in the slave, the master can still use + * If the alias has been renamed in the child, the parent can still use * the original name (with which it was created) to find the alias to * describe it. */ - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; - hPtr = Tcl_FindHashEntry(&slavePtr->aliasTable, Tcl_GetString(namePtr)); + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; + hPtr = Tcl_FindHashEntry(&childPtr->aliasTable, Tcl_GetString(namePtr)); if (hPtr == NULL) { return TCL_OK; } @@ -1730,7 +1730,7 @@ AliasDescribe( * * AliasList -- * - * Computes a list of aliases defined in a slave interpreter. + * Computes a list of aliases defined in a child interpreter. * * Results: * A standard Tcl result. @@ -1744,17 +1744,17 @@ AliasDescribe( static int AliasList( Tcl_Interp *interp, /* Interp for data return. */ - Tcl_Interp *slaveInterp) /* Interp whose aliases to compute. */ + Tcl_Interp *childInterp) /* Interp whose aliases to compute. */ { Tcl_HashEntry *entryPtr; Tcl_HashSearch hashSearch; Tcl_Obj *resultPtr = Tcl_NewObj(); Alias *aliasPtr; - Slave *slavePtr; + Child *childPtr; - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; - entryPtr = Tcl_FirstHashEntry(&slavePtr->aliasTable, &hashSearch); + entryPtr = Tcl_FirstHashEntry(&childPtr->aliasTable, &hashSearch); for ( ; entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&hashSearch)) { aliasPtr = Tcl_GetHashValue(entryPtr); Tcl_ListObjAppendElement(NULL, resultPtr, aliasPtr->token); @@ -1768,10 +1768,10 @@ AliasList( * * AliasObjCmd -- * - * This is the function that services invocations of aliases in a slave + * This is the function that services invocations of aliases in a child * interpreter. One such command exists for each alias. When invoked, * this function redirects the invocation to the target command in the - * master interpreter as designated by the Alias record associated with + * parent interpreter as designated by the Alias record associated with * this command. * * Results: @@ -1929,7 +1929,7 @@ AliasObjCmd( * * AliasObjCmdDeleteProc -- * - * Is invoked when an alias command is deleted in a slave. Cleans up all + * Is invoked when an alias command is deleted in a child. Cleans up all * storage associated with this alias. * * Results: @@ -1959,17 +1959,17 @@ AliasObjCmdDeleteProc( Tcl_DeleteHashEntry(aliasPtr->aliasEntryPtr); /* - * Splice the target record out of the target interpreter's master list. + * Splice the target record out of the target interpreter's parent list. */ targetPtr = aliasPtr->targetPtr; if (targetPtr->prevPtr != NULL) { targetPtr->prevPtr->nextPtr = targetPtr->nextPtr; } else { - Master *masterPtr = &((InterpInfo *) ((Interp *) - aliasPtr->targetInterp)->interpInfo)->master; + Parent *parentPtr = &((InterpInfo *) ((Interp *) + aliasPtr->targetInterp)->interpInfo)->parent; - masterPtr->targetsPtr = targetPtr->nextPtr; + parentPtr->targetsPtr = targetPtr->nextPtr; } if (targetPtr->nextPtr != NULL) { targetPtr->nextPtr->prevPtr = targetPtr->prevPtr; @@ -1984,11 +1984,11 @@ AliasObjCmdDeleteProc( * * Tcl_CreateChild -- * - * Creates a slave interpreter. The slavePath argument denotes the name - * of the new slave relative to the current interpreter; the slave is a + * Creates a child interpreter. The childPath argument denotes the name + * of the new child relative to the current interpreter; the child is a * direct descendant of the one-before-last component of the path, - * e.g. it is a descendant of the current interpreter if the slavePath - * argument contains only one component. Optionally makes the slave + * e.g. it is a descendant of the current interpreter if the childPath + * argument contains only one component. Optionally makes the child * interpreter safe. * * Results: @@ -1997,7 +1997,7 @@ AliasObjCmdDeleteProc( * * Side effects: * Creates a new interpreter and a new interpreter object command in the - * interpreter indicated by the slavePath argument. + * interpreter indicated by the childPath argument. * *---------------------------------------------------------------------- */ @@ -2005,17 +2005,17 @@ AliasObjCmdDeleteProc( Tcl_Interp * Tcl_CreateChild( Tcl_Interp *interp, /* Interpreter to start search at. */ - const char *slavePath, /* Name of slave to create. */ - int isSafe) /* Should new slave be "safe" ? */ + const char *childPath, /* Name of child to create. */ + int isSafe) /* Should new child be "safe" ? */ { Tcl_Obj *pathPtr; - Tcl_Interp *slaveInterp; + Tcl_Interp *childInterp; - pathPtr = Tcl_NewStringObj(slavePath, -1); - slaveInterp = SlaveCreate(interp, pathPtr, isSafe); + pathPtr = Tcl_NewStringObj(childPath, -1); + childInterp = ChildCreate(interp, pathPtr, isSafe); Tcl_DecrRefCount(pathPtr); - return slaveInterp; + return childInterp; } /* @@ -2023,7 +2023,7 @@ Tcl_CreateChild( * * Tcl_GetChild -- * - * Finds a slave interpreter by its path name. + * Finds a child interpreter by its path name. * * Results: * Returns a Tcl_Interp * for the named interpreter or NULL if not found. @@ -2037,16 +2037,16 @@ Tcl_CreateChild( Tcl_Interp * Tcl_GetChild( Tcl_Interp *interp, /* Interpreter to start search from. */ - const char *slavePath) /* Path of slave to find. */ + const char *childPath) /* Path of child to find. */ { Tcl_Obj *pathPtr; - Tcl_Interp *slaveInterp; + Tcl_Interp *childInterp; - pathPtr = Tcl_NewStringObj(slavePath, -1); - slaveInterp = GetInterp(interp, pathPtr); + pathPtr = Tcl_NewStringObj(childPath, -1); + childInterp = GetInterp(interp, pathPtr); Tcl_DecrRefCount(pathPtr); - return slaveInterp; + return childInterp; } /* @@ -2054,10 +2054,10 @@ Tcl_GetChild( * * Tcl_GetParent -- * - * Finds the master interpreter of a slave interpreter. + * Finds the parent interpreter of a child interpreter. * * Results: - * Returns a Tcl_Interp * for the master interpreter or NULL if none. + * Returns a Tcl_Interp * for the parent interpreter or NULL if none. * * Side effects: * None. @@ -2067,15 +2067,15 @@ Tcl_GetChild( Tcl_Interp * Tcl_GetParent( - Tcl_Interp *interp) /* Get the master of this interpreter. */ + Tcl_Interp *interp) /* Get the parent of this interpreter. */ { - Slave *slavePtr; /* Slave record of this interpreter. */ + Child *childPtr; /* Child record of this interpreter. */ if (interp == NULL) { return NULL; } - slavePtr = &((InterpInfo *) ((Interp *) interp)->interpInfo)->slave; - return slavePtr->masterInterp; + childPtr = &((InterpInfo *) ((Interp *) interp)->interpInfo)->child; + return childPtr->parentInterp; } /* @@ -2083,7 +2083,7 @@ Tcl_GetParent( * * TclSetChildCancelFlags -- * - * This function marks all slave interpreters belonging to a given + * This function marks all child interpreters belonging to a given * interpreter as being canceled or not canceled, depending on the * provided flags. * @@ -2106,10 +2106,10 @@ TclSetChildCancelFlags( int force) /* Non-zero to ignore numLevels for the purpose * of resetting the cancellation flags. */ { - Master *masterPtr; /* Master record of given interpreter. */ + Parent *parentPtr; /* Parent record of given interpreter. */ Tcl_HashEntry *hPtr; /* Search element. */ Tcl_HashSearch hashSearch; /* Search variable. */ - Slave *slavePtr; /* Slave record of interpreter. */ + Child *childPtr; /* Child record of interpreter. */ Interp *iPtr; if (interp == NULL) { @@ -2118,12 +2118,12 @@ TclSetChildCancelFlags( flags &= (CANCELED | TCL_CANCEL_UNWIND); - masterPtr = &((InterpInfo *) ((Interp *) interp)->interpInfo)->master; + parentPtr = &((InterpInfo *) ((Interp *) interp)->interpInfo)->parent; - hPtr = Tcl_FirstHashEntry(&masterPtr->slaveTable, &hashSearch); + hPtr = Tcl_FirstHashEntry(&parentPtr->childTable, &hashSearch); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hashSearch)) { - slavePtr = Tcl_GetHashValue(hPtr); - iPtr = (Interp *) slavePtr->slaveInterp; + childPtr = Tcl_GetHashValue(hPtr); + iPtr = (Interp *) childPtr->childInterp; if (iPtr == NULL) { continue; @@ -2136,7 +2136,7 @@ TclSetChildCancelFlags( } /* - * Now, recursively handle this for the slaves of this slave + * Now, recursively handle this for the children of this child * interpreter. */ @@ -2152,7 +2152,7 @@ TclSetChildCancelFlags( * Sets the result of the asking interpreter to a proper Tcl list * containing the names of interpreters between the asking and target * interpreters. The target interpreter must be either the same as the - * asking interpreter or one of its slaves (including recursively). + * asking interpreter or one of its children (including recursively). * * Results: * TCL_OK if the target interpreter is the same as, or a descendant of, @@ -2183,12 +2183,12 @@ Tcl_GetInterpPath( return TCL_ERROR; } iiPtr = (InterpInfo *) ((Interp *) targetInterp)->interpInfo; - if (Tcl_GetInterpPath(interp, iiPtr->slave.masterInterp) != TCL_OK){ + if (Tcl_GetInterpPath(interp, iiPtr->child.parentInterp) != TCL_OK){ return TCL_ERROR; } Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), - Tcl_NewStringObj(Tcl_GetHashKey(&iiPtr->master.slaveTable, - iiPtr->slave.slaveEntryPtr), -1)); + Tcl_NewStringObj(Tcl_GetHashKey(&iiPtr->parent.childTable, + iiPtr->child.childEntryPtr), -1)); return TCL_OK; } @@ -2197,10 +2197,10 @@ Tcl_GetInterpPath( * * GetInterp -- * - * Helper function to find a slave interpreter given a pathname. + * Helper function to find a child interpreter given a pathname. * * Results: - * Returns the slave interpreter known by that name in the calling + * Returns the child interpreter known by that name in the calling * interpreter, or NULL if no interpreter known by that name exists. * * Side effects: @@ -2216,11 +2216,11 @@ GetInterp( * be found. */ { Tcl_HashEntry *hPtr; /* Search element. */ - Slave *slavePtr; /* Interim slave record. */ + Child *childPtr; /* Interim child record. */ Tcl_Obj **objv; int objc, i; Tcl_Interp *searchInterp; /* Interim storage for interp. to find. */ - InterpInfo *masterInfoPtr; + InterpInfo *parentInfoPtr; if (TclListObjGetElements(interp, pathPtr, &objc, &objv) != TCL_OK) { return NULL; @@ -2228,15 +2228,15 @@ GetInterp( searchInterp = interp; for (i = 0; i < objc; i++) { - masterInfoPtr = (InterpInfo *) ((Interp *) searchInterp)->interpInfo; - hPtr = Tcl_FindHashEntry(&masterInfoPtr->master.slaveTable, + parentInfoPtr = (InterpInfo *) ((Interp *) searchInterp)->interpInfo; + hPtr = Tcl_FindHashEntry(&parentInfoPtr->parent.childTable, TclGetString(objv[i])); if (hPtr == NULL) { searchInterp = NULL; break; } - slavePtr = Tcl_GetHashValue(hPtr); - searchInterp = slavePtr->slaveInterp; + childPtr = Tcl_GetHashValue(hPtr); + searchInterp = childPtr->childInterp; if (searchInterp == NULL) { break; } @@ -2253,7 +2253,7 @@ GetInterp( /* *---------------------------------------------------------------------- * - * SlaveBgerror -- + * ChildBgerror -- * * Helper function to set/query the background error handling command * prefix of an interp @@ -2262,16 +2262,16 @@ GetInterp( * A standard Tcl result. * * Side effects: - * When (objc == 1), slaveInterp will be set to a new background handler + * When (objc == 1), childInterp will be set to a new background handler * of objv[0]. * *---------------------------------------------------------------------- */ static int -SlaveBgerror( +ChildBgerror( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* Interp in which limit is set/queried. */ + Tcl_Interp *childInterp, /* Interp in which limit is set/queried. */ int objc, /* Set or Query. */ Tcl_Obj *const objv[]) /* Argument strings. */ { @@ -2286,19 +2286,19 @@ SlaveBgerror( "BGERRORFORMAT", NULL); return TCL_ERROR; } - TclSetBgErrorHandler(slaveInterp, objv[0]); + TclSetBgErrorHandler(childInterp, objv[0]); } - Tcl_SetObjResult(interp, TclGetBgErrorHandler(slaveInterp)); + Tcl_SetObjResult(interp, TclGetBgErrorHandler(childInterp)); return TCL_OK; } /* *---------------------------------------------------------------------- * - * SlaveCreate -- + * ChildCreate -- * - * Helper function to do the actual work of creating a slave interp and - * new object command. Also optionally makes the new slave interpreter + * Helper function to do the actual work of creating a child interp and + * new object command. Also optionally makes the new child interpreter * "safe". * * Results: @@ -2306,20 +2306,20 @@ SlaveBgerror( * the result of the invoking interpreter contains an error message. * * Side effects: - * Creates a new slave interpreter and a new object command. + * Creates a new child interpreter and a new object command. * *---------------------------------------------------------------------- */ static Tcl_Interp * -SlaveCreate( +ChildCreate( Tcl_Interp *interp, /* Interp. to start search from. */ - Tcl_Obj *pathPtr, /* Path (name) of slave to create. */ + Tcl_Obj *pathPtr, /* Path (name) of child to create. */ int safe) /* Should we make it "safe"? */ { - Tcl_Interp *masterInterp, *slaveInterp; - Slave *slavePtr; - InterpInfo *masterInfoPtr; + Tcl_Interp *parentInterp, *childInterp; + Child *childPtr; + InterpInfo *parentInfoPtr; Tcl_HashEntry *hPtr; const char *path; int isNew, objc; @@ -2329,25 +2329,25 @@ SlaveCreate( return NULL; } if (objc < 2) { - masterInterp = interp; + parentInterp = interp; path = TclGetString(pathPtr); } else { Tcl_Obj *objPtr; objPtr = Tcl_NewListObj(objc - 1, objv); - masterInterp = GetInterp(interp, objPtr); + parentInterp = GetInterp(interp, objPtr); Tcl_DecrRefCount(objPtr); - if (masterInterp == NULL) { + if (parentInterp == NULL) { return NULL; } path = TclGetString(objv[objc - 1]); } if (safe == 0) { - safe = Tcl_IsSafe(masterInterp); + safe = Tcl_IsSafe(parentInterp); } - masterInfoPtr = (InterpInfo *) ((Interp *) masterInterp)->interpInfo; - hPtr = Tcl_CreateHashEntry(&masterInfoPtr->master.slaveTable, path, + parentInfoPtr = (InterpInfo *) ((Interp *) parentInterp)->interpInfo; + hPtr = Tcl_CreateHashEntry(&parentInfoPtr->parent.childTable, path, &isNew); if (isNew == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -2356,51 +2356,51 @@ SlaveCreate( return NULL; } - slaveInterp = Tcl_CreateInterp(); - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; - slavePtr->masterInterp = masterInterp; - slavePtr->slaveEntryPtr = hPtr; - slavePtr->slaveInterp = slaveInterp; - slavePtr->interpCmd = Tcl_NRCreateCommand(masterInterp, path, - SlaveObjCmd, NRSlaveCmd, slaveInterp, SlaveObjCmdDeleteProc); - Tcl_InitHashTable(&slavePtr->aliasTable, TCL_STRING_KEYS); - Tcl_SetHashValue(hPtr, slavePtr); - Tcl_SetVar(slaveInterp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); + childInterp = Tcl_CreateInterp(); + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; + childPtr->parentInterp = parentInterp; + childPtr->childEntryPtr = hPtr; + childPtr->childInterp = childInterp; + childPtr->interpCmd = Tcl_NRCreateCommand(parentInterp, path, + ChildObjCmd, NRChildCmd, childInterp, ChildObjCmdDeleteProc); + Tcl_InitHashTable(&childPtr->aliasTable, TCL_STRING_KEYS); + Tcl_SetHashValue(hPtr, childPtr); + Tcl_SetVar(childInterp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); /* * Inherit the recursion limit. */ - ((Interp *) slaveInterp)->maxNestingDepth = - ((Interp *) masterInterp)->maxNestingDepth; + ((Interp *) childInterp)->maxNestingDepth = + ((Interp *) parentInterp)->maxNestingDepth; if (safe) { - if (Tcl_MakeSafe(slaveInterp) == TCL_ERROR) { + if (Tcl_MakeSafe(childInterp) == TCL_ERROR) { goto error; } } else { - if (Tcl_Init(slaveInterp) == TCL_ERROR) { + if (Tcl_Init(childInterp) == TCL_ERROR) { goto error; } /* - * This will create the "memory" command in slave interpreters if we + * This will create the "memory" command in child interpreters if we * compiled with TCL_MEM_DEBUG, otherwise it does nothing. */ - Tcl_InitMemory(slaveInterp); + Tcl_InitMemory(childInterp); } /* * Inherit the TIP#143 limits. */ - InheritLimitsFromMaster(slaveInterp, masterInterp); + InheritLimitsFromParent(childInterp, parentInterp); /* * The [clock] command presents a safe API, but uses unsafe features in * its implementation. This means it has to be implemented in safe interps - * as an alias to a version in the (trusted) master. + * as an alias to a version in the (trusted) parent. */ if (safe) { @@ -2409,7 +2409,7 @@ SlaveCreate( TclNewLiteralStringObj(clockObj, "clock"); Tcl_IncrRefCount(clockObj); - status = AliasCreate(interp, slaveInterp, masterInterp, clockObj, + status = AliasCreate(interp, childInterp, parentInterp, clockObj, clockObj, 0, NULL); Tcl_DecrRefCount(clockObj); if (status != TCL_OK) { @@ -2417,12 +2417,12 @@ SlaveCreate( } } - return slaveInterp; + return childInterp; error: - Tcl_TransferResult(slaveInterp, TCL_ERROR, interp); + Tcl_TransferResult(childInterp, TCL_ERROR, interp); error2: - Tcl_DeleteInterp(slaveInterp); + Tcl_DeleteInterp(childInterp); return NULL; } @@ -2430,10 +2430,10 @@ SlaveCreate( /* *---------------------------------------------------------------------- * - * SlaveObjCmd -- + * ChildObjCmd -- * * Command to manipulate an interpreter, e.g. to send commands to it to - * be evaluated. One such command exists for each slave interpreter. + * be evaluated. One such command exists for each child interpreter. * * Results: * A standard Tcl result. @@ -2445,23 +2445,23 @@ SlaveCreate( */ static int -SlaveObjCmd( - ClientData clientData, /* Slave interpreter. */ +ChildObjCmd( + ClientData clientData, /* Child interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - return Tcl_NRCallObjProc(interp, NRSlaveCmd, clientData, objc, objv); + return Tcl_NRCallObjProc(interp, NRChildCmd, clientData, objc, objv); } static int -NRSlaveCmd( - ClientData clientData, /* Slave interpreter. */ +NRChildCmd( + ClientData clientData, /* Child interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tcl_Interp *slaveInterp = clientData; + Tcl_Interp *childInterp = clientData; int index; static const char *const options[] = { "alias", "aliases", "bgerror", "debug", @@ -2476,8 +2476,8 @@ NRSlaveCmd( OPT_RECLIMIT }; - if (slaveInterp == NULL) { - Tcl_Panic("SlaveObjCmd: interpreter has been deleted"); + if (childInterp == NULL) { + Tcl_Panic("ChildObjCmd: interpreter has been deleted"); } if (objc < 2) { @@ -2493,14 +2493,14 @@ NRSlaveCmd( case OPT_ALIAS: if (objc > 2) { if (objc == 3) { - return AliasDescribe(interp, slaveInterp, objv[2]); + return AliasDescribe(interp, childInterp, objv[2]); } if (TclGetString(objv[3])[0] == '\0') { if (objc == 4) { - return AliasDelete(interp, slaveInterp, objv[2]); + return AliasDelete(interp, childInterp, objv[2]); } } else { - return AliasCreate(interp, slaveInterp, interp, objv[2], + return AliasCreate(interp, childInterp, interp, objv[2], objv[3], objc - 4, objv + 4); } } @@ -2511,13 +2511,13 @@ NRSlaveCmd( Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - return AliasList(interp, slaveInterp); + return AliasList(interp, childInterp); case OPT_BGERROR: if (objc != 2 && objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "?cmdPrefix?"); return TCL_ERROR; } - return SlaveBgerror(interp, slaveInterp, objc - 2, objv + 2); + return ChildBgerror(interp, childInterp, objc - 2, objv + 2); case OPT_DEBUG: /* * TIP #378 @@ -2527,37 +2527,37 @@ NRSlaveCmd( Tcl_WrongNumArgs(interp, 2, objv, "?-frame ?bool??"); return TCL_ERROR; } - return SlaveDebugCmd(interp, slaveInterp, objc - 2, objv + 2); + return ChildDebugCmd(interp, childInterp, objc - 2, objv + 2); case OPT_EVAL: if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "arg ?arg ...?"); return TCL_ERROR; } - return SlaveEval(interp, slaveInterp, objc - 2, objv + 2); + return ChildEval(interp, childInterp, objc - 2, objv + 2); case OPT_EXPOSE: if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "hiddenCmdName ?cmdName?"); return TCL_ERROR; } - return SlaveExpose(interp, slaveInterp, objc - 2, objv + 2); + return ChildExpose(interp, childInterp, objc - 2, objv + 2); case OPT_HIDE: if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "cmdName ?hiddenCmdName?"); return TCL_ERROR; } - return SlaveHide(interp, slaveInterp, objc - 2, objv + 2); + return ChildHide(interp, childInterp, objc - 2, objv + 2); case OPT_HIDDEN: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - return SlaveHidden(interp, slaveInterp); + return ChildHidden(interp, childInterp); case OPT_ISSAFE: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(Tcl_IsSafe(slaveInterp))); + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(Tcl_IsSafe(childInterp))); return TCL_OK; case OPT_INVOKEHIDDEN: { int i; @@ -2596,7 +2596,7 @@ NRSlaveCmd( "?-namespace ns? ?-global? ?--? cmd ?arg ..?"); return TCL_ERROR; } - return SlaveInvokeHidden(interp, slaveInterp, namespaceName, + return ChildInvokeHidden(interp, childInterp, namespaceName, objc - i, objv + i); } case OPT_LIMIT: { @@ -2618,9 +2618,9 @@ NRSlaveCmd( } switch ((enum LimitTypes) limitType) { case LIMIT_TYPE_COMMANDS: - return SlaveCommandLimitCmd(interp, slaveInterp, 3, objc,objv); + return ChildCommandLimitCmd(interp, childInterp, 3, objc,objv); case LIMIT_TYPE_TIME: - return SlaveTimeLimitCmd(interp, slaveInterp, 3, objc, objv); + return ChildTimeLimitCmd(interp, childInterp, 3, objc, objv); } } break; @@ -2629,13 +2629,13 @@ NRSlaveCmd( Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - return SlaveMarkTrusted(interp, slaveInterp); + return ChildMarkTrusted(interp, childInterp); case OPT_RECLIMIT: if (objc != 2 && objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "?newlimit?"); return TCL_ERROR; } - return SlaveRecursionLimit(interp, slaveInterp, objc - 2, objv + 2); + return ChildRecursionLimit(interp, childInterp, objc - 2, objv + 2); } return TCL_ERROR; @@ -2644,71 +2644,71 @@ NRSlaveCmd( /* *---------------------------------------------------------------------- * - * SlaveObjCmdDeleteProc -- + * ChildObjCmdDeleteProc -- * - * Invoked when an object command for a slave interpreter is deleted; - * cleans up all state associated with the slave interpreter and destroys - * the slave interpreter. + * Invoked when an object command for a child interpreter is deleted; + * cleans up all state associated with the child interpreter and destroys + * the child interpreter. * * Results: * None. * * Side effects: - * Cleans up all state associated with the slave interpreter and destroys - * the slave interpreter. + * Cleans up all state associated with the child interpreter and destroys + * the child interpreter. * *---------------------------------------------------------------------- */ static void -SlaveObjCmdDeleteProc( - ClientData clientData) /* The SlaveRecord for the command. */ +ChildObjCmdDeleteProc( + ClientData clientData) /* The ChildRecord for the command. */ { - Slave *slavePtr; /* Interim storage for Slave record. */ - Tcl_Interp *slaveInterp = clientData; - /* And for a slave interp. */ + Child *childPtr; /* Interim storage for Child record. */ + Tcl_Interp *childInterp = clientData; + /* And for a child interp. */ - slavePtr = &((InterpInfo *) ((Interp *) slaveInterp)->interpInfo)->slave; + childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; /* - * Unlink the slave from its master interpreter. + * Unlink the child from its parent interpreter. */ - Tcl_DeleteHashEntry(slavePtr->slaveEntryPtr); + Tcl_DeleteHashEntry(childPtr->childEntryPtr); /* - * Set to NULL so that when the InterpInfo is cleaned up in the slave it + * Set to NULL so that when the InterpInfo is cleaned up in the child it * does not try to delete the command causing all sorts of grief. See - * SlaveRecordDeleteProc(). + * ChildRecordDeleteProc(). */ - slavePtr->interpCmd = NULL; + childPtr->interpCmd = NULL; - if (slavePtr->slaveInterp != NULL) { - Tcl_DeleteInterp(slavePtr->slaveInterp); + if (childPtr->childInterp != NULL) { + Tcl_DeleteInterp(childPtr->childInterp); } } /* *---------------------------------------------------------------------- * - * SlaveDebugCmd -- TIP #378 + * ChildDebugCmd -- TIP #378 * - * Helper function to handle 'debug' command in a slave interpreter. + * Helper function to handle 'debug' command in a child interpreter. * * Results: * A standard Tcl result. * * Side effects: - * May modify INTERP_DEBUG_FRAME flag in the slave. + * May modify INTERP_DEBUG_FRAME flag in the child. * *---------------------------------------------------------------------- */ static int -SlaveDebugCmd( +ChildDebugCmd( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* The slave interpreter in which command + Tcl_Interp *childInterp, /* The child interpreter in which command * will be evaluated. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2723,7 +2723,7 @@ SlaveDebugCmd( Interp *iPtr; Tcl_Obj *resultPtr; - iPtr = (Interp *) slaveInterp; + iPtr = (Interp *) childInterp; if (objc == 0) { resultPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, resultPtr, @@ -2763,9 +2763,9 @@ SlaveDebugCmd( /* *---------------------------------------------------------------------- * - * SlaveEval -- + * ChildEval -- * - * Helper function to evaluate a command in a slave interpreter. + * Helper function to evaluate a command in a child interpreter. * * Results: * A standard Tcl result. @@ -2777,9 +2777,9 @@ SlaveDebugCmd( */ static int -SlaveEval( +ChildEval( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* The slave interpreter in which command + Tcl_Interp *childInterp, /* The child interpreter in which command * will be evaluated. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2787,17 +2787,17 @@ SlaveEval( int result; /* - * TIP #285: If necessary, reset the cancellation flags for the slave - * interpreter now; otherwise, canceling a script in a master interpreter - * can result in a situation where a slave interpreter can no longer + * TIP #285: If necessary, reset the cancellation flags for the child + * interpreter now; otherwise, canceling a script in a parent interpreter + * can result in a situation where a child interpreter can no longer * evaluate any scripts unless somebody calls the TclResetCancellation * function for that particular Tcl_Interp. */ - TclSetChildCancelFlags(slaveInterp, 0, 0); + TclSetChildCancelFlags(childInterp, 0, 0); - Tcl_Preserve(slaveInterp); - Tcl_AllowExceptions(slaveInterp); + Tcl_Preserve(childInterp); + Tcl_AllowExceptions(childInterp); if (objc == 1) { /* @@ -2810,40 +2810,40 @@ SlaveEval( TclArgumentGet(interp, objv[0], &invoker, &word); - result = TclEvalObjEx(slaveInterp, objv[0], 0, invoker, word); + result = TclEvalObjEx(childInterp, objv[0], 0, invoker, word); } else { Tcl_Obj *objPtr = Tcl_ConcatObj(objc, objv); Tcl_IncrRefCount(objPtr); - result = Tcl_EvalObjEx(slaveInterp, objPtr, 0); + result = Tcl_EvalObjEx(childInterp, objPtr, 0); Tcl_DecrRefCount(objPtr); } - Tcl_TransferResult(slaveInterp, result, interp); + Tcl_TransferResult(childInterp, result, interp); - Tcl_Release(slaveInterp); + Tcl_Release(childInterp); return result; } /* *---------------------------------------------------------------------- * - * SlaveExpose -- + * ChildExpose -- * - * Helper function to expose a command in a slave interpreter. + * Helper function to expose a command in a child interpreter. * * Results: * A standard Tcl result. * * Side effects: - * After this call scripts in the slave will be able to invoke the newly + * After this call scripts in the child will be able to invoke the newly * exposed command. * *---------------------------------------------------------------------- */ static int -SlaveExpose( +ChildExpose( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* Interp in which command will be exposed. */ + Tcl_Interp *childInterp, /* Interp in which command will be exposed. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { @@ -2859,9 +2859,9 @@ SlaveExpose( } name = TclGetString(objv[(objc == 1) ? 0 : 1]); - if (Tcl_ExposeCommand(slaveInterp, TclGetString(objv[0]), + if (Tcl_ExposeCommand(childInterp, TclGetString(objv[0]), name) != TCL_OK) { - Tcl_TransferResult(slaveInterp, TCL_ERROR, interp); + Tcl_TransferResult(childInterp, TCL_ERROR, interp); return TCL_ERROR; } return TCL_OK; @@ -2870,7 +2870,7 @@ SlaveExpose( /* *---------------------------------------------------------------------- * - * SlaveRecursionLimit -- + * ChildRecursionLimit -- * * Helper function to set/query the Recursion limit of an interp * @@ -2878,16 +2878,16 @@ SlaveExpose( * A standard Tcl result. * * Side effects: - * When (objc == 1), slaveInterp will be set to a new recursion limit of + * When (objc == 1), childInterp will be set to a new recursion limit of * objv[0]. * *---------------------------------------------------------------------- */ static int -SlaveRecursionLimit( +ChildRecursionLimit( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* Interp in which limit is set/queried. */ + Tcl_Interp *childInterp, /* Interp in which limit is set/queried. */ int objc, /* Set or Query. */ Tcl_Obj *const objv[]) /* Argument strings. */ { @@ -2912,9 +2912,9 @@ SlaveRecursionLimit( NULL); return TCL_ERROR; } - Tcl_SetRecursionLimit(slaveInterp, limit); - iPtr = (Interp *) slaveInterp; - if (interp == slaveInterp && iPtr->numLevels > limit) { + Tcl_SetRecursionLimit(childInterp, limit); + iPtr = (Interp *) childInterp; + if (interp == childInterp && iPtr->numLevels > limit) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "falling back due to new recursion limit", -1)); Tcl_SetErrorCode(interp, "TCL", "RECURSION", NULL); @@ -2923,7 +2923,7 @@ SlaveRecursionLimit( Tcl_SetObjResult(interp, objv[0]); return TCL_OK; } else { - limit = Tcl_SetRecursionLimit(slaveInterp, 0); + limit = Tcl_SetRecursionLimit(childInterp, 0); Tcl_SetObjResult(interp, Tcl_NewIntObj(limit)); return TCL_OK; } @@ -2932,24 +2932,24 @@ SlaveRecursionLimit( /* *---------------------------------------------------------------------- * - * SlaveHide -- + * ChildHide -- * - * Helper function to hide a command in a slave interpreter. + * Helper function to hide a command in a child interpreter. * * Results: * A standard Tcl result. * * Side effects: - * After this call scripts in the slave will no longer be able to invoke + * After this call scripts in the child will no longer be able to invoke * the named command. * *---------------------------------------------------------------------- */ static int -SlaveHide( +ChildHide( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* Interp in which command will be exposed. */ + Tcl_Interp *childInterp, /* Interp in which command will be exposed. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { @@ -2965,8 +2965,8 @@ SlaveHide( } name = TclGetString(objv[(objc == 1) ? 0 : 1]); - if (Tcl_HideCommand(slaveInterp, TclGetString(objv[0]), name) != TCL_OK) { - Tcl_TransferResult(slaveInterp, TCL_ERROR, interp); + if (Tcl_HideCommand(childInterp, TclGetString(objv[0]), name) != TCL_OK) { + Tcl_TransferResult(childInterp, TCL_ERROR, interp); return TCL_ERROR; } return TCL_OK; @@ -2975,9 +2975,9 @@ SlaveHide( /* *---------------------------------------------------------------------- * - * SlaveHidden -- + * ChildHidden -- * - * Helper function to compute list of hidden commands in a slave + * Helper function to compute list of hidden commands in a child * interpreter. * * Results: @@ -2990,16 +2990,16 @@ SlaveHide( */ static int -SlaveHidden( +ChildHidden( Tcl_Interp *interp, /* Interp for data return. */ - Tcl_Interp *slaveInterp) /* Interp whose hidden commands to query. */ + Tcl_Interp *childInterp) /* Interp whose hidden commands to query. */ { Tcl_Obj *listObjPtr = Tcl_NewObj(); /* Local object pointer. */ Tcl_HashTable *hTblPtr; /* For local searches. */ Tcl_HashEntry *hPtr; /* For local searches. */ Tcl_HashSearch hSearch; /* For local searches. */ - hTblPtr = ((Interp *) slaveInterp)->hiddenCmdTablePtr; + hTblPtr = ((Interp *) childInterp)->hiddenCmdTablePtr; if (hTblPtr != NULL) { for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); hPtr != NULL; @@ -3015,9 +3015,9 @@ SlaveHidden( /* *---------------------------------------------------------------------- * - * SlaveInvokeHidden -- + * ChildInvokeHidden -- * - * Helper function to invoke a hidden command in a slave interpreter. + * Helper function to invoke a hidden command in a child interpreter. * * Results: * A standard Tcl result. @@ -3029,9 +3029,9 @@ SlaveHidden( */ static int -SlaveInvokeHidden( +ChildInvokeHidden( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp, /* The slave interpreter in which command will + Tcl_Interp *childInterp, /* The child interpreter in which command will * be invoked. */ const char *namespaceName, /* The namespace to use, if any. */ int objc, /* Number of arguments. */ @@ -3048,31 +3048,31 @@ SlaveInvokeHidden( return TCL_ERROR; } - Tcl_Preserve(slaveInterp); - Tcl_AllowExceptions(slaveInterp); + Tcl_Preserve(childInterp); + Tcl_AllowExceptions(childInterp); if (namespaceName == NULL) { - NRE_callback *rootPtr = TOP_CB(slaveInterp); + NRE_callback *rootPtr = TOP_CB(childInterp); - Tcl_NRAddCallback(interp, NRPostInvokeHidden, slaveInterp, + Tcl_NRAddCallback(interp, NRPostInvokeHidden, childInterp, rootPtr, NULL, NULL); - return TclNRInvoke(NULL, slaveInterp, objc, objv); + return TclNRInvoke(NULL, childInterp, objc, objv); } else { Namespace *nsPtr, *dummy1, *dummy2; const char *tail; - result = TclGetNamespaceForQualName(slaveInterp, namespaceName, NULL, + result = TclGetNamespaceForQualName(childInterp, namespaceName, NULL, TCL_FIND_ONLY_NS | TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG | TCL_CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail); if (result == TCL_OK) { - result = TclObjInvokeNamespace(slaveInterp, objc, objv, + result = TclObjInvokeNamespace(childInterp, objc, objv, (Tcl_Namespace *) nsPtr, TCL_INVOKE_HIDDEN); } } - Tcl_TransferResult(slaveInterp, result, interp); + Tcl_TransferResult(childInterp, result, interp); - Tcl_Release(slaveInterp); + Tcl_Release(childInterp); return result; } @@ -3082,38 +3082,38 @@ NRPostInvokeHidden( Tcl_Interp *interp, int result) { - Tcl_Interp *slaveInterp = (Tcl_Interp *)data[0]; + Tcl_Interp *childInterp = (Tcl_Interp *)data[0]; NRE_callback *rootPtr = (NRE_callback *)data[1]; - if (interp != slaveInterp) { - result = TclNRRunCallbacks(slaveInterp, result, rootPtr); - Tcl_TransferResult(slaveInterp, result, interp); + if (interp != childInterp) { + result = TclNRRunCallbacks(childInterp, result, rootPtr); + Tcl_TransferResult(childInterp, result, interp); } - Tcl_Release(slaveInterp); + Tcl_Release(childInterp); return result; } /* *---------------------------------------------------------------------- * - * SlaveMarkTrusted -- + * ChildMarkTrusted -- * - * Helper function to mark a slave interpreter as trusted (unsafe). + * Helper function to mark a child interpreter as trusted (unsafe). * * Results: * A standard Tcl result. * * Side effects: * After this call the hard-wired security checks in the core no longer - * prevent the slave from performing certain operations. + * prevent the child from performing certain operations. * *---------------------------------------------------------------------- */ static int -SlaveMarkTrusted( +ChildMarkTrusted( Tcl_Interp *interp, /* Interp for error return. */ - Tcl_Interp *slaveInterp) /* The slave interpreter which will be marked + Tcl_Interp *childInterp) /* The child interpreter which will be marked * trusted. */ { if (Tcl_IsSafe(interp)) { @@ -3124,7 +3124,7 @@ SlaveMarkTrusted( NULL); return TCL_ERROR; } - ((Interp *) slaveInterp)->flags &= ~SAFE_INTERP; + ((Interp *) childInterp)->flags &= ~SAFE_INTERP; return TCL_OK; } @@ -3181,23 +3181,23 @@ Tcl_MakeSafe( { Tcl_Channel chan; /* Channel to remove from safe interpreter. */ Interp *iPtr = (Interp *) interp; - Tcl_Interp *master = ((InterpInfo*) iPtr->interpInfo)->slave.masterInterp; + Tcl_Interp *parent = ((InterpInfo*) iPtr->interpInfo)->child.parentInterp; TclHideUnsafeCommands(interp); - if (master != NULL) { + if (parent != NULL) { /* - * Alias these function implementations in the slave to those in the - * master; the overall implementations are safe, but they're normally + * Alias these function implementations in the child to those in the + * parent; the overall implementations are safe, but they're normally * defined by init.tcl which is not sourced by safe interpreters. * Assume these functions all work. [Bug 2895741] */ (void) Tcl_Eval(interp, "namespace eval ::tcl {namespace eval mathfunc {}}"); - (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::min", master, + (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::min", parent, "::tcl::mathfunc::min", 0, NULL); - (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::max", master, + (void) Tcl_CreateAlias(interp, "::tcl::mathfunc::max", parent, "::tcl::mathfunc::max", 0, NULL); } @@ -3209,7 +3209,7 @@ Tcl_MakeSafe( */ /* - * No env array in a safe slave. + * No env array in a safe child. */ Tcl_UnsetVar(interp, "env", TCL_GLOBAL_ONLY); @@ -4113,7 +4113,7 @@ Tcl_LimitGetGranularity( * DeleteScriptLimitCallback -- * * Callback for when a script limit (a limit callback implemented as a - * Tcl script in a master interpreter, as set up from Tcl) is deleted. + * Tcl script in a parent interpreter, as set up from Tcl) is deleted. * * Results: * None. @@ -4326,48 +4326,48 @@ TclInitLimitSupport( /* *---------------------------------------------------------------------- * - * InheritLimitsFromMaster -- + * InheritLimitsFromParent -- * - * Derive the interpreter limit configuration for a slave interpreter - * from the limit config for the master. + * Derive the interpreter limit configuration for a child interpreter + * from the limit config for the parent. * * Results: * None. * * Side effects: - * The slave interpreter limits are set so that if the master has a - * limit, it may not exceed it by handing off work to slave interpreters. - * Note that this does not transfer limit callbacks from the master to - * the slave. + * The child interpreter limits are set so that if the parent has a + * limit, it may not exceed it by handing off work to child interpreters. + * Note that this does not transfer limit callbacks from the parent to + * the child. * *---------------------------------------------------------------------- */ static void -InheritLimitsFromMaster( - Tcl_Interp *slaveInterp, - Tcl_Interp *masterInterp) +InheritLimitsFromParent( + Tcl_Interp *childInterp, + Tcl_Interp *parentInterp) { - Interp *slavePtr = (Interp *) slaveInterp; - Interp *masterPtr = (Interp *) masterInterp; + Interp *childPtr = (Interp *) childInterp; + Interp *parentPtr = (Interp *) parentInterp; - if (masterPtr->limit.active & TCL_LIMIT_COMMANDS) { - slavePtr->limit.active |= TCL_LIMIT_COMMANDS; - slavePtr->limit.cmdCount = 0; - slavePtr->limit.cmdGranularity = masterPtr->limit.cmdGranularity; + if (parentPtr->limit.active & TCL_LIMIT_COMMANDS) { + childPtr->limit.active |= TCL_LIMIT_COMMANDS; + childPtr->limit.cmdCount = 0; + childPtr->limit.cmdGranularity = parentPtr->limit.cmdGranularity; } - if (masterPtr->limit.active & TCL_LIMIT_TIME) { - slavePtr->limit.active |= TCL_LIMIT_TIME; - memcpy(&slavePtr->limit.time, &masterPtr->limit.time, + if (parentPtr->limit.active & TCL_LIMIT_TIME) { + childPtr->limit.active |= TCL_LIMIT_TIME; + memcpy(&childPtr->limit.time, &parentPtr->limit.time, sizeof(Tcl_Time)); - slavePtr->limit.timeGranularity = masterPtr->limit.timeGranularity; + childPtr->limit.timeGranularity = parentPtr->limit.timeGranularity; } } /* *---------------------------------------------------------------------- * - * SlaveCommandLimitCmd -- + * ChildCommandLimitCmd -- * * Implementation of the [interp limit $i commands] and [$i limit * commands] subcommands. See the interp manual page for a full @@ -4383,9 +4383,9 @@ InheritLimitsFromMaster( */ static int -SlaveCommandLimitCmd( +ChildCommandLimitCmd( Tcl_Interp *interp, /* Current interpreter. */ - Tcl_Interp *slaveInterp, /* Interpreter being adjusted. */ + Tcl_Interp *childInterp, /* Interpreter being adjusted. */ int consumedObjc, /* Number of args already parsed. */ int objc, /* Total number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -4409,7 +4409,7 @@ SlaveCommandLimitCmd( * avoid. [Bug 3398794] */ - if (interp == slaveInterp) { + if (interp == childInterp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "limits on current interpreter inaccessible", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF", NULL); @@ -4420,7 +4420,7 @@ SlaveCommandLimitCmd( Tcl_Obj *dictPtr; TclNewObj(dictPtr); - key.interp = slaveInterp; + key.interp = childInterp; key.type = TCL_LIMIT_COMMANDS; hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, (char *) &key); if (hPtr != NULL) { @@ -4440,12 +4440,12 @@ SlaveCommandLimitCmd( Tcl_NewStringObj(options[0], -1), empty); } Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1), - Tcl_NewIntObj(Tcl_LimitGetGranularity(slaveInterp, + Tcl_NewIntObj(Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_COMMANDS))); - if (Tcl_LimitTypeEnabled(slaveInterp, TCL_LIMIT_COMMANDS)) { + if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_COMMANDS)) { Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1), - Tcl_NewIntObj(Tcl_LimitGetCommands(slaveInterp))); + Tcl_NewIntObj(Tcl_LimitGetCommands(childInterp))); } else { Tcl_Obj *empty; @@ -4462,7 +4462,7 @@ SlaveCommandLimitCmd( } switch ((enum Options) index) { case OPT_CMD: - key.interp = slaveInterp; + key.interp = childInterp; key.type = TCL_LIMIT_COMMANDS; hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, (char *) &key); if (hPtr != NULL) { @@ -4474,12 +4474,12 @@ SlaveCommandLimitCmd( break; case OPT_GRAN: Tcl_SetObjResult(interp, Tcl_NewIntObj( - Tcl_LimitGetGranularity(slaveInterp, TCL_LIMIT_COMMANDS))); + Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_COMMANDS))); break; case OPT_VAL: - if (Tcl_LimitTypeEnabled(slaveInterp, TCL_LIMIT_COMMANDS)) { + if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_COMMANDS)) { Tcl_SetObjResult(interp, - Tcl_NewIntObj(Tcl_LimitGetCommands(slaveInterp))); + Tcl_NewIntObj(Tcl_LimitGetCommands(childInterp))); } break; } @@ -4535,18 +4535,18 @@ SlaveCommandLimitCmd( } } if (scriptObj != NULL) { - SetScriptLimitCallback(interp, TCL_LIMIT_COMMANDS, slaveInterp, + SetScriptLimitCallback(interp, TCL_LIMIT_COMMANDS, childInterp, (scriptLen > 0 ? scriptObj : NULL)); } if (granObj != NULL) { - Tcl_LimitSetGranularity(slaveInterp, TCL_LIMIT_COMMANDS, gran); + Tcl_LimitSetGranularity(childInterp, TCL_LIMIT_COMMANDS, gran); } if (limitObj != NULL) { if (limitLen > 0) { - Tcl_LimitSetCommands(slaveInterp, limit); - Tcl_LimitTypeSet(slaveInterp, TCL_LIMIT_COMMANDS); + Tcl_LimitSetCommands(childInterp, limit); + Tcl_LimitTypeSet(childInterp, TCL_LIMIT_COMMANDS); } else { - Tcl_LimitTypeReset(slaveInterp, TCL_LIMIT_COMMANDS); + Tcl_LimitTypeReset(childInterp, TCL_LIMIT_COMMANDS); } } return TCL_OK; @@ -4556,7 +4556,7 @@ SlaveCommandLimitCmd( /* *---------------------------------------------------------------------- * - * SlaveTimeLimitCmd -- + * ChildTimeLimitCmd -- * * Implementation of the [interp limit $i time] and [$i limit time] * subcommands. See the interp manual page for a full description. @@ -4571,9 +4571,9 @@ SlaveCommandLimitCmd( */ static int -SlaveTimeLimitCmd( +ChildTimeLimitCmd( Tcl_Interp *interp, /* Current interpreter. */ - Tcl_Interp *slaveInterp, /* Interpreter being adjusted. */ + Tcl_Interp *childInterp, /* Interpreter being adjusted. */ int consumedObjc, /* Number of args already parsed. */ int objc, /* Total number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -4597,7 +4597,7 @@ SlaveTimeLimitCmd( * avoid. [Bug 3398794] */ - if (interp == slaveInterp) { + if (interp == childInterp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "limits on current interpreter inaccessible", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF", NULL); @@ -4608,7 +4608,7 @@ SlaveTimeLimitCmd( Tcl_Obj *dictPtr; TclNewObj(dictPtr); - key.interp = slaveInterp; + key.interp = childInterp; key.type = TCL_LIMIT_TIME; hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, (char *) &key); if (hPtr != NULL) { @@ -4627,13 +4627,13 @@ SlaveTimeLimitCmd( Tcl_NewStringObj(options[0], -1), empty); } Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1), - Tcl_NewIntObj(Tcl_LimitGetGranularity(slaveInterp, + Tcl_NewIntObj(Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_TIME))); - if (Tcl_LimitTypeEnabled(slaveInterp, TCL_LIMIT_TIME)) { + if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_TIME)) { Tcl_Time limitMoment; - Tcl_LimitGetTime(slaveInterp, &limitMoment); + Tcl_LimitGetTime(childInterp, &limitMoment); Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1), Tcl_NewLongObj(limitMoment.usec/1000)); Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[3], -1), @@ -4656,7 +4656,7 @@ SlaveTimeLimitCmd( } switch ((enum Options) index) { case OPT_CMD: - key.interp = slaveInterp; + key.interp = childInterp; key.type = TCL_LIMIT_TIME; hPtr = Tcl_FindHashEntry(&iPtr->limit.callbacks, (char *) &key); if (hPtr != NULL) { @@ -4668,22 +4668,22 @@ SlaveTimeLimitCmd( break; case OPT_GRAN: Tcl_SetObjResult(interp, Tcl_NewIntObj( - Tcl_LimitGetGranularity(slaveInterp, TCL_LIMIT_TIME))); + Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_TIME))); break; case OPT_MILLI: - if (Tcl_LimitTypeEnabled(slaveInterp, TCL_LIMIT_TIME)) { + if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_TIME)) { Tcl_Time limitMoment; - Tcl_LimitGetTime(slaveInterp, &limitMoment); + Tcl_LimitGetTime(childInterp, &limitMoment); Tcl_SetObjResult(interp, Tcl_NewLongObj(limitMoment.usec/1000)); } break; case OPT_SEC: - if (Tcl_LimitTypeEnabled(slaveInterp, TCL_LIMIT_TIME)) { + if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_TIME)) { Tcl_Time limitMoment; - Tcl_LimitGetTime(slaveInterp, &limitMoment); + Tcl_LimitGetTime(childInterp, &limitMoment); Tcl_SetObjResult(interp, Tcl_NewLongObj(limitMoment.sec)); } break; @@ -4700,7 +4700,7 @@ SlaveTimeLimitCmd( Tcl_Time limitMoment; int tmp; - Tcl_LimitGetTime(slaveInterp, &limitMoment); + Tcl_LimitGetTime(childInterp, &limitMoment); for (i=consumedObjc ; i 0 ? scriptObj : NULL)); } if (granObj != NULL) { - Tcl_LimitSetGranularity(slaveInterp, TCL_LIMIT_TIME, gran); + Tcl_LimitSetGranularity(childInterp, TCL_LIMIT_TIME, gran); } return TCL_OK; } diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 062f007..5a736de 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -196,9 +196,9 @@ Tcl_LoadObjCmd( target = interp; if (objc == 4) { - const char *slaveIntName = Tcl_GetString(objv[3]); + const char *childIntName = Tcl_GetString(objv[3]); - target = Tcl_GetChild(interp, slaveIntName); + target = Tcl_GetChild(interp, childIntName); if (target == NULL) { code = TCL_ERROR; goto done; @@ -619,9 +619,9 @@ Tcl_UnloadObjCmd( target = interp; if (objc - i == 3) { - const char *slaveIntName = Tcl_GetString(objv[i + 2]); + const char *childIntName = Tcl_GetString(objv[i + 2]); - target = Tcl_GetChild(interp, slaveIntName); + target = Tcl_GetChild(interp, childIntName); if (target == NULL) { return TCL_ERROR; } diff --git a/generic/tclOO.c b/generic/tclOO.c index c1db80c..f8a0f12 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -132,7 +132,7 @@ static const Tcl_MethodType classConstructor = { }; /* - * Scripted parts of TclOO. First, the master script (cannot be outside this + * Scripted parts of TclOO. First, the main script (cannot be outside this * file). */ diff --git a/generic/tclOOInfo.c b/generic/tclOOInfo.c index c9263b5..4b25c1a 100644 --- a/generic/tclOOInfo.c +++ b/generic/tclOOInfo.c @@ -110,7 +110,7 @@ TclOOInitInfo( TclMakeEnsemble(interp, "::oo::InfoClass", infoClassCmds); /* - * Install into the master [info] ensemble. + * Install into the [info] ensemble. */ infoCmd = Tcl_FindCommand(interp, "info", NULL, TCL_GLOBAL_ONLY); diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h index 0e4503a..44316ac 100644 --- a/generic/tclOOInt.h +++ b/generic/tclOOInt.h @@ -277,7 +277,7 @@ typedef struct Class { */ typedef struct ThreadLocalData { - int nsCount; /* Master epoch counter is used for keeping + int nsCount; /* Epoch counter is used for keeping * the values used in Tcl_Obj internal * representations sane. Must be thread-local * because Tcl_Objs can cross interpreter @@ -289,7 +289,7 @@ typedef struct Foundation { Tcl_Interp *interp; Class *objectCls; /* The root of the object system. */ Class *classCls; /* The class of all classes. */ - Tcl_Namespace *ooNs; /* Master ::oo namespace. */ + Tcl_Namespace *ooNs; /* ::oo namespace. */ Tcl_Namespace *defineNs; /* Namespace containing special commands for * manipulating objects and classes. The * "oo::define" command acts as a special kind diff --git a/generic/tclParse.c b/generic/tclParse.c index 7a51dae..57b2b35 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -2172,7 +2172,7 @@ TclSubstTokens( * command, which is refered to by 'script'. * The 'clNextOuter' refers to the current * entry in the table of continuation lines in - * this "master script", and the character + * this "main script", and the character * offsets are relative to the 'outerScript' * as well. * diff --git a/generic/tclTest.c b/generic/tclTest.c index 7624004..297cd11 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -1508,15 +1508,15 @@ TestdelCmd( const char **argv) /* Argument strings. */ { DelCmd *dPtr; - Tcl_Interp *slave; + Tcl_Interp *child; if (argc != 4) { Tcl_SetResult(interp, "wrong # args", TCL_STATIC); return TCL_ERROR; } - slave = Tcl_GetChild(interp, argv[1]); - if (slave == NULL) { + child = Tcl_GetChild(interp, argv[1]); + if (child == NULL) { return TCL_ERROR; } @@ -1525,7 +1525,7 @@ TestdelCmd( dPtr->deleteCmd = (char *)ckalloc(strlen(argv[3]) + 1); strcpy(dPtr->deleteCmd, argv[3]); - Tcl_CreateCommand(slave, argv[2], DelCmdProc, (ClientData) dPtr, + Tcl_CreateCommand(child, argv[2], DelCmdProc, (ClientData) dPtr, DelDeleteProc); return TCL_OK; } @@ -2691,18 +2691,18 @@ TestinterpdeleteCmd( int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { - Tcl_Interp *slaveToDelete; + Tcl_Interp *childToDelete; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " path\"", NULL); return TCL_ERROR; } - slaveToDelete = Tcl_GetChild(interp, argv[1]); - if (slaveToDelete == NULL) { + childToDelete = Tcl_GetChild(interp, argv[1]); + if (childToDelete == NULL) { return TCL_ERROR; } - Tcl_DeleteInterp(slaveToDelete); + Tcl_DeleteInterp(childToDelete); return TCL_OK; } diff --git a/library/auto.tcl b/library/auto.tcl index 27173df..825aeeb 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -376,10 +376,10 @@ proc auto_mkindex_parser::mkindex {file} { # auto_mkindex_parser::hook command # -# Registers a Tcl command to evaluate when initializing the slave interpreter +# Registers a Tcl command to evaluate when initializing the child interpreter # used by the mkindex parser. The command is evaluated in the parent # interpreter, and can use the variable auto_mkindex_parser::parser to get to -# the slave +# the child proc auto_mkindex_parser::hook {cmd} { variable initCommands @@ -389,14 +389,14 @@ proc auto_mkindex_parser::hook {cmd} { # auto_mkindex_parser::slavehook command # -# Registers a Tcl command to evaluate when initializing the slave interpreter -# used by the mkindex parser. The command is evaluated in the slave +# Registers a Tcl command to evaluate when initializing the child interpreter +# used by the mkindex parser. The command is evaluated in the child # interpreter. proc auto_mkindex_parser::slavehook {cmd} { variable initCommands - # The $parser variable is defined to be the name of the slave interpreter + # The $parser variable is defined to be the name of the child interpreter # when this command is used later. lappend initCommands "\$parser eval [list $cmd]" @@ -550,7 +550,7 @@ auto_mkindex_parser::command proc {name args} { # Conditionally add support for Tcl byte code files. There are some tricky # details here. First, we need to get the tbcload library initialized in the -# current interpreter. We cannot load tbcload into the slave until we have +# current interpreter. We cannot load tbcload into the child until we have # done so because it needs access to the tcl_patchLevel variable. Second, # because the package index file may defer loading the library until we invoke # a command, we need to explicitly invoke auto_load to force it to be loaded. diff --git a/tests/appendComp.test b/tests/appendComp.test index bbf5f9c..a0069ac 100644 --- a/tests/appendComp.test +++ b/tests/appendComp.test @@ -359,9 +359,9 @@ test appendComp-7.9 {append var does not trigger read trace} -setup { } -result {0} test appendComp-8.1 {defer error to runtime} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { proc foo {} { proc append args {} append @@ -369,7 +369,7 @@ test appendComp-8.1 {defer error to runtime} -setup { foo } } -cleanup { - interp delete slave + interp delete child } -result {} # New tests for bug 3057639 to show off the more consistent behaviour of diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test index 4721553..6768772 100644 --- a/tests/autoMkindex.test +++ b/tests/autoMkindex.test @@ -146,10 +146,10 @@ test autoMkindex-1.3 {examine tclIndex} -setup { test autoMkindex-2.1 {commands on the autoload path can be imported} -setup { file delete tclIndex - interp create slave + interp create child } -body { auto_mkindex . autoMkindex.tcl - slave eval { + child eval { namespace eval blt {} set auto_path [linsert $auto_path 0 .] set info [list [catch {namespace import buried::*} result] $result] @@ -159,7 +159,7 @@ test autoMkindex-2.1 {commands on the autoload path can be imported} -setup { return $info } } -cleanup { - interp delete slave + interp delete child } -result "0 {} pub_one ::buried::pub_one pub_two ::buried::pub_two" # Test auto_mkindex hooks @@ -180,7 +180,7 @@ test autoMkindex-3.1 {slaveHook} -setup { } -cleanup { # Reset initCommands to avoid trashing other tests AutoMkindexTestReset -} -result 1 +} -result 1 # The auto_mkindex_parser::command is used to register commands that create # new commands. test autoMkindex-3.2 {auto_mkindex_parser::command} -setup { @@ -335,14 +335,14 @@ test autoMkindex-5.2 {correctly locate auto loaded procs with []} -setup { proc {[magic mojo proc]} {} {} } [file join pkg magicchar2.tcl] set result {} - interp create slave + interp create child } -body { auto_mkindex . pkg/magicchar2.tcl - # Make a slave interp to test the autoloading - slave eval {lappend auto_path [pwd]} - slave eval {catch {{[magic mojo proc]}}} + # Make a child interp to test the autoloading + child eval {lappend auto_path [pwd]} + child eval {catch {{[magic mojo proc]}}} } -cleanup { - interp delete slave + interp delete child removeFile [file join pkg magicchar2.tcl] removeDirectory pkg } -result 0 diff --git a/tests/basic.test b/tests/basic.test index 5066877..bea5870 100644 --- a/tests/basic.test +++ b/tests/basic.test @@ -256,7 +256,7 @@ test basic-18.1 {TclRenameCommand, name of existing cmd can have namespace quali } list [test_ns_basic::p] \ [rename test_ns_basic::p test_ns_basic::q] \ - [test_ns_basic::q] + [test_ns_basic::q] } {{p in ::test_ns_basic} {} {p in ::test_ns_basic}} test basic-18.2 {TclRenameCommand, existing cmd must be found} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -469,11 +469,11 @@ test basic-26.2 {Tcl_EvalObjEx, pure-list branch: preserve "objv"} -body { # a - the pure-list internal rep is destroyed by shimmering # b - the command returns an error # As the error code in Tcl_EvalObjv accesses the list elements, this will - # cause a segfault if [Bug 1119369] has not been fixed. + # cause a segfault if [Bug 1119369] has not been fixed. # NOTE: a MEM_DEBUG build may be necessary to guarantee the segfault. # - set SRC [list foo 1] ;# pure-list command + set SRC [list foo 1] ;# pure-list command proc foo str { # Shimmer pure-list to cmdName, cleanup and error proc $::SRC {} {}; $::SRC @@ -491,11 +491,11 @@ test basic-26.3 {Tcl_EvalObjEx, pure-list branch: preserve "objv"} -body { # Follow the pure-list branch in a manner that # a - the pure-list internal rep is destroyed by shimmering # b - the command accesses its command line - # This will cause a segfault if [Bug 1119369] has not been fixed. + # This will cause a segfault if [Bug 1119369] has not been fixed. # NOTE: a MEM_DEBUG build may be necessary to guarantee the segfault. # - set SRC [list foo 1] ;# pure-list command + set SRC [list foo 1] ;# pure-list command proc foo str { # Shimmer pure-list to cmdName, cleanup and error proc $::SRC {} {}; $::SRC @@ -607,7 +607,7 @@ test basic-46.2 {Tcl_AllowExceptions: exception return not allowed} -setup { invoked "break" outside of a loop while executing "break" - (file "*BREAKtest" line 3)} + (file "*BREAKtest" line 3)} test basic-46.3 {Tcl_AllowExceptions: exception return not allowed} -setup { set fName [makeFile { @@ -624,7 +624,7 @@ test basic-46.3 {Tcl_AllowExceptions: exception return not allowed} -setup { } -returnCodes error -match glob -result {invoked "break" outside of a loop while executing "break" - (file "*BREAKtest" line 4)} + (file "*BREAKtest" line 4)} test basic-46.4 {Tcl_AllowExceptions: exception return not allowed} -setup { set fName [makeFile { @@ -752,7 +752,7 @@ test basic-48.1.$noComp {expansion: parsing} $constraints { # Another comment list 1 2\ 3 {*}$::l1 - + # Comment again } } {1 2 3 a {b b} c d} @@ -825,7 +825,7 @@ test basic-48.13.$noComp {expansion: odd usage} $constraints { test basic-48.14.$noComp {expansion: hash command} -setup { catch {rename \# ""} set cmd "#" - } -constraints $constraints -body { + } -constraints $constraints -body { run { {*}$cmd apa bepa } } -cleanup { unset cmd @@ -885,7 +885,7 @@ test basic-48.16.$noComp {expansion: testing for leaks} -setup { stress set tmp $end set end [getbytes] - } + } set leak [expr {$end - $tmp}] } -cleanup { unset end i tmp @@ -896,7 +896,7 @@ test basic-48.16.$noComp {expansion: testing for leaks} -setup { test basic-48.17.$noComp {expansion: object safety} -setup { set old_precision $::tcl_precision set ::tcl_precision 4 - } -constraints $constraints -body { + } -constraints $constraints -body { set third [expr {1.0/3.0}] set l [list $third $third] set x [run {list $third {*}$l $third}] @@ -1003,13 +1003,13 @@ test basic-49.2 {Tcl_EvalEx: verify TCL_EVAL_GLOBAL operation} testevalex { } {global} test basic-50.1 {[586e71dce4] EvalObjv level #0 exception handling} -setup { - interp create slave - interp alias {} foo slave return + interp create child + interp alias {} foo child return } -body { list [catch foo m] $m } -cleanup { unset -nocomplain m - interp delete slave + interp delete child } -result {0 {}} # Clean up after expand tests diff --git a/tests/cmdAH.test b/tests/cmdAH.test index f19e11a..3809f23 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -1638,7 +1638,7 @@ test cmdAH-31.9 {Tcl_FileObjCmd: channels in other interp} { lsort [safeInterp eval [list file channels]] } [lsort [list stdout $newFileId]] test cmdAH-31.10 {Tcl_FileObjCmd: channels in other interp} { - # we can now write to $newFileId from slave + # we can now write to $newFileId from child safeInterp eval [list puts $newFileId "hello"] } {} interp transfer {} $newFileId safeInterp diff --git a/tests/compExpr.test b/tests/compExpr.test index 14c875d..d1739de 100644 --- a/tests/compExpr.test +++ b/tests/compExpr.test @@ -353,9 +353,9 @@ test compExpr-7.1 {Memory Leak} -constraints memory -setup { } -body { set end [getbytes] for {set i 0} {$i < 5} {incr i} { - interp create slave - slave eval expr 1+2+3+4+5+6+7+8+9+10+11+12+13 - interp delete slave + interp create child + child eval expr 1+2+3+4+5+6+7+8+9+10+11+12+13 + interp delete child set tmp $end set end [getbytes] } diff --git a/tests/coroutine.test b/tests/coroutine.test index df545f5..4c35460 100644 --- a/tests/coroutine.test +++ b/tests/coroutine.test @@ -66,7 +66,7 @@ test coroutine-1.3 {yield returns new arg} -setup { incr i } } - coroutine foo ::apply [list {{start 2} {stop 10}} $body] + coroutine foo ::apply [list {{start 2} {stop 10}} $body] set res {} } -body { for {set k 1} {$k < 4} {incr k} { @@ -476,7 +476,7 @@ test coroutine-5.1 {right numLevels on coro return} -constraints {testnrelevels} expr {[lindex [testnrelevels] 1] - 1} } proc relativeLevel base { - # remove the level for this proc's call + # remove the level for this proc's call expr {[getNumLevel] - $base - 1} } proc foo {} { @@ -517,7 +517,7 @@ test coroutine-5.2 {right numLevels within coro} -constraints {testnrelevels} \ expr {[lindex [testnrelevels] 1] - 1} } proc relativeLevel base { - # remove the level for this proc's call + # remove the level for this proc's call expr {[getNumLevel] - $base - 1} } proc foo base { @@ -588,7 +588,7 @@ test coroutine-7.2 {multi-argument yielding with yieldto} -body { coroutine a corobody coroutine b corobody list [a x] [a y z] [a \{p] [a \{q r] [a] [a] [rename a {}] \ - [b ok] [rename b {}] + [b ok] [rename b {}] } -cleanup { rename corobody {} } -result {x {y z 2} \{p {\{q r 2} {} 0 {} ok {}} @@ -771,25 +771,25 @@ test coroutine-8.0.1 {coro inject after error} -body { lappend ::result [catch {demo} err] $err } -result {inject-executed 1 test} test coroutine-8.1.1 {coro inject, ticket 42202ba1e5ff566e} -body { - interp create slave - slave eval { + interp create child + child eval { coroutine demo apply {{} { while {1} yield }} demo tcl::unsupported::inject demo set ::result inject-executed } - interp delete slave + interp delete child } -result {} test coroutine-8.1.2 {coro inject with result, ticket 42202ba1e5ff566e} -body { - interp create slave - slave eval { + interp create child + child eval { coroutine demo apply {{} { while {1} yield }} demo tcl::unsupported::inject demo set ::result inject-executed } - slave eval demo - set result [slave eval {set ::result}] + child eval demo + set result [child eval {set ::result}] - interp delete slave + interp delete child set result } -result {inject-executed} diff --git a/tests/env.test b/tests/env.test index 8eb5612..9b8016c 100644 --- a/tests/env.test +++ b/tests/env.test @@ -324,11 +324,11 @@ test env-5.2 {corner cases - unset the env array} -setup { } -result {0} -test env-5.3 {corner cases: unset the env in master should unset child} -setup { +test env-5.3 {corner cases: unset the env in parent should unset child} -setup { setup1 interp create i } -body { - # Variables deleted in a master interp should be deleted in child interp + # Variables deleted in a parent interp should be deleted in child interp # too. i eval {set env(THIS_SHOULD_EXIST) a} set result [set env(THIS_SHOULD_EXIST)] diff --git a/tests/execute.test b/tests/execute.test index 468901d..da3e2d4 100644 --- a/tests/execute.test +++ b/tests/execute.test @@ -657,56 +657,56 @@ test execute-6.8 {TclCompEvalObj: bytecode name resolution epoch validation} -se namespace delete foo } -result {0 AHA!} test execute-6.9 {TclCompEvalObj: bytecode interp validation} -setup { - interp create slave + interp create child } -body { set script { llength {} } - slave eval {proc llength args {return AHA!}} + child eval {proc llength args {return AHA!}} set result {} lappend result [if 1 $script] - lappend result [slave eval $script] + lappend result [child eval $script] } -cleanup { - interp delete slave + interp delete child } -result {0 AHA!} test execute-6.10 {TclCompEvalObj: bytecode interp validation} -body { set script { llength {} } - interp create slave + interp create child set result {} - lappend result [slave eval $script] - interp delete slave - interp create slave - lappend result [slave eval $script] + lappend result [child eval $script] + interp delete child + interp create child + lappend result [child eval $script] } -cleanup { - catch {interp delete slave} + catch {interp delete child} } -result {0 0} test execute-6.11 {Tcl_ExprObj: exprcode interp validation} -setup { - interp create slave + interp create child } -constraints testexprlongobj -body { set e { [llength {}]+1 } set result {} - load {} Tcltest slave - interp alias {} e slave testexprlongobj + load {} Tcltest child + interp alias {} e child testexprlongobj lappend result [e $e] - interp delete slave - interp create slave - load {} Tcltest slave - interp alias {} e slave testexprlongobj + interp delete child + interp create child + load {} Tcltest child + interp alias {} e child testexprlongobj lappend result [e $e] } -cleanup { - interp delete slave + interp delete child } -result {{This is a result: 1} {This is a result: 1}} test execute-6.12 {Tcl_ExprObj: exprcode interp validation} -setup { - interp create slave + interp create child } -body { set e { [llength {}]+1 } set result {} - interp alias {} e slave expr + interp alias {} e child expr lappend result [e $e] - interp delete slave - interp create slave - interp alias {} e slave expr + interp delete child + interp create child + interp alias {} e child expr lappend result [e $e] } -cleanup { - interp delete slave + interp delete child } -result {1 1} test execute-6.13 {Tcl_ExprObj: exprcode epoch validation} -body { set e { [llength {}]+1 } @@ -747,16 +747,16 @@ test execute-6.15 {Tcl_ExprObj: exprcode name resolution epoch validation} -setu namespace delete foo } -result {1 2} test execute-6.16 {Tcl_ExprObj: exprcode interp validation} -setup { - interp create slave + interp create child } -body { set e { [llength {}]+1 } - interp alias {} e slave expr - slave eval {proc llength args {return 1}} + interp alias {} e child expr + child eval {proc llength args {return 1}} set result {} lappend result [expr $e] lappend result [e $e] } -cleanup { - interp delete slave + interp delete child } -result {1 2} test execute-6.17 {Tcl_ExprObj: exprcode context validation} -body { proc foo e {set v 0; expr $e} @@ -982,8 +982,8 @@ test execute-8.5 {Bug 2038069} -setup { "catch \[list error FOO\] m o"} -errorline 2} test execute-8.6 {Compile epoch bump in global level (bug [fa6bf38d07])} -setup { - interp create slave - slave eval { + interp create child + child eval { package require tcltest catch [list package require -exact Tcltest [info patchlevel]] ::tcltest::loadTestedCommands @@ -992,31 +992,31 @@ test execute-8.6 {Compile epoch bump in global level (bug [fa6bf38d07])} -setup } } } -body { - slave eval { + child eval { lappend res A; testbumpinterpepoch; lappend res B; return; lappend res C; } - slave eval { + child eval { set i 0; while {[incr i] < 3} { lappend res A; testbumpinterpepoch; lappend res B; return; lappend res C; } } - slave eval { + child eval { set i 0; while {[incr i] < 3} { lappend res A; testbumpinterpepoch; lappend res B; break; lappend res C; } } - slave eval { + child eval { catch { lappend res A; testbumpinterpepoch; lappend res B; error test; lappend res C; } } - slave eval {set res} + child eval {set res} } -cleanup { - interp delete slave + interp delete child } -result [lrepeat 4 A B] test execute-8.7 {Compile epoch bump in global level (bug [fa6bf38d07]), exception case} -setup { - interp create slave - slave eval { + interp create child + child eval { package require tcltest catch [list package require -exact Tcltest [info patchlevel]] ::tcltest::loadTestedCommands @@ -1027,28 +1027,28 @@ test execute-8.7 {Compile epoch bump in global level (bug [fa6bf38d07]), excepti } -body { set res {} lappend res [catch { - slave eval { + child eval { lappend res A; testbumpinterpepoch; lappend res B; return -code error test; lappend res C; } } e] $e lappend res [catch { - slave eval { + child eval { lappend res A; testbumpinterpepoch; lappend res B; error test; lappend res C; } } e] $e lappend res [catch { - slave eval { + child eval { lappend res A; testbumpinterpepoch; lappend res B; return -code return test; lappend res C; } } e] $e lappend res [catch { - slave eval { + child eval { lappend res A; testbumpinterpepoch; lappend res B; break; lappend res C; } } e] $e - list $res [slave eval {set res}] + list $res [child eval {set res}] } -cleanup { - interp delete slave + interp delete child } -result [list {1 test 1 test 2 test 3 {}} [lrepeat 4 A B]] test execute-9.1 {Interp result resetting [Bug 1522803]} { @@ -1069,16 +1069,16 @@ test execute-10.1 {TclExecuteByteCode, INST_CONCAT1, bytearrays} { apply {s {binary scan $s c x; list $x [scan $s$s %c%c]}} \u0130 } {48 {304 304}} test execute-10.2 {Bug 2802881} -setup { - interp create slave + interp create child } -body { # If [Bug 2802881] is not fixed, this will segfault - slave eval { + child eval { trace add variable ::errorInfo write {expr {$foo} ;#} proc demo {} {a {}{}} demo } } -cleanup { - interp delete slave + interp delete child } -returnCodes error -match glob -result * test execute-10.3 {Bug 3072640} -setup { proc generate {n} { @@ -1086,8 +1086,8 @@ test execute-10.3 {Bug 3072640} -setup { yield $i } } - proc t {args} { - incr ::foo + proc t {args} { + incr ::foo } set ::foo 0 trace add execution ::generate enterstep ::t @@ -1103,9 +1103,9 @@ test execute-10.3 {Bug 3072640} -setup { } -result 4 test execute-11.1 {Bug 3142026: GrowEvaluationStack off-by-one} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { set x [lrepeat 1320 199] for {set i 0} {$i < 20} {incr i} { lappend x $i @@ -1115,7 +1115,7 @@ test execute-11.1 {Bug 3142026: GrowEvaluationStack off-by-one} -setup { return ok } } -cleanup { - interp delete slave + interp delete child } -result ok test execute-11.2 {Bug 268b23df11} -setup { diff --git a/tests/http.test b/tests/http.test index 73fe10c..e6255bf 100644 --- a/tests/http.test +++ b/tests/http.test @@ -19,7 +19,7 @@ if {[catch {package require http 2} version]} { catch {puts "Cannot load http 2.* package"} return } else { - catch {puts "Running http 2.* tests in slave interp"} + catch {puts "Running http 2.* tests in child interp"} set interp [interp create http2] $interp eval [list set http2 "running"] $interp eval [list set argv $argv] diff --git a/tests/httpold.test b/tests/httpold.test index e63bcda..acc5a6e 100644 --- a/tests/httpold.test +++ b/tests/httpold.test @@ -22,7 +22,7 @@ if {[catch {package require http 1.0}]} { ::tcltest::cleanupTests return } else { - catch {puts "Running http 1.0 tests in slave interp"} + catch {puts "Running http 1.0 tests in child interp"} set interp [interp create httpold] $interp eval [list set httpold "running"] $interp eval [list set argv $argv] diff --git a/tests/interp.test b/tests/interp.test index 3fe8c67..8a4d064 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -56,7 +56,7 @@ test interp-1.8 {options for interp command} -returnCodes error -body { } -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.9 {options for interp command} -returnCodes error -body { interp -froboz -safe -} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} test interp-1.10 {options for interp command} -returnCodes error -body { interp target } -result {wrong # args: should be "interp target path alias"} @@ -70,7 +70,7 @@ test interp-2.2 {basic interpreter creation} { } 0 test interp-2.3 {basic interpreter creation} { catch {interp create -safe} -} 0 +} 0 test interp-2.4 {basic interpreter creation} -setup { catch {interp create a} } -returnCodes error -body { @@ -106,7 +106,7 @@ test interp-2.11 {anonymous interps vs existing procs} { set x [interp create] regexp "interp(\[0-9]+)" $x dummy anothernum expr $anothernum > $thenum -} 1 +} 1 test interp-2.12 {anonymous interps vs existing procs} { set x [interp create -safe] regexp "interp(\[0-9]+)" $x dummy thenum @@ -247,27 +247,27 @@ test interp-6.6 {testing eval} -returnCodes error -body { interp eval {a x2} foo } -result {invalid command name "foo"} -# UTILITY PROCEDURE RUNNING IN MASTER INTERPRETER: -proc in_master {args} { - return [list seen in master: $args] +# UTILITY PROCEDURE RUNNING IN PARENT INTERPRETER: +proc in_parent {args} { + return [list seen in parent: $args] } # Part 6: Testing basic alias creation test interp-7.1 {testing basic alias creation} { - a alias foo in_master + a alias foo in_parent } foo -catch {a alias foo in_master} +catch {a alias foo in_parent} test interp-7.2 {testing basic alias creation} { - a alias bar in_master a1 a2 a3 + a alias bar in_parent a1 a2 a3 } bar -catch {a alias bar in_master a1 a2 a3} +catch {a alias bar in_parent a1 a2 a3} # Test 6.3 has been deleted. test interp-7.3 {testing basic alias creation} { a alias foo -} in_master +} in_parent test interp-7.4 {testing basic alias creation} { a alias bar -} {in_master a1 a2 a3} +} {in_parent a1 a2 a3} test interp-7.5 {testing basic alias creation} { lsort [a aliases] } {bar foo} @@ -278,14 +278,14 @@ test interp-7.6 {testing basic aliases arg checking} -returnCodes error -body { # Part 7: testing basic alias invocation test interp-8.1 {testing basic alias invocation} { catch {interp create a} - a alias foo in_master + a alias foo in_parent a eval foo s1 s2 s3 -} {seen in master: {s1 s2 s3}} +} {seen in parent: {s1 s2 s3}} test interp-8.2 {testing basic alias invocation} { catch {interp create a} - a alias bar in_master a1 a2 a3 + a alias bar in_parent a1 a2 a3 a eval bar s1 s2 s3 -} {seen in master: {a1 a2 a3 s1 s2 s3}} +} {seen in parent: {a1 a2 a3 s1 s2 s3}} test interp-8.3 {testing basic alias invocation} -returnCodes error -body { catch {interp create a} a alias @@ -294,13 +294,13 @@ test interp-8.3 {testing basic alias invocation} -returnCodes error -body { # Part 8: Testing aliases for non-existent or hidden targets test interp-9.1 {testing aliases for non-existent targets} { catch {interp create a} - a alias zop nonexistent-command-in-master + a alias zop nonexistent-command-in-parent list [catch {a eval zop} msg] $msg -} {1 {invalid command name "nonexistent-command-in-master"}} +} {1 {invalid command name "nonexistent-command-in-parent"}} test interp-9.2 {testing aliases for non-existent targets} { catch {interp create a} - a alias zop nonexistent-command-in-master - proc nonexistent-command-in-master {} {return i_exist!} + a alias zop nonexistent-command-in-parent + proc nonexistent-command-in-parent {} {return i_exist!} a eval zop } i_exist! test interp-9.3 {testing aliases for hidden commands} { @@ -329,8 +329,8 @@ test interp-9.4 {testing aliases and namespace commands} { set res } {GLOBAL GLOBAL} -if {[info command nonexistent-command-in-master] != ""} { - rename nonexistent-command-in-master {} +if {[info command nonexistent-command-in-parent] != ""} { + rename nonexistent-command-in-parent {} } # Part 9: Aliasing between interpreters @@ -380,9 +380,9 @@ test interp-10.6 {testing aliasing between interpreters} { interp create a interp create b interp alias a a_command b b_command a1 a2 a3 - b alias b_command in_master b1 b2 b3 + b alias b_command in_parent b1 b2 b3 a eval a_command m1 m2 m3 -} {seen in master: {b1 b2 b3 a1 a2 a3 m1 m2 m3}} +} {seen in parent: {b1 b2 b3 a1 a2 a3 m1 m2 m3}} test interp-10.7 {testing aliases between interpreters} { catch {interp delete a} interp create a @@ -513,7 +513,7 @@ test interp-14.3 {testing interp aliases} { interp alias {a x3} froboz "" puts interp aliases {a x3} } froboz -test interp-14.4 {testing interp alias - alias over master} { +test interp-14.4 {testing interp alias - alias over parent} { # SF Bug 641195 catch {interp delete a} interp create a @@ -793,32 +793,32 @@ test interp-17.6 {alias loop prevention} { } {1 {cannot define or rename alias "b": would create a loop}} # -# Test robustness of Tcl_DeleteInterp when applied to a slave interpreter. +# Test robustness of Tcl_DeleteInterp when applied to a child interpreter. # If there are bugs in the implementation these tests are likely to expose # the bugs as a core dump. # -test interp-18.1 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.1 {testing Tcl_DeleteInterp vs children} testinterpdelete { list [catch {testinterpdelete} msg] $msg } {1 {wrong # args: should be "testinterpdelete path"}} -test interp-18.2 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.2 {testing Tcl_DeleteInterp vs children} testinterpdelete { catch {interp delete a} interp create a testinterpdelete a } "" -test interp-18.3 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.3 {testing Tcl_DeleteInterp vs children} testinterpdelete { catch {interp delete a} interp create a interp create {a b} testinterpdelete {a b} } "" -test interp-18.4 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.4 {testing Tcl_DeleteInterp vs children} testinterpdelete { catch {interp delete a} interp create a interp create {a b} testinterpdelete a } "" -test interp-18.5 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.5 {testing Tcl_DeleteInterp vs children} testinterpdelete { catch {interp delete a} interp create a interp create {a b} @@ -826,7 +826,7 @@ test interp-18.5 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { proc dodel {x} {testinterpdelete $x} list [catch {interp eval {a b} {dodel {a b}}} msg] $msg } {0 {}} -test interp-18.6 {testing Tcl_DeleteInterp vs slaves} testinterpdelete { +test interp-18.6 {testing Tcl_DeleteInterp vs children} testinterpdelete { catch {interp delete a} interp create a interp create {a b} @@ -876,12 +876,12 @@ test interp-18.9 {eval in deleted interp, bug 495830} { interp create tst interp alias tst suicide {} interp delete tst list [catch {tst eval {suicide; set a 5}} msg] $msg -} {1 {attempt to call eval in deleted interpreter}} +} {1 {attempt to call eval in deleted interpreter}} test interp-18.10 {eval in deleted interp, bug 495830} { interp create tst interp alias tst suicide {} interp delete tst list [catch {tst eval {set set set; suicide; $set a 5}} msg] $msg -} {1 {attempt to call eval in deleted interpreter}} +} {1 {attempt to call eval in deleted interpreter}} # Test alias deletion @@ -971,7 +971,7 @@ test interp-19.9 {alias deletion, renaming} { set l [interp eval a foo] interp delete a set l -} 1156 +} 1156 test interp-20.1 {interp hide, interp expose and interp invokehidden} { set a [interp create] @@ -1192,7 +1192,7 @@ test interp-20.21 {interp hide vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {a hide list} msg] + lappend l [catch {a hide list} msg] lappend l $msg interp delete a set l @@ -1201,7 +1201,7 @@ test interp-20.22 {interp hide vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {interp hide a list} msg] + lappend l [catch {interp hide a list} msg] lappend l $msg interp delete a set l @@ -1210,7 +1210,7 @@ test interp-20.23 {interp hide vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {a eval {interp hide {} list}} msg] + lappend l [catch {a eval {interp hide {} list}} msg] lappend l $msg interp delete a set l @@ -1220,7 +1220,7 @@ test interp-20.24 {interp hide vs safety} { interp create a -safe interp create {a b} set l "" - lappend l [catch {a eval {interp hide b list}} msg] + lappend l [catch {a eval {interp hide b list}} msg] lappend l $msg interp delete a set l @@ -1239,7 +1239,7 @@ test interp-20.26 {interp expoose vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {a hide list} msg] + lappend l [catch {a hide list} msg] lappend l $msg lappend l [catch {a expose list} msg] lappend l $msg @@ -1250,9 +1250,9 @@ test interp-20.27 {interp expose vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {interp hide a list} msg] + lappend l [catch {interp hide a list} msg] lappend l $msg - lappend l [catch {interp expose a list} msg] + lappend l [catch {interp expose a list} msg] lappend l $msg interp delete a set l @@ -1261,7 +1261,7 @@ test interp-20.28 {interp expose vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {a hide list} msg] + lappend l [catch {a hide list} msg] lappend l $msg lappend l [catch {a eval {interp expose {} list}} msg] lappend l $msg @@ -1272,9 +1272,9 @@ test interp-20.29 {interp expose vs safety} { catch {interp delete a} interp create a -safe set l "" - lappend l [catch {interp hide a list} msg] + lappend l [catch {interp hide a list} msg] lappend l $msg - lappend l [catch {a eval {interp expose {} list}} msg] + lappend l [catch {a eval {interp expose {} list}} msg] lappend l $msg interp delete a set l @@ -1284,9 +1284,9 @@ test interp-20.30 {interp expose vs safety} { interp create a -safe interp create {a b} set l "" - lappend l [catch {interp hide {a b} list} msg] + lappend l [catch {interp hide {a b} list} msg] lappend l $msg - lappend l [catch {a eval {interp expose b list}} msg] + lappend l [catch {a eval {interp expose b list}} msg] lappend l $msg interp delete a set l @@ -1296,7 +1296,7 @@ test interp-20.31 {interp expose vs safety} { interp create a -safe interp create {a b} set l "" - lappend l [catch {interp hide {a b} list} msg] + lappend l [catch {interp hide {a b} list} msg] lappend l $msg lappend l [catch {interp expose {a b} list} msg] lappend l $msg @@ -1615,36 +1615,36 @@ test interp-20.49 {interp invokehidden -namespace} -setup { set script [makeFile { set x [namespace current] } script] - interp create -safe slave + interp create -safe child } -body { - slave invokehidden -namespace ::foo source $script - slave eval {set ::foo::x} + child invokehidden -namespace ::foo source $script + child eval {set ::foo::x} } -cleanup { - interp delete slave + interp delete child removeFile script } -result ::foo test interp-20.50 {Bug 2486550} -setup { - interp create slave + interp create child } -body { - slave hide coroutine - slave invokehidden coroutine + child hide coroutine + child invokehidden coroutine } -cleanup { - interp delete slave + interp delete child } -returnCodes error -match glob -result * test interp-20.50.1 {Bug 2486550} -setup { - interp create slave + interp create child } -body { - slave hide coroutine - catch {slave invokehidden coroutine} m o + child hide coroutine + catch {child invokehidden coroutine} m o dict get $o -errorinfo } -cleanup { unset -nocomplain m 0 - interp delete slave + interp delete child } -returnCodes ok -result {wrong # args: should be "coroutine name cmd ?arg ...?" while executing "coroutine" invoked from within -"slave invokehidden coroutine"} +"child invokehidden coroutine"} test interp-21.1 {interp hidden} { interp hidden {} @@ -1676,7 +1676,7 @@ test interp-21.5 {interp hidden} -setup { lsort [interp hidden a] } -cleanup { interp delete a -} -result $hidden_cmds +} -result $hidden_cmds test interp-21.6 {interp hidden vs interp hide, interp expose} -setup { catch {interp delete a} set l "" @@ -2058,8 +2058,8 @@ test interp-25.1 {testing aliasing of string commands} -setup { test interp-26.1 {result code transmission : interp eval direct} { # Test that all the possibles error codes from Tcl get passed up - # from the slave interp's context to the master, even though the - # slave nominally thinks the command is running at the root level. + # from the child interp's context to the parent, even though the + # child nominally thinks the command is running at the root level. catch {interp delete a} interp create a set res {} @@ -2085,7 +2085,7 @@ test interp-26.2 {result code transmission : interp eval indirect} { } {-1 ret-1 0 ret0 1 ret1 0 ret2 3 ret3 4 ret4 5 ret5} test interp-26.3 {result code transmission : aliases} { # Test that all the possibles error codes from Tcl get passed up from the - # slave interp's context to the master, even though the slave nominally + # child interp's context to the parent, even though the child nominally # thinks the command is running at the root level. catch {interp delete a} interp create a @@ -2180,7 +2180,7 @@ test interp-26.8 {errorInfo transmission: safe interps--bug 1637} -setup { } -constraints knownBug -body { # this test fails because the errorInfo is fully transmitted whether the # interp is safe or not. The errorInfo should never report data from the - # master interpreter because it could contain sensitive information. + # parent interpreter because it could contain sensitive information. proc MyError {secret} { return -code error "msg" } @@ -2200,7 +2200,7 @@ test interp-27.1 {interp aliases & namespaces} -setup { set i [interp create] } -body { set aliasTrace {} - proc tstAlias {args} { + proc tstAlias {args} { global aliasTrace lappend aliasTrace [list [namespace current] $args] } @@ -2214,7 +2214,7 @@ test interp-27.2 {interp aliases & namespaces} -setup { set i [interp create] } -body { set aliasTrace {} - proc tstAlias {args} { + proc tstAlias {args} { global aliasTrace lappend aliasTrace [list [namespace current] $args] } @@ -2228,7 +2228,7 @@ test interp-27.3 {interp aliases & namespaces} -setup { set i [interp create] } -body { set aliasTrace {} - proc tstAlias {args} { + proc tstAlias {args} { global aliasTrace lappend aliasTrace [list [namespace current] $args] } @@ -2244,7 +2244,7 @@ test interp-27.4 {interp aliases & namespaces} -setup { } -body { namespace eval foo2 { variable aliasTrace {} - proc bar {args} { + proc bar {args} { variable aliasTrace lappend aliasTrace [list [namespace current] $args] } @@ -2275,22 +2275,22 @@ test interp-27.5 {interp hidden & namespaces} -setup { test interp-27.6 {interp hidden & aliases & namespaces} -setup { set i [interp create] } -constraints knownBug -body { - set v root-master + set v root-parent namespace eval foo { - variable v foo-master + variable v foo-parent proc bar {interp args} { variable v - list "master bar called ($v) ([namespace current]) ($args)"\ + list "parent bar called ($v) ([namespace current]) ($args)"\ [interp invokehidden $interp foo::bar $args] } } interp eval $i { namespace eval foo { namespace export * - variable v foo-slave + variable v foo-child proc bar {args} { variable v - return "slave bar called ($v) ([namespace current]) ($args)" + return "child bar called ($v) ([namespace current]) ($args)" } } } @@ -2298,7 +2298,7 @@ test interp-27.6 {interp hidden & aliases & namespaces} -setup { $i hide foo::bar $i alias foo::bar foo::bar $i set res [concat $res [interp eval $i { - set v root-slave + set v root-child namespace eval test { variable v foo-test namespace import ::foo::* @@ -2308,29 +2308,29 @@ test interp-27.6 {interp hidden & aliases & namespaces} -setup { } -cleanup { namespace delete foo interp delete $i -} -result {{slave bar called (foo-slave) (::foo) (test1)} {master bar called (foo-master) (::foo) (test2)} {slave bar called (foo-slave) (::foo) (test2)}} +} -result {{child bar called (foo-child) (::foo) (test1)} {parent bar called (foo-parent) (::foo) (test2)} {child bar called (foo-child) (::foo) (test2)}} test interp-27.7 {interp hidden & aliases & imports & namespaces} -setup { set i [interp create] } -constraints knownBug -body { - set v root-master + set v root-parent namespace eval mfoo { - variable v foo-master + variable v foo-parent proc bar {interp args} { variable v - list "master bar called ($v) ([namespace current]) ($args)"\ + list "parent bar called ($v) ([namespace current]) ($args)"\ [interp invokehidden $interp test::bar $args] } } interp eval $i { namespace eval foo { namespace export * - variable v foo-slave + variable v foo-child proc bar {args} { variable v - return "slave bar called ($v) ([info level 0]) ([uplevel namespace current]) ([namespace current]) ($args)" + return "child bar called ($v) ([info level 0]) ([uplevel namespace current]) ([namespace current]) ($args)" } } - set v root-slave + set v root-child namespace eval test { variable v foo-test namespace import ::foo::* @@ -2343,7 +2343,7 @@ test interp-27.7 {interp hidden & aliases & imports & namespaces} -setup { } -cleanup { namespace delete mfoo interp delete $i -} -result {{slave bar called (foo-slave) (bar test1) (::tcltest) (::foo) (test1)} {master bar called (foo-master) (::mfoo) (test2)} {slave bar called (foo-slave) (test::bar test2) (::) (::foo) (test2)}} +} -result {{child bar called (foo-child) (bar test1) (::tcltest) (::foo) (test1)} {parent bar called (foo-parent) (::mfoo) (test2)} {child bar called (foo-child) (test::bar test2) (::) (::foo) (test2)}} test interp-27.8 {hiding, namespaces and integrity} knownBug { namespace eval foo { variable v 3 @@ -2355,25 +2355,25 @@ test interp-27.8 {hiding, namespaces and integrity} knownBug { list [catch {interp invokehidden {} foo::bar} msg] $msg } {1 {invalid hidden command name "foo"}} -test interp-28.1 {getting fooled by slave's namespace ?} -setup { +test interp-28.1 {getting fooled by child's namespace ?} -setup { set i [interp create -safe] - proc master {interp args} {interp hide $interp list} + proc parent {interp args} {interp hide $interp list} } -body { - $i alias master master $i + $i alias parent parent $i set r [interp eval $i { namespace eval foo { proc list {args} { return "dummy foo::list" } - master + parent } info commands list }] } -cleanup { - rename master {} + rename parent {} interp delete $i } -result {} -test interp-28.2 {master's nsName cache should not cross} -setup { +test interp-28.2 {parent's nsName cache should not cross} -setup { set i [interp create] $i eval {proc filter lst {lsearch -all -inline -not $lst "::tcl"}} } -body { @@ -2432,31 +2432,31 @@ test interp-29.1.7 {interp recursionlimit argument checking} { interp delete moo list $result [string range $msg 0 35] } {1 {integer value too large to represent}} -test interp-29.1.8 {slave recursionlimit argument checking} { +test interp-29.1.8 {child recursionlimit argument checking} { interp create moo set result [catch {moo recursionlimit foo bar} msg] interp delete moo list $result $msg } {1 {wrong # args: should be "moo recursionlimit ?newlimit?"}} -test interp-29.1.9 {slave recursionlimit argument checking} { +test interp-29.1.9 {child recursionlimit argument checking} { interp create moo set result [catch {moo recursionlimit foo} msg] interp delete moo list $result $msg } {1 {expected integer but got "foo"}} -test interp-29.1.10 {slave recursionlimit argument checking} { +test interp-29.1.10 {child recursionlimit argument checking} { interp create moo set result [catch {moo recursionlimit 0} msg] interp delete moo list $result $msg } {1 {recursion limit must be > 0}} -test interp-29.1.11 {slave recursionlimit argument checking} { +test interp-29.1.11 {child recursionlimit argument checking} { interp create moo set result [catch {moo recursionlimit -1} msg] interp delete moo list $result $msg } {1 {recursion limit must be > 0}} -test interp-29.1.12 {slave recursionlimit argument checking} { +test interp-29.1.12 {child recursionlimit argument checking} { interp create moo set result [catch {moo recursionlimit [expr {wide(1)<<32}]} msg] interp delete moo @@ -2549,8 +2549,8 @@ test interp-29.3.3 {recursion limit} { set r } {1 {too many nested evaluations (infinite loop?)} 49} test interp-29.3.4 {recursion limit error reporting} { - interp create slave - set r1 [slave eval { + interp create child + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2564,13 +2564,13 @@ test interp-29.3.4 {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {falling back due to new recursion limit}} test interp-29.3.5 {recursion limit error reporting} { - interp create slave - set r1 [slave eval { + interp create child + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2584,13 +2584,13 @@ test interp-29.3.5 {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {falling back due to new recursion limit}} test interp-29.3.6 {recursion limit error reporting} { - interp create slave - set r1 [slave eval { + interp create child + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2604,8 +2604,8 @@ test interp-29.3.6 {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} # @@ -2613,9 +2613,9 @@ test interp-29.3.6 {recursion limit error reporting} { # level will only be verified when it invokes a non-bcc'd command. # test interp-29.3.7a {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 5} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 5} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2629,14 +2629,14 @@ test interp-29.3.7a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.7b {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 5} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 5} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2650,14 +2650,14 @@ test interp-29.3.7b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.7c {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 5} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 5} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2672,14 +2672,14 @@ test interp-29.3.7c {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {too many nested evaluations (infinite loop?)}} test interp-29.3.8a {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 4} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 4} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2693,14 +2693,14 @@ test interp-29.3.8a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.8b {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 4} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 4} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2714,14 +2714,14 @@ test interp-29.3.8b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {too many nested evaluations (infinite loop?)}} test interp-29.3.9a {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 6} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 6} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2735,14 +2735,14 @@ test interp-29.3.9a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.9b {recursion limit error reporting} { - interp create slave - after 0 {interp recursionlimit slave 6} - set r1 [slave eval { + interp create child + after 0 {interp recursionlimit child 6} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2756,14 +2756,14 @@ test interp-29.3.9b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.10a {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 4} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 4} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2777,14 +2777,14 @@ test interp-29.3.10a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.10b {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 4} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 4} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2798,14 +2798,14 @@ test interp-29.3.10b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {too many nested evaluations (infinite loop?)}} test interp-29.3.11a {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 5} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 5} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2819,14 +2819,14 @@ test interp-29.3.11a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.11b {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 5} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 5} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2841,14 +2841,14 @@ test interp-29.3.11b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {1 {too many nested evaluations (infinite loop?)}} test interp-29.3.12a {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 6} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 6} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2862,14 +2862,14 @@ test interp-29.3.12a {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.3.12b {recursion limit error reporting} { - interp create slave - after 0 {slave recursionlimit 6} - set r1 [slave eval { + interp create child + after 0 {child recursionlimit 6} + set r1 [child eval { catch { # nesting level 1 eval { # 2 eval { # 3 @@ -2884,8 +2884,8 @@ test interp-29.3.12b {recursion limit error reporting} { } } msg }] - set r2 [slave eval { set msg }] - interp delete slave + set r2 [child eval { set msg }] + interp delete child list $r1 $r2 } {0 ok} test interp-29.4.1 {recursion limit inheritance} { @@ -2916,121 +2916,121 @@ test interp-29.4.2 {recursion limit inheritance} { interp delete $i set r } 50 -test interp-29.5.1 {does slave recursion limit affect master?} { +test interp-29.5.1 {does child recursion limit affect parent?} { set before [interp recursionlimit {}] set i [interp create] interp recursionlimit $i 20000 set after [interp recursionlimit {}] - set slavelimit [interp recursionlimit $i] + set childlimit [interp recursionlimit $i] interp delete $i - list [expr {$before == $after}] $slavelimit + list [expr {$before == $after}] $childlimit } {1 20000} -test interp-29.5.2 {does slave recursion limit affect master?} { +test interp-29.5.2 {does child recursion limit affect parent?} { set before [interp recursionlimit {}] set i [interp create] interp recursionlimit $i 20000 set after [interp recursionlimit {}] - set slavelimit [$i recursionlimit] + set childlimit [$i recursionlimit] interp delete $i - list [expr {$before == $after}] $slavelimit + list [expr {$before == $after}] $childlimit } {1 20000} -test interp-29.5.3 {does slave recursion limit affect master?} { +test interp-29.5.3 {does child recursion limit affect parent?} { set before [interp recursionlimit {}] set i [interp create] $i recursionlimit 20000 set after [interp recursionlimit {}] - set slavelimit [interp recursionlimit $i] + set childlimit [interp recursionlimit $i] interp delete $i - list [expr {$before == $after}] $slavelimit + list [expr {$before == $after}] $childlimit } {1 20000} -test interp-29.5.4 {does slave recursion limit affect master?} { +test interp-29.5.4 {does child recursion limit affect parent?} { set before [interp recursionlimit {}] set i [interp create] $i recursionlimit 20000 set after [interp recursionlimit {}] - set slavelimit [$i recursionlimit] + set childlimit [$i recursionlimit] interp delete $i - list [expr {$before == $after}] $slavelimit + list [expr {$before == $after}] $childlimit } {1 20000} test interp-29.6.1 {safe interpreter recursion limit} { - interp create slave -safe - set n [interp recursionlimit slave] - interp delete slave + interp create child -safe + set n [interp recursionlimit child] + interp delete child set n } 1000 test interp-29.6.2 {safe interpreter recursion limit} { - interp create slave -safe - set n [slave recursionlimit] - interp delete slave + interp create child -safe + set n [child recursionlimit] + interp delete child set n } 1000 test interp-29.6.3 {safe interpreter recursion limit} { - interp create slave -safe - set n1 [interp recursionlimit slave 42] - set n2 [interp recursionlimit slave] - interp delete slave + interp create child -safe + set n1 [interp recursionlimit child 42] + set n2 [interp recursionlimit child] + interp delete child list $n1 $n2 } {42 42} test interp-29.6.4 {safe interpreter recursion limit} { - interp create slave -safe - set n1 [slave recursionlimit 42] - set n2 [interp recursionlimit slave] - interp delete slave + interp create child -safe + set n1 [child recursionlimit 42] + set n2 [interp recursionlimit child] + interp delete child list $n1 $n2 } {42 42} test interp-29.6.5 {safe interpreter recursion limit} { - interp create slave -safe - set n1 [interp recursionlimit slave 42] - set n2 [slave recursionlimit] - interp delete slave + interp create child -safe + set n1 [interp recursionlimit child 42] + set n2 [child recursionlimit] + interp delete child list $n1 $n2 } {42 42} test interp-29.6.6 {safe interpreter recursion limit} { - interp create slave -safe - set n1 [slave recursionlimit 42] - set n2 [slave recursionlimit] - interp delete slave + interp create child -safe + set n1 [child recursionlimit 42] + set n2 [child recursionlimit] + interp delete child list $n1 $n2 } {42 42} test interp-29.6.7 {safe interpreter recursion limit} { - interp create slave -safe - set n1 [slave recursionlimit 42] - set n2 [slave recursionlimit] - interp delete slave + interp create child -safe + set n1 [child recursionlimit 42] + set n2 [child recursionlimit] + interp delete child list $n1 $n2 } {42 42} test interp-29.6.8 {safe interpreter recursion limit} { - interp create slave -safe - set n [catch {slave eval {interp recursionlimit {} 42}} msg] - interp delete slave + interp create child -safe + set n [catch {child eval {interp recursionlimit {} 42}} msg] + interp delete child list $n $msg } {1 {permission denied: safe interpreters cannot change recursion limit}} test interp-29.6.9 {safe interpreter recursion limit} { - interp create slave -safe + interp create child -safe set result [ - slave eval { - interp create slave2 -safe + child eval { + interp create child2 -safe set n [catch { - interp recursionlimit slave2 42 + interp recursionlimit child2 42 } msg] list $n $msg } ] - interp delete slave + interp delete child set result } {1 {permission denied: safe interpreters cannot change recursion limit}} test interp-29.6.10 {safe interpreter recursion limit} { - interp create slave -safe + interp create child -safe set result [ - slave eval { - interp create slave2 -safe + child eval { + interp create child2 -safe set n [catch { - slave2 recursionlimit 42 + child2 recursionlimit 42 } msg] list $n $msg } ] - interp delete slave + interp delete child set result } {1 {permission denied: safe interpreters cannot change recursion limit}} @@ -3321,7 +3321,7 @@ test interp-34.9 {time limits trigger in blocking after} { } msg] set t1 [clock seconds] interp delete $i - list $code $msg [expr {($t1-$t0) < 3 ? "OK" : $t1-$t0}] + list $code $msg [expr {($t1-$t0) < 3 ? "OK" : $t1-$t0}] } {1 {time limit exceeded} OK} test interp-34.10 {time limits trigger in vwaits: Bug 1221395} -body { set i [interp create] @@ -3555,48 +3555,48 @@ test interp-35.24 {interp time limits can't touch current interp} -body { test interp-36.1 {interp bgerror syntax} -body { interp bgerror } -returnCodes error -result {wrong # args: should be "interp bgerror path ?cmdPrefix?"} -test interp-36.2 {interp bgerror syntax} -body { +test interp-36.2 {interp bgerror syntax} -body { interp bgerror x y z } -returnCodes error -result {wrong # args: should be "interp bgerror path ?cmdPrefix?"} test interp-36.3 {interp bgerror syntax} -setup { - interp create slave + interp create child } -body { - slave bgerror x y + child bgerror x y } -cleanup { - interp delete slave -} -returnCodes error -result {wrong # args: should be "slave bgerror ?cmdPrefix?"} -test interp-36.4 {SlaveBgerror syntax} -setup { - interp create slave + interp delete child +} -returnCodes error -result {wrong # args: should be "child bgerror ?cmdPrefix?"} +test interp-36.4 {ChildBgerror syntax} -setup { + interp create child } -body { - slave bgerror \{ + child bgerror \{ } -cleanup { - interp delete slave + interp delete child } -returnCodes error -result {cmdPrefix must be list of length >= 1} -test interp-36.5 {SlaveBgerror syntax} -setup { - interp create slave +test interp-36.5 {ChildBgerror syntax} -setup { + interp create child } -body { - slave bgerror {} + child bgerror {} } -cleanup { - interp delete slave + interp delete child } -returnCodes error -result {cmdPrefix must be list of length >= 1} -test interp-36.6 {SlaveBgerror returns handler} -setup { - interp create slave +test interp-36.6 {ChildBgerror returns handler} -setup { + interp create child } -body { - slave bgerror {foo bar soom} + child bgerror {foo bar soom} } -cleanup { - interp delete slave + interp delete child } -result {foo bar soom} -test interp-36.7 {SlaveBgerror sets error handler of slave [1999035]} -setup { - interp create slave - slave alias handler handler - slave bgerror handler +test interp-36.7 {ChildBgerror sets error handler of child [1999035]} -setup { + interp create child + child alias handler handler + child bgerror handler variable result {untouched} proc handler {args} { variable result set result [lindex $args 0] } } -body { - slave eval { + child eval { variable done {} after 0 error foo after 10 [list ::set [namespace which -variable done] {}] @@ -3606,7 +3606,7 @@ test interp-36.7 {SlaveBgerror sets error handler of slave [1999035]} -setup { } -cleanup { variable result {} unset -nocomplain result - interp delete slave + interp delete child } -result foo test interp-37.1 {safe interps and min() and max(): Bug 2895741} -setup { diff --git a/tests/io.test b/tests/io.test index 18636c1..2dc1715 100644 --- a/tests/io.test +++ b/tests/io.test @@ -8694,16 +8694,16 @@ 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 + interp create child } -constraints testobj -body { teststringobj set 1 [string range $rfd 0 end] read [teststringobj get 1] testobj duplicate 1 2 - interp transfer {} $rfd slave + interp transfer {} $rfd child catch {read [teststringobj get 1]} read [teststringobj get 2] } -cleanup { - interp delete slave + interp delete child testobj freeallvars removeFile io-74.1 } -returnCodes error -match glob -result {can not find channel named "*"} diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 5c45630..18b228e 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -2029,7 +2029,7 @@ test iocmd-32.0 {origin interpreter of moved channel gone} -match glob -body { set ida [interp create];#puts <<$ida>> set idb [interp create];#puts <<$idb>> - # Magic to get the test* commands in the slaves + # Magic to get the test* commands in the children load {} Tcltest $ida load {} Tcltest $idb @@ -2067,7 +2067,7 @@ test iocmd-32.1 {origin interpreter of moved channel destroyed during access} -m set ida [interp create];#puts <<$ida>> set idb [interp create];#puts <<$idb>> - # Magic to get the test* commands in the slaves + # Magic to get the test* commands in the children load {} Tcltest $ida load {} Tcltest $idb diff --git a/tests/ioTrans.test b/tests/ioTrans.test index 85e427a..867362a 100644 --- a/tests/ioTrans.test +++ b/tests/ioTrans.test @@ -1162,7 +1162,7 @@ test iortrans-8.3 {chan flush, bug 2921116} -match glob -setup { test iortrans-11.0 {origin interpreter of moved transform gone} -setup { set ida [interp create]; #puts <<$ida>> set idb [interp create]; #puts <<$idb>> - # Magic to get the test* commands in the slaves + # Magic to get the test* commands in the children load {} Tcltest $ida load {} Tcltest $idb } -constraints {testchannel} -match glob -body { @@ -1205,7 +1205,7 @@ test iortrans-11.0 {origin interpreter of moved transform gone} -setup { test iortrans-11.1 {origin interpreter of moved transform destroyed during access} -setup { set ida [interp create]; #puts <<$ida>> set idb [interp create]; #puts <<$idb>> - # Magic to get the test* commands in the slaves + # Magic to get the test* commands in the children load {} Tcltest $ida load {} Tcltest $idb } -constraints {testchannel} -match glob -body { @@ -1320,7 +1320,7 @@ proc inthread {chan script args} { # forwarded channel operations. set ::tres "" - thread::send -async $tid { + thread::send -async $tid { after 50 catch {s} res; # This runs the script, 's' was defined at (*) thread::send -async $mid [list set ::tres $res] diff --git a/tests/load.test b/tests/load.test index 4cd1fcd..7d2e5df 100644 --- a/tests/load.test +++ b/tests/load.test @@ -103,7 +103,7 @@ test load-3.1 {error in _Init procedure, same interpreter} \ "if 44 {open non_existent}" invoked from within "load [file join $testDir pkge$ext] pkge"} {POSIX ENOENT {no such file or directory}}} -test load-3.2 {error in _Init procedure, slave interpreter} \ +test load-3.2 {error in _Init procedure, child interpreter} \ [list $dll $loaded] { catch {interp delete x} interp create x diff --git a/tests/namespace.test b/tests/namespace.test index 796b46b..2b25803 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -56,7 +56,7 @@ test namespace-2.2 {Tcl_GetCurrentNamespace} { test namespace-3.1 {Tcl_GetGlobalNamespace} { namespace eval test_ns_1 {namespace eval foo {namespace eval bar {} } } - # namespace children uses Tcl_GetGlobalNamespace + # namespace children uses Tcl_GetGlobalNamespace namespace eval test_ns_1 {namespace children foo b*} } {::test_ns_1::foo::bar} @@ -108,7 +108,7 @@ test namespace-6.2 {Tcl_CreateNamespace, odd number of :'s in name is okay} { [namespace eval test_ns_2:::::foo {namespace current}] } {::test_ns_1::foo ::test_ns_2::foo} test namespace-6.3 {Tcl_CreateNamespace, trailing ::s in ns name are ignored} { - list [catch {namespace eval test_ns_7::: {namespace current}} msg] $msg + list [catch {namespace eval test_ns_7::: {namespace current}} msg] $msg } {0 ::test_ns_7} test namespace-6.4 {Tcl_CreateNamespace, trailing ::s in ns name are ignored} { catch {namespace delete {*}[namespace children :: test_ns_*]} @@ -179,21 +179,21 @@ test namespace-7.6 {recursive Tcl_DeleteNamespace, no active call frames in ns} namespace delete test_ns_2 } {} test namespace-7.7 {Bug 1655305} -setup { - interp create slave + interp create child # Can't invoke through the ensemble, since deleting the global namespace # (indirectly, via deleting ::tcl) deletes the ensemble. - slave eval {rename ::tcl::info::commands ::infocommands} - slave hide infocommands - slave eval { + child eval {rename ::tcl::info::commands ::infocommands} + child hide infocommands + child eval { proc foo {} { namespace delete :: } } } -body { - slave eval foo - slave invokehidden infocommands + child eval foo + child invokehidden infocommands } -cleanup { - interp delete slave + interp delete child } -result {} test namespace-7.8 {Bug ba1419303b4c} -setup { @@ -205,7 +205,7 @@ test namespace-7.8 {Bug ba1419303b4c} -setup { namespace delete ns1 } } -body { - # No segmentation fault given --enable-symbols=mem. + # No segmentation fault given --enable-symbols=mem. namespace delete ns1 } -result {} @@ -269,28 +269,28 @@ test namespace-8.4 {TclTeardownNamespace, cmds imported from deleted ns go away} [info commands test_ns_import::*] } [list [lsort {::test_ns_import::p ::test_ns_import::cmd1 ::test_ns_import::cmd2}] {} ::test_ns_import::p] test namespace-8.5 {TclTeardownNamespace: preserve errorInfo; errorCode values} { - interp create slave - slave eval {trace add execution error leave {namespace delete :: ;#}} - catch {slave eval error foo bar baz} - interp delete slave + interp create child + child eval {trace add execution error leave {namespace delete :: ;#}} + catch {child eval error foo bar baz} + interp delete child set ::errorInfo } {bar invoked from within -"slave eval error foo bar baz"} +"child eval error foo bar baz"} test namespace-8.6 {TclTeardownNamespace: preserve errorInfo; errorCode values} { - interp create slave - slave eval {trace add variable errorCode write {namespace delete :: ;#}} - catch {slave eval error foo bar baz} - interp delete slave + interp create child + child eval {trace add variable errorCode write {namespace delete :: ;#}} + catch {child eval error foo bar baz} + interp delete child set ::errorInfo } {bar invoked from within -"slave eval error foo bar baz"} +"child eval error foo bar baz"} test namespace-8.7 {TclTeardownNamespace: preserve errorInfo; errorCode values} { - interp create slave - slave eval {trace add execution error leave {namespace delete :: ;#}} - catch {slave eval error foo bar baz} - interp delete slave + interp create child + child eval {trace add execution error leave {namespace delete :: ;#}} + catch {child eval error foo bar baz} + interp delete child set ::errorCode } baz @@ -1098,17 +1098,17 @@ test namespace-22.5 {NamespaceCodeCmd, in other namespace} { namespace code cmd } } {::namespace inscope ::test_ns_1 cmd} -test namespace-22.6 {NamespaceCodeCmd, in other namespace} { - namespace eval test_ns_1 { - variable v 42 - } - namespace eval test_ns_2 { - proc namespace args {} - } - namespace eval test_ns_2 [namespace eval test_ns_1 { - namespace code {set v} - }] -} {42} +test namespace-22.6 {NamespaceCodeCmd, in other namespace} { + namespace eval test_ns_1 { + variable v 42 + } + namespace eval test_ns_2 { + proc namespace args {} + } + namespace eval test_ns_2 [namespace eval test_ns_1 { + namespace code {set v} + }] +} {42} test namespace-22.7 {NamespaceCodeCmd, Bug 3202171} { namespace eval demo { proc namespace args {puts $args} @@ -1659,7 +1659,7 @@ test namespace-40.1 {Ignoring namespace proc "unknown"} -setup { namespace eval ns {proc unknown args {return local}} list [namespace eval ns aaa bbb] [namespace eval ns aaa] } -cleanup { - rename unknown {} + rename unknown {} rename _unknown unknown namespace delete ns } -result {global global} @@ -1670,7 +1670,7 @@ test namespace-41.1 {Shadowing byte-compiled commands, Bug: 231259} { set res {} proc test {} { set ::g 0 - } + } lappend ::res [test] proc set {a b} { ::set a [incr b] @@ -2797,9 +2797,9 @@ test namespace-51.15 {namespace resolution path control} -body { namespace delete ::test_ns_2 } test namespace-51.16 {Bug 1566526} { - interp create slave - slave eval namespace eval demo namespace path :: - interp delete slave + interp create child + child eval namespace eval demo namespace path :: + interp delete child } {} test namespace-51.17 {resolution epoch handling: Bug 2898722} -setup { set result {} @@ -3000,19 +3000,19 @@ test namespace-52.11 {unknown: with TCL_EVAL_INVOKE} -setup { } } catch {rename ::noSuchCommand {}} - set ::slave [interp create] + set ::child [interp create] } -body { - $::slave alias bar noSuchCommand + $::child alias bar noSuchCommand namespace eval test_ns_1 { namespace unknown unknown proc unknown args { return FAIL } - $::slave eval bar + $::child eval bar } } -cleanup { - interp delete $::slave - unset ::slave + interp delete $::child + unset ::child namespace delete test_ns_1 rename ::unknown {} rename unknown.save ::unknown @@ -3373,7 +3373,7 @@ test namespace-57.0 { rename ns2::p2 {} return $res } -cleanup { - unset res + unset res namespace delete ns2 namespace delete ns3 } -result success diff --git a/tests/oo.test b/tests/oo.test index e917bc9..612fb9b 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -142,7 +142,7 @@ test oo-1.4 {basic test of OO functionality} -body { oo::object create {} } -returnCodes 1 -result {object name must not be empty} test oo-1.4.1 {fully-qualified nested name} -body { - oo::object create ::one::two::three + oo::object create ::one::two::three } -result {::one::two::three} test oo-1.4.2 {automatic command name has same name as namespace} -body { set obj [oo::object new] @@ -306,19 +306,19 @@ test oo-1.18.2 {Bug 75b8433707: memory leak in oo-1.18} -setup { rename test-oo-1.18 {} } -result 0 test oo-1.18.3 {Bug 21c144f0f5} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { oo::define [oo::class create foo] superclass oo::class oo::class destroy } } -cleanup { - interp delete slave + interp delete child } test oo-1.18.4 {correct handling of cleanup in superclass set error} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { oo::class create A oo::class create B { superclass oo::class @@ -330,12 +330,12 @@ test oo-1.18.4 {correct handling of cleanup in superclass set error} -setup { [B create C] create d } } -returnCodes error -cleanup { - interp delete slave + interp delete child } -result {class should only be a direct superclass once} test oo-1.18.5 {correct handling of cleanup in superclass set error} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { oo::class create A oo::class create B { superclass oo::class @@ -347,7 +347,7 @@ test oo-1.18.5 {correct handling of cleanup in superclass set error} -setup { [B create C {B C}] create d } } -returnCodes error -cleanup { - interp delete slave + interp delete child } -result {attempt to form circular dependency graph} test oo-1.19 {basic test of OO functionality: teardown order} -body { oo::object create o @@ -2291,7 +2291,7 @@ test oo-15.10 {variable binding must not bleed through oo::copy} -setup { } -body { set obj1 [FooClass new] oo::objdefine $obj1 { - variable var + variable var method m {} { set var foo } @@ -2340,7 +2340,7 @@ test oo-15.13.1 { } -cleanup { Cls destroy Cls2 destroy -} -result done +} -result done test oo-15.13.2 {OO: object cloning with target NS} -setup { oo::class create Super oo::class create Cls {superclass Super} @@ -2368,7 +2368,7 @@ test oo-15.15 {method cloning must ensure that there is a string representation } -body { cls create foo oo::objdefine foo { - method m1 {} [string map {a b} {return hello}] + method m1 {} [string map {a b} {return hello}] } [oo::copy foo] m1 } -cleanup { @@ -3029,7 +3029,7 @@ test oo-20.10 {OO: variable and varname methods refer to same things} -setup { test oo-20.11 {OO: variable mustn't crash when recursing} -body { oo::class create A { constructor {name} { - my variable np_name + my variable np_name set np_name $name } method copy {nm} { @@ -3044,7 +3044,7 @@ test oo-20.11 {OO: variable mustn't crash when recursing} -body { lappend objs [$ref copy {}] } $cpy prop $var $objs - } else { + } else { $cpy prop $var $val } } @@ -4181,7 +4181,7 @@ test oo-35.6 { return done } -cleanup { rename obj {} -} -result done +} -result done diff --git a/tests/parse.test b/tests/parse.test index d73c725..9980015 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -369,7 +369,7 @@ test parse-8.8 {Tcl_EvalObjv procedure, async handlers} -constraints { variable ::aresult variable ::acode proc async1 {result code} { - variable ::aresult + variable ::aresult variable ::acode set aresult $result set acode $code @@ -405,14 +405,14 @@ test parse-8.11 {Tcl_EvalObjv procedure, TCL_EVAL_INVOKE} testevalobjv { proc ::unknown args {lappend ::info [info level]; uplevel 1 foo} proc ::foo args {lappend ::info global} catch {rename ::noSuchCommand {}} - set ::slave [interp create] - $::slave alias bar noSuchCommand + set ::child [interp create] + $::child alias bar noSuchCommand set ::info {} namespace eval test_ns_1 { proc foo args {lappend ::info namespace} - $::slave eval bar - testevalobjv 1 [list $::slave eval bar] - uplevel #0 [list $::slave eval bar] + $::child eval bar + testevalobjv 1 [list $::child eval bar] + uplevel #0 [list $::child eval bar] } namespace delete test_ns_1 rename ::foo {} @@ -429,14 +429,14 @@ test parse-8.12 {Tcl_EvalObjv procedure, TCL_EVAL_INVOKE} { lappend ::info ns }] catch {rename ::noSuchCommand {}} - set ::slave [interp create] - $::slave alias bar noSuchCommand + set ::child [interp create] + $::child alias bar noSuchCommand set ::info {} namespace eval test_ns_1 { - $::slave eval bar + $::child eval bar } namespace delete test_ns_1 - interp delete $::slave + interp delete $::child catch {rename ::noSuchCommand {}} set ::info } global diff --git a/tests/pkgMkIndex.test b/tests/pkgMkIndex.test index 84c82ce..37afafa 100644 --- a/tests/pkgMkIndex.test +++ b/tests/pkgMkIndex.test @@ -72,11 +72,11 @@ proc pkgtest::parseArgs { args } { # of the command line. proc pkgtest::parseIndex { filePath } { - # create a slave interpreter, where we override "package ifneeded" + # create a child interpreter, where we override "package ifneeded" - set slave [interp create] + set child [interp create] if {[catch { - $slave eval { + $child eval { rename package package_original proc package { args } { if {[lindex $args 0] eq "ifneeded"} { @@ -91,17 +91,17 @@ proc pkgtest::parseIndex { filePath } { } set dir [file dirname $filePath] - $slave eval {set curdir [pwd]} - $slave eval [list cd $dir] - $slave eval [list set dir $dir] - $slave eval [list source [file tail $filePath]] - $slave eval {cd $curdir} + $child eval {set curdir [pwd]} + $child eval [list cd $dir] + $child eval [list set dir $dir] + $child eval [list source [file tail $filePath]] + $child eval {cd $curdir} # Create the list in sorted order, so that we don't get spurious # errors because the order has changed. array set P {} - foreach {k v} [$slave eval {array get ::PKGS}] { + foreach {k v} [$child eval {array get ::PKGS}] { set P($k) $v } @@ -113,12 +113,12 @@ proc pkgtest::parseIndex { filePath } { set ei [dict get $opts -errorinfo] set ec [dict get $opts -errorcode] - catch {interp delete $slave} + catch {interp delete $child} error $ei $ec } - interp delete $slave + interp delete $child return $PKGS } @@ -231,7 +231,7 @@ proc pkgtest::runCreatedIndex {rv args} { set result [list 0 [makePkgList [parseIndex $idxFile]]] } err]} { set result [list 1 $err] - } + } file delete $idxFile } else { set result $rv diff --git a/tests/proc.test b/tests/proc.test index 9be056f..585efa5 100644 --- a/tests/proc.test +++ b/tests/proc.test @@ -99,7 +99,7 @@ test proc-1.6 {Tcl_ProcObjCmd, namespace code ignores single ":"s in middle or e test proc-1.7 {Tcl_ProcObjCmd, check that formal parameter names are not array elements} -setup { catch {rename p ""} } -returnCodes error -body { - proc p {a(1) a(2)} { + proc p {a(1) a(2)} { set z [expr $a(1)+$a(2)] puts "$z=z, $a(1)=$a(1)" } @@ -107,7 +107,7 @@ test proc-1.7 {Tcl_ProcObjCmd, check that formal parameter names are not array e test proc-1.8 {Tcl_ProcObjCmd, check that formal parameter names are simple names} -setup { catch {rename p ""} } -body { - proc p {b:a b::a} { + proc p {b:a b::a} { } } -returnCodes error -result {formal parameter "b::a" is not a simple name} test proc-1.9 {Tcl_ProcObjCmd, arguments via canonical list (string-representation bug [631b4c45df])} -body { @@ -340,7 +340,7 @@ test proc-5.1 {Bytecompiling noop; test for correct argument substitution} -body } -cleanup { catch {rename p ""} catch {rename t ""} -} -result {aba} +} -result {aba} test proc-6.1 {ProcessProcResultCode: Bug 647307 (negative return code)} -body { proc a {} {return -code -5} @@ -389,9 +389,9 @@ test proc-7.3 {Returning loop exception from redefined cmd: Bug 729692} -body { test proc-7.4 {Proc struct outlives its interp: Bug 3532959} { set lambda x lappend lambda {set a 1} - interp create slave - slave eval [list apply $lambda foo] - interp delete slave + interp create child + child eval [list apply $lambda foo] + interp delete child unset lambda } {} diff --git a/tests/resolver.test b/tests/resolver.test index b0b395d..db524a0 100644 --- a/tests/resolver.test +++ b/tests/resolver.test @@ -203,7 +203,7 @@ test resolver-2.1 {compiled var resolver: Bug #3383616} -setup { # resolver-agnostic). # # In order to make the test cases for the per-interpreter cmd literal pool -# reproducable and to minimize interactions between test cases, we use a slave +# reproducable and to minimize interactions between test cases, we use a child # interpreter per test-case. # # diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test index 3f20d77..337527c 100644 --- a/tests/safe-stock86.test +++ b/tests/safe-stock86.test @@ -56,7 +56,7 @@ test safe-stock86-7.1 {tests that everything works at high level, uses http 2} - set i [safe::interpCreate] # no error shall occur: # (because the default access_path shall include 1st level sub dirs so - # package require in a slave works like in the parent) + # package require in a child works like in the parent) set v [interp eval $i {package require http 2}] # no error shall occur: interp eval $i {http::config} diff --git a/tests/subst.test b/tests/subst.test index 189dfe8..21aecc5 100644 --- a/tests/subst.test +++ b/tests/subst.test @@ -166,7 +166,7 @@ test subst-8.6 {return in a subst} -returnCodes error -body { subst "foo \[return {x}; bogus code bar" } -result {missing close-bracket} test subst-8.7 {return in a subst, parse error} -body { - subst {foo [return {x} ; set a {}"" ; stuff] bar} + subst {foo [return {x} ; set a {}"" ; stuff] bar} } -returnCodes error -result {extra characters after close-brace} test subst-8.8 {return in a subst, parse error} -body { subst {foo [return {x} ; set bar baz ; set a {}"" ; stuff] bar} @@ -282,18 +282,18 @@ test subst-13.1 {Bug 3081065} -setup { demo name2 } subst13.tcl] } -body { - interp create slave - slave eval [list source $script] - interp delete slave - interp create slave - slave eval { + interp create child + child eval [list source $script] + interp delete child + interp create child + child eval { set count 400 while {[incr count -1]} { lappend bloat [expr {rand()}] } } - slave eval [list source $script] - interp delete slave + child eval [list source $script] + interp delete child } -cleanup { removeFile subst13.tcl } diff --git a/tests/tcltest.test b/tests/tcltest.test index c856209..b02c18d 100644 --- a/tests/tcltest.test +++ b/tests/tcltest.test @@ -13,7 +13,7 @@ # testing to run the test itself. Ditto on things like [verbose]. # # It would be better to have the -body of the tests run the tcltest -# commands in a slave interp so the [test] being tested would not +# commands in a child interp so the [test] being tested would not # interfere with the [test] doing the testing. # @@ -63,11 +63,11 @@ test tcltest-1.3 {tcltest -h} {exec} { } {1 0} # -verbose, implicit & explicit testing of [verbose] -proc slave {msgVar args} { +proc child {msgVar args} { upvar 1 $msgVar msg interp create [namespace current]::i - # Fake the slave interp into dumping output to a file + # Fake the child interp into dumping output to a file i eval {namespace eval ::tcltest {}} i eval "set tcltest::outputChannel\ \[[list open [set of [makeFile {} output]] w]]" @@ -99,44 +99,44 @@ proc slave {msgVar args} { return $code } test tcltest-2.0 {tcltest (verbose default - 'b')} {unixOrWin} { - set result [slave msg test.tcl] + set result [child msg test.tcl] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 1 0 0 1} test tcltest-2.1 {tcltest -verbose 'b'} {unixOrWin} { - set result [slave msg test.tcl -verbose 'b'] + set result [child msg test.tcl -verbose 'b'] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 1 0 0 1} test tcltest-2.2 {tcltest -verbose 'p'} {unixOrWin} { - set result [slave msg test.tcl -verbose 'p'] + set result [child msg test.tcl -verbose 'p'] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 0 1 0 1} test tcltest-2.3 {tcltest -verbose 's'} {unixOrWin} { - set result [slave msg test.tcl -verbose 's'] + set result [child msg test.tcl -verbose 's'] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 0 0 1 1} test tcltest-2.4 {tcltest -verbose 'ps'} {unixOrWin} { - set result [slave msg test.tcl -verbose 'ps'] + set result [child msg test.tcl -verbose 'ps'] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 0 1 1 1} test tcltest-2.5 {tcltest -verbose 'psb'} {unixOrWin} { - set result [slave msg test.tcl -verbose 'psb'] + set result [child msg test.tcl -verbose 'psb'] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 1 1 1 1} test tcltest-2.5a {tcltest -verbose 'pass skip body'} {unixOrWin} { - set result [slave msg test.tcl -verbose "pass skip body"] + set result [child msg test.tcl -verbose "pass skip body"] list $result [regexp "Contents of test case" $msg] [regexp a-1.0 $msg] \ [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] @@ -145,7 +145,7 @@ test tcltest-2.5a {tcltest -verbose 'pass skip body'} {unixOrWin} { test tcltest-2.6 {tcltest -verbose 't'} { -constraints {unixOrWin} -body { - set result [slave msg test.tcl -verbose 't'] + set result [child msg test.tcl -verbose 't'] list $result $msg } -result {^0 .*a-1.0 start.*b-1.0 start} @@ -155,7 +155,7 @@ test tcltest-2.6 {tcltest -verbose 't'} { test tcltest-2.6a {tcltest -verbose 'start'} { -constraints {unixOrWin} -body { - set result [slave msg test.tcl -verbose start] + set result [child msg test.tcl -verbose start] list $result $msg } -result {^0 .*a-1.0 start.*b-1.0 start} @@ -178,7 +178,7 @@ test tcltest-2.7 {tcltest::verbose} { test tcltest-2.8 {tcltest -verbose 'error'} { -constraints {unixOrWin} -body { - set result [slave msg test.tcl -verbose error] + set result [child msg test.tcl -verbose error] list $result $msg } -result {errorInfo: foo.*errorCode: 9} @@ -186,22 +186,22 @@ test tcltest-2.8 {tcltest -verbose 'error'} { } # -match, [match] test tcltest-3.1 {tcltest -match 'a*'} {unixOrWin} { - set result [slave msg test.tcl -match a* -verbose 'ps'] + set result [child msg test.tcl -match a* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+3.+Failed.+0" $msg] } {0 1 0 0 1} test tcltest-3.2 {tcltest -match 'b*'} {unixOrWin} { - set result [slave msg test.tcl -match b* -verbose 'ps'] + set result [child msg test.tcl -match b* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+0.+Skipped.+3.+Failed.+1" $msg] } {0 0 1 0 1} test tcltest-3.3 {tcltest -match 'c*'} {unixOrWin} { - set result [slave msg test.tcl -match c* -verbose 'ps'] + set result [child msg test.tcl -match c* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+0.+Skipped.+4.+Failed.+0" $msg] } {0 0 0 1 1} test tcltest-3.4 {tcltest -match 'a* b*'} {unixOrWin} { - set result [slave msg test.tcl -match {a* b*} -verbose 'ps'] + set result [child msg test.tcl -match {a* b*} -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+2.+Failed.+1" $msg] } {0 1 1 0 1} @@ -221,27 +221,27 @@ test tcltest-3.5 {tcltest::match} { # -skip, [skip] test tcltest-4.1 {tcltest -skip 'a*'} {unixOrWin} { - set result [slave msg test.tcl -skip a* -verbose 'ps'] + set result [child msg test.tcl -skip a* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+0.+Skipped.+2.+Failed.+1" $msg] } {0 0 1 1 1} test tcltest-4.2 {tcltest -skip 'b*'} {unixOrWin} { - set result [slave msg test.tcl -skip b* -verbose 'ps'] + set result [child msg test.tcl -skip b* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+2.+Failed.+1" $msg] } {0 1 0 1 1} test tcltest-4.3 {tcltest -skip 'c*'} {unixOrWin} { - set result [slave msg test.tcl -skip c* -verbose 'ps'] + set result [child msg test.tcl -skip c* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+1.+Failed.+2" $msg] } {0 1 1 0 1} test tcltest-4.4 {tcltest -skip 'a* b*'} {unixOrWin} { - set result [slave msg test.tcl -skip {a* b*} -verbose 'ps'] + set result [child msg test.tcl -skip {a* b*} -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+0.+Skipped.+3.+Failed.+1" $msg] } {0 0 0 1 1} test tcltest-4.5 {tcltest -match 'a* b*' -skip 'b*'} {unixOrWin} { - set result [slave msg test.tcl -match {a* b*} -skip b* -verbose 'ps'] + set result [child msg test.tcl -match {a* b*} -skip b* -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+3.+Failed.+0" $msg] } {0 1 0 0 1} @@ -262,12 +262,12 @@ test tcltest-4.6 {tcltest::skip} { # -constraints, -limitconstraints, [testConstraint], # $constraintsSpecified, [limitConstraints] test tcltest-5.1 {tcltest -constraints 'knownBug'} {unixOrWin} { - set result [slave msg test.tcl -constraints knownBug -verbose 'ps'] + set result [child msg test.tcl -constraints knownBug -verbose 'ps'] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+2.+Skipped.+0.+Failed.+2" $msg] } {0 1 1 1 1} test tcltest-5.2 {tcltest -constraints 'knownBug' -limitconstraints 1} {unixOrWin} { - set result [slave msg test.tcl -constraints knownBug -verbose 'p' -limitconstraints 1] + set result [child msg test.tcl -constraints knownBug -verbose 'p' -limitconstraints 1] list $result [regexp a-1.0 $msg] [regexp b-1.0 $msg] [regexp c-1.0 $msg] \ [regexp "Total.+4.+Passed.+1.+Skipped.+3.+Failed.+0" $msg] } {0 0 0 1 1} @@ -357,28 +357,28 @@ set printerror [makeFile { test tcltest-6.1 {tcltest -outfile, -errfile defaults} { -constraints unixOrWin -body { - slave msg $printerror + child msg $printerror return $msg } -result {a test.*a really} -match regexp } test tcltest-6.2 {tcltest -outfile a.tmp} {unixOrWin unixExecs} { - slave msg $printerror -outfile a.tmp + child msg $printerror -outfile a.tmp set result1 [catch {exec grep "a test" a.tmp}] set result2 [catch {exec grep "a really" a.tmp}] list [regexp "a test" $msg] [regexp "a really" $msg] \ $result1 $result2 [file exists a.tmp] [file delete a.tmp] } {0 1 0 1 1 {}} test tcltest-6.3 {tcltest -errfile a.tmp} {unixOrWin unixExecs} { - slave msg $printerror -errfile a.tmp + child msg $printerror -errfile a.tmp set result1 [catch {exec grep "a test" a.tmp}] set result2 [catch {exec grep "a really" a.tmp}] list [regexp "a test" $msg] [regexp "a really" $msg] \ $result1 $result2 [file exists a.tmp] [file delete a.tmp] } {1 0 1 0 1 {}} test tcltest-6.4 {tcltest -outfile a.tmp -errfile b.tmp} {unixOrWin unixExecs} { - slave msg $printerror -outfile a.tmp -errfile b.tmp + child msg $printerror -outfile a.tmp -errfile b.tmp set result1 [catch {exec grep "a test" a.tmp}] set result2 [catch {exec grep "a really" b.tmp}] list [regexp "a test" $msg] [regexp "a really" $msg] \ @@ -463,7 +463,7 @@ test tcltest-6.8 {tcltest::outputFile (implicit outputFile)} { # -debug, [debug] # Must use child processes to test -debug because it always writes # messages to stdout, and we have no way to capture stdout of a -# slave interp +# child interp test tcltest-7.1 {tcltest test.tcl -debug 0} {unixOrWin} { catch {exec [interpreter] test.tcl -debug 0} msg regexp "Flags passed into tcltest" $msg @@ -525,7 +525,7 @@ normalizePath normaldirectory test tcltest-8.1 {tcltest a.tcl -tmpdir a} -constraints unixOrWin -setup { file delete -force thisdirectorydoesnotexist } -body { - slave msg $a -tmpdir thisdirectorydoesnotexist + child msg $a -tmpdir thisdirectorydoesnotexist file exists [file join thisdirectorydoesnotexist a.tmp] } -cleanup { file delete -force thisdirectorydoesnotexist @@ -533,7 +533,7 @@ test tcltest-8.1 {tcltest a.tcl -tmpdir a} -constraints unixOrWin -setup { test tcltest-8.2 {tcltest a.tcl -tmpdir thisdirectoryisafile} { -constraints unixOrWin -body { - slave msg $a -tmpdir $tdiaf + child msg $a -tmpdir $tdiaf return $msg } -result {*not a directory*} @@ -558,7 +558,7 @@ switch -- $::tcl_platform(platform) { test tcltest-8.3 {tcltest a.tcl -tmpdir notReadableDir} { -constraints {unix notRoot} -body { - slave msg $a -tmpdir $notReadableDir + child msg $a -tmpdir $notReadableDir return $msg } -result {*not readable*} @@ -574,7 +574,7 @@ testConstraint notFAT [expr { test tcltest-8.4 {tcltest a.tcl -tmpdir notWriteableDir} { -constraints {unixOrWin notRoot notFAT} -body { - slave msg $a -tmpdir $notWriteableDir + child msg $a -tmpdir $notWriteableDir return $msg } -result {*not writeable*} @@ -583,7 +583,7 @@ test tcltest-8.4 {tcltest a.tcl -tmpdir notWriteableDir} { test tcltest-8.5 {tcltest a.tcl -tmpdir normaldirectory} { -constraints unixOrWin -body { - slave msg $a -tmpdir $normaldirectory + child msg $a -tmpdir $normaldirectory # The join is necessary because the message can be split on multiple # lines file exists [file join $normaldirectory a.tmp] @@ -629,7 +629,7 @@ test tcltest-8.10 {tcltest a.tcl -testdir thisdirectorydoesnotexist} { file delete -force thisdirectorydoesnotexist } -body { - slave msg $a -testdir thisdirectorydoesnotexist + child msg $a -testdir thisdirectorydoesnotexist return $msg } -match glob @@ -638,7 +638,7 @@ test tcltest-8.10 {tcltest a.tcl -testdir thisdirectorydoesnotexist} { test tcltest-8.11 {tcltest a.tcl -testdir thisdirectoryisafile} { -constraints unixOrWin -body { - slave msg $a -testdir $tdiaf + child msg $a -testdir $tdiaf return $msg } -match glob @@ -647,7 +647,7 @@ test tcltest-8.11 {tcltest a.tcl -testdir thisdirectoryisafile} { test tcltest-8.12 {tcltest a.tcl -testdir notReadableDir} { -constraints {unix notRoot} -body { - slave msg $a -testdir $notReadableDir + child msg $a -testdir $notReadableDir return $msg } -match glob @@ -656,7 +656,7 @@ test tcltest-8.12 {tcltest a.tcl -testdir notReadableDir} { test tcltest-8.13 {tcltest a.tcl -testdir normaldirectory} { -constraints unixOrWin -body { - slave msg $a -testdir $normaldirectory + child msg $a -testdir $normaldirectory # The join is necessary because the message can be split on multiple # lines list [string first "testdir: $normaldirectory" [join $msg]] \ @@ -735,7 +735,7 @@ test tcltest-9.1 {-file d*.tcl} -constraints {unixOrWin} -setup { set old [testsDirectory] testsDirectory [file dirname [info script]] } -body { - slave msg [file join [testsDirectory] all.tcl] -file d*.test + child msg [file join [testsDirectory] all.tcl] -file d*.test return $msg } -cleanup { testsDirectory $old @@ -745,7 +745,7 @@ test tcltest-9.2 {-file d*.tcl} -constraints {unixOrWin} -setup { set old [testsDirectory] testsDirectory [file dirname [info script]] } -body { - slave msg [file join [testsDirectory] all.tcl] \ + child msg [file join [testsDirectory] all.tcl] \ -file d*.test -notfile dstring* regexp {dstring\.test} $msg } -cleanup { @@ -784,7 +784,7 @@ test tcltest-9.5 {GetMatchingFiles: Bug 1119798} -setup { makeFile {} fee $d file copy [file join [file dirname [info script]] all.tcl] $d } -body { - slave msg [file join [temporaryDirectory] all.tcl] -file f* + child msg [file join [temporaryDirectory] all.tcl] -file f* regexp {exiting with errors:} $msg } -cleanup { file delete [file join $d all.tcl] @@ -807,23 +807,23 @@ set mc [makeFile { cd [temporaryDirectory] test tcltest-10.1 {-preservecore 0} {unixOrWin} { - slave msg $mc -preservecore 0 + child msg $mc -preservecore 0 file delete core regexp "Core file produced" $msg } {0} test tcltest-10.2 {-preservecore 1} {unixOrWin} { - slave msg $mc -preservecore 1 + child msg $mc -preservecore 1 file delete core regexp "Core file produced" $msg } {1} test tcltest-10.3 {-preservecore 2} {unixOrWin} { - slave msg $mc -preservecore 2 + child msg $mc -preservecore 2 file delete core list [regexp "Core file produced" $msg] [regexp "Moving file to" $msg] \ [regexp "core-" $msg] [file delete core-makecore] } {1 1 1 {}} test tcltest-10.4 {-preservecore 3} {unixOrWin} { - slave msg $mc -preservecore 3 + child msg $mc -preservecore 3 file delete core list [regexp "Core file produced" $msg] [regexp "Moving file to" $msg] \ [regexp "core-" $msg] [file delete core-makecore] @@ -854,7 +854,7 @@ set contents { set loadfile [makeFile $contents load.tcl] test tcltest-12.1 {-load xxx} {unixOrWin} { - slave msg $loadfile -load xxx + child msg $loadfile -load xxx return $msg } {xxx} @@ -952,7 +952,7 @@ cd [workingDirectory] test tcltest-14.1 {-singleproc - single process} { -constraints {unixOrWin} -body { - slave msg $allfile -singleproc 0 -tmpdir [temporaryDirectory] + child msg $allfile -singleproc 0 -tmpdir [temporaryDirectory] return $msg } -result {Test file error: can't unset .foo.: no such variable} @@ -962,7 +962,7 @@ test tcltest-14.1 {-singleproc - single process} { test tcltest-14.2 {-singleproc - multiple process} { -constraints {unixOrWin} -body { - slave msg $allfile -singleproc 1 -tmpdir [temporaryDirectory] + child msg $allfile -singleproc 1 -tmpdir [temporaryDirectory] return $msg } -result {single1.test.*single2.test.*all\-single.tcl:.*Total.*0.*Passed.*0.*Skipped.*0.*Failed.*0} @@ -1026,7 +1026,7 @@ makeFile { test tcltest-15.1 {basic directory walking} { -constraints {unixOrWin} -body { - if {[slave msg \ + if {[child msg \ [file join $dtd all.tcl] \ -tmpdir [temporaryDirectory]] == 1} { error $msg @@ -1040,7 +1040,7 @@ test tcltest-15.1 {basic directory walking} { test tcltest-15.2 {-asidefromdir} { -constraints {unixOrWin} -body { - if {[slave msg \ + if {[child msg \ [file join $dtd all.tcl] \ -asidefromdir dirtestdir2.3 \ -tmpdir [temporaryDirectory]] == 1} { @@ -1058,7 +1058,7 @@ Error: No test files remain after applying your match and skip patterns!$} test tcltest-15.3 {-relateddir, non-existent dir} { -constraints {unixOrWin} -body { - if {[slave msg \ + if {[child msg \ [file join $dtd all.tcl] \ -relateddir [file join [temporaryDirectory] dirtestdir0] \ -tmpdir [temporaryDirectory]] == 1} { @@ -1073,7 +1073,7 @@ test tcltest-15.3 {-relateddir, non-existent dir} { test tcltest-15.4 {-relateddir, subdir} { -constraints {unixOrWin} -body { - if {[slave msg \ + if {[child msg \ [file join $dtd all.tcl] \ -relateddir dirtestdir2.1 -tmpdir [temporaryDirectory]] == 1} { error $msg @@ -1086,7 +1086,7 @@ test tcltest-15.4 {-relateddir, subdir} { test tcltest-15.5 {-relateddir, -asidefromdir} { -constraints {unixOrWin} -body { - if {[slave msg \ + if {[child msg \ [file join $dtd all.tcl] \ -relateddir "dirtestdir2.1 dirtestdir2.2" \ -asidefromdir dirtestdir2.2 \ @@ -1147,25 +1147,25 @@ test tcltest-19.1 {TCLTEST_OPTIONS default} -setup { # set this to { } instead of just {} to get around quirk in # Windows env handling that removes empty elements from env array. set ::env(TCLTEST_OPTIONS) { } - interp create slave1 - slave1 eval [list set argv {-debug 2}] - slave1 alias puts puts - interp create slave2 - slave2 alias puts puts + interp create child1 + child1 eval [list set argv {-debug 2}] + child1 alias puts puts + interp create child2 + child2 alias puts puts } -cleanup { - interp delete slave2 - interp delete slave1 + interp delete child2 + interp delete child1 if {$oldoptions eq "none"} { unset ::env(TCLTEST_OPTIONS) } else { set ::env(TCLTEST_OPTIONS) $oldoptions } } -body { - slave1 eval [package ifneeded tcltest [package provide tcltest]] - slave1 eval tcltest::debug + child1 eval [package ifneeded tcltest [package provide tcltest]] + child1 eval tcltest::debug set ::env(TCLTEST_OPTIONS) "-debug 3" - slave2 eval [package ifneeded tcltest [package provide tcltest]] - slave2 eval tcltest::debug + child2 eval [package ifneeded tcltest [package provide tcltest]] + child2 eval tcltest::debug } -result {^3$} -match regexp -output\ {tcltest::debug\s+= 2.*tcltest::debug\s+= 3} @@ -1174,7 +1174,7 @@ test tcltest-19.1 {TCLTEST_OPTIONS default} -setup { cd [temporaryDirectory] # PrintError test tcltest-20.1 {PrintError} {unixOrWin} { - set result [slave msg $printerror] + set result [child msg $printerror] list $result [regexp "Error: a really short string" $msg] \ [regexp " \"quotes\"" $msg] [regexp " \"Path" $msg] \ [regexp " \"Really" $msg] [regexp Problem $msg] @@ -1407,7 +1407,7 @@ makeFile { } test.test $atd # Must use a child process because stdout/stderr parsing can't be -# duplicated in slave interp. +# duplicated in child interp. test tcltest-22.1 {runAllTests} { -constraints {unixOrWin} -body { @@ -1806,7 +1806,7 @@ test tcltest-26.1 {Bug/RFE 1017151} -setup { tcltest::cleanupTests } test.tcl } -body { - slave msg [file join [temporaryDirectory] test.tcl] + child msg [file join [temporaryDirectory] test.tcl] return $msg } -cleanup { removeFile test.tcl @@ -1826,7 +1826,7 @@ test tcltest-26.2 {Bug/RFE 1017151} -setup { tcltest::cleanupTests } test.tcl } -body { - slave msg [file join [temporaryDirectory] test.tcl] + child msg [file join [temporaryDirectory] test.tcl] return $msg } -cleanup { removeFile test.tcl diff --git a/tests/thread.test b/tests/thread.test index eaaaa41..9f14470 100644 --- a/tests/thread.test +++ b/tests/thread.test @@ -802,7 +802,7 @@ test thread-7.21 {cancel: subst -unwind} -constraints {thread drainEventQueue} - } -cleanup { unset -nocomplain ::threadSawError ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} -test thread-7.22 {cancel: slave interp} -constraints {thread drainEventQueue} -setup { +test thread-7.22 {cancel: child interp} -constraints {thread drainEventQueue} -setup { unset -nocomplain ::threadSawError ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ @@ -832,7 +832,7 @@ test thread-7.22 {cancel: slave interp} -constraints {thread drainEventQueue} -s } -cleanup { unset -nocomplain ::threadSawError ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} -test thread-7.23 {cancel: slave interp -unwind} -constraints {thread drainEventQueue} -setup { +test thread-7.23 {cancel: child interp -unwind} -constraints {thread drainEventQueue} -setup { unset -nocomplain ::threadSawError ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ diff --git a/tests/timer.test b/tests/timer.test index 740d05e..b422f35 100644 --- a/tests/timer.test +++ b/tests/timer.test @@ -568,15 +568,15 @@ test timer-9.1 {AfterCleanupProc procedure} -setup { } -result {before after2 after4} test timer-10.1 {Bug 1016167: [after] overwrites imports} -setup { - interp create slave - slave eval namespace export after - slave eval namespace eval foo namespace import ::after + interp create child + child eval namespace export after + child eval namespace eval foo namespace import ::after } -body { - slave eval foo::after 1 - slave eval namespace origin foo::after + child eval foo::after 1 + child eval namespace origin foo::after } -cleanup { # Bug will cause crash here; would cause failure otherwise - interp delete slave + interp delete child } -result ::after test timer-11.1 {Bug 1350291: [after] overflowing 32-bit field} -body { diff --git a/tests/trace.test b/tests/trace.test index d830f3c..c54efff 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -2197,11 +2197,11 @@ foo {if {[catch {bar}]} { }} 2 error leavestep foo foo 0 error leave}} -test trace-28.4 {exec traces in slave with 'return -code error'} { - interp create slave - interp alias slave traceExecute {} traceExecute +test trace-28.4 {exec traces in child with 'return -code error'} { + interp create child + interp alias child traceExecute {} traceExecute set info {} - set res [interp eval slave { + set res [interp eval child { set info {} set res {} @@ -2229,7 +2229,7 @@ test trace-28.4 {exec traces in slave with 'return -code error'} { list $res }] - interp delete slave + interp delete child lappend res [join $info \n] } {{error error} {foo foo enter foo {if {[catch {bar}]} { diff --git a/tests/var.test b/tests/var.test index 32388a2..202b66c 100644 --- a/tests/var.test +++ b/tests/var.test @@ -53,7 +53,7 @@ catch {unset arr} test var-1.1 {TclLookupVar, Array handling} -setup { catch {unset a} } -body { - set x "incr" ;# force no compilation and runtime call to Tcl_IncrCmd + set x "incr" ;# force no compilation and runtime call to Tcl_IncrCmd set i 10 set arr(foo) 37 list [$x i] $i [$x arr(foo)] $arr(foo) @@ -256,7 +256,7 @@ test var-3.3 {MakeUpvar, my var has TCL_GLOBAL_ONLY specified} -setup { set a 123321 proc p {} { # create global xx linked to global a - testupvar 1 a {} xx global + testupvar 1 a {} xx global } list [p] $xx [set xx 789] $a } -result {{} 123321 789 789} @@ -268,7 +268,7 @@ test var-3.4 {MakeUpvar, my var has TCL_NAMESPACE_ONLY specified} -setup { catch {unset ::test_ns_var::vv} proc p {} { # create namespace var vv linked to global a - testupvar 1 a {} vv namespace + testupvar 1 a {} vv namespace } p } @@ -570,11 +570,11 @@ test var-7.14 {Tcl_VariableObjCmd, array element parameter} -body { namespace eval test_ns_var { variable arrayvar(1) } } -returnCodes error -result "can't define \"arrayvar(1)\": name refers to an element in an array" test var-7.15 {Tcl_VariableObjCmd, array element parameter} -body { - namespace eval test_ns_var { + namespace eval test_ns_var { variable arrayvar set arrayvar(1) x variable arrayvar(1) y - } + } } -returnCodes error -result "can't define \"arrayvar(1)\": name refers to an element in an array" test var-7.16 {Tcl_VariableObjCmd, no args (TIP 323)} { variable @@ -828,7 +828,7 @@ test var-15.1 {segfault in [unset], [Bug 735335]} { set var $name } # - # Note that the variable name has to be + # Note that the variable name has to be # unused previously for the segfault to # be triggered. # @@ -1046,15 +1046,15 @@ test var-22.1 {leak in localVarName intrep: Bug 80304238ac} -setup { lindex [split [memory info] \n] 3 3 } proc doit {} { - interp create slave - slave eval { + interp create child + child eval { proc doit script { eval $script set foo bar } doit {foreach foo baz {}} } - interp delete slave + interp delete child } } -constraints memory -body { set end [getbytes] diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index a7231f7..a9327b8 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -587,6 +587,7 @@ array set exclude_refs_map { scrollbar.n {set} selection.n {string} tcltest.n {error} + text.n {bind image lower raise} tkvars.n {tk} tkwait.n {variable} tm.n {exec} diff --git a/unix/Makefile.in b/unix/Makefile.in index 87f0844..670e76c 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -2027,9 +2027,9 @@ rpm: all rm -rf RPMS THIS.TCL.SPEC # -# Target to create a proper Tcl distribution from information in the master -# source directory. DISTDIR must be defined to indicate where to put the -# distribution. DISTDIR must be an absolute path name. +# Target to create a proper Tcl distribution from information in the +# source directory. DISTDIR must be defined to indicate where to put +# the distribution. DISTDIR must be an absolute path name. # DISTROOT = /tmp/dist diff --git a/win/rules.vc b/win/rules.vc index d4765b9..6dca6d9 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -514,7 +514,7 @@ CFG_ENCODING = \"cp1252\" # information about supported compiler options etc. # # Tcl itself will always use the nmakehlp.c program which is -# in its own source. This is the "master" copy and kept updated. +# in its own source. It will be kept updated there. # # Extensions built against an installed Tcl will use the installed # copy of Tcl's nmakehlp.c if there is one and their own version @@ -1669,7 +1669,7 @@ default-shell: default-setup $(PROJECT) !ifdef RCFILE # Note: don't use $** in below rule because there may be other dependencies -# and only the "master" rc must be passed to the resource compiler +# and only the "main" rc must be passed to the resource compiler $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc $(RESCMD) $(RCDIR)\$(PROJECT).rc @@ -1723,7 +1723,7 @@ DISABLE_IMPLICIT_RULES = 0 !if !$(DISABLE_IMPLICIT_RULES) # Implicit rule definitions - only for building library objects. For stubs and -# main application, the master makefile should define explicit rules. +# main application, the makefile should define explicit rules. {$(ROOT)}.c{$(TMP_DIR)}.obj:: $(CCPKGCMD) @<< -- cgit v0.12 From 008cd7d2a99f93f590fdefbea117b9f78d03b4ce Mon Sep 17 00:00:00 2001 From: pooryorick Date: Tue, 1 Sep 2020 22:36:41 +0000 Subject: Fix for [c1a376375e0e6488], imported namespace ensemble command name distorted during deletion trace on the import --- generic/tclBasic.c | 20 ++++++----- generic/tclCompile.c | 2 +- generic/tclEnsemble.c | 8 ++--- generic/tclExecute.c | 20 +++++++---- generic/tclInt.h | 38 +++++++++++++++----- generic/tclNamesp.c | 34 +++++++++--------- generic/tclOO.c | 2 +- generic/tclObj.c | 2 +- tests/namespace.test | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 174 insertions(+), 48 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 4cc579b..75f8527 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -2785,6 +2785,8 @@ TclCreateObjCommandInNs( Command *refCmdPtr = oldRefPtr->importedCmdPtr; dataPtr = (ImportedCmdData*)refCmdPtr->objClientData; + cmdPtr->refCount++; + TclCleanupCommandMacro(dataPtr->realCmdPtr); dataPtr->realCmdPtr = cmdPtr; oldRefPtr = oldRefPtr->nextPtr; } @@ -3374,7 +3376,7 @@ Tcl_GetCommandFullName( * separator, and the command name. */ - if (cmdPtr != NULL) { + if ((cmdPtr != NULL) && TclRoutineHasName(cmdPtr)) { if (cmdPtr->nsPtr != NULL) { Tcl_AppendToObj(objPtr, cmdPtr->nsPtr->fullName, -1); if (cmdPtr->nsPtr != iPtr->globalNsPtr) { @@ -3464,7 +3466,7 @@ Tcl_DeleteCommandFromToken( * and skip nested deletes. */ - if (cmdPtr->flags & CMD_IS_DELETED) { + if (cmdPtr->flags & CMD_DYING) { /* * Another deletion is already in progress. Remove the hash table * entry now, but don't invoke a callback or free the command @@ -3496,7 +3498,7 @@ Tcl_DeleteCommandFromToken( * be ignored. */ - cmdPtr->flags |= CMD_IS_DELETED; + cmdPtr->flags |= CMD_DYING; /* * Call trace functions for the command being deleted. Then delete its @@ -3526,7 +3528,7 @@ Tcl_DeleteCommandFromToken( } /* - * The list of command exported from the namespace might have changed. + * The list of commands exported from the namespace might have changed. * However, we do not need to recompute this just yet; next time we need * the info will be soon enough. */ @@ -3661,7 +3663,7 @@ CallCommandTraces( * While a rename trace is active, we will not process any more rename * traces; while a delete trace is active we will never reach here - * because Tcl_DeleteCommandFromToken checks for the condition - * (cmdPtr->flags & CMD_IS_DELETED) and returns immediately when a + * (cmdPtr->flags & CMD_DYING) and returns immediately when a * command deletion is in progress. For all other traces, delete * traces will not be invoked but a call to TraceCommandProc will * ensure that tracePtr->clientData is freed whenever the command @@ -5214,7 +5216,7 @@ TEOV_RunLeaveTraces( int length; const char *command = TclGetStringFromObj(commandPtr, &length); - if (!(cmdPtr->flags & CMD_IS_DELETED)) { + if (!(cmdPtr->flags & CMD_DYING)) { if (cmdPtr->flags & CMD_HAS_EXEC_TRACES) { traceCode = TclCheckExecutionTraces(interp, command, length, cmdPtr, result, TCL_TRACE_LEAVE_EXEC, objc, objv); @@ -6460,7 +6462,7 @@ TclNREvalObjEx( /* * Shimmer protection! Always pass an unshared obj. The caller could * incr the refCount of objPtr AFTER calling us! To be completely safe - * we always make a copy. The callback takes care od the refCounts for + * we always make a copy. The callback takes care of the refCounts for * both listPtr and objPtr. * * TODO: Create a test to demo this need, or eliminate it. @@ -9513,7 +9515,7 @@ NRCoroutineCallerCallback( SAVE_CONTEXT(corPtr->running); RESTORE_CONTEXT(corPtr->caller); - if (cmdPtr->flags & CMD_IS_DELETED) { + if (cmdPtr->flags & CMD_DYING) { /* * The command was deleted while it was running: wind down the * execEnv, this will do the complete cleanup. RewindCoroutine will @@ -10282,7 +10284,7 @@ TclInfoCoroutineCmd( return TCL_ERROR; } - if (corPtr && !(corPtr->cmdPtr->flags & CMD_IS_DELETED)) { + if (corPtr && !(corPtr->cmdPtr->flags & CMD_DYING)) { Tcl_Obj *namePtr; TclNewObj(namePtr); diff --git a/generic/tclCompile.c b/generic/tclCompile.c index fd63da3..7d67e12 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1834,7 +1834,7 @@ CompileCmdLiteral( bytes = TclGetStringFromObj(cmdObj, &numBytes); cmdLitIdx = TclRegisterLiteral(envPtr, bytes, numBytes, extraLiteralFlags); - if (cmdPtr) { + if (cmdPtr && TclRoutineHasName(cmdPtr)) { TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr); } TclEmitPush(cmdLitIdx, envPtr); diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 3c99631..16bf8f7 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -3161,7 +3161,7 @@ TclCompileEnsemble( } /* - * Now we've done the mapping process, can now actually try to compile. + * Now that the mapping process is done we actually try to compile. * If there is a subcommand compiler and that successfully produces code, * we'll use that. Otherwise, we fall back to generating opcodes to do the * invoke at runtime. @@ -3261,9 +3261,9 @@ TclAttemptCompileProc( /* * Advance parsePtr->tokenPtr so that it points at the last subcommand. - * This will be wrong, but it will not matter, and it will put the - * tokens for the arguments in the right place without the needed to - * allocate a synthetic Tcl_Parse struct, or copy tokens around. + * This will be wrong but it will not matter, and it will put the + * tokens for the arguments in the right place without the need to + * allocate a synthetic Tcl_Parse struct or copy tokens around. */ for (i = 0; i < depth - 1; i++) { diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 0f1c2cc..786fffb 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4464,7 +4464,7 @@ TEBCresume( CoroutineData *corPtr = iPtr->execEnvPtr->corPtr; TclNewObj(objResultPtr); - if (corPtr && !(corPtr->cmdPtr->flags & CMD_IS_DELETED)) { + if (corPtr && !(corPtr->cmdPtr->flags & CMD_DYING)) { Tcl_GetCommandFullName(interp, (Tcl_Command) corPtr->cmdPtr, objResultPtr); } @@ -4524,6 +4524,18 @@ TEBCresume( TRACE(("\"%.30s\" => ", O2S(OBJ_AT_TOS))); cmd = Tcl_GetCommandFromObj(interp, OBJ_AT_TOS); if (cmd == NULL) { + goto instOriginError; + } + origCmd = TclGetOriginalCommand(cmd); + if (origCmd == NULL) { + origCmd = cmd; + } + + TclNewObj(objResultPtr); + Tcl_GetCommandFullName(interp, origCmd, objResultPtr); + if (TclCheckEmptyString(objResultPtr) == TCL_EMPTYSTRING_YES ) { + Tcl_DecrRefCount(objResultPtr); + instOriginError: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid command name \"%s\"", TclGetString(OBJ_AT_TOS))); DECACHE_STACK_INFO(); @@ -4533,12 +4545,6 @@ TEBCresume( TRACE_APPEND(("ERROR: not command\n")); goto gotError; } - origCmd = TclGetOriginalCommand(cmd); - if (origCmd == NULL) { - origCmd = cmd; - } - TclNewObj(objResultPtr); - Tcl_GetCommandFullName(interp, origCmd, objResultPtr); TRACE_APPEND(("\"%.30s\"", O2S(OBJ_AT_TOS))); NEXT_INST_F(1, 1, 1); } diff --git a/generic/tclInt.h b/generic/tclInt.h index 792b675..9ccb3c5 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1707,18 +1707,18 @@ typedef struct Command { /* * Flag bits for commands. * - * CMD_IS_DELETED - Means that the command is in the process of + * CMD_DYING - If 1 the command is in the process of * being deleted (its deleteProc is currently * executing). Other attempts to delete the * command should be ignored. - * CMD_TRACE_ACTIVE - 1 means that trace processing is currently + * CMD_TRACE_ACTIVE - If 1 the trace processing is currently * underway for a rename/delete change. See the * two flags below for which is currently being * processed. - * CMD_HAS_EXEC_TRACES - 1 means that this command has at least one + * CMD_HAS_EXEC_TRACES - If 1 means that this command has at least one * execution trace (as opposed to simple * delete/rename traces) in its tracePtr list. - * CMD_COMPILES_EXPANDED - 1 means that this command has a compiler that + * CMD_COMPILES_EXPANDED - If 1 this command has a compiler that * can handle expansion (provided it is not the * first word). * TCL_TRACE_RENAME - A rename trace is in progress. Further @@ -1728,7 +1728,7 @@ typedef struct Command { * (these last two flags are defined in tcl.h) */ -#define CMD_IS_DELETED 0x01 +#define CMD_DYING 0x01 #define CMD_TRACE_ACTIVE 0x02 #define CMD_HAS_EXEC_TRACES 0x04 #define CMD_COMPILES_EXPANDED 0x08 @@ -4960,10 +4960,30 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; * the internal stubs, but the core can use the macro instead. */ -#define TclCleanupCommandMacro(cmdPtr) \ - if ((cmdPtr)->refCount-- <= 1) { \ - ckfree(cmdPtr);\ - } +#define TclCleanupCommandMacro(cmdPtr) \ + do { \ + if ((cmdPtr)->refCount-- <= 1) { \ + ckfree(cmdPtr); \ + } \ + } while (0) + + +/* + * inside this routine crement refCount first incase cmdPtr is replacing itself + */ +#define TclRoutineAssign(location, cmdPtr) \ + do { \ + (cmdPtr)->refCount++; \ + if ((location) != NULL \ + && (location--) <= 1) { \ + ckfree(((location))); \ + } \ + (location) = (cmdPtr); \ + } while (0) + + +#define TclRoutineHasName(cmdPtr) \ + (cmdPtr)->hPtr != NULL /* *---------------------------------------------------------------- diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 26dca62..673acb0 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -1770,6 +1770,8 @@ DoImport( TclInvokeImportedCmd, InvokeImportedNRCmd, dataPtr, DeleteImportedCmd); dataPtr->realCmdPtr = cmdPtr; + /* corresponding decrement is in DeleteImportedCmd */ + cmdPtr->refCount++; dataPtr->selfPtr = (Command *) importedCmd; dataPtr->selfPtr->compileProc = cmdPtr->compileProc; Tcl_DStringFree(&ds); @@ -2077,6 +2079,7 @@ DeleteImportedCmd( prevPtr->nextPtr = refPtr->nextPtr; } ckfree(refPtr); + TclCleanupCommandMacro(realCmdPtr); ckfree(dataPtr); return; } @@ -3888,7 +3891,7 @@ NamespaceOriginCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tcl_Command command, origCommand; + Tcl_Command cmd, origCmd; Tcl_Obj *resultPtr; if (objc != 2) { @@ -3896,30 +3899,29 @@ NamespaceOriginCmd( return TCL_ERROR; } - command = Tcl_GetCommandFromObj(interp, objv[1]); - if (command == NULL) { + cmd = Tcl_GetCommandFromObj(interp, objv[1]); + if (cmd == NULL) { + goto namespaceOriginError; + } + origCmd = TclGetOriginalCommand(cmd); + if (origCmd == NULL) { + origCmd = cmd; + } + TclNewObj(resultPtr); + Tcl_GetCommandFullName(interp, origCmd, resultPtr); + if (TclCheckEmptyString(resultPtr) == TCL_EMPTYSTRING_YES ) { + Tcl_DecrRefCount(resultPtr); + namespaceOriginError: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid command name \"%s\"", TclGetString(objv[1]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND", TclGetString(objv[1]), NULL); return TCL_ERROR; } - origCommand = TclGetOriginalCommand(command); - TclNewObj(resultPtr); - if (origCommand == NULL) { - /* - * The specified command isn't an imported command. Return the - * command's name qualified by the full name of the namespace it was - * defined in. - */ - - Tcl_GetCommandFullName(interp, command, resultPtr); - } else { - Tcl_GetCommandFullName(interp, origCommand, resultPtr); - } Tcl_SetObjResult(interp, resultPtr); return TCL_OK; } + /* *---------------------------------------------------------------------- diff --git a/generic/tclOO.c b/generic/tclOO.c index 85f4470..21018ac 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -1177,7 +1177,7 @@ ObjectNamespaceDeleted( * freed memory. */ - if (((Command *) oPtr->command)->flags && CMD_IS_DELETED) { + if (((Command *) oPtr->command)->flags && CMD_DYING) { /* * Something has already started the command deletion process. We can * go ahead and clean up the the namespace, diff --git a/generic/tclObj.c b/generic/tclObj.c index dbe6686..44b2785 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4667,7 +4667,7 @@ SetCmdNameFromAny( * report the failure to find the command as an error. */ - if (cmdPtr == NULL) { + if (cmdPtr == NULL || !TclRoutineHasName(cmdPtr)) { return TCL_ERROR; } diff --git a/tests/namespace.test b/tests/namespace.test index 2b25803..9c4672f 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -616,6 +616,102 @@ test namespace-13.2 {DeleteImportedCmd, Bug a4494e28ed} { namespace delete src } {} + +test namespace-13.3 { + deleting origin of import in trace on deletion of import +} -setup { + namespace eval ns0 { + namespace export * + variable res {} + + proc traced {oldname newname op} { + variable res + + lappend res {Is oldname the name of the imported routine?} + set expected [namespace qualifiers [namespace current]::fake]::ns2::ns1 + if {$oldname eq $expected} { + lappend res 1 + } else { + lappend res 0 + } + + lappend res {[namespace which] finds the old name} + set which [namespace which $oldname] + if {$which eq $expected} { + lappend res 1 + } else { + lappend res $which + } + + lappend res {Is origin name correct} + catch { + namespace origin $oldname + } cres copts + set expected [namespace qualifiers [namespace current]::fake]::ns1 + if {$cres eq $expected} { + lappend res 1 + } else { + lappend res $cres + } + + set origin $cres + rename $origin {} + + lappend res {After deletion of the origin is it an error to ask for the origin (compiled)?} + set status [catch { + namespace origin $oldname + } cres copts] + if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { + lappend res 1 + } else { + lappend res $cres + } + + lappend res {After deletion of the origin is it an error to ask for the origin (uncompiled)?} + set status [catch { + namespace eval [namespace current] "namespace origin $oldname" + } cres copts] + if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { + lappend res 1 + } else { + lappend res $cres + } + + lappend res {after deletion of origin, [namespace which] on the imported routine returns the empty string} + set which [namespace which $oldname] + if {$which eq {}} { + lappend res 1 + } else { + lappend res $which + } + + return + } + + } +} -body { + namespace eval ns0::ns1 { + namespace ensemble create + } + + namespace eval ns0::ns2 { + namespace import [namespace parent]::ns1 + trace add command ns1 delete [namespace parent]::traced + rename ns1 {} + } + return $ns0::res +} -cleanup { + namespace delete ns0 +} -result [list \ + {Is oldname the name of the imported routine?} 1 \ + {[namespace which] finds the old name} 1 \ + {Is origin name correct} 1 \ + {After deletion of the origin is it an error to ask for the origin (compiled)?} 1 \ + {After deletion of the origin is it an error to ask for the origin (uncompiled)?} 1 \ + {after deletion of origin, [namespace which] on the imported routine returns the empty string} 1 \ +] + + test namespace-14.1 {TclGetNamespaceForQualName, absolute names} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} variable v 10 -- cgit v0.12 From 264c84606b485bb031fbd8ac6b3eba23938b0d7f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Sep 2020 11:46:35 +0000 Subject: Upgrade Travis build from xcode 11.5 to 11.7 --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad3f03a..7f93fa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,9 +126,9 @@ jobs: - BUILD_DIR=unix - CFGOPT="--enable-symbols=mem" # Testing on Mac, various styles - - name: "macOS/Xcode 11.5/Shared" + - name: "macOS/Xcode 11.7/Shared" os: osx - osx_image: xcode11.5 + osx_image: xcode11.7 env: - BUILD_DIR=macosx install: [] @@ -136,9 +136,9 @@ jobs: - make all # The styles=develop avoids some weird problems on OSX - make test styles=develop - - name: "macOS/Xcode 11.5/Shared/Unix-like" + - name: "macOS/Xcode 11.7/Shared/Unix-like" os: osx - osx_image: xcode11.5 + osx_image: xcode11.7 env: - BUILD_DIR=unix # Older MacOS versions -- cgit v0.12 From 4cdb0426f4766ad093409f1bef7d84d6a671c9de Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Sep 2020 13:01:50 +0000 Subject: Fix windows debug build, broken by previous commit --- generic/tclInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 9ccb3c5..2f12b8f 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4983,7 +4983,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; #define TclRoutineHasName(cmdPtr) \ - (cmdPtr)->hPtr != NULL + ((cmdPtr)->hPtr != NULL) /* *---------------------------------------------------------------- -- cgit v0.12 From de2793025fcbb875f0ac1e7efed956bbfedca273 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 2 Sep 2020 16:20:20 +0000 Subject: Different fix where existing protection tools for nesting bytecode execution calls are used. This solution suggests there may be many more places needing protection. Any routine that gets passed "interp" is a possibility. --- generic/tclExecute.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 0f1c2cc..70ed54a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5298,10 +5298,13 @@ TEBCresume( */ length = Tcl_GetCharLength(valuePtr); + DECACHE_STACK_INFO(); if (TclGetIntForIndexM(interp, value2Ptr, length-1, &index)!=TCL_OK) { + CACHE_STACK_INFO(); TRACE_ERROR(interp); goto gotError; } + CACHE_STACK_INFO(); if ((index < 0) || (index >= length)) { TclNewObj(objResultPtr); -- cgit v0.12 From ee7073e46860e7e4746d0f8d68a8b66e708eb763 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 2 Sep 2020 19:50:32 +0000 Subject: Test lindex-18.0 demonstrates same issue with INST_LIST_INDEX --- tests/lindex.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/lindex.test b/tests/lindex.test index 41c803b..fa5c996 100644 --- a/tests/lindex.test +++ b/tests/lindex.test @@ -449,6 +449,14 @@ test lindex-17.1 {Bug 1718580} -body { lindex a end foo } -match glob -result {bad index "foo"*} -returnCodes 1 +test lindex-18.0 {nested bytecode execution} -setup { + proc demo {i} {lindex {a b c} $i} +} -body { + demo 0+0x10000000000000000 +} -cleanup { + rename demo {} +} + catch { unset minus } # cleanup -- cgit v0.12 From 712f88bef73db43ea3e8169d8c5609ec420b3bf2 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 2 Sep 2020 20:22:15 +0000 Subject: Fix for test lindex-18.0 --- generic/tclExecute.c | 20 +++++++++++++------- generic/tclUtil.c | 17 ++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 70ed54a..890ce08 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4857,13 +4857,19 @@ TEBCresume( */ if ((TclListObjGetElements(interp, valuePtr, &objc, &objv) == TCL_OK) - && !TclHasIntRep(value2Ptr, &tclListType) - && (TclGetIntForIndexM(NULL, value2Ptr, objc-1, - &index) == TCL_OK)) { - TclDecrRefCount(value2Ptr); - tosPtr--; - pcAdjustment = 1; - goto lindexFastPath; + && !TclHasIntRep(value2Ptr, &tclListType)) { + int code; + + DECACHE_STACK_INFO(); + code = TclGetIntForIndexM(interp, value2Ptr, objc-1, &index); + CACHE_STACK_INFO(); + if (code == TCL_OK) { + TclDecrRefCount(value2Ptr); + tosPtr--; + pcAdjustment = 1; + goto lindexFastPath; + } + Tcl_ResetResult(interp); } objResultPtr = TclLindexList(interp, valuePtr, value2Ptr); diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 5b296f0..8db6606 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3817,7 +3817,7 @@ GetEndOffsetFromObj( if ((t1 == TCL_NUMBER_INT) && (t2 == TCL_NUMBER_INT)) { /* Both are wide, do wide-integer math */ if (*opPtr == '-') { - if ((w2 == WIDE_MIN) && (interp != NULL)) { + if (w2 == WIDE_MIN) { goto extreme; } w2 = -w2; @@ -3839,13 +3839,6 @@ GetEndOffsetFromObj( offset = WIDE_MIN; } } - } else if (interp == NULL) { - /* - * We use an interp to do bignum index calculations. - * If we don't get one, call all indices with bignums errors, - * and rely on callers to handle it. - */ - goto parseError; } else { /* * At least one is big, do bignum math. Little reason to @@ -3856,7 +3849,13 @@ GetEndOffsetFromObj( Tcl_Obj *sum; extreme: - Tcl_ExprObj(interp, objPtr, &sum); + if (interp) { + Tcl_ExprObj(interp, objPtr, &sum); + } else { + Tcl_Interp *compute = Tcl_CreateInterp(); + Tcl_ExprObj(compute, objPtr, &sum); + Tcl_DeleteInterp(compute); + } TclGetNumberFromObj(NULL, sum, &cd, &numType); if (numType == TCL_NUMBER_INT) { -- cgit v0.12 From 9f309d56cc2544def77f3c913d28aa1c1f8e2e14 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 2 Sep 2020 20:50:43 +0000 Subject: Tests string-12.2[45].* and fixes to INST_STRING_RANGE. --- generic/tclExecute.c | 12 ++++++++++-- tests/string.test | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 890ce08..3d39e89 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5347,13 +5347,21 @@ TEBCresume( TRACE(("\"%.20s\" %.20s %.20s =>", O2S(OBJ_AT_DEPTH(2)), O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS))); length = Tcl_GetCharLength(OBJ_AT_DEPTH(2)) - 1; + + DECACHE_STACK_INFO(); if (TclGetIntForIndexM(interp, OBJ_UNDER_TOS, length, - &fromIdx) != TCL_OK - || TclGetIntForIndexM(interp, OBJ_AT_TOS, length, + &fromIdx) != TCL_OK) { + CACHE_STACK_INFO(); + TRACE_ERROR(interp); + goto gotError; + } + if (TclGetIntForIndexM(interp, OBJ_AT_TOS, length, &toIdx) != TCL_OK) { + CACHE_STACK_INFO(); TRACE_ERROR(interp); goto gotError; } + CACHE_STACK_INFO(); if (fromIdx < 0) { fromIdx = 0; diff --git a/tests/string.test b/tests/string.test index e42da8e..ba0780a 100644 --- a/tests/string.test +++ b/tests/string.test @@ -1506,6 +1506,20 @@ test string-12.22.$noComp {string range, shimmering binary/index} { test string-12.23.$noComp {string range, surrogates, bug [11ae2be95dac9417]} utf16 { run {list [string range a\U100000b 1 1] [string range a\U100000b 2 2] [string range a\U100000b 3 3]} } [list \U100000 {} b] +test string-12.24.$noComp {bignum index arithmetic} -setup { + proc demo {i j} {string range fubar $i $j} +} -cleanup { + rename demo {} +} -body { + demo 2 0+0x10000000000000000 +} -result bar +test string-12.25.$noComp {bignum index arithmetic} -setup { + proc demo {i j} {string range fubar $i $j} +} -cleanup { + rename demo {} +} -body { + demo 0x10000000000000000-0xffffffffffffffff 3 +} -result uba test string-13.1.$noComp {string repeat} { list [catch {run {string repeat}} msg] $msg -- cgit v0.12 From 2b83b2c9993319e242389505cc899ceacdea58c5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Sep 2020 21:04:25 +0000 Subject: Implementation of TIP #585 - Promote the INDEX_TEMP_TABLE flag of Tcl_GetIndexFromObj*() to the public interface --- doc/GetIndex.3 | 19 +++++++++++++------ generic/tcl.h | 9 ++++++--- generic/tclFCmd.c | 4 ++-- generic/tclIndexObj.c | 8 ++++---- generic/tclInt.h | 9 --------- generic/tclTestObj.c | 2 +- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/doc/GetIndex.3 b/doc/GetIndex.3 index 17a31d4..8591c56 100644 --- a/doc/GetIndex.3 +++ b/doc/GetIndex.3 @@ -27,19 +27,22 @@ Interpreter to use for error reporting; if NULL, then no message is provided on errors. .AP Tcl_Obj *objPtr in/out The string value of this value is used to search through \fItablePtr\fR. -The internal representation is modified to hold the index of the matching +If the \fBTCL_INDEX_TEMP_TABLE\fR flag is not specified, +the internal representation is modified to hold the index of the matching table entry. .AP "const char *const" *tablePtr in An array of null-terminated strings. The end of the array is marked by a NULL string pointer. -Note that references to the \fItablePtr\fR may be retained in the +Note that, unless the \fBTCL_INDEX_TEMP_TABLE\fR flag is specified, +references to the \fItablePtr\fR may be retained in the internal representation of \fIobjPtr\fR, so this should represent the address of a statically-allocated array. .AP "const void" *structTablePtr in An array of arbitrary type, typically some \fBstruct\fR type. The first member of the structure must be a null-terminated string. The size of the structure is given by \fIoffset\fR. -Note that references to the \fIstructTablePtr\fR may be retained in the +Note that, unless the \fBTCL_INDEX_TEMP_TABLE\fR flag is specified, +references to the \fIstructTablePtr\fR may be retained in the internal representation of \fIobjPtr\fR, so this should represent the address of a statically-allocated array of structures. .AP int offset in @@ -50,7 +53,8 @@ Null-terminated string describing what is being looked up, such as \fBoption\fR. This string is included in error messages. .AP int flags in OR-ed combination of bits providing additional information for -operation. The only bit that is currently defined is \fBTCL_EXACT\fR. +operation. The only bits that are currently defined are \fBTCL_EXACT\fR +and \fBTCL_INDEX_TEMP_TABLE\fR. .AP int *indexPtr out The index of the string in \fItablePtr\fR that matches the value of \fIobjPtr\fR is returned here. @@ -76,7 +80,8 @@ error message to indicate what was being looked up. For example, if \fImsg\fR is \fBoption\fR the error message will have a form like .QW "\fBbad option \N'34'firt\N'34': must be first, second, or third\fR" . .PP -If \fBTcl_GetIndexFromObj\fR completes successfully it modifies the +If the \fBTCL_INDEX_TEMP_TABLE\fR was not specified, when +\fBTcl_GetIndexFromObj\fR completes successfully it modifies the internal representation of \fIobjPtr\fR to hold the address of the table and the index of the matching entry. If \fBTcl_GetIndexFromObj\fR is invoked again with the same \fIobjPtr\fR and \fItablePtr\fR @@ -84,7 +89,9 @@ arguments (e.g. during a reinvocation of a Tcl command), it returns the matching index immediately without having to redo the lookup operation. Note: \fBTcl_GetIndexFromObj\fR assumes that the entries in \fItablePtr\fR are static: they must not change between -invocations. If the value of \fIobjPtr\fR is the empty string, +invocations. This caching mechanism can be disallowed by specifying +the \fBTCL_INDEX_TEMP_TABLE\fR flag. +If the value of \fIobjPtr\fR is the empty string, \fBTcl_GetIndexFromObj\fR will treat it as a non-matching value and return \fBTCL_ERROR\fR. .PP diff --git a/generic/tcl.h b/generic/tcl.h index 02ef01e..65169c0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -973,11 +973,14 @@ typedef struct Tcl_DString { #define TCL_DONT_QUOTE_HASH 8 /* - * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow - * abbreviated strings. + * Flags that may be passed to Tcl_GetIndexFromObj. + * TCL_EXACT disallows abbreviated strings. + * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is + * a table that will not live long enough to make it worthwhile. */ -#define TCL_EXACT 1 +#define TCL_EXACT 1 +#define TCL_INDEX_TEMP_TABLE 2 /* *---------------------------------------------------------------------------- diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index 3babd43..d6a152a 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -1085,7 +1085,7 @@ TclFileAttrsCmd( } if (Tcl_GetIndexFromObj(interp, objv[0], attributeStrings, - "option", INDEX_TEMP_TABLE, &index) != TCL_OK) { + "option", TCL_INDEX_TEMP_TABLE, &index) != TCL_OK) { goto end; } if (Tcl_FSFileAttrsGet(interp, index, filePtr, @@ -1110,7 +1110,7 @@ TclFileAttrsCmd( for (i = 0; i < objc ; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], attributeStrings, - "option", INDEX_TEMP_TABLE, &index) != TCL_OK) { + "option", TCL_INDEX_TEMP_TABLE, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 4749e6e..a0a31da 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -114,7 +114,7 @@ Tcl_GetIndexFromObj( int flags, /* 0 or TCL_EXACT */ int *indexPtr) /* Place to store resulting integer index. */ { - if (!(flags & INDEX_TEMP_TABLE)) { + if (!(flags & TCL_INDEX_TEMP_TABLE)) { /* * See if there is a valid cached result from a previous lookup (doing the @@ -216,7 +216,7 @@ GetIndexFromObjList( tablePtr[objc] = NULL; result = Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, - sizeof(char *), msg, flags | INDEX_TEMP_TABLE, indexPtr); + sizeof(char *), msg, flags | TCL_INDEX_TEMP_TABLE, indexPtr); ckfree(tablePtr); @@ -280,7 +280,7 @@ Tcl_GetIndexFromObjStruct( * See if there is a valid cached result from a previous lookup. */ - if (!(flags & INDEX_TEMP_TABLE)) { + if (!(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchIntRep(objPtr, &indexType); if (irPtr) { indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; @@ -344,7 +344,7 @@ Tcl_GetIndexFromObjStruct( * operation. */ - if (!(flags & INDEX_TEMP_TABLE)) { + if (!(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchIntRep(objPtr, &indexType); if (irPtr) { indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; diff --git a/generic/tclInt.h b/generic/tclInt.h index 2f12b8f..7791a1c 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2606,15 +2606,6 @@ 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. */ diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 99cb1f4..bd5d92e 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -627,7 +627,7 @@ TestindexobjCmd( argv[objc-4] = NULL; result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3], - argv, "token", INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT), + argv, "token", TCL_INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT), &index); ckfree(argv); if (result == TCL_OK) { -- cgit v0.12 From db325590a751eae6a25ee6ba9f749ba499ff2078 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Sep 2020 06:04:47 +0000 Subject: Protect INST_STR_REPLACE too --- generic/tclExecute.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 3d39e89..6c631e2 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5444,14 +5444,17 @@ TEBCresume( endIdx = Tcl_GetCharLength(valuePtr) - 1; TRACE(("\"%.20s\" %s %s \"%.20s\" => ", O2S(valuePtr), O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), O2S(value3Ptr))); + DECACHE_STACK_INFO(); if (TclGetIntForIndexM(interp, OBJ_UNDER_TOS, endIdx, &fromIdx) != TCL_OK || TclGetIntForIndexM(interp, OBJ_AT_TOS, endIdx, &toIdx) != TCL_OK) { + CACHE_STACK_INFO(); TclDecrRefCount(value3Ptr); TRACE_ERROR(interp); goto gotError; } + CACHE_STACK_INFO(); TclDecrRefCount(OBJ_AT_TOS); (void) POP_OBJECT(); TclDecrRefCount(OBJ_AT_TOS); -- cgit v0.12 From a4abf50c23f2a2b458181704617172b1de3e772a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Sep 2020 07:28:20 +0000 Subject: TIP #581: Mainly documentation and some testcases --- doc/CrtAlias.3 | 34 ++++---- doc/FileSystem.3 | 4 +- doc/Limit.3 | 2 +- doc/interp.n | 240 ++++++++++++++++++++++++++-------------------------- doc/library.n | 2 +- doc/pkgMkIndex.n | 4 +- doc/safe.n | 104 +++++++++++------------ generic/tcl.decls | 14 +-- generic/tclDecls.h | 35 ++++---- generic/tclEvent.c | 4 +- generic/tclIOUtil.c | 2 +- tests/winDde.test | 178 +++++++++++++++++++------------------- 12 files changed, 311 insertions(+), 312 deletions(-) diff --git a/doc/CrtAlias.3 b/doc/CrtAlias.3 index a0041af..2934fc3 100644 --- a/doc/CrtAlias.3 +++ b/doc/CrtAlias.3 @@ -44,22 +44,22 @@ Tcl_Interp * \fBTcl_GetMaster\fR(\fIinterp\fR) .sp int -\fBTcl_GetInterpPath\fR(\fIinterp, slaveInterp\fR) +\fBTcl_GetInterpPath\fR(\fIinterp, childInterp\fR) .sp int -\fBTcl_CreateAlias\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, +\fBTcl_CreateAlias\fR(\fIchildInterp, childCmd, targetInterp, targetCmd, argc, argv\fR) .sp int -\fBTcl_CreateAliasObj\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, +\fBTcl_CreateAliasObj\fR(\fIchildInterp, childCmd, targetInterp, targetCmd, objc, objv\fR) .sp int -\fBTcl_GetAlias\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, +\fBTcl_GetAlias\fR(\fIinterp, childCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtr\fR) .sp int -\fBTcl_GetAliasObj\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, +\fBTcl_GetAliasObj\fR(\fIinterp, childCmd, targetInterpPtr, targetCmdPtr, objcPtr, objvPtr\fR) .sp int @@ -72,16 +72,16 @@ int .AP Tcl_Interp *interp in Interpreter in which to execute the specified command. .AP "const char" *name in -Name of slave interpreter to create or manipulate. +Name of child interpreter to create or manipulate. .AP int isSafe in If non-zero, a .QW safe -slave that is suitable for running untrusted code -is created, otherwise a trusted slave is created. -.AP Tcl_Interp *slaveInterp in +child that is suitable for running untrusted code +is created, otherwise a trusted child is created. +.AP Tcl_Interp *childInterp in Interpreter to use for creating the source command for an alias (see below). -.AP "const char" *slaveCmd in +.AP "const char" *childCmd in Name of source command for alias. .AP Tcl_Interp *targetInterp in Interpreter that contains the target command for an alias. @@ -186,22 +186,22 @@ top-level interpreter) then \fBNULL\fR is returned. .VE "TIP 581" .PP \fBTcl_GetInterpPath\fR stores in the result of \fIinterp\fR -the relative path between \fIinterp\fR and \fIslaveInterp\fR; -\fIslaveInterp\fR must be a slave of \fIinterp\fR. If the computation +the relative path between \fIinterp\fR and \fIchildInterp\fR; +\fIchildInterp\fR must be a slave of \fIinterp\fR. If the computation of the relative path succeeds, \fBTCL_OK\fR is returned, else \fBTCL_ERROR\fR is returned and an error message is stored as the result of \fIinterp\fR. .PP -\fBTcl_CreateAlias\fR creates a command named \fIslaveCmd\fR in -\fIslaveInterp\fR that when invoked, will cause the command \fItargetCmd\fR +\fBTcl_CreateAlias\fR creates a command named \fIchildCmd\fR in +\fIchildInterp\fR that when invoked, will cause the command \fItargetCmd\fR to be invoked in \fItargetInterp\fR. The arguments specified by the strings contained in \fIargv\fR are always prepended to any arguments supplied in the -invocation of \fIslaveCmd\fR and passed to \fItargetCmd\fR. +invocation of \fIchildCmd\fR and passed to \fItargetCmd\fR. This operation returns \fBTCL_OK\fR if it succeeds, or \fBTCL_ERROR\fR if it fails; in that case, an error message is left in the value result -of \fIslaveInterp\fR. +of \fIchildInterp\fR. Note that there are no restrictions on the ancestry relationship (as -created by \fBTcl_CreateSlave\fR) between \fIslaveInterp\fR and +created by \fBTcl_CreateSlave\fR) between \fIchildInterp\fR and \fItargetInterp\fR. Any two interpreters can be used, without any restrictions on how they are related. .PP diff --git a/doc/FileSystem.3 b/doc/FileSystem.3 index 28ee8f0..4a57743 100644 --- a/doc/FileSystem.3 +++ b/doc/FileSystem.3 @@ -1350,11 +1350,11 @@ is considered to be owned by the filesystem (not by Tcl's core), but should be given a reference count for Tcl. Tcl will use the contents of the list and then decrement that reference count. This allows filesystems to choose whether they actually want to retain a -.QW "master list" +.QW "global list" of volumes or not (if not, they generate the list on the fly and pass it to Tcl with a reference count of 1 and then forget about the list, if yes, then -they simply increment the reference count of their master list and pass it +they simply increment the reference count of their global list and pass it to Tcl which will copy the contents and then decrement the count back to where it was). .PP diff --git a/doc/Limit.3 b/doc/Limit.3 index 5939a80..3d202fc 100644 --- a/doc/Limit.3 +++ b/doc/Limit.3 @@ -116,7 +116,7 @@ execution of the callbacks is unspecified) execution in the limited interpreter is stopped by raising an error and setting a flag that prevents the \fBcatch\fR command in that interpreter from trapping that error. It is up to the context that started execution in that -interpreter (typically a master interpreter) to handle the error. +interpreter (typically the main interpreter) to handle the error. .SH "LIMIT CHECKING API" .PP To check the resource limits for an interpreter, call diff --git a/doc/interp.n b/doc/interp.n index 9f975d0..61aa151 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -19,18 +19,18 @@ interp \- Create and manipulate Tcl interpreters .PP This command makes it possible to create one or more new Tcl interpreters that co-exist with the creating interpreter in the -same application. The creating interpreter is called the \fImaster\fR -and the new interpreter is called a \fIslave\fR. -A master can create any number of slaves, and each slave can -itself create additional slaves for which it is master, resulting +same application. The creating interpreter is called the \fIparent\fR +and the new interpreter is called a \fIchild\fR. +A parent can create any number of children, and each child can +itself create additional children for which it is parent, resulting in a hierarchy of interpreters. .PP Each interpreter is independent from the others: it has its own name space for commands, procedures, and global variables. -A master interpreter may create connections between its slaves and +A parent interpreter may create connections between its children and itself using a mechanism called an \fIalias\fR. An \fIalias\fR is -a command in a slave interpreter which, when invoked, causes a -command to be invoked in its master interpreter or in another slave +a command in a child interpreter which, when invoked, causes a +command to be invoked in its parent interpreter or in another child interpreter. The only other connections between interpreters are through environment variables (the \fBenv\fR variable), which are normally shared among all interpreters in the application, @@ -41,7 +41,7 @@ share files and to transfer references to open files from one interpreter to another. .PP The \fBinterp\fR command also provides support for \fIsafe\fR -interpreters. A safe interpreter is a slave whose functions have +interpreters. A safe interpreter is a child whose functions have been greatly restricted, so that it is safe to execute untrusted scripts without fear of them damaging other interpreters or the application's environment. For example, all IO channel creation @@ -54,18 +54,18 @@ instead, it is \fIhidden\fR, so that only trusted interpreters can obtain access to it. For a detailed explanation of hidden commands, see \fBHIDDEN COMMANDS\fR, below. The alias mechanism can be used for protected communication (analogous to a -kernel call) between a slave interpreter and its master. +kernel call) between a child interpreter and its parent. See \fBALIAS INVOCATION\fR, below, for more details on how the alias mechanism works. .PP A qualified interpreter name is a proper Tcl lists containing a subset of its ancestors in the interpreter hierarchy, terminated by the string naming the -interpreter in its immediate master. Interpreter names are relative to the +interpreter in its immediate parent. Interpreter names are relative to the interpreter in which they are used. For example, if .QW \fBa\fR -is a slave of the current interpreter and it has a slave +is a child of the current interpreter and it has a child .QW \fBa1\fR , -which in turn has a slave +which in turn has a child .QW \fBa11\fR , the qualified name of .QW \fBa11\fR @@ -77,14 +77,14 @@ is the list The \fBinterp\fR command, described below, accepts qualified interpreter names as arguments; the interpreter in which the command is being evaluated can always be referred to as \fB{}\fR (the empty list or string). Note that -it is impossible to refer to a master (ancestor) interpreter by name in a -slave interpreter except through aliases. Also, there is no global name by +it is impossible to refer to a parent (ancestor) interpreter by name in a +child interpreter except through aliases. Also, there is no global name by which one can refer to the first interpreter created in an application. Both restrictions are motivated by safety concerns. .SH "THE INTERP COMMAND" .PP The \fBinterp\fR command is used to create, delete, and manipulate -slave interpreters, and to share or transfer +child interpreters, and to share or transfer channels between interpreters. It can have any of several forms, depending on the \fIsubcommand\fR argument: .TP @@ -94,11 +94,11 @@ Returns a Tcl list whose elements are the \fItargetCmd\fR and \fIarg\fRs associated with the alias represented by \fIsrcToken\fR (this is the value returned when the alias was created; it is possible that the name of the source command in the -slave is different from \fIsrcToken\fR). +child is different from \fIsrcToken\fR). .TP \fBinterp\fR \fBalias\fR \fIsrcPath\fR \fIsrcToken\fR \fB{}\fR . -Deletes the alias for \fIsrcToken\fR in the slave interpreter identified by +Deletes the alias for \fIsrcToken\fR in the child interpreter identified by \fIsrcPath\fR. \fIsrcToken\fR refers to the value returned when the alias was created; if the source command has been renamed, the renamed @@ -106,9 +106,9 @@ command will be deleted. .TP \fBinterp\fR \fBalias\fR \fIsrcPath\fR \fIsrcCmd\fR \fItargetPath\fR \fItargetCmd \fR?\fIarg arg ...\fR? . -This command creates an alias between one slave and another (see the -\fBalias\fR slave command below for creating aliases between a slave -and its master). In this command, either of the slave interpreters +This command creates an alias between one child and another (see the +\fBalias\fR child command below for creating aliases between a child +and its parent). In this command, either of the child interpreters may be anywhere in the hierarchy of interpreters under the interpreter invoking the command. \fISrcPath\fR and \fIsrcCmd\fR identify the source of the alias. @@ -117,9 +117,9 @@ interpreter. For example, .QW "\fBa b\fR" identifies an interpreter .QW \fBb\fR , -which is a slave of interpreter +which is a child of interpreter .QW \fBa\fR , -which is a slave of the invoking interpreter. An empty list specifies +which is a child of the invoking interpreter. An empty list specifies the interpreter invoking the command. \fIsrcCmd\fR gives the name of a new command, which will be created in the source interpreter. \fITargetPath\fR and \fItargetCmd\fR specify a target interpreter @@ -171,33 +171,33 @@ used. .TP \fBinterp\fR \fBcreate \fR?\fB\-safe\fR? ?\fB\-\|\-\fR? ?\fIpath\fR? . -Creates a slave interpreter identified by \fIpath\fR and a new command, -called a \fIslave command\fR. The name of the slave command is the last -component of \fIpath\fR. The new slave interpreter and the slave command +Creates a child interpreter identified by \fIpath\fR and a new command, +called a \fIchild command\fR. The name of the child command is the last +component of \fIpath\fR. The new child interpreter and the child command are created in the interpreter identified by the path obtained by removing the last component from \fIpath\fR. For example, if \fIpath\fR is \fBa b -c\fR then a new slave interpreter and slave command named \fBc\fR are +c\fR then a new child interpreter and child command named \fBc\fR are created in the interpreter identified by the path \fBa b\fR. -The slave command may be used to manipulate the new interpreter as +The child command may be used to manipulate the new interpreter as described below. If \fIpath\fR is omitted, Tcl creates a unique name of the form \fBinterp\fIx\fR, where \fIx\fR is an integer, and uses it for the -interpreter and the slave command. If the \fB\-safe\fR switch is specified -(or if the master interpreter is a safe interpreter), the new slave +interpreter and the child command. If the \fB\-safe\fR switch is specified +(or if the parent interpreter is a safe interpreter), the new child interpreter will be created as a safe interpreter with limited -functionality; otherwise the slave will include the full set of Tcl +functionality; otherwise the child will include the full set of Tcl built-in commands and variables. The \fB\-\|\-\fR switch can be used to mark the end of switches; it may be needed if \fIpath\fR is an unusual value such as \fB\-safe\fR. The result of the command is the name of the -new interpreter. The name of a slave interpreter must be unique among all -the slaves for its master; an error occurs if a slave interpreter by the -given name already exists in this master. -The initial recursion limit of the slave interpreter is set to the +new interpreter. The name of a child interpreter must be unique among all +the children for its parent; an error occurs if a child interpreter by the +given name already exists in this parent. +The initial recursion limit of the child interpreter is set to the current recursion limit of its parent interpreter. .TP \fBinterp\fR \fBdebug \fIpath\fR ?\fB\-frame\fR ?\fIbool\fR?? . Controls whether frame-level stack information is captured in the -slave interpreter identified by \fIpath\fR. If no arguments are +child interpreter identified by \fIpath\fR. If no arguments are given, option and current setting are returned. If \fB\-frame\fR is given, the debug setting is set to the given boolean if provided and the current setting is returned. @@ -239,8 +239,8 @@ consistency of the underlying interpreter's state. \fBinterp\fR \fBdelete \fR?\fIpath ...?\fR . Deletes zero or more interpreters given by the optional \fIpath\fR -arguments, and for each interpreter, it also deletes its slaves. The -command also deletes the slave command for each interpreter deleted. +arguments, and for each interpreter, it also deletes its children. The +command also deletes the child command for each interpreter deleted. For each \fIpath\fR argument, if no interpreter by that name exists, the command raises an error. .TP @@ -248,20 +248,20 @@ exists, the command raises an error. . This command concatenates all of the \fIarg\fR arguments in the same fashion as the \fBconcat\fR command, then evaluates the resulting string as -a Tcl script in the slave interpreter identified by \fIpath\fR. The result +a Tcl script in the child interpreter identified by \fIpath\fR. The result of this evaluation (including all \fBreturn\fR options, such as \fB\-errorinfo\fR and \fB\-errorcode\fR information, if an error occurs) is returned to the invoking interpreter. Note that the script will be executed in the current context stack frame of the -\fIpath\fR interpreter; this is so that the implementations (in a master -interpreter) of aliases in a slave interpreter can execute scripts in -the slave that find out information about the slave's current state +\fIpath\fR interpreter; this is so that the implementations (in a parent +interpreter) of aliases in a child interpreter can execute scripts in +the child that find out information about the child's current state and stack frame. .TP \fBinterp exists \fIpath\fR . -Returns \fB1\fR if a slave interpreter by the specified \fIpath\fR -exists in this master, \fB0\fR otherwise. If \fIpath\fR is omitted, the +Returns \fB1\fR if a child interpreter by the specified \fIpath\fR +exists in this parent, \fB0\fR otherwise. If \fIpath\fR is omitted, the invoking interpreter is used. .TP \fBinterp expose \fIpath\fR \fIhiddenName\fR ?\fIexposedCmdName\fR? @@ -287,7 +287,7 @@ Currently both \fIexposedCmdName\fR and \fIhiddenCmdName\fR can not contain namespace qualifiers, or an error is raised. Commands to be hidden by \fBinterp hide\fR are looked up in the global namespace even if the current namespace is not the global one. This -prevents slaves from fooling a master interpreter into hiding the wrong +prevents children from fooling a parent interpreter into hiding the wrong command, by making the current namespace be different from the global one. Hidden commands are explained in more detail in \fBHIDDEN COMMANDS\fR, below. .TP @@ -373,7 +373,7 @@ interpreter is destroyed. .TP \fBinterp\fR \fBslaves\fR ?\fIpath\fR? . -Returns a Tcl list of the names of all the slave interpreters associated +Returns a Tcl list of the names of all the child interpreters associated with the interpreter identified by \fIpath\fR. If \fIpath\fR is omitted, the invoking interpreter is used. .TP @@ -399,48 +399,48 @@ The target command does not have to be defined at the time of this invocation. Causes the IO channel identified by \fIchannelId\fR to become available in the interpreter identified by \fIdestPath\fR and unavailable in the interpreter identified by \fIsrcPath\fR. -.SH "SLAVE COMMAND" +.SH "child COMMAND" .PP -For each slave interpreter created with the \fBinterp\fR command, a -new Tcl command is created in the master interpreter with the same +For each child interpreter created with the \fBinterp\fR command, a +new Tcl command is created in the parent interpreter with the same name as the new interpreter. This command may be used to invoke various operations on the interpreter. It has the following general form: .PP .CS -\fIslave command \fR?\fIarg arg ...\fR? +\fIchild command \fR?\fIarg arg ...\fR? .CE .PP -\fISlave\fR is the name of the interpreter, and \fIcommand\fR +\fIchild\fR is the name of the interpreter, and \fIcommand\fR and the \fIarg\fRs determine the exact behavior of the command. The valid forms of this command are: .TP -\fIslave \fBaliases\fR +\fIchild \fBaliases\fR . Returns a Tcl list whose elements are the tokens of all the -aliases in \fIslave\fR. The tokens correspond to the values returned when +aliases in \fIchild\fR. The tokens correspond to the values returned when the aliases were created (which may not be the same as the current names of the commands). .TP -\fIslave \fBalias \fIsrcToken\fR +\fIchild \fBalias \fIsrcToken\fR . Returns a Tcl list whose elements are the \fItargetCmd\fR and \fIarg\fRs associated with the alias represented by \fIsrcToken\fR (this is the value returned when the alias was created; it is possible that the actual source command in the -slave is different from \fIsrcToken\fR). +child is different from \fIsrcToken\fR). .TP -\fIslave \fBalias \fIsrcToken \fB{}\fR +\fIchild \fBalias \fIsrcToken \fB{}\fR . -Deletes the alias for \fIsrcToken\fR in the slave interpreter. +Deletes the alias for \fIsrcToken\fR in the child interpreter. \fIsrcToken\fR refers to the value returned when the alias was created; if the source command has been renamed, the renamed command will be deleted. .TP -\fIslave \fBalias \fIsrcCmd targetCmd \fR?\fIarg ..\fR? +\fIchild \fBalias \fIsrcCmd targetCmd \fR?\fIarg ..\fR? . Creates an alias such that whenever \fIsrcCmd\fR is invoked -in \fIslave\fR, \fItargetCmd\fR is invoked in the master. +in \fIchild\fR, \fItargetCmd\fR is invoked in the parent. The \fIarg\fR arguments will be passed to \fItargetCmd\fR as additional arguments, prepended before any arguments passed in the invocation of \fIsrcCmd\fR. @@ -449,69 +449,69 @@ The command returns a token that uniquely identifies the command created \fIsrcCmd\fR, even if the command is renamed afterwards. The token may but does not have to be equal to \fIsrcCmd\fR. .TP -\fIslave \fBbgerror\fR ?\fIcmdPrefix\fR? +\fIchild \fBbgerror\fR ?\fIcmdPrefix\fR? . This command either gets or sets the current background exception handler -for the \fIslave\fR interpreter. If \fIcmdPrefix\fR is +for the \fIchild\fR interpreter. If \fIcmdPrefix\fR is absent, the current background exception handler is returned, and if it is present, it is a list of words (of minimum length one) that describes what to set the interpreter's background exception handler to. See the \fBBACKGROUND EXCEPTION HANDLING\fR section for more details. .TP -\fIslave \fBeval \fIarg \fR?\fIarg ..\fR? +\fIchild \fBeval \fIarg \fR?\fIarg ..\fR? . This command concatenates all of the \fIarg\fR arguments in the same fashion as the \fBconcat\fR command, then evaluates -the resulting string as a Tcl script in \fIslave\fR. +the resulting string as a Tcl script in \fIchild\fR. The result of this evaluation (including all \fBreturn\fR options, such as \fB\-errorinfo\fR and \fB\-errorcode\fR information, if an error occurs) is returned to the invoking interpreter. Note that the script will be executed in the current context stack frame -of \fIslave\fR; this is so that the implementations (in a master -interpreter) of aliases in a slave interpreter can execute scripts in -the slave that find out information about the slave's current state +of \fIchild\fR; this is so that the implementations (in a parent +interpreter) of aliases in a child interpreter can execute scripts in +the child that find out information about the child's current state and stack frame. .TP -\fIslave \fBexpose \fIhiddenName \fR?\fIexposedCmdName\fR? +\fIchild \fBexpose \fIhiddenName \fR?\fIexposedCmdName\fR? . This command exposes the hidden command \fIhiddenName\fR, eventually bringing it back under a new \fIexposedCmdName\fR name (this name is currently accepted only if it is a valid global name space name without any ::), -in \fIslave\fR. +in \fIchild\fR. If an exposed command with the targeted name already exists, this command fails. For more details on hidden commands, see \fBHIDDEN COMMANDS\fR, below. .TP -\fIslave \fBhide \fIexposedCmdName\fR ?\fIhiddenCmdName\fR? +\fIchild \fBhide \fIexposedCmdName\fR ?\fIhiddenCmdName\fR? . This command hides the exposed command \fIexposedCmdName\fR, renaming it to the hidden command \fIhiddenCmdName\fR, or keeping the same name if the -argument is not given, in the \fIslave\fR interpreter. +argument is not given, in the \fIchild\fR interpreter. If a hidden command with the targeted name already exists, this command fails. Currently both \fIexposedCmdName\fR and \fIhiddenCmdName\fR can not contain namespace qualifiers, or an error is raised. Commands to be hidden are looked up in the global namespace even if the current namespace is not the global one. This -prevents slaves from fooling a master interpreter into hiding the wrong +prevents children from fooling a parent interpreter into hiding the wrong command, by making the current namespace be different from the global one. For more details on hidden commands, see \fBHIDDEN COMMANDS\fR, below. .TP -\fIslave \fBhidden\fR +\fIchild \fBhidden\fR . -Returns a list of the names of all hidden commands in \fIslave\fR. +Returns a list of the names of all hidden commands in \fIchild\fR. .TP -\fIslave \fBinvokehidden\fR ?\fI\-option ...\fR? \fIhiddenName \fR?\fIarg ..\fR? +\fIchild \fBinvokehidden\fR ?\fI\-option ...\fR? \fIhiddenName \fR?\fIarg ..\fR? . This command invokes the hidden command \fIhiddenName\fR with the -supplied arguments, in \fIslave\fR. No substitutions or evaluations are +supplied arguments, in \fIchild\fR. No substitutions or evaluations are applied to the arguments. Three \fI\-option\fRs are supported, all of which start with \fB\-\fR: \fB\-namespace\fR (which takes a single argument afterwards, \fInsName\fR), \fB\-global\fR, and \fB\-\|\-\fR. If the \fB\-namespace\fR flag is given, the hidden command is invoked in -the specified namespace in the slave. +the specified namespace in the child. If the \fB\-global\fR flag is given, the command is invoked at the global -level in the slave; otherwise it is invoked at the current call frame and +level in the child; otherwise it is invoked at the current call frame and can access local variables in that or outer call frames. The \fB\-\|\-\fR flag allows the \fIhiddenCmdName\fR argument to start with a .QW \- @@ -519,37 +519,37 @@ character, and is otherwise unnecessary. If both the \fB\-namespace\fR and \fB\-global\fR flags are given, the \fB\-namespace\fR flag is ignored. Note that the hidden command will be executed (by default) in the -current context stack frame of \fIslave\fR. +current context stack frame of \fIchild\fR. For more details on hidden commands, see \fBHIDDEN COMMANDS\fR, below. .TP -\fIslave \fBissafe\fR +\fIchild \fBissafe\fR . -Returns \fB1\fR if the slave interpreter is safe, \fB0\fR otherwise. +Returns \fB1\fR if the child interpreter is safe, \fB0\fR otherwise. .TP -\fIslave \fBlimit\fR \fIlimitType\fR ?\fI\-option\fR? ?\fIvalue\fR \fI...\fR? +\fIchild \fBlimit\fR \fIlimitType\fR ?\fI\-option\fR? ?\fIvalue\fR \fI...\fR? . Sets up, manipulates and queries the configuration of the resource -limit \fIlimitType\fR for the slave interpreter. If no \fI\-option\fR +limit \fIlimitType\fR for the child interpreter. If no \fI\-option\fR is specified, return the current configuration of the limit. If \fI\-option\fR is the sole argument, return the value of that option. Otherwise, a list of \fI\-option\fR/\fIvalue\fR argument pairs must supplied. See \fBRESOURCE LIMITS\fR below for a more detailed explanation of what limits and options are supported. .TP -\fIslave \fBmarktrusted\fR +\fIchild \fBmarktrusted\fR . -Marks the slave interpreter as trusted. Can only be invoked by a +Marks the child interpreter as trusted. Can only be invoked by a trusted interpreter. This command does not expose any hidden -commands in the slave interpreter. The command has no effect if the slave +commands in the child interpreter. The command has no effect if the child is already trusted. .TP -\fIslave\fR \fBrecursionlimit\fR ?\fInewlimit\fR? +\fIchild\fR \fBrecursionlimit\fR ?\fInewlimit\fR? . -Returns the maximum allowable nesting depth for the \fIslave\fR interpreter. -If \fInewlimit\fR is specified, the recursion limit in \fIslave\fR will be +Returns the maximum allowable nesting depth for the \fIchild\fR interpreter. +If \fInewlimit\fR is specified, the recursion limit in \fIchild\fR will be set so that nesting of more than \fInewlimit\fR calls to \fBTcl_Eval()\fR -and related procedures in \fIslave\fR will return an error. +and related procedures in \fIchild\fR will return an error. The \fInewlimit\fR value is also returned. The \fInewlimit\fR value must be a positive integer between 1 and the maximum value of a non-long integer on the platform. @@ -573,14 +573,14 @@ For example, commands to create files on disk are removed, and the \fBexec\fR command is removed, since it could be used to cause damage through subprocesses. Limited access to these facilities can be provided, by creating -aliases to the master interpreter which check their arguments carefully +aliases to the parent interpreter which check their arguments carefully and provide restricted access to a safe subset of facilities. For example, file creation might be allowed in a particular subdirectory and subprocess invocation might be allowed for a carefully selected and fixed set of programs. .PP A safe interpreter is created by specifying the \fB\-safe\fR switch -to the \fBinterp create\fR command. Furthermore, any slave created +to the \fBinterp create\fR command. Furthermore, any child created by a safe interpreter will also be safe. .PP A safe interpreter is created with exactly the following set of @@ -668,14 +668,14 @@ including itself. .PP The alias mechanism has been carefully designed so that it can be used safely when an untrusted script is executing -in a safe slave and the target of the alias is a trusted -master. The most important thing in guaranteeing safety is to -ensure that information passed from the slave to the master is -never evaluated or substituted in the master; if this were to -occur, it would enable an evil script in the slave to invoke -arbitrary functions in the master, which would compromise security. -.PP -When the source for an alias is invoked in the slave interpreter, the +in a safe child and the target of the alias is a trusted +parent. The most important thing in guaranteeing safety is to +ensure that information passed from the child to the parent is +never evaluated or substituted in the parent; if this were to +occur, it would enable an evil script in the child to invoke +arbitrary functions in the parent, which would compromise security. +.PP +When the source for an alias is invoked in the child interpreter, the usual Tcl substitutions are performed when parsing that command. These substitutions are carried out in the source interpreter just as they would be for any other command invoked in that interpreter. @@ -702,8 +702,8 @@ the alias's source command is parsed in the source interpreter. When writing the \fItargetCmd\fRs for aliases in safe interpreters, it is very important that the arguments to that command never be evaluated or substituted, since this would provide an escape -mechanism whereby the slave interpreter could execute arbitrary -code in the master. This in turn would compromise the security +mechanism whereby the child interpreter could execute arbitrary +code in the parent. This in turn would compromise the security of the system. .SH "HIDDEN COMMANDS" .PP @@ -730,28 +730,28 @@ invoke\fR. Hidden commands and exposed commands reside in separate name spaces. It is possible to define a hidden command and an exposed command by the same name within one interpreter. .PP -Hidden commands in a slave interpreter can be invoked in the body of -procedures called in the master during alias invocation. For example, an -alias for \fBsource\fR could be created in a slave interpreter. When it is -invoked in the slave interpreter, a procedure is called in the master +Hidden commands in a child interpreter can be invoked in the body of +procedures called in the parent during alias invocation. For example, an +alias for \fBsource\fR could be created in a child interpreter. When it is +invoked in the child interpreter, a procedure is called in the parent interpreter to check that the operation is allowable (e.g. it asks to -source a file that the slave interpreter is allowed to access). The -procedure then it invokes the hidden \fBsource\fR command in the slave +source a file that the child interpreter is allowed to access). The +procedure then it invokes the hidden \fBsource\fR command in the child interpreter to actually source in the contents of the file. Note that two -commands named \fBsource\fR exist in the slave interpreter: the alias, and +commands named \fBsource\fR exist in the child interpreter: the alias, and the hidden command. .PP -Because a master interpreter may invoke a hidden command as part of +Because a parent interpreter may invoke a hidden command as part of handling an alias invocation, great care must be taken to avoid evaluating any arguments passed in through the alias invocation. -Otherwise, malicious slave interpreters could cause a trusted master +Otherwise, malicious child interpreters could cause a trusted parent interpreter to execute dangerous commands on their behalf. See the section on \fBALIAS INVOCATION\fR for a more complete discussion of this topic. To help avoid this problem, no substitutions or evaluations are applied to arguments of \fBinterp invokehidden\fR. .PP Safe interpreters are not allowed to invoke hidden commands in themselves -or in their descendants. This prevents safe slaves from gaining access to +or in their descendants. This prevents safe children from gaining access to hidden functionality in themselves or their descendants. .PP The set of hidden commands in an interpreter can be manipulated by a trusted @@ -770,12 +770,12 @@ qualifiers, and you must first rename a command in a namespace to the global namespace before you can hide it. Commands to be hidden by \fBinterp hide\fR are looked up in the global namespace even if the current namespace is not the global one. This -prevents slaves from fooling a master interpreter into hiding the wrong +prevents children from fooling a parent interpreter into hiding the wrong command, by making the current namespace be different from the global one. .SH "RESOURCE LIMITS" .PP Every interpreter has two kinds of resource limits that may be imposed by any -master interpreter upon its slaves. Command limits (of type \fBcommand\fR) +parent interpreter upon its children. Command limits (of type \fBcommand\fR) restrict the total number of Tcl commands that may be executed by an interpreter (as can be inspected via the \fBinfo cmdcount\fR command), and time limits (of type \fBtime\fR) place a limit by which execution within the @@ -784,7 +784,7 @@ interpreter must complete. Note that time limits are expressed as \fBafter\fR) because they may be modified after creation. .PP When a limit is exceeded for an interpreter, first any handler callbacks -defined by master interpreters are called. If those callbacks increase or +defined by parent interpreters are called. If those callbacks increase or remove the limit, execution within the (previously) limited interpreter continues. If the limit is still in force, an error is generated at that point and normal processing of errors within the interpreter (by the \fBcatch\fR @@ -841,13 +841,13 @@ This option specifies the number of commands that the interpreter may execute before triggering the command limit. This option may be the empty string, which indicates that a command limit is not set for the interpreter. .PP -Where an interpreter with a resource limit set on it creates a slave -interpreter, that slave interpreter will have resource limits imposed on it -that are at least as restrictive as the limits on the creating master -interpreter. If the master interpreter of the limited master wishes to relax +Where an interpreter with a resource limit set on it creates a child +interpreter, that child interpreter will have resource limits imposed on it +that are at least as restrictive as the limits on the creating parent +interpreter. If the parent interpreter of the limited parent wishes to relax these conditions, it should hide the \fBinterp\fR command in the child and then use aliases and the \fBinterp invokehidden\fR subcommand to provide such -access as it chooses to the \fBinterp\fR command to the limited master as +access as it chooses to the \fBinterp\fR command to the limited parent as necessary. .SH "BACKGROUND EXCEPTION HANDLING" .PP @@ -908,9 +908,9 @@ set i [\fBinterp create\fR] } .CE .SH "SEE ALSO" -bgerror(n), load(n), safe(n), Tcl_CreateSlave(3), Tcl_Eval(3), Tcl_BackgroundException(3) +bgerror(n), load(n), safe(n), Tcl_CreateChild(3), Tcl_Eval(3), Tcl_BackgroundException(3) .SH KEYWORDS -alias, master interpreter, safe interpreter, slave interpreter +alias, parent interpreter, safe interpreter, child interpreter '\"Local Variables: '\"mode: nroff '\"End: diff --git a/doc/library.n b/doc/library.n index 6f8f265..87f13bd 100644 --- a/doc/library.n +++ b/doc/library.n @@ -124,7 +124,7 @@ will read all the \fB.tcl\fR files in subdirectory \fBfoo\fR and generate a new index file \fBfoo/tclIndex\fR. .PP \fBAuto_mkindex\fR parses the Tcl scripts by sourcing them into a -slave interpreter and monitoring the proc and namespace commands that +child interpreter and monitoring the proc and namespace commands that are executed. Extensions can use the (undocumented) auto_mkindex_parser package to register other commands that can contribute to the auto_load index. You will have to read through diff --git a/doc/pkgMkIndex.n b/doc/pkgMkIndex.n index ec39be9..5a6b905 100644 --- a/doc/pkgMkIndex.n +++ b/doc/pkgMkIndex.n @@ -42,7 +42,7 @@ The default pattern is \fB*.tcl\fR and \fB*.[info sharedlibextension]\fR. \fBPkg_mkIndex\fR will create a file \fBpkgIndex.tcl\fR in \fIdir\fR with package information about all the files given by the \fIpattern\fR arguments. -It does this by loading each file into a slave +It does this by loading each file into a child interpreter and seeing what packages and new commands appear (this is why it is essential to have \fBpackage provide\fR commands or \fBTcl_PkgProvide\fR calls @@ -109,7 +109,7 @@ the use of \fIauto_reset\fR, and therefore its use is discouraged. .TP 15 \fB\-load \fIpkgPat\fR The index process will pre-load any packages that exist in the -current interpreter and match \fIpkgPat\fR into the slave interpreter used to +current interpreter and match \fIpkgPat\fR into the child interpreter used to generate the index. The pattern match uses string match rules, but without making case distinctions. See \fBCOMPLEX CASES\fR below. diff --git a/doc/safe.n b/doc/safe.n index 7ddb182..819287d 100644 --- a/doc/safe.n +++ b/doc/safe.n @@ -11,17 +11,17 @@ .SH NAME safe \- Creating and manipulating safe interpreters .SH SYNOPSIS -\fB::safe::interpCreate\fR ?\fIslave\fR? ?\fIoptions...\fR? +\fB::safe::interpCreate\fR ?\fIchild\fR? ?\fIoptions...\fR? .sp -\fB::safe::interpInit\fR \fIslave\fR ?\fIoptions...\fR? +\fB::safe::interpInit\fR \fIchild\fR ?\fIoptions...\fR? .sp -\fB::safe::interpConfigure\fR \fIslave\fR ?\fIoptions...\fR? +\fB::safe::interpConfigure\fR \fIchild\fR ?\fIoptions...\fR? .sp -\fB::safe::interpDelete\fR \fIslave\fR +\fB::safe::interpDelete\fR \fIchild\fR .sp -\fB::safe::interpAddToAccessPath\fR \fIslave\fR \fIdirectory\fR +\fB::safe::interpAddToAccessPath\fR \fIchild\fR \fIdirectory\fR .sp -\fB::safe::interpFindInAccessPath\fR \fIslave\fR \fIdirectory\fR +\fB::safe::interpFindInAccessPath\fR \fIchild\fR \fIdirectory\fR .sp \fB::safe::setLogCmd\fR ?\fIcmd arg...\fR? .SS OPTIONS @@ -44,7 +44,7 @@ application or computer. Untrusted scripts are also prevented from disclosing information stored on the hosting computer or in the hosting application to any party. .PP -Safe Tcl allows a master interpreter to create safe, restricted +Safe Tcl allows a parent interpreter to create safe, restricted interpreters that contain a set of predefined aliases for the \fBsource\fR, \fBload\fR, \fBfile\fR, \fBencoding\fR, and \fBexit\fR commands and are able to use the auto-loading and package mechanisms. @@ -53,47 +53,47 @@ No knowledge of the file system structure is leaked to the safe interpreter, because it has access only to a virtualized path containing tokens. When the safe interpreter requests to source a file, it uses the token in the virtual path as part of the file name to source; the -master interpreter transparently +parent interpreter transparently translates the token into a real directory name and executes the requested operation (see the section \fBSECURITY\fR below for details). Different levels of security can be selected by using the optional flags of the commands described below. .PP -All commands provided in the master interpreter by Safe Tcl reside in +All commands provided in the parent interpreter by Safe Tcl reside in the \fBsafe\fR namespace. .SH COMMANDS -The following commands are provided in the master interpreter: +The following commands are provided in the parent interpreter: .TP -\fB::safe::interpCreate\fR ?\fIslave\fR? ?\fIoptions...\fR? +\fB::safe::interpCreate\fR ?\fIchild\fR? ?\fIoptions...\fR? Creates a safe interpreter, installs the aliases described in the section \fBALIASES\fR and initializes the auto-loading and package mechanism as specified by the supplied \fIoptions\fR. See the \fBOPTIONS\fR section below for a description of the optional arguments. -If the \fIslave\fR argument is omitted, a name will be generated. +If the \fIchild\fR argument is omitted, a name will be generated. \fB::safe::interpCreate\fR always returns the interpreter name. .sp -The interpreter name \fIslave\fR may include namespace separators, +The interpreter name \fIchild\fR may include namespace separators, but may not have leading or trailing namespace separators, or excess colon characters in namespace separators. The interpreter name is qualified relative to the global namespace ::, not the namespace in which the \fB::safe::interpCreate\fR command is evaluated. .TP -\fB::safe::interpInit\fR \fIslave\fR ?\fIoptions...\fR? +\fB::safe::interpInit\fR \fIchild\fR ?\fIoptions...\fR? This command is similar to \fBinterpCreate\fR except it that does not -create the safe interpreter. \fIslave\fR must have been created by some +create the safe interpreter. \fIchild\fR must have been created by some other means, like \fBinterp create\fR \fB\-safe\fR. The interpreter -name \fIslave\fR may include namespace separators, subject to the same +name \fIchild\fR may include namespace separators, subject to the same restrictions as for \fBinterpCreate\fR. .TP -\fB::safe::interpConfigure\fR \fIslave\fR ?\fIoptions...\fR? +\fB::safe::interpConfigure\fR \fIchild\fR ?\fIoptions...\fR? If no \fIoptions\fR are given, returns the settings for all options for the named safe interpreter as a list of options and their current values -for that \fIslave\fR. +for that \fIchild\fR. If a single additional argument is provided, it will return a list of 2 elements \fIname\fR and \fIvalue\fR where \fIname\fR is the full name of that option and \fIvalue\fR the current value -for that option and the \fIslave\fR. +for that option and the \fIchild\fR. If more than two additional arguments are provided, it will reconfigure the safe interpreter and change each and only the provided options. See the section on \fBOPTIONS\fR below for options description. @@ -113,14 +113,14 @@ safe::interpConfigure $i0 \-delete {foo bar} \-statics 0 .CE .RE .TP -\fB::safe::interpDelete\fR \fIslave\fR +\fB::safe::interpDelete\fR \fIchild\fR Deletes the safe interpreter and cleans up the corresponding -master interpreter data structures. +parent interpreter data structures. If a \fIdeleteHook\fR script was specified for this interpreter it is evaluated before the interpreter is deleted, with the name of the interpreter as an additional argument. .TP -\fB::safe::interpFindInAccessPath\fR \fIslave\fR \fIdirectory\fR +\fB::safe::interpFindInAccessPath\fR \fIchild\fR \fIdirectory\fR This command finds and returns the token for the real directory \fIdirectory\fR in the safe interpreter's current virtual access path. It generates an error if the directory is not found. @@ -128,14 +128,14 @@ Example of use: .RS .PP .CS -$slave eval [list set tk_library \e +$child eval [list set tk_library \e [::safe::interpFindInAccessPath $name $tk_library]] .CE .RE .TP -\fB::safe::interpAddToAccessPath\fR \fIslave\fR \fIdirectory\fR +\fB::safe::interpAddToAccessPath\fR \fIchild\fR \fIdirectory\fR This command adds \fIdirectory\fR to the virtual path maintained for the -safe interpreter in the master, and returns the token that can be used in +safe interpreter in the parent, and returns the token that can be used in the safe interpreter to obtain access to files in that directory. If the directory is already in the virtual path, it only returns the token without adding the directory to the virtual path again. @@ -143,7 +143,7 @@ Example of use: .RS .PP .CS -$slave eval [list set tk_library \e +$child eval [list set tk_library \e [::safe::interpAddToAccessPath $name $tk_library]] .CE .RE @@ -176,10 +176,10 @@ Note that the safe interpreter only received an error message saying that the file was not found: .PP .CS -NOTICE for slave interp10 : Created -NOTICE for slave interp10 : Setting accessPath=(/foo/bar) staticsok=1 nestedok=0 deletehook=() -NOTICE for slave interp10 : auto_path in interp10 has been set to {$p(:0:)} -ERROR for slave interp10 : /foo/bar/init.tcl: no such file or directory +NOTICE for child interp10 : Created +NOTICE for child interp10 : Setting accessPath=(/foo/bar) staticsok=1 nestedok=0 deletehook=() +NOTICE for child interp10 : auto_path in interp10 has been set to {$p(:0:)} +ERROR for child interp10 : /foo/bar/init.tcl: no such file or directory .CE .RE .SS OPTIONS @@ -195,7 +195,7 @@ This option sets the list of directories from which the safe interpreter can \fBsource\fR and \fBload\fR files. If this option is not specified, or if it is given as the empty list, the safe interpreter will use the same directories as its -master for auto-loading. +parent for auto-loading. See the section \fBSECURITY\fR below for more detail about virtual paths, tokens and access control. .TP @@ -224,7 +224,7 @@ to load packages into its own sub-interpreters. .TP \fB\-deleteHook\fR \fIscript\fR When this option is given a non-empty \fIscript\fR, it will be -evaluated in the master with the name of +evaluated in the parent with the name of the safe interpreter as an additional argument just before actually deleting the safe interpreter. Giving an empty value removes any currently installed deletion hook @@ -289,8 +289,8 @@ potential for information leakage about its directory structure. To prevent this, commands that take file names as arguments in a safe interpreter use tokens instead of the real directory names. These tokens are translated to the real directory name while a request to, -e.g., source a file is mediated by the master interpreter. -This virtual path system is maintained in the master interpreter for each safe +e.g., source a file is mediated by the parent interpreter. +This virtual path system is maintained in the parent interpreter for each safe interpreter created by \fB::safe::interpCreate\fR or initialized by \fB::safe::interpInit\fR and the path maps tokens accessible in the safe interpreter into real path @@ -299,7 +299,7 @@ from gaining knowledge about the structure of the file system of the host on which the interpreter is executing. The only valid file names arguments -for the \fBsource\fR and \fBload\fR aliases provided to the slave +for the \fBsource\fR and \fBload\fR aliases provided to the child are path in the form of \fB[file join \fItoken filename\fB]\fR (i.e. when using the native file path formats: \fItoken\fB/\fIfilename\fR @@ -328,26 +328,26 @@ or be called .PP Each element of the initial access path list will be assigned a token that will be set in -the slave \fBauto_path\fR and the first element of that list will be set as -the \fBtcl_library\fR for that slave. +the child \fBauto_path\fR and the first element of that list will be set as +the \fBtcl_library\fR for that child. .PP If the access path argument is not given or is the empty list, -the default behavior is to let the slave access the same packages -as the master has access to (Or to be more precise: +the default behavior is to let the child access the same packages +as the parent has access to (Or to be more precise: only packages written in Tcl (which by definition cannot be dangerous -as they run in the slave interpreter) and C extensions that -provides a _SafeInit entry point). For that purpose, the master's -\fBauto_path\fR will be used to construct the slave access path. -In order that the slave successfully loads the Tcl library files +as they run in the child interpreter) and C extensions that +provides a _SafeInit entry point). For that purpose, the parent's +\fBauto_path\fR will be used to construct the child access path. +In order that the child successfully loads the Tcl library files (which includes the auto-loading mechanism itself) the \fBtcl_library\fR will be added or moved to the first position if necessary, in the -slave access path, so the slave -\fBtcl_library\fR will be the same as the master's (its real -path will still be invisible to the slave though). -In order that auto-loading works the same for the slave and -the master in this by default case, the first-level -sub directories of each directory in the master \fBauto_path\fR will -also be added (if not already included) to the slave access path. +child access path, so the child +\fBtcl_library\fR will be the same as the parent's (its real +path will still be invisible to the child though). +In order that auto-loading works the same for the child and +the parent in this by default case, the first-level +sub directories of each directory in the parent \fBauto_path\fR will +also be added (if not already included) to the child access path. You can always specify a more restrictive path for which sub directories will never be searched by explicitly specifying your directory list with the \fB\-accessPath\fR flag @@ -360,8 +360,8 @@ to synchronize its \fBauto_index\fR with the new token list. .SH "SEE ALSO" interp(n), library(n), load(n), package(n), source(n), unknown(n) .SH KEYWORDS -alias, auto\-loading, auto_mkindex, load, master interpreter, safe -interpreter, slave interpreter, source +alias, auto\-loading, auto_mkindex, load, parent interpreter, safe +interpreter, child interpreter, source '\" Local Variables: '\" mode: nroff '\" End: diff --git a/generic/tcl.decls b/generic/tcl.decls index 6f35631..23e8f6a 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -316,12 +316,12 @@ declare 85 { int flags) } declare 86 { - int Tcl_CreateAlias(Tcl_Interp *slave, const char *slaveCmd, + int Tcl_CreateAlias(Tcl_Interp *childInterp, const char *childCmd, Tcl_Interp *target, const char *targetCmd, int argc, CONST84 char *const *argv) } declare 87 { - int Tcl_CreateAliasObj(Tcl_Interp *slave, const char *slaveCmd, + int Tcl_CreateAliasObj(Tcl_Interp *childInterp, const char *childCmd, Tcl_Interp *target, const char *targetCmd, int objc, Tcl_Obj *const objv[]) } @@ -364,7 +364,7 @@ declare 96 { Tcl_CmdDeleteProc *deleteProc) } declare 97 { - Tcl_Interp *Tcl_CreateSlave(Tcl_Interp *interp, const char *slaveName, + Tcl_Interp *Tcl_CreateSlave(Tcl_Interp *interp, const char *name, int isSafe) } declare 98 { @@ -527,12 +527,12 @@ declare 147 { void Tcl_FreeResult(Tcl_Interp *interp) } declare 148 { - int Tcl_GetAlias(Tcl_Interp *interp, const char *slaveCmd, + int Tcl_GetAlias(Tcl_Interp *interp, const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *argcPtr, CONST84 char ***argvPtr) } declare 149 { - int Tcl_GetAliasObj(Tcl_Interp *interp, const char *slaveCmd, + int Tcl_GetAliasObj(Tcl_Interp *interp, const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv) } @@ -582,7 +582,7 @@ declare 162 { CONST84_RETURN char *Tcl_GetHostName(void) } declare 163 { - int Tcl_GetInterpPath(Tcl_Interp *interp, Tcl_Interp *slaveInterp) + int Tcl_GetInterpPath(Tcl_Interp *interp, Tcl_Interp *childInterp) } declare 164 { Tcl_Interp *Tcl_GetMaster(Tcl_Interp *interp) @@ -616,7 +616,7 @@ declare 171 { int Tcl_GetServiceMode(void) } declare 172 { - Tcl_Interp *Tcl_GetSlave(Tcl_Interp *interp, const char *slaveName) + Tcl_Interp *Tcl_GetSlave(Tcl_Interp *interp, const char *name) } declare 173 { Tcl_Channel Tcl_GetStdChannel(int type) diff --git a/generic/tclDecls.h b/generic/tclDecls.h index e0854d6..0f18dd4 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -279,13 +279,13 @@ EXTERN int Tcl_ConvertElement(const char *src, char *dst, EXTERN int Tcl_ConvertCountedElement(const char *src, int length, char *dst, int flags); /* 86 */ -EXTERN int Tcl_CreateAlias(Tcl_Interp *slave, - const char *slaveCmd, Tcl_Interp *target, +EXTERN int Tcl_CreateAlias(Tcl_Interp *childInterp, + const char *childCmd, Tcl_Interp *target, const char *targetCmd, int argc, CONST84 char *const *argv); /* 87 */ -EXTERN int Tcl_CreateAliasObj(Tcl_Interp *slave, - const char *slaveCmd, Tcl_Interp *target, +EXTERN int Tcl_CreateAliasObj(Tcl_Interp *childInterp, + const char *childCmd, Tcl_Interp *target, const char *targetCmd, int objc, Tcl_Obj *const objv[]); /* 88 */ @@ -323,8 +323,8 @@ EXTERN Tcl_Command Tcl_CreateObjCommand(Tcl_Interp *interp, ClientData clientData, Tcl_CmdDeleteProc *deleteProc); /* 97 */ -EXTERN Tcl_Interp * Tcl_CreateSlave(Tcl_Interp *interp, - const char *slaveName, int isSafe); +EXTERN Tcl_Interp * Tcl_CreateSlave(Tcl_Interp *interp, const char *name, + int isSafe); /* 98 */ EXTERN Tcl_TimerToken Tcl_CreateTimerHandler(int milliseconds, Tcl_TimerProc *proc, ClientData clientData); @@ -458,13 +458,13 @@ EXTERN int Tcl_Flush(Tcl_Channel chan); EXTERN void Tcl_FreeResult(Tcl_Interp *interp); /* 148 */ EXTERN int Tcl_GetAlias(Tcl_Interp *interp, - const char *slaveCmd, + const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *argcPtr, CONST84 char ***argvPtr); /* 149 */ EXTERN int Tcl_GetAliasObj(Tcl_Interp *interp, - const char *slaveCmd, + const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv); @@ -504,7 +504,7 @@ EXTERN int Tcl_GetErrno(void); EXTERN CONST84_RETURN char * Tcl_GetHostName(void); /* 163 */ EXTERN int Tcl_GetInterpPath(Tcl_Interp *interp, - Tcl_Interp *slaveInterp); + Tcl_Interp *childInterp); /* 164 */ EXTERN Tcl_Interp * Tcl_GetMaster(Tcl_Interp *interp); /* 165 */ @@ -532,8 +532,7 @@ EXTERN int Tcl_GetsObj(Tcl_Channel chan, Tcl_Obj *objPtr); /* 171 */ EXTERN int Tcl_GetServiceMode(void); /* 172 */ -EXTERN Tcl_Interp * Tcl_GetSlave(Tcl_Interp *interp, - const char *slaveName); +EXTERN Tcl_Interp * Tcl_GetSlave(Tcl_Interp *interp, const char *name); /* 173 */ EXTERN Tcl_Channel Tcl_GetStdChannel(int type); /* 174 */ @@ -1949,8 +1948,8 @@ typedef struct TclStubs { char * (*tcl_Concat) (int argc, CONST84 char *const *argv); /* 83 */ int (*tcl_ConvertElement) (const char *src, char *dst, int flags); /* 84 */ int (*tcl_ConvertCountedElement) (const char *src, int length, char *dst, int flags); /* 85 */ - int (*tcl_CreateAlias) (Tcl_Interp *slave, const char *slaveCmd, Tcl_Interp *target, const char *targetCmd, int argc, CONST84 char *const *argv); /* 86 */ - int (*tcl_CreateAliasObj) (Tcl_Interp *slave, const char *slaveCmd, Tcl_Interp *target, const char *targetCmd, int objc, Tcl_Obj *const objv[]); /* 87 */ + int (*tcl_CreateAlias) (Tcl_Interp *childInterp, const char *childCmd, Tcl_Interp *target, const char *targetCmd, int argc, CONST84 char *const *argv); /* 86 */ + int (*tcl_CreateAliasObj) (Tcl_Interp *childInterp, const char *childCmd, Tcl_Interp *target, const char *targetCmd, int objc, Tcl_Obj *const objv[]); /* 87 */ Tcl_Channel (*tcl_CreateChannel) (const Tcl_ChannelType *typePtr, const char *chanName, ClientData instanceData, int mask); /* 88 */ void (*tcl_CreateChannelHandler) (Tcl_Channel chan, int mask, Tcl_ChannelProc *proc, ClientData clientData); /* 89 */ void (*tcl_CreateCloseHandler) (Tcl_Channel chan, Tcl_CloseProc *proc, ClientData clientData); /* 90 */ @@ -1960,7 +1959,7 @@ typedef struct TclStubs { Tcl_Interp * (*tcl_CreateInterp) (void); /* 94 */ void (*tcl_CreateMathFunc) (Tcl_Interp *interp, const char *name, int numArgs, Tcl_ValueType *argTypes, Tcl_MathProc *proc, ClientData clientData); /* 95 */ Tcl_Command (*tcl_CreateObjCommand) (Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc *proc, ClientData clientData, Tcl_CmdDeleteProc *deleteProc); /* 96 */ - Tcl_Interp * (*tcl_CreateSlave) (Tcl_Interp *interp, const char *slaveName, int isSafe); /* 97 */ + Tcl_Interp * (*tcl_CreateSlave) (Tcl_Interp *interp, const char *name, int isSafe); /* 97 */ Tcl_TimerToken (*tcl_CreateTimerHandler) (int milliseconds, Tcl_TimerProc *proc, ClientData clientData); /* 98 */ Tcl_Trace (*tcl_CreateTrace) (Tcl_Interp *interp, int level, Tcl_CmdTraceProc *proc, ClientData clientData); /* 99 */ void (*tcl_DeleteAssocData) (Tcl_Interp *interp, const char *name); /* 100 */ @@ -2011,8 +2010,8 @@ typedef struct TclStubs { Tcl_HashEntry * (*tcl_FirstHashEntry) (Tcl_HashTable *tablePtr, Tcl_HashSearch *searchPtr); /* 145 */ int (*tcl_Flush) (Tcl_Channel chan); /* 146 */ void (*tcl_FreeResult) (Tcl_Interp *interp); /* 147 */ - int (*tcl_GetAlias) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *argcPtr, CONST84 char ***argvPtr); /* 148 */ - int (*tcl_GetAliasObj) (Tcl_Interp *interp, const char *slaveCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv); /* 149 */ + int (*tcl_GetAlias) (Tcl_Interp *interp, const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *argcPtr, CONST84 char ***argvPtr); /* 148 */ + int (*tcl_GetAliasObj) (Tcl_Interp *interp, const char *childCmd, Tcl_Interp **targetInterpPtr, CONST84 char **targetCmdPtr, int *objcPtr, Tcl_Obj ***objv); /* 149 */ ClientData (*tcl_GetAssocData) (Tcl_Interp *interp, const char *name, Tcl_InterpDeleteProc **procPtr); /* 150 */ Tcl_Channel (*tcl_GetChannel) (Tcl_Interp *interp, const char *chanName, int *modePtr); /* 151 */ int (*tcl_GetChannelBufferSize) (Tcl_Channel chan); /* 152 */ @@ -2026,7 +2025,7 @@ typedef struct TclStubs { CONST84_RETURN char * (*tcl_GetCommandName) (Tcl_Interp *interp, Tcl_Command command); /* 160 */ int (*tcl_GetErrno) (void); /* 161 */ CONST84_RETURN char * (*tcl_GetHostName) (void); /* 162 */ - int (*tcl_GetInterpPath) (Tcl_Interp *interp, Tcl_Interp *slaveInterp); /* 163 */ + int (*tcl_GetInterpPath) (Tcl_Interp *interp, Tcl_Interp *childInterp); /* 163 */ Tcl_Interp * (*tcl_GetMaster) (Tcl_Interp *interp); /* 164 */ const char * (*tcl_GetNameOfExecutable) (void); /* 165 */ Tcl_Obj * (*tcl_GetObjResult) (Tcl_Interp *interp); /* 166 */ @@ -2043,7 +2042,7 @@ typedef struct TclStubs { int (*tcl_Gets) (Tcl_Channel chan, Tcl_DString *dsPtr); /* 169 */ int (*tcl_GetsObj) (Tcl_Channel chan, Tcl_Obj *objPtr); /* 170 */ int (*tcl_GetServiceMode) (void); /* 171 */ - Tcl_Interp * (*tcl_GetSlave) (Tcl_Interp *interp, const char *slaveName); /* 172 */ + Tcl_Interp * (*tcl_GetSlave) (Tcl_Interp *interp, const char *name); /* 172 */ Tcl_Channel (*tcl_GetStdChannel) (int type); /* 173 */ CONST84_RETURN char * (*tcl_GetStringResult) (Tcl_Interp *interp); /* 174 */ CONST84_RETURN char * (*tcl_GetVar) (Tcl_Interp *interp, const char *varName, int flags); /* 175 */ diff --git a/generic/tclEvent.c b/generic/tclEvent.c index e56c21b..ae40850 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1043,7 +1043,7 @@ TclInitSubsystems(void) * implementation of self-initializing locks. */ - TclInitThreadStorage(); /* Creates master hash table for + TclInitThreadStorage(); /* Creates hash table for * thread local storage */ #if USE_TCLALLOC TclInitAlloc(); /* Process wide mutex init */ @@ -1157,7 +1157,7 @@ Tcl_Finalize(void) TclFinalizeFilesystem(); /* - * Undo all Tcl_ObjType registrations, and reset the master list of free + * Undo all Tcl_ObjType registrations, and reset the global list of free * Tcl_Obj's. After this returns, no more Tcl_Obj's should be allocated or * freed. * diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index e67da14..6e1cb1f 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -4619,7 +4619,7 @@ Tcl_FSGetFileSystemForPath( /* * Check if the filesystem has changed in some way since this object's * internal representation was calculated. Before doing that, assure we - * have the most up-to-date copy of the master filesystem. This is + * have the most up-to-date copy of the first filesystem. This is * accomplished by the FsGetFirstFilesystem() call. */ diff --git a/tests/winDde.test b/tests/winDde.test index acba304..6ba2ba1 100644 --- a/tests/winDde.test +++ b/tests/winDde.test @@ -279,19 +279,19 @@ test winDde-6.6 {DDE remote servername collision force} -constraints {dde stdio} # ------------------------------------------------------------------------- -test winDde-7.1 {Load DDE in slave interpreter} -constraints dde -setup { - interp create slave +test winDde-7.1 {Load DDE in child interpreter} -constraints dde -setup { + interp create child } -body { - slave eval [list load $::ddelib Dde] - slave eval [list dde servername -- dde-interp-7.1] + child eval [list load $::ddelib Dde] + child eval [list dde servername -- dde-interp-7.1] } -cleanup { - interp delete slave + interp delete child } -result {dde-interp-7.1} -test winDde-7.2 {DDE slave cleanup} -constraints dde -setup { - interp create slave - slave eval [list load $::ddelib Dde] - slave eval [list dde servername -- dde-interp-7.5] - interp delete slave +test winDde-7.2 {DDE child cleanup} -constraints dde -setup { + interp create child + child eval [list load $::ddelib Dde] + child eval [list dde servername -- dde-interp-7.5] + interp delete child } -body { dde services TclEval {} set s [dde services TclEval {}] @@ -300,128 +300,128 @@ test winDde-7.2 {DDE slave cleanup} -constraints dde -setup { set s } } -result {} -test winDde-7.3 {DDE present in slave interp} -constraints dde -setup { - interp create slave - slave eval [list load $::ddelib Dde] - slave eval [list dde servername -- dde-interp-7.3] +test winDde-7.3 {DDE present in child interp} -constraints dde -setup { + interp create child + child eval [list load $::ddelib Dde] + child eval [list dde servername -- dde-interp-7.3] } -body { dde services TclEval dde-interp-7.3 } -cleanup { - interp delete slave + interp delete child } -result {{TclEval dde-interp-7.3}} test winDde-7.4 {interp name collision with -force} -constraints dde -setup { - interp create slave - slave eval [list load $::ddelib Dde] - slave eval [list dde servername -- dde-interp-7.4] + interp create child + child eval [list load $::ddelib Dde] + child eval [list dde servername -- dde-interp-7.4] } -body { dde servername -force -- dde-interp-7.4 } -cleanup { - interp delete slave + interp delete child } -result {dde-interp-7.4} test winDde-7.5 {interp name collision without -force} -constraints dde -setup { - interp create slave - slave eval [list load $::ddelib Dde] - slave eval [list dde servername -- dde-interp-7.5] + interp create child + child eval [list load $::ddelib Dde] + child eval [list dde servername -- dde-interp-7.5] } -body { dde servername -- dde-interp-7.5 } -cleanup { - interp delete slave + interp delete child } -result "dde-interp-7.5 #2" # ------------------------------------------------------------------------- test winDde-8.1 {Safe DDE load} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde + interp create -safe child + child invokehidden load $::ddelib Dde } -body { - slave eval dde servername slave + child eval dde servername child } -cleanup { - interp delete slave + interp delete child } -returnCodes error -result {invalid command name "dde"} test winDde-8.2 {Safe DDE set servername} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde + interp create -safe child + child invokehidden load $::ddelib Dde } -body { - slave invokehidden dde servername slave -} -cleanup {interp delete slave} -result {slave} + child invokehidden dde servername child +} -cleanup {interp delete child} -result {child} test winDde-8.3 {Safe DDE check handler required for eval} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave invokehidden dde servername slave + interp create -safe child + child invokehidden load $::ddelib Dde + child invokehidden dde servername child } -body { - catch {dde eval slave set a 1} msg -} -cleanup {interp delete slave} -result {1} + catch {dde eval child set a 1} msg +} -cleanup {interp delete child} -result {1} test winDde-8.4 {Safe DDE check that execute is denied} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave invokehidden dde servername slave + interp create -safe child + child invokehidden load $::ddelib Dde + child invokehidden dde servername child } -body { - slave eval set a 1 - dde execute TclEval slave {set a 2} - slave eval set a -} -cleanup {interp delete slave} -result 1 + child eval set a 1 + dde execute TclEval child {set a 2} + child eval set a +} -cleanup {interp delete child} -result 1 test winDde-8.5 {Safe DDE check that request is denied} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave invokehidden dde servername slave + interp create -safe child + child invokehidden load $::ddelib Dde + child invokehidden dde servername child } -body { - slave eval set a 1 - dde request TclEval slave a + child eval set a 1 + dde request TclEval child a } -cleanup { - interp delete slave + interp delete child } -returnCodes error -result {remote server cannot handle this command} test winDde-8.6 {Safe DDE assign handler procedure} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} } -body { - slave invokehidden dde servername -handler DDEACCEPT slave -} -cleanup {interp delete slave} -result slave + child invokehidden dde servername -handler DDEACCEPT child +} -cleanup {interp delete child} -result child test winDde-8.7 {Safe DDE check simple command} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} - slave invokehidden dde servername -handler DDEACCEPT slave + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} + child invokehidden dde servername -handler DDEACCEPT child } -body { - dde eval slave set x 1 -} -cleanup {interp delete slave} -result {set x 1} + dde eval child set x 1 +} -cleanup {interp delete child} -result {set x 1} test winDde-8.8 {Safe DDE check non-list command} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} - slave invokehidden dde servername -handler DDEACCEPT slave + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD $cmd}} + child invokehidden dde servername -handler DDEACCEPT child } -body { set s "c:\\Program Files\\Microsoft Visual Studio\\" - dde eval slave $s - string equal [slave eval set DDECMD] $s -} -cleanup {interp delete slave} -result 1 + dde eval child $s + string equal [child eval set DDECMD] $s +} -cleanup {interp delete child} -result 1 test winDde-8.9 {Safe DDE check command evaluation} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} - slave invokehidden dde servername -handler DDEACCEPT slave + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} + child invokehidden dde servername -handler DDEACCEPT child } -body { - dde eval slave set \xe1 1 - slave eval set \xe1 -} -cleanup {interp delete slave} -result 1 + dde eval child set \xe1 1 + child eval set \xe1 +} -cleanup {interp delete child} -result 1 test winDde-8.10 {Safe DDE check command evaluation (2)} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} - slave invokehidden dde servername -handler DDEACCEPT slave + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} + child invokehidden dde servername -handler DDEACCEPT child } -body { - dde eval slave [list set x 1] - slave eval set x -} -cleanup {interp delete slave} -result 1 + dde eval child [list set x 1] + child eval set x +} -cleanup {interp delete child} -result 1 test winDde-8.11 {Safe DDE check command evaluation (3)} -constraints dde -setup { - interp create -safe slave - slave invokehidden load $::ddelib Dde - slave eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} - slave invokehidden dde servername -handler DDEACCEPT slave + interp create -safe child + child invokehidden load $::ddelib Dde + child eval {proc DDEACCEPT {cmd} {set ::DDECMD [uplevel \#0 $cmd]}} + child invokehidden dde servername -handler DDEACCEPT child } -body { - dde eval slave [list [list set x 1]] - slave eval set x -} -cleanup {interp delete slave} -returnCodes error -result {invalid command name "set x 1"} + dde eval child [list [list set x 1]] + child eval set x +} -cleanup {interp delete child} -returnCodes error -result {invalid command name "set x 1"} # ------------------------------------------------------------------------- @@ -481,7 +481,7 @@ test winDde-9.4 {External safe DDE check null data passing} -constraints {dde st # ------------------------------------------------------------------------- #cleanup -#catch {interp delete $slave}; # ensure we clean up the slave. +#catch {interp delete $child}; # ensure we clean up the child. file delete -force $::scriptName ::tcltest::cleanupTests return -- cgit v0.12 From f2963d15d036e305300773f74a602c9c0a8c9229 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Sep 2020 15:48:08 +0000 Subject: Let all test-cases load the "tcltest" package the same way. Depend on tcltest 2.5, since we never test with earlier tcltest versions --- doc/Tcl_Main.3 | 12 ++++++------ doc/tcltest.n | 22 +++++++++++----------- macosx/Tcl.xcode/project.pbxproj | 2 +- macosx/Tcl.xcodeproj/project.pbxproj | 2 +- pkgs/README | 2 +- tests/aaa_exit.test | 4 ++-- tests/append.test | 4 ++-- tests/appendComp.test | 4 ++-- tests/apply.test | 4 ++-- tests/assemble.test | 2 +- tests/assocd.test | 2 +- tests/async.test | 4 ++-- tests/autoMkindex.test | 2 +- tests/basic.test | 6 ++++-- tests/binary.test | 4 ++-- tests/case.test | 4 ++-- tests/chan.test | 4 ++-- tests/chanio.test | 5 ++--- tests/clock.test | 4 ++-- tests/cmdIL.test | 4 ++-- tests/cmdInfo.test | 6 ++++-- tests/compExpr-old.test | 4 ++-- tests/compExpr.test | 2 +- tests/compile.test | 6 ++++-- tests/concat.test | 2 +- tests/config.test | 4 ++-- tests/coroutine.test | 4 ++-- tests/dcall.test | 6 ++++-- tests/dict.test | 4 ++-- tests/dstring.test | 2 +- tests/encoding.test | 7 ++++--- tests/env.test | 4 ++-- tests/error.test | 4 ++-- tests/eval.test | 2 +- tests/event.test | 6 ++++-- tests/exec.test | 6 ++++-- tests/execute.test | 6 +++--- tests/expr.test | 4 ++-- tests/fCmd.test | 2 +- tests/fileName.test | 2 +- tests/fileSystem.test | 6 +++++- tests/fileSystemEncoding.test | 7 +++++-- tests/for-old.test | 4 ++-- tests/for.test | 4 ++-- tests/foreach.test | 4 ++-- tests/format.test | 4 ++-- tests/get.test | 4 ++-- tests/history.test | 2 +- tests/http.test | 6 ++++-- tests/http11.test | 6 ++++-- tests/httpPipeline.test | 6 ++++-- tests/httpold.test | 4 ++-- tests/if-old.test | 4 ++-- tests/if.test | 4 ++-- tests/incr-old.test | 4 ++-- tests/incr.test | 2 +- tests/indexObj.test | 4 ++-- tests/info.test | 2 +- tests/io.test | 10 +++++----- tests/ioCmd.test | 4 ++-- tests/ioTrans.test | 8 ++++---- tests/join.test | 4 ++-- tests/lindex.test | 4 ++-- tests/link.test | 2 +- tests/linsert.test | 4 ++-- tests/list.test | 4 ++-- tests/listObj.test | 4 ++-- tests/llength.test | 4 ++-- tests/lmap.test | 2 +- tests/load.test | 4 ++-- tests/lrange.test | 4 ++-- tests/lrepeat.test | 4 ++-- tests/lreplace.test | 4 ++-- tests/lsearch.test | 2 +- tests/lset.test | 4 ++-- tests/lsetComp.test | 4 ++-- tests/macOSXFCmd.test | 4 ++-- tests/macOSXLoad.test | 5 +++-- tests/mathop.test | 2 +- tests/misc.test | 4 ++-- tests/msgcat.test | 8 ++++---- tests/namespace.test | 6 ++++-- tests/notify.test | 4 ++-- tests/nre.test | 4 ++-- tests/obj.test | 4 ++-- tests/oo.test | 4 ++-- tests/ooNext2.test | 4 ++-- tests/opt.test | 4 ++-- tests/parseExpr.test | 6 ++++-- tests/parseOld.test | 6 ++++-- tests/pid.test | 4 ++-- tests/pkgMkIndex.test | 6 ++++-- tests/platform.test | 2 +- tests/proc-old.test | 4 ++-- tests/proc.test | 2 +- tests/pwd.test | 4 ++-- tests/reg.test | 4 ++-- tests/regexp.test | 2 +- tests/regexpComp.test | 4 ++-- tests/registry.test | 4 ++-- tests/rename.test | 4 ++-- tests/resolver.test | 4 ++-- tests/result.test | 6 ++++-- tests/safe-stock86.test | 6 ++---- tests/safe.test | 6 ++---- tests/scan.test | 2 +- tests/security.test | 2 +- tests/set-old.test | 4 ++-- tests/set.test | 4 ++-- tests/socket.test | 7 +++++-- tests/split.test | 4 ++-- tests/stack.test | 6 ++++-- tests/string.test | 4 ++-- tests/stringComp.test | 4 ++-- tests/stringObj.test | 4 ++-- tests/subst.test | 2 +- tests/switch.test | 2 +- tests/tailcall.test | 4 ++-- tests/tcltest.test | 28 ++++++++++++++-------------- tests/tcltests.tcl | 2 +- tests/timer.test | 4 ++-- tests/tm.test | 2 +- tests/trace.test | 6 ++++-- tests/unixFCmd.test | 4 ++-- tests/unixFile.test | 4 ++-- tests/unixForkEvent.test | 2 +- tests/unixInit.test | 2 +- tests/unixNotfy.test | 4 ++-- tests/unknown.test | 2 +- tests/unload.test | 4 ++-- tests/uplevel.test | 4 ++-- tests/upvar.test | 4 ++-- tests/utf.test | 4 ++-- tests/util.test | 4 ++-- tests/var.test | 2 +- tests/while-old.test | 4 ++-- tests/while.test | 2 +- tests/winConsole.test | 4 ++-- tests/winDde.test | 4 ++-- tests/winFCmd.test | 4 ++-- tests/winFile.test | 4 ++-- tests/winNotify.test | 4 ++-- tests/winPipe.test | 2 +- tests/winTime.test | 4 ++-- tests/zlib.test | 2 +- 145 files changed, 332 insertions(+), 293 deletions(-) diff --git a/doc/Tcl_Main.3 b/doc/Tcl_Main.3 index 3ec33d1..2eae4b8 100644 --- a/doc/Tcl_Main.3 +++ b/doc/Tcl_Main.3 @@ -79,7 +79,7 @@ against the standard Tcl library. Extensions (stub-enabled or not) are not intended to call \fBTcl_Main\fR. .PP \fBTcl_Main\fR is not thread-safe. It should only be called by -a single master thread of a multi-threaded application. This +a single main thread of a multi-threaded application. This restriction is not a problem with normal use described above. .PP \fBTcl_Main\fR and therefore all applications based upon it, like @@ -112,7 +112,7 @@ The file name and encoding values managed by the routines \fBTcl_SetStartupScript\fR and \fBTcl_GetStartupScript\fR are stored per-thread. Although the storage and retrieval functions of these routines work in any thread, only those -calls in the same master thread as \fBTcl_Main\fR can have +calls in the same main thread as \fBTcl_Main\fR can have any influence on it. .PP The caller of \fBTcl_Main\fR may call \fBTcl_SetStartupScript\fR @@ -126,7 +126,7 @@ a \fIstartup script\fR, and \fIname\fR is taken to be the name of the encoding of the contents of that file. \fBTcl_Main\fR then calls \fBTcl_SetStartupScript\fR with these values. .PP -\fBTcl_Main\fR then defines in its master interpreter +\fBTcl_Main\fR then defines in its main interpreter the Tcl variables \fIargc\fR, \fIargv\fR, \fIargv0\fR, and \fItcl_interactive\fR, as described in the documentation for \fBtclsh\fR. .PP @@ -154,9 +154,9 @@ When the \fIappInitProc\fR is finished, \fBTcl_Main\fR calls been requested, if any. If a startup script has been provided, \fBTcl_Main\fR attempts to evaluate it. Otherwise, interactive mode begins with examination of the variable \fItcl_rcFileName\fR -in the master interpreter. If that variable exists and holds the +in the main interpreter. If that variable exists and holds the name of a readable file, the contents of that file are evaluated -in the master interpreter. Then interactive operations begin, +in the main interpreter. Then interactive operations begin, with prompts and command evaluation results written to the standard output channel, and commands read from the standard input channel and then evaluated. The prompts written to the standard output @@ -164,7 +164,7 @@ channel may be customized by defining the Tcl variables \fItcl_prompt1\fR and \fItcl_prompt2\fR as described in the documentation for \fBtclsh\fR. The prompts and command evaluation results are written to the standard output channel only if the Tcl variable \fItcl_interactive\fR in the -master interpreter holds a non-zero integer value. +main interpreter holds a non-zero integer value. .PP \fBTcl_SetMainLoop\fR allows setting an event loop procedure to be run. This allows, for example, Tk to be dynamically loaded and set its event diff --git a/doc/tcltest.n b/doc/tcltest.n index b161a2b..25e5e5e 100644 --- a/doc/tcltest.n +++ b/doc/tcltest.n @@ -203,7 +203,7 @@ array. Returns an empty string. .TP \fBrunAllTests\fR . -This is a master command meant to run an entire suite of tests, +This is a main command meant to run an entire suite of tests, spanning multiple files and/or directories, as governed by the configurable options of \fBtcltest\fR. See \fBRUNNING ALL TESTS\fR below for a complete description of the many variations possible @@ -804,17 +804,17 @@ then a copy of \fBinterpreter\fR will be \fBexec\fR'd to evaluate each file. The multi-process operation is useful when testing can cause errors so severe that a process terminates. Although such an error may terminate a child -process evaluating one file, the master process can continue +process evaluating one file, the main process can continue with the rest of the test suite. In multi-process operation, -the configuration of \fBtcltest\fR in the master process is +the configuration of \fBtcltest\fR in the main process is passed to the child processes as command line arguments, with the exception of \fBconfigure \-outfile\fR. The \fBrunAllTests\fR command in the -master process collects all output from the child processes -and collates their results into one master report. Any +main process collects all output from the child processes +and collates their results into one main report. Any reports of individual test failures, or messages requested by a \fBconfigure \-verbose\fR setting are passed directly -on to \fBoutputChannel\fR by the master process. +on to \fBoutputChannel\fR by the main process. .PP After evaluating all selected test files, a summary of the results is printed to \fBoutputChannel\fR. The summary @@ -1134,7 +1134,7 @@ A good namespace to use is a child namespace \fBtest\fR of the namespace of the module you are testing. .PP A test file should also be able to be evaluated directly as a script, -not depending on being called by a master \fBrunAllTests\fR. This +not depending on being called by a main \fBrunAllTests\fR. This means that each test file should process command line arguments to give the tester all the configuration control that \fBtcltest\fR provides. .PP @@ -1145,7 +1145,7 @@ Here is a sketch of a sample test file illustrating those points: .RS .PP .CS -package require tcltest 2.2 +package require tcltest 2.5 eval \fB::tcltest::configure\fR $argv package require example namespace eval ::example::test { @@ -1175,12 +1175,12 @@ doing any necessary setup. This script is usually named \fBall.tcl\fR because that is the default name used by \fBrunAllTests\fR when combining multiple test suites into one testing run. .IP [8] -Here is a sketch of a sample test suite master script: +Here is a sketch of a sample test suite main script: .RS .PP .CS -package require Tcl 8.4 -package require tcltest 2.2 +package require Tcl 8.6 +package require tcltest 2.5 package require example \fB::tcltest::configure\fR -testdir \e [file dirname [file normalize [info script]]] diff --git a/macosx/Tcl.xcode/project.pbxproj b/macosx/Tcl.xcode/project.pbxproj index 06c7fa0..aceb929 100644 --- a/macosx/Tcl.xcode/project.pbxproj +++ b/macosx/Tcl.xcode/project.pbxproj @@ -1909,7 +1909,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "if [ \"${ACTION:-build}\" == \"build\" ]; then\nif [ -z \"${HOME}\" ]; then export HOME=\"$(echo ~)\"; fi\ncd \"${TARGET_TEMP_DIR}\"; rm -rf \"${DERIVED_FILE_DIR}\"; mkdir -p \"${DERIVED_FILE_DIR}\"\nprintf '%s%s%s%s%s' '\npackage require tcltest 2.2\nnamespace import tcltest::*\nconfigure -testdir [file normalize {' \"${TCL_SRCROOT}\" '/tests}]\nconfigure -tmpdir [file normalize {' \"${DERIVED_FILE_DIR}\" '}]\nconfigure -verbose [concat [configure -verbose] line]\nrunAllTests\n' | \"${TEST_RIG}\"; TEST_RIG_RESULT=$?\n[ ${TEST_RIG_RESULT} -ne 0 ] && echo \"tcltest:0: error: tcltest exited abnormally with code ${TEST_RIG_RESULT}.\"\nexit ${TEST_RIG_RESULT}\nfi"; + shellScript = "if [ \"${ACTION:-build}\" == \"build\" ]; then\nif [ -z \"${HOME}\" ]; then export HOME=\"$(echo ~)\"; fi\ncd \"${TARGET_TEMP_DIR}\"; rm -rf \"${DERIVED_FILE_DIR}\"; mkdir -p \"${DERIVED_FILE_DIR}\"\nprintf '%s%s%s%s%s' '\npackage require tcltest 2.5\nnamespace import tcltest::*\nconfigure -testdir [file normalize {' \"${TCL_SRCROOT}\" '/tests}]\nconfigure -tmpdir [file normalize {' \"${DERIVED_FILE_DIR}\" '}]\nconfigure -verbose [concat [configure -verbose] line]\nrunAllTests\n' | \"${TEST_RIG}\"; TEST_RIG_RESULT=$?\n[ ${TEST_RIG_RESULT} -ne 0 ] && echo \"tcltest:0: error: tcltest exited abnormally with code ${TEST_RIG_RESULT}.\"\nexit ${TEST_RIG_RESULT}\nfi"; showEnvVarsInLog = 0; }; F97AF02F0B665DA900310EA2 /* Build Tcl */ = { diff --git a/macosx/Tcl.xcodeproj/project.pbxproj b/macosx/Tcl.xcodeproj/project.pbxproj index a0d4f2a..da16424 100644 --- a/macosx/Tcl.xcodeproj/project.pbxproj +++ b/macosx/Tcl.xcodeproj/project.pbxproj @@ -1909,7 +1909,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "if [ \"${ACTION:-build}\" == \"build\" ]; then\nif [ -z \"${HOME}\" ]; then export HOME=\"$(echo ~)\"; fi\ncd \"${TARGET_TEMP_DIR}\"; rm -rf \"${DERIVED_FILE_DIR}\"; mkdir -p \"${DERIVED_FILE_DIR}\"\nprintf '%s%s%s%s%s' '\npackage require tcltest 2.2\nnamespace import tcltest::*\nconfigure -testdir [file normalize {' \"${TCL_SRCROOT}\" '/tests}]\nconfigure -tmpdir [file normalize {' \"${DERIVED_FILE_DIR}\" '}]\nconfigure -verbose [concat [configure -verbose] line]\nrunAllTests\n' | \"${TEST_RIG}\"; TEST_RIG_RESULT=$?\n[ ${TEST_RIG_RESULT} -ne 0 ] && echo \"tcltest:0: error: tcltest exited abnormally with code ${TEST_RIG_RESULT}.\"\nexit ${TEST_RIG_RESULT}\nfi"; + shellScript = "if [ \"${ACTION:-build}\" == \"build\" ]; then\nif [ -z \"${HOME}\" ]; then export HOME=\"$(echo ~)\"; fi\ncd \"${TARGET_TEMP_DIR}\"; rm -rf \"${DERIVED_FILE_DIR}\"; mkdir -p \"${DERIVED_FILE_DIR}\"\nprintf '%s%s%s%s%s' '\npackage require tcltest 2.5\nnamespace import tcltest::*\nconfigure -testdir [file normalize {' \"${TCL_SRCROOT}\" '/tests}]\nconfigure -tmpdir [file normalize {' \"${DERIVED_FILE_DIR}\" '}]\nconfigure -verbose [concat [configure -verbose] line]\nrunAllTests\n' | \"${TEST_RIG}\"; TEST_RIG_RESULT=$?\n[ ${TEST_RIG_RESULT} -ne 0 ] && echo \"tcltest:0: error: tcltest exited abnormally with code ${TEST_RIG_RESULT}.\"\nexit ${TEST_RIG_RESULT}\nfi"; showEnvVarsInLog = 0; }; F97AF02F0B665DA900310EA2 /* Build Tcl */ = { diff --git a/pkgs/README b/pkgs/README index 159a237..4633e0b 100644 --- a/pkgs/README +++ b/pkgs/README @@ -17,7 +17,7 @@ needs to conform to the following conventions. "configure". When the program "configure" is run, it should generate a file "Makefile" in the current working directory. The "configure" program should be able to accept as command line arguments all the - arguments that can be passed to the master unix/configure program. It + arguments that can be passed to the top unix/configure program. It should also accept the --with-tcl= and --with-tclinclude= options in the conventional way. diff --git a/tests/aaa_exit.test b/tests/aaa_exit.test index 3ba5167..d4d2a7c 100644 --- a/tests/aaa_exit.test +++ b/tests/aaa_exit.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/append.test b/tests/append.test index 8fa4e61..ef4a194 100644 --- a/tests/append.test +++ b/tests/append.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } unset -nocomplain x diff --git a/tests/appendComp.test b/tests/appendComp.test index a0069ac..66941a9 100644 --- a/tests/appendComp.test +++ b/tests/appendComp.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } catch {unset x} diff --git a/tests/apply.test b/tests/apply.test index ba19b81..5fed6ec 100644 --- a/tests/apply.test +++ b/tests/apply.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2.2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/assemble.test b/tests/assemble.test index 45368de..d2e626b 100644 --- a/tests/assemble.test +++ b/tests/assemble.test @@ -12,7 +12,7 @@ # Commands covered: assemble if {"::tcltest" ni [namespace children]} { - package require tcltest 2.2 + package require tcltest 2.5 namespace import -force ::tcltest::* } namespace eval tcl::unsupported {namespace export assemble} diff --git a/tests/assocd.test b/tests/assocd.test index edf55c4..863bf78 100644 --- a/tests/assocd.test +++ b/tests/assocd.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 +package require tcltest 2.5 namespace import ::tcltest::* ::tcltest::loadTestedCommands diff --git a/tests/async.test b/tests/async.test index 4e7eadf..1aef907 100644 --- a/tests/async.test +++ b/tests/async.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test index 6768772..6c57de0 100644 --- a/tests/autoMkindex.test +++ b/tests/autoMkindex.test @@ -10,7 +10,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/basic.test b/tests/basic.test index bea5870..6f8d350 100644 --- a/tests/basic.test +++ b/tests/basic.test @@ -15,8 +15,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/binary.test b/tests/binary.test index c2c5eb4..07ecf6f 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}] diff --git a/tests/case.test b/tests/case.test index 6d63cea..d32d7d3 100644 --- a/tests/case.test +++ b/tests/case.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/chan.test b/tests/chan.test index d8390e2..4efec11 100644 --- a/tests/chan.test +++ b/tests/chan.test @@ -7,8 +7,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/chanio.test b/tests/chanio.test index c4c88a0..c811b00 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -13,9 +13,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -# TODO: This test is likely worthless. Confirm and remove -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 } namespace eval ::tcl::test::io { diff --git a/tests/clock.test b/tests/clock.test index 0dc5caf..6d502d4 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/cmdIL.test b/tests/cmdIL.test index 0bf34a2..27f1df1 100644 --- a/tests/cmdIL.test +++ b/tests/cmdIL.test @@ -8,8 +8,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/cmdInfo.test b/tests/cmdInfo.test index 0a587e8..e690002 100644 --- a/tests/cmdInfo.test +++ b/tests/cmdInfo.test @@ -13,8 +13,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test index bae26a0..d4525e6 100644 --- a/tests/compExpr-old.test +++ b/tests/compExpr-old.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/compExpr.test b/tests/compExpr.test index d1739de..677266c 100644 --- a/tests/compExpr.test +++ b/tests/compExpr.test @@ -9,7 +9,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/compile.test b/tests/compile.test index cb41063..0663270 100644 --- a/tests/compile.test +++ b/tests/compile.test @@ -11,8 +11,10 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/concat.test b/tests/concat.test index eeb11ca..8ff5500 100644 --- a/tests/concat.test +++ b/tests/concat.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/config.test b/tests/config.test index d14837e..15be790 100644 --- a/tests/config.test +++ b/tests/config.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/coroutine.test b/tests/coroutine.test index 4c35460..c60b568 100644 --- a/tests/coroutine.test +++ b/tests/coroutine.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/dcall.test b/tests/dcall.test index 41dd777..7d86135 100644 --- a/tests/dcall.test +++ b/tests/dcall.test @@ -11,8 +11,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/dict.test b/tests/dict.test index a6b0cb4..6ede398 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/dstring.test b/tests/dstring.test index 5feb355..8a24ebe 100644 --- a/tests/dstring.test +++ b/tests/dstring.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/encoding.test b/tests/encoding.test index 935bef8..72d218b 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -8,13 +8,14 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} namespace eval ::tcl::test::encoding { variable x -namespace import -force ::tcltest::* - catch { ::tcltest::loadTestedCommands package require -exact Tcltest [info patchlevel] diff --git a/tests/env.test b/tests/env.test index 9b8016c..8cc57d2 100644 --- a/tests/env.test +++ b/tests/env.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/error.test b/tests/error.test index af07ed7..a111c80 100644 --- a/tests/error.test +++ b/tests/error.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/eval.test b/tests/eval.test index 70ceac8..d473fdf 100644 --- a/tests/eval.test +++ b/tests/eval.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/event.test b/tests/event.test index 70d4cff..77f13d3 100644 --- a/tests/event.test +++ b/tests/event.test @@ -9,8 +9,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} catch { ::tcltest::loadTestedCommands diff --git a/tests/exec.test b/tests/exec.test index 62133e8..3aaec6e 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -14,8 +14,10 @@ # There is no point in running Valgrind on cases where [exec] forks but then # fails and the child process doesn't go through full cleanup. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} package require tcltests diff --git a/tests/execute.test b/tests/execute.test index da3e2d4..14c2f76 100644 --- a/tests/execute.test +++ b/tests/execute.test @@ -15,7 +15,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } @@ -984,7 +984,7 @@ test execute-8.5 {Bug 2038069} -setup { test execute-8.6 {Compile epoch bump in global level (bug [fa6bf38d07])} -setup { interp create child child eval { - package require tcltest + package require tcltest 2.5 catch [list package require -exact Tcltest [info patchlevel]] ::tcltest::loadTestedCommands if {[namespace which -command testbumpinterpepoch] eq ""} { @@ -1017,7 +1017,7 @@ test execute-8.6 {Compile epoch bump in global level (bug [fa6bf38d07])} -setup test execute-8.7 {Compile epoch bump in global level (bug [fa6bf38d07]), exception case} -setup { interp create child child eval { - package require tcltest + package require tcltest 2.5 catch [list package require -exact Tcltest [info patchlevel]] ::tcltest::loadTestedCommands if {[namespace which -command testbumpinterpepoch] eq ""} { diff --git a/tests/expr.test b/tests/expr.test index 0e3bd61..d2f767d 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2.1 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/fCmd.test b/tests/fCmd.test index 260fde9..bb8fb4a 100644 --- a/tests/fCmd.test +++ b/tests/fCmd.test @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/fileName.test b/tests/fileName.test index 0e4cb9e..725c1dd 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/fileSystem.test b/tests/fileSystem.test index d9264ee..c1deb1b 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -9,7 +9,11 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} + namespace eval ::tcl::test::fileSystem { namespace import ::tcltest::* diff --git a/tests/fileSystemEncoding.test b/tests/fileSystemEncoding.test index da301ce..40a0090 100644 --- a/tests/fileSystemEncoding.test +++ b/tests/fileSystemEncoding.test @@ -7,8 +7,11 @@ if {[string equal $::tcl_platform(os) "Windows NT"]} { } namespace eval ::tcl::test::fileSystemEncoding { - package require tcltest 2 - namespace import ::tcltest::* + + if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* + } variable fname1 \u767b\u9e1b\u9d72\u6a13 diff --git a/tests/for-old.test b/tests/for-old.test index a11a791..d00a4ee 100644 --- a/tests/for-old.test +++ b/tests/for-old.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/for.test b/tests/for.test index 1a65274..65d8fc8 100644 --- a/tests/for.test +++ b/tests/for.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/foreach.test b/tests/foreach.test index 84af4bd..cdbfc85 100644 --- a/tests/foreach.test +++ b/tests/foreach.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/format.test b/tests/format.test index c26bbe9..ea0e929 100644 --- a/tests/format.test +++ b/tests/format.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/get.test b/tests/get.test index 7aa06c1..b9a83ac 100644 --- a/tests/get.test +++ b/tests/get.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/history.test b/tests/history.test index 3201ad7..76ce54e 100644 --- a/tests/history.test +++ b/tests/history.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/http.test b/tests/http.test index e6255bf..636a651 100644 --- a/tests/http.test +++ b/tests/http.test @@ -11,8 +11,10 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} if {[catch {package require http 2} version]} { if {[info exists http2]} { diff --git a/tests/http11.test b/tests/http11.test index 989b00f..7ca57f4 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -7,8 +7,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} package require http 2.9 diff --git a/tests/httpPipeline.test b/tests/httpPipeline.test index de1a7d8..4306149 100644 --- a/tests/httpPipeline.test +++ b/tests/httpPipeline.test @@ -8,8 +8,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} package require http 2.9 diff --git a/tests/httpold.test b/tests/httpold.test index acc5a6e..dec4697 100644 --- a/tests/httpold.test +++ b/tests/httpold.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/if-old.test b/tests/if-old.test index fbcf56c..e537fea 100644 --- a/tests/if-old.test +++ b/tests/if-old.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/if.test b/tests/if.test index 040364a..f5acf60 100644 --- a/tests/if.test +++ b/tests/if.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/incr-old.test b/tests/incr-old.test index ed457cf..5d792e1 100644 --- a/tests/incr-old.test +++ b/tests/incr-old.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/incr.test b/tests/incr.test index 9243be0..af15f5e 100644 --- a/tests/incr.test +++ b/tests/incr.test @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/indexObj.test b/tests/indexObj.test index 646cb02..60ee61a 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -8,8 +8,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/info.test b/tests/info.test index 5fe2240..3f42d93 100644 --- a/tests/info.test +++ b/tests/info.test @@ -16,7 +16,7 @@ # DO NOT DELETE THIS LINE if {{::tcltest} ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/io.test b/tests/io.test index 1df017a..5f668e6 100644 --- a/tests/io.test +++ b/tests/io.test @@ -13,12 +13,12 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 -} - namespace eval ::tcl::test::io { - namespace import ::tcltest::* + + if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* + } variable umaskValue variable path diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 18b228e..8d961ae 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/ioTrans.test b/tests/ioTrans.test index 867362a..2872fbb 100644 --- a/tests/ioTrans.test +++ b/tests/ioTrans.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } @@ -36,8 +36,8 @@ testConstraint thread [expr {0 == [catch {package require Thread 2.7-}]}] # can access this variable. set helperscript { - if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 + if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/join.test b/tests/join.test index 4aeb093..9ea554d 100644 --- a/tests/join.test +++ b/tests/join.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lindex.test b/tests/lindex.test index e513b62..dadf275 100644 --- a/tests/lindex.test +++ b/tests/lindex.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2.2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/link.test b/tests/link.test index 189762e..d37f08a 100644 --- a/tests/link.test +++ b/tests/link.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/linsert.test b/tests/linsert.test index 4939e5c..ddc56a9 100644 --- a/tests/linsert.test +++ b/tests/linsert.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/list.test b/tests/list.test index 2686bd7..edb572c 100644 --- a/tests/list.test +++ b/tests/list.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/listObj.test b/tests/listObj.test index d7fb46c..ce6c978 100644 --- a/tests/listObj.test +++ b/tests/listObj.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/llength.test b/tests/llength.test index 169c7ca..a2770c0 100644 --- a/tests/llength.test +++ b/tests/llength.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lmap.test b/tests/lmap.test index 08035d9..432e195 100644 --- a/tests/lmap.test +++ b/tests/lmap.test @@ -14,7 +14,7 @@ # RCS: @(#) $Id: $ if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/load.test b/tests/load.test index 7d2e5df..9fdf1cf 100644 --- a/tests/load.test +++ b/tests/load.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lrange.test b/tests/lrange.test index d5676ad..4bce1b3 100644 --- a/tests/lrange.test +++ b/tests/lrange.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lrepeat.test b/tests/lrepeat.test index 788bb9b..61f2b62 100644 --- a/tests/lrepeat.test +++ b/tests/lrepeat.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lreplace.test b/tests/lreplace.test index fd2f7f8..b7caf47 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lsearch.test b/tests/lsearch.test index 7e6a345..aa43862 100644 --- a/tests/lsearch.test +++ b/tests/lsearch.test @@ -12,7 +12,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lset.test b/tests/lset.test index 1c1300b..a130fe9 100644 --- a/tests/lset.test +++ b/tests/lset.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/lsetComp.test b/tests/lsetComp.test index 6846cbf..d8ad246 100644 --- a/tests/lsetComp.test +++ b/tests/lsetComp.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/macOSXFCmd.test b/tests/macOSXFCmd.test index f1758f5..0a147f0 100644 --- a/tests/macOSXFCmd.test +++ b/tests/macOSXFCmd.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/macOSXLoad.test b/tests/macOSXLoad.test index 12c77e0..e68c4bb 100644 --- a/tests/macOSXLoad.test +++ b/tests/macOSXLoad.test @@ -10,10 +10,11 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } + set oldTSF $::tcltest::testSingleFile set ::tcltest::testSingleFile false diff --git a/tests/mathop.test b/tests/mathop.test index a1a3f80..f6d0c00 100644 --- a/tests/mathop.test +++ b/tests/mathop.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { +if {"::tcltest" ni [namespace children]} { package require tcltest 2.1 namespace import -force ::tcltest::* } diff --git a/tests/misc.test b/tests/misc.test index d4ece74..8b6e1b7 100644 --- a/tests/misc.test +++ b/tests/misc.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/msgcat.test b/tests/msgcat.test index 1c3ce58..9a6eac0 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -12,11 +12,11 @@ # Note that after running these tests, entries will be left behind in the # message catalogs for locales foo, foo_BAR, and foo_BAR_baz. -package require Tcl 8.5- -if {[catch {package require tcltest 2}]} { - puts stderr "Skipping tests in [info script]. tcltest 2 required." - return +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* } + if {[catch {package require msgcat 1.6}]} { puts stderr "Skipping tests in [info script]. No msgcat 1.6 found to test." return diff --git a/tests/namespace.test b/tests/namespace.test index 2b25803..8209cf3 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -12,8 +12,10 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} testConstraint memory [llength [info commands memory]] ::tcltest::loadTestedCommands diff --git a/tests/notify.test b/tests/notify.test index d2b9123..7375f83 100644 --- a/tests/notify.test +++ b/tests/notify.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/nre.test b/tests/nre.test index 09061d2..e420b06 100644 --- a/tests/nre.test +++ b/tests/nre.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/obj.test b/tests/obj.test index 7273b40..b6b6eb8 100644 --- a/tests/obj.test +++ b/tests/obj.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/oo.test b/tests/oo.test index 612fb9b..94537b7 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -8,8 +8,8 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. package require TclOO 1.0.3 -package require tcltest 2 -if {"::tcltest" in [namespace children]} { +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/ooNext2.test b/tests/ooNext2.test index 6a48d28..84a2bdd 100644 --- a/tests/ooNext2.test +++ b/tests/ooNext2.test @@ -8,8 +8,8 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. package require TclOO 1.0.3 -package require tcltest 2 -if {"::tcltest" in [namespace children]} { +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/opt.test b/tests/opt.test index 7ed25b5..0af4488 100644 --- a/tests/opt.test +++ b/tests/opt.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/parseExpr.test b/tests/parseExpr.test index ef05454..bb0920e 100644 --- a/tests/parseExpr.test +++ b/tests/parseExpr.test @@ -8,8 +8,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/parseOld.test b/tests/parseOld.test index 504d063..134a3c2 100644 --- a/tests/parseOld.test +++ b/tests/parseOld.test @@ -13,8 +13,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/pid.test b/tests/pid.test index af21f30..47f753b 100644 --- a/tests/pid.test +++ b/tests/pid.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/pkgMkIndex.test b/tests/pkgMkIndex.test index 37afafa..8121377 100644 --- a/tests/pkgMkIndex.test +++ b/tests/pkgMkIndex.test @@ -8,8 +8,10 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} set fullPkgPath [makeDirectory pkg] diff --git a/tests/platform.test b/tests/platform.test index e5a4c90..e40ff39 100644 --- a/tests/platform.test +++ b/tests/platform.test @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 +package require tcltest 2.5 package require tcltests namespace eval ::tcl::test::platform { diff --git a/tests/proc-old.test b/tests/proc-old.test index e45cf5c..79ee1fa 100644 --- a/tests/proc-old.test +++ b/tests/proc-old.test @@ -14,8 +14,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/proc.test b/tests/proc.test index 585efa5..7039dbb 100644 --- a/tests/proc.test +++ b/tests/proc.test @@ -14,7 +14,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/pwd.test b/tests/pwd.test index 175c852..3486e70 100644 --- a/tests/pwd.test +++ b/tests/pwd.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/reg.test b/tests/reg.test index a95d1e2..02677c7 100644 --- a/tests/reg.test +++ b/tests/reg.test @@ -9,8 +9,8 @@ # # Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 } ::tcltest::loadTestedCommands diff --git a/tests/regexp.test b/tests/regexp.test index 6be902b..563a5ee 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -12,7 +12,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/regexpComp.test b/tests/regexpComp.test index 01ef06d..2fd7f88 100644 --- a/tests/regexpComp.test +++ b/tests/regexpComp.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/registry.test b/tests/registry.test index 8cfd5be..53e48fe 100644 --- a/tests/registry.test +++ b/tests/registry.test @@ -10,8 +10,8 @@ # Copyright (c) 1997 by Sun Microsystems, Inc. All rights reserved. # Copyright (c) 1998-1999 by Scriptics Corporation. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/rename.test b/tests/rename.test index ebf5425..ddda909 100644 --- a/tests/rename.test +++ b/tests/rename.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/resolver.test b/tests/resolver.test index db524a0..9916529 100644 --- a/tests/resolver.test +++ b/tests/resolver.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -if {"::tcltest" in [namespace children]} { +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/result.test b/tests/result.test index 9e8a66b..6e51e4e 100644 --- a/tests/result.test +++ b/tests/result.test @@ -10,8 +10,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test index 337527c..402ea31 100644 --- a/tests/safe-stock86.test +++ b/tests/safe-stock86.test @@ -18,10 +18,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tcl 8.5- - -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/safe.test b/tests/safe.test index 217200c..eb4bfaf 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -21,10 +21,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tcl 8.5- - -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/scan.test b/tests/scan.test index 98c581b..e3fab05 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -12,7 +12,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/security.test b/tests/security.test index eeabc9c..3235a1f 100644 --- a/tests/security.test +++ b/tests/security.test @@ -11,7 +11,7 @@ # All rights reserved. if {"::tcltest" ni [namespace children]} { - package require tcltest + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/set-old.test b/tests/set-old.test index 309abaf..68e0497 100644 --- a/tests/set-old.test +++ b/tests/set-old.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/set.test b/tests/set.test index 3c87000..303c2d7 100644 --- a/tests/set.test +++ b/tests/set.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/socket.test b/tests/socket.test index 87169ae..4f1a198 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -60,8 +60,11 @@ # listening at port 2048. If all fails, a message is printed and the tests # using the remote server are not performed. -package require tcltest 2 -namespace import -force ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} + ::tcltest::loadTestedCommands if {[expr {[info exists ::env(TRAVIS_OSX_IMAGE)] && [string match xcode* $::env(TRAVIS_OSX_IMAGE)]}]} { diff --git a/tests/split.test b/tests/split.test index 18055b3..8e82367 100644 --- a/tests/split.test +++ b/tests/split.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/stack.test b/tests/stack.test index 13bc524..44417df 100644 --- a/tests/stack.test +++ b/tests/stack.test @@ -9,8 +9,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} # Note that a failure in this test may result in a crash of the executable. diff --git a/tests/string.test b/tests/string.test index 124bda7..dabe3a4 100644 --- a/tests/string.test +++ b/tests/string.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/stringComp.test b/tests/stringComp.test index 2aeb08e..1cd0193 100644 --- a/tests/stringComp.test +++ b/tests/stringComp.test @@ -15,8 +15,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/stringObj.test b/tests/stringObj.test index 49f268e..ce19e96 100644 --- a/tests/stringObj.test +++ b/tests/stringObj.test @@ -12,8 +12,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/subst.test b/tests/subst.test index 21aecc5..e203ad2 100644 --- a/tests/subst.test +++ b/tests/subst.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { +if {"::tcltest" ni [namespace children]} { package require tcltest 2.1 namespace import -force ::tcltest::* } diff --git a/tests/switch.test b/tests/switch.test index 4d204bb..8ca049c 100644 --- a/tests/switch.test +++ b/tests/switch.test @@ -12,7 +12,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/tailcall.test b/tests/tailcall.test index 3751c35..c664455 100644 --- a/tests/tailcall.test +++ b/tests/tailcall.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/tcltest.test b/tests/tcltest.test index b02c18d..fc6b183 100644 --- a/tests/tcltest.test +++ b/tests/tcltest.test @@ -27,7 +27,7 @@ namespace eval ::tcltest::test { namespace import ::tcltest::* makeFile { - package require tcltest + package require tcltest 2.5 namespace import ::tcltest::test test a-1.0 {test a} { list 0 @@ -340,7 +340,7 @@ test tcltest-5.5 {InitConstraints: list of built-in constraints} \ # -outfile, -errfile, [outputChannel], [outputFile], [errorChannel], [errorFile] set printerror [makeFile { - package require tcltest + package require tcltest 2.5 namespace import ::tcltest::* puts [outputChannel] "a test" ::tcltest::PrintError "a really short string" @@ -510,7 +510,7 @@ removeFile test.tcl # directory tests set a [makeFile { - package require tcltest + package require tcltest 2.5 tcltest::makeFile {} a.tmp puts [tcltest::outputChannel] "testdir: [tcltest::testsDirectory]" exit @@ -795,7 +795,7 @@ test tcltest-9.5 {GetMatchingFiles: Bug 1119798} -setup { # -preservecore, [preserveCore] set mc [makeFile { - package require tcltest + package require tcltest 2.5 namespace import ::tcltest::test test makecore {make a core file} { set f [open core w] @@ -846,7 +846,7 @@ removeFile makecore.tcl # -load, -loadfile, [loadScript], [loadFile] set contents { - package require tcltest + package require tcltest 2.5 namespace import tcltest::* puts [outputChannel] $::tcltest::loadScript exit @@ -942,7 +942,7 @@ makeFile { } single2.test $spd set allfile [makeFile { - package require tcltest + package require tcltest 2.5 namespace import tcltest::* testsDirectory [file join [temporaryDirectory] singleprocdir] runAllTests @@ -999,25 +999,25 @@ set dtd1 [makeDirectory dirtestdir2.1 $dtd] set dtd2 [makeDirectory dirtestdir2.2 $dtd] set dtd3 [makeDirectory dirtestdir2.3 $dtd] makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* testsDirectory [file join [temporaryDirectory] dirtestdir] runAllTests } all.tcl $dtd makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* testsDirectory [file join [temporaryDirectory] dirtestdir dirtestdir2.1] runAllTests } all.tcl $dtd1 makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* testsDirectory [file join [temporaryDirectory] dirtestdir dirtestdir2.2] runAllTests } all.tcl $dtd2 makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* testsDirectory [file join [temporaryDirectory] dirtestdir dirtestdir2.3] runAllTests @@ -1385,7 +1385,7 @@ test tcltest-21.12 { set atd [makeDirectory alltestdir] makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* testsDirectory [file join [temporaryDirectory] alltestdir] runAllTests @@ -1397,7 +1397,7 @@ makeFile { error "throw an error" } error.test $atd makeFile { - package require tcltest + package require tcltest 2.5 namespace import -force tcltest::* test foo-1.1 {foo} { -body { return 1 } @@ -1796,7 +1796,7 @@ test tcltest-25.3 { test tcltest-26.1 {Bug/RFE 1017151} -setup { makeFile { - package require tcltest + package require tcltest 2.5 set ::errorInfo "Should never see this" tcltest::test tcltest-26.1.0 { no errorInfo when only return code mismatch @@ -1816,7 +1816,7 @@ test tcltest-26.1 {Bug/RFE 1017151} -setup { test tcltest-26.2 {Bug/RFE 1017151} -setup { makeFile { - package require tcltest + package require tcltest 2.5 set ::errorInfo "Should never see this" tcltest::test tcltest-26.2.0 {do not mask body errorInfo} -body { error "body error" diff --git a/tests/tcltests.tcl b/tests/tcltests.tcl index a1fdb3d..58e6bfb 100644 --- a/tests/tcltests.tcl +++ b/tests/tcltests.tcl @@ -1,6 +1,6 @@ #! /usr/bin/env tclsh -package require tcltest 2.2 +package require tcltest 2.5 namespace import ::tcltest::* testConstraint exec [llength [info commands exec]] diff --git a/tests/timer.test b/tests/timer.test index b422f35..48d88b6 100644 --- a/tests/timer.test +++ b/tests/timer.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/tm.test b/tests/tm.test index 001b73e..ed14567 100644 --- a/tests/tm.test +++ b/tests/tm.test @@ -8,7 +8,7 @@ package require Tcl 8.5- if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/trace.test b/tests/trace.test index c54efff..726590f 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -11,8 +11,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest -namespace import ::tcltest::* +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/unixFCmd.test b/tests/unixFCmd.test index 183c145..c98e3f0 100644 --- a/tests/unixFCmd.test +++ b/tests/unixFCmd.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/unixFile.test b/tests/unixFile.test index 8147f48..492e5d0 100644 --- a/tests/unixFile.test +++ b/tests/unixFile.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/unixForkEvent.test b/tests/unixForkEvent.test index 120f362..4a0ac15 100644 --- a/tests/unixForkEvent.test +++ b/tests/unixForkEvent.test @@ -8,7 +8,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 2 +package require tcltest 2.5 namespace import -force ::tcltest::* testConstraint testfork [llength [info commands testfork]] diff --git a/tests/unixInit.test b/tests/unixInit.test index 681a931..51ecafe 100644 --- a/tests/unixInit.test +++ b/tests/unixInit.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2.2 +package require tcltest 2.5 namespace import ::tcltest::* unset -nocomplain path catch {set oldlang $env(LANG)} diff --git a/tests/unixNotfy.test b/tests/unixNotfy.test index 2f03529..df95c46 100644 --- a/tests/unixNotfy.test +++ b/tests/unixNotfy.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/unknown.test b/tests/unknown.test index 6c31c3d..7600cba 100644 --- a/tests/unknown.test +++ b/tests/unknown.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 +package require tcltest 2.5 namespace import ::tcltest::* unset -nocomplain x diff --git a/tests/unload.test b/tests/unload.test index 73f1091..05a0104 100644 --- a/tests/unload.test +++ b/tests/unload.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/uplevel.test b/tests/uplevel.test index 9fe1645..f44cedc 100644 --- a/tests/uplevel.test +++ b/tests/uplevel.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/upvar.test b/tests/upvar.test index aea9333..10e0e9f 100644 --- a/tests/upvar.test +++ b/tests/upvar.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/utf.test b/tests/utf.test index b1fafb6..6839860 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -8,8 +8,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest 2 +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/util.test b/tests/util.test index f5a59ee..a7d21f1 100644 --- a/tests/util.test +++ b/tests/util.test @@ -7,8 +7,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/var.test b/tests/var.test index 202b66c..4c6664d 100644 --- a/tests/var.test +++ b/tests/var.test @@ -15,7 +15,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2.2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/while-old.test b/tests/while-old.test index ee17d0b..eddc025 100644 --- a/tests/while-old.test +++ b/tests/while-old.test @@ -13,8 +13,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/while.test b/tests/while.test index 642ec93..30aff4b 100644 --- a/tests/while.test +++ b/tests/while.test @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/winConsole.test b/tests/winConsole.test index fdde41c..9075ff3 100644 --- a/tests/winConsole.test +++ b/tests/winConsole.test @@ -9,8 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/winDde.test b/tests/winDde.test index 6ba2ba1..1c3daa5 100644 --- a/tests/winDde.test +++ b/tests/winDde.test @@ -10,7 +10,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2 + package require tcltest 2.5 #tcltest::configure -verbose {pass start} namespace import -force ::tcltest::* } @@ -43,7 +43,7 @@ proc createChildProcess {ddeServerName args} { # DDE child server - # if {"::tcltest" ni [namespace children]} { - package require tcltest + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/winFCmd.test b/tests/winFCmd.test index 2ce4916..6d87319 100644 --- a/tests/winFCmd.test +++ b/tests/winFCmd.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/winFile.test b/tests/winFile.test index eb6addd..3737d9f 100644 --- a/tests/winFile.test +++ b/tests/winFile.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[catch {package require tcltest 2.0.2}]} { - puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required." +if {[catch {package require tcltest 2.5}]} { + puts stderr "Skipping tests in [info script]. tcltest 2.5 required." return } namespace import -force ::tcltest::* diff --git a/tests/winNotify.test b/tests/winNotify.test index 3e9aa29..0433b4a 100644 --- a/tests/winNotify.test +++ b/tests/winNotify.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/winPipe.test b/tests/winPipe.test index 06bd67e..d3a580c 100644 --- a/tests/winPipe.test +++ b/tests/winPipe.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest +package require tcltest 2.5 namespace import -force ::tcltest::* unset -nocomplain path diff --git a/tests/winTime.test b/tests/winTime.test index dbaa14c..19e4c58 100644 --- a/tests/winTime.test +++ b/tests/winTime.test @@ -10,8 +10,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 namespace import -force ::tcltest::* } diff --git a/tests/zlib.test b/tests/zlib.test index d3a6dff..7809482 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. if {"::tcltest" ni [namespace children]} { - package require tcltest 2.1 + package require tcltest 2.5 namespace import -force ::tcltest::* } -- cgit v0.12 From 66dd14a48053da5e5f4463d0d83b9e5480a9bd5e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 5 Sep 2020 20:45:04 +0000 Subject: TIP #581: Last possible master/slave -> parent/child changes, without affecting anything serious --- doc/CrtAlias.3 | 22 ++-- library/safe.tcl | 338 ++++++++++++++++++++++++++--------------------------- tests/ioCmd.test | 6 +- tests/ioTrans.test | 16 +-- tests/oo.test | 136 ++++++++++----------- tests/ooNext2.test | 8 +- tests/safe.test | 2 +- tests/socket.test | 30 ++--- 8 files changed, 279 insertions(+), 279 deletions(-) diff --git a/doc/CrtAlias.3 b/doc/CrtAlias.3 index 2934fc3..a642d08 100644 --- a/doc/CrtAlias.3 +++ b/doc/CrtAlias.3 @@ -136,17 +136,17 @@ interpreter. The return value for those procedures that return an \fBint\fR is either \fBTCL_OK\fR or \fBTCL_ERROR\fR. If \fBTCL_ERROR\fR is returned then the interpreter's result contains an error message. .PP -\fBTcl_CreateSlave\fR creates a new interpreter as a slave of \fIinterp\fR. -It also creates a slave command named \fIslaveName\fR in \fIinterp\fR which -allows \fIinterp\fR to manipulate the new slave. -If \fIisSafe\fR is zero, the command creates a trusted slave in which Tcl +\fBTcl_CreateSlave\fR creates a new interpreter as a child of \fIinterp\fR. +It also creates a child command named \fIchildName\fR in \fIinterp\fR which +allows \fIinterp\fR to manipulate the new child. +If \fIisSafe\fR is zero, the command creates a trusted child in which Tcl code has access to all the Tcl commands. If it is \fB1\fR, the command creates a .QW safe -slave in which Tcl code has access only to set of Tcl commands defined as +child in which Tcl code has access only to set of Tcl commands defined as .QW "Safe Tcl" ; see the manual entry for the Tcl \fBinterp\fR command for details. -If the creation of the new slave interpreter failed, \fBNULL\fR is returned. +If the creation of the new child interpreter failed, \fBNULL\fR is returned. .PP .VS "TIP 581" \fBTcl_CreateChild\fR is a synonym for \fBTcl_CreateSlave\fR. @@ -169,9 +169,9 @@ Callers will want to take care with their use of \fBTcl_MakeSafe\fR to avoid false claims of safety. For many situations, \fBTcl_CreateSlave\fR may be a better choice, since it creates interpreters in a known-safe state. .PP -\fBTcl_GetSlave\fR returns a pointer to a slave interpreter of -\fIinterp\fR. The slave interpreter is identified by \fIslaveName\fR. -If no such slave interpreter exists, \fBNULL\fR is returned. +\fBTcl_GetSlave\fR returns a pointer to a child interpreter of +\fIinterp\fR. The child interpreter is identified by \fIchildName\fR. +If no such child interpreter exists, \fBNULL\fR is returned. .PP .VS "TIP 581" \fBTcl_GetChild\fR is a synonym for \fBTcl_GetSlave\fR. @@ -187,7 +187,7 @@ top-level interpreter) then \fBNULL\fR is returned. .PP \fBTcl_GetInterpPath\fR stores in the result of \fIinterp\fR the relative path between \fIinterp\fR and \fIchildInterp\fR; -\fIchildInterp\fR must be a slave of \fIinterp\fR. If the computation +\fIchildInterp\fR must be a child of \fIinterp\fR. If the computation of the relative path succeeds, \fBTCL_OK\fR is returned, else \fBTCL_ERROR\fR is returned and an error message is stored as the result of \fIinterp\fR. @@ -260,4 +260,4 @@ interp .SH KEYWORDS alias, command, exposed commands, hidden commands, interpreter, invoke, -master, slave +parent, child diff --git a/library/safe.tcl b/library/safe.tcl index 96177d5..48cb0de 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -1,9 +1,9 @@ # safe.tcl -- # # This file provide a safe loading/sourcing mechanism for safe interpreters. -# It implements a virtual path mecanism to hide the real pathnames from the -# slave. It runs in a parent interpreter and sets up data structure and -# aliases that will be invoked when used from a slave interpreter. +# It implements a virtual path mechanism to hide the real pathnames from the +# child. It runs in a parent interpreter and sets up data structure and +# aliases that will be invoked when used from a child interpreter. # # See the safe.n man page for details. # @@ -94,12 +94,12 @@ proc ::safe::interpInit {args} { [InterpStatics] [InterpNested] $deleteHook } -# Check that the given slave is "one of us" -proc ::safe::CheckInterp {slave} { - namespace upvar ::safe [VarName $slave] state - if {![info exists state] || ![::interp exists $slave]} { +# Check that the given child is "one of us" +proc ::safe::CheckInterp {child} { + namespace upvar ::safe [VarName $child] state + if {![info exists state] || ![::interp exists $child]} { return -code error \ - "\"$slave\" is not an interpreter managed by ::safe::" + "\"$child\" is not an interpreter managed by ::safe::" } } @@ -121,7 +121,7 @@ proc ::safe::interpConfigure {args} { 1 { # If we have exactly 1 argument the semantic is to return all # the current configuration. We still call OptKeyParse though - # we know that "slave" is our given argument because it also + # we know that "child" is our given argument because it also # checks for the "-help" option. set Args [::tcl::OptKeyParse ::safe::interpIC $args] CheckInterp $slave @@ -220,7 +220,7 @@ proc ::safe::interpConfigure {args} { } # we can now reconfigure : InterpSetConfig $slave $accessPath $statics $nested $deleteHook - # auto_reset the slave (to completly synch the new access_path) + # auto_reset the child (to completly synch the new access_path) if {$doreset} { if {[catch {::interp eval $slave {auto_reset}} msg]} { Log $slave "auto_reset failed: $msg" @@ -260,15 +260,15 @@ proc ::safe::interpConfigure {args} { # # safe::InterpCreate : doing the real job # -# This procedure creates a safe slave and initializes it with the safe +# This procedure creates a safe child and initializes it with the safe # base aliases. -# NB: slave name must be simple alphanumeric string, no spaces, no (), no +# NB: child name must be simple alphanumeric string, no spaces, no (), no # {},... {because the state array is stored as part of the name} # -# Returns the slave name. +# Returns the child name. # # Optional Arguments : -# + slave name : if empty, generated name will be used +# + child name : if empty, generated name will be used # + access_path: path list controlling where load/source can occur, # if empty: the parent auto_path will be used. # + staticsok : flag, if 0 :no static package can be loaded (load {} Xxx) @@ -278,37 +278,37 @@ proc ::safe::interpConfigure {args} { # use the full name and no indent so auto_mkIndex can find us proc ::safe::InterpCreate { - slave + child access_path staticsok nestedok deletehook } { - # Create the slave. + # Create the child. # If evaluated in ::safe, the interpreter command for foo is ::foo; # but for foo::bar is safe::foo::bar. So evaluate in :: instead. - if {$slave ne ""} { - namespace eval :: [list ::interp create -safe $slave] + if {$child ne ""} { + namespace eval :: [list ::interp create -safe $child] } else { - # empty argument: generate slave name - set slave [::interp create -safe] + # empty argument: generate child name + set child [::interp create -safe] } - Log $slave "Created" NOTICE + Log $child "Created" NOTICE - # Initialize it. (returns slave name) - InterpInit $slave $access_path $staticsok $nestedok $deletehook + # Initialize it. (returns child name) + InterpInit $child $access_path $staticsok $nestedok $deletehook } # # InterpSetConfig (was setAccessPath) : -# Sets up slave virtual auto_path and corresponding structure within -# the parent. Also sets the tcl_library in the slave to be the first +# Sets up child virtual auto_path and corresponding structure within +# the parent. Also sets the tcl_library in the child to be the first # directory in the path. -# NB: If you change the path after the slave has been initialized you -# probably need to call "auto_reset" in the slave in order that it gets +# NB: If you change the path after the child has been initialized you +# probably need to call "auto_reset" in the child in order that it gets # the right auto_index() array values. -proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { +proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} { global auto_path # determine and store the access path if empty @@ -321,33 +321,33 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { if {$where == -1} { # not found, add it. set access_path [linsert $access_path 0 [info library]] - Log $slave "tcl_library was not in auto_path,\ + Log $child "tcl_library was not in auto_path,\ added it to slave's access_path" NOTICE } elseif {$where != 0} { # not first, move it first set access_path [linsert \ [lreplace $access_path $where $where] \ 0 [info library]] - Log $slave "tcl_libray was not in first in auto_path,\ + Log $child "tcl_libray was not in first in auto_path,\ moved it to front of slave's access_path" NOTICE } # Add 1st level sub dirs (will searched by auto loading from tcl - # code in the slave using glob and thus fail, so we add them here + # code in the child using glob and thus fail, so we add them here # so by default it works the same). set access_path [AddSubDirs $access_path] } - Log $slave "Setting accessPath=($access_path) staticsok=$staticsok\ + Log $child "Setting accessPath=($access_path) staticsok=$staticsok\ nestedok=$nestedok deletehook=($deletehook)" NOTICE - namespace upvar ::safe [VarName $slave] state + namespace upvar ::safe [VarName $child] state # clear old autopath if it existed # build new one # Extend the access list with the paths used to look for Tcl Modules. # We save the virtual form separately as well, as syncing it with the - # slave has to be defered until the necessary commands are present for + # child has to be deferred until the necessary commands are present for # setup. set norm_access_path {} @@ -420,7 +420,7 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { set state(nestedok) $nestedok set state(cleanupHook) $deletehook - SyncAccessPath $slave + SyncAccessPath $child return } @@ -429,9 +429,9 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} { # FindInAccessPath: # Search for a real directory and returns its virtual Id (including the # "$") -proc ::safe::interpFindInAccessPath {slave path} { - CheckInterp $slave - namespace upvar ::safe [VarName $slave] state +proc ::safe::interpFindInAccessPath {child path} { + CheckInterp $child + namespace upvar ::safe [VarName $child] state if {![dict exists $state(access_path,remap) $path]} { return -code error "$path not found in access path" @@ -444,11 +444,11 @@ proc ::safe::interpFindInAccessPath {slave path} { # addToAccessPath: # add (if needed) a real directory to access path and return its # virtual token (including the "$"). -proc ::safe::interpAddToAccessPath {slave path} { +proc ::safe::interpAddToAccessPath {child path} { # first check if the directory is already in there # (inlined interpFindInAccessPath). - CheckInterp $slave - namespace upvar ::safe [VarName $slave] state + CheckInterp $child + namespace upvar ::safe [VarName $child] state if {[dict exists $state(access_path,remap) $path]} { return [dict get $state(access_path,remap) $path] @@ -463,7 +463,7 @@ proc ::safe::interpAddToAccessPath {slave path} { lappend state(access_path,remap) $path $token lappend state(access_path,norm) [file normalize $path] - SyncAccessPath $slave + SyncAccessPath $child return $token } @@ -471,25 +471,25 @@ proc ::safe::interpAddToAccessPath {slave path} { # interpreter. It is useful when you want to install the safe base aliases # into a preexisting safe interpreter. proc ::safe::InterpInit { - slave + child access_path staticsok nestedok deletehook } { # Configure will generate an access_path when access_path is empty. - InterpSetConfig $slave $access_path $staticsok $nestedok $deletehook + InterpSetConfig $child $access_path $staticsok $nestedok $deletehook # NB we need to add [namespace current], aliases are always absolute # paths. - # These aliases let the slave load files to define new commands - # This alias lets the slave use the encoding names, convertfrom, + # These aliases let the child load files to define new commands + # This alias lets the child use the encoding names, convertfrom, # convertto, and system, but not "encoding system " to set the # system encoding. # Handling Tcl Modules, we need a restricted form of Glob. # This alias interposes on the 'exit' command and cleanly terminates - # the slave. + # the child. foreach {command alias} { source AliasSource @@ -498,61 +498,61 @@ proc ::safe::InterpInit { exit interpDelete glob AliasGlob } { - ::interp alias $slave $command {} [namespace current]::$alias $slave + ::interp alias $child $command {} [namespace current]::$alias $child } - # This alias lets the slave have access to a subset of the 'file' + # This alias lets the child have access to a subset of the 'file' # command functionality. - ::interp expose $slave file + ::interp expose $child file foreach subcommand {dirname extension rootname tail} { - ::interp alias $slave ::tcl::file::$subcommand {} \ - ::safe::AliasFileSubcommand $slave $subcommand + ::interp alias $child ::tcl::file::$subcommand {} \ + ::safe::AliasFileSubcommand $child $subcommand } foreach subcommand { atime attributes copy delete executable exists isdirectory isfile link lstat mtime mkdir nativename normalize owned readable readlink rename size stat tempfile type volumes writable } { - ::interp alias $slave ::tcl::file::$subcommand {} \ - ::safe::BadSubcommand $slave file $subcommand + ::interp alias $child ::tcl::file::$subcommand {} \ + ::safe::BadSubcommand $child file $subcommand } # Subcommands of info foreach {subcommand alias} { nameofexecutable AliasExeName } { - ::interp alias $slave ::tcl::info::$subcommand \ - {} [namespace current]::$alias $slave + ::interp alias $child ::tcl::info::$subcommand \ + {} [namespace current]::$alias $child } - # The allowed slave variables already have been set by Tcl_MakeSafe(3) + # The allowed child variables already have been set by Tcl_MakeSafe(3) - # Source init.tcl and tm.tcl into the slave, to get auto_load and + # Source init.tcl and tm.tcl into the child, to get auto_load and # other procedures defined: - if {[catch {::interp eval $slave { + if {[catch {::interp eval $child { source [file join $tcl_library init.tcl] }} msg opt]} { - Log $slave "can't source init.tcl ($msg)" - return -options $opt "can't source init.tcl into slave $slave ($msg)" + Log $child "can't source init.tcl ($msg)" + return -options $opt "can't source init.tcl into slave $child ($msg)" } - if {[catch {::interp eval $slave { + if {[catch {::interp eval $child { source [file join $tcl_library tm.tcl] }} msg opt]} { - Log $slave "can't source tm.tcl ($msg)" - return -options $opt "can't source tm.tcl into slave $slave ($msg)" + Log $child "can't source tm.tcl ($msg)" + return -options $opt "can't source tm.tcl into slave $child ($msg)" } # Sync the paths used to search for Tcl modules. This can be done only # now, after tm.tcl was loaded. - namespace upvar ::safe [VarName $slave] state + namespace upvar ::safe [VarName $child] state if {[llength $state(tm_path_slave)] > 0} { - ::interp eval $slave [list \ + ::interp eval $child [list \ ::tcl::tm::add {*}[lreverse $state(tm_path_slave)]] } - return $slave + return $child } # Add (only if needed, avoid duplicates) 1 level of sub directories to an @@ -578,30 +578,30 @@ proc ::safe::AddSubDirs {pathList} { return $res } -# This procedure deletes a safe slave managed by Safe Tcl and cleans up +# This procedure deletes a safe child managed by Safe Tcl and cleans up # associated state. # - The command will also delete non-Safe-Base interpreters. # - This is regrettable, but to avoid breaking existing code this should be # amended at the next major revision by uncommenting "CheckInterp". -proc ::safe::interpDelete {slave} { - Log $slave "About to delete" NOTICE +proc ::safe::interpDelete {child} { + Log $child "About to delete" NOTICE - # CheckInterp $slave - namespace upvar ::safe [VarName $slave] state + # CheckInterp $child + namespace upvar ::safe [VarName $child] state # When an interpreter is deleted with [interp delete], any sub-interpreters # are deleted automatically, but this leaves behind their data in the Safe # Base. To clean up properly, we call safe::interpDelete recursively on each # Safe Base sub-interpreter, so each one is deleted cleanly and not by # the automatic mechanism built into [interp delete]. - foreach sub [interp children $slave] { - if {[info exists ::safe::[VarName [list $slave $sub]]]} { - ::safe::interpDelete [list $slave $sub] + foreach sub [interp children $child] { + if {[info exists ::safe::[VarName [list $child $sub]]]} { + ::safe::interpDelete [list $child $sub] } } - # If the slave has a cleanup hook registered, call it. Check the + # If the child has a cleanup hook registered, call it. Check the # existance because we might be called to delete an interp which has # not been registered with us at all @@ -612,14 +612,14 @@ proc ::safe::interpDelete {slave} { # we'll loop unset state(cleanupHook) try { - {*}$hook $slave + {*}$hook $child } on error err { - Log $slave "Delete hook error ($err)" + Log $child "Delete hook error ($err)" } } } - # Discard the global array of state associated with the slave, and + # Discard the global array of state associated with the child, and # delete the interpreter. if {[info exists state]} { @@ -628,9 +628,9 @@ proc ::safe::interpDelete {slave} { # if we have been called twice, the interp might have been deleted # already - if {[::interp exists $slave]} { - ::interp delete $slave - Log $slave "Deleted" NOTICE + if {[::interp exists $child]} { + ::interp delete $child + Log $child "Deleted" NOTICE } return @@ -656,9 +656,9 @@ proc ::safe::setLogCmd {args} { } else { # Activate logging, define proper command. - proc ::safe::Log {slave msg {type ERROR}} { + proc ::safe::Log {child msg {type ERROR}} { variable Log - {*}$Log "$type for slave $slave : $msg" + {*}$Log "$type for slave $child : $msg" return } } @@ -667,23 +667,23 @@ proc ::safe::setLogCmd {args} { # ------------------- END OF PUBLIC METHODS ------------ # -# Sets the slave auto_path to the parent recorded value. Also sets +# Sets the child auto_path to the parent recorded value. Also sets # tcl_library to the first token of the virtual path. # -proc ::safe::SyncAccessPath {slave} { - namespace upvar ::safe [VarName $slave] state +proc ::safe::SyncAccessPath {child} { + namespace upvar ::safe [VarName $child] state set slave_access_path $state(access_path,slave) - ::interp eval $slave [list set auto_path $slave_access_path] + ::interp eval $child [list set auto_path $slave_access_path] - Log $slave "auto_path in $slave has been set to $slave_access_path"\ + Log $child "auto_path in $child has been set to $slave_access_path"\ NOTICE # This code assumes that info library is the first element in the # list of auto_path's. See -> InterpSetConfig for the code which # ensures this condition. - ::interp eval $slave [list \ + ::interp eval $child [list \ set tcl_library [lindex $slave_access_path 0]] } @@ -697,8 +697,8 @@ proc ::safe::PathToken {n} { # # translate virtual path into real path # -proc ::safe::TranslatePath {slave path} { - namespace upvar ::safe [VarName $slave] state +proc ::safe::TranslatePath {child path} { + namespace upvar ::safe [VarName $child] state # somehow strip the namespaces 'functionality' out (the danger is that # we would strip valid macintosh "../" queries... : @@ -713,7 +713,7 @@ proc ::safe::TranslatePath {slave path} { # file name control (limit access to files/resources that should be a # valid tcl source file) -proc ::safe::CheckFileName {slave file} { +proc ::safe::CheckFileName {child file} { # This used to limit what can be sourced to ".tcl" and forbid files # with more than 1 dot and longer than 14 chars, but I changed that # for 8.4 as a safe interp has enough internal protection already to @@ -734,17 +734,17 @@ proc ::safe::CheckFileName {slave file} { # interpreters that are *almost* safe. In particular, it just acts to # prevent discovery of what home directories exist. -proc ::safe::AliasFileSubcommand {slave subcommand name} { +proc ::safe::AliasFileSubcommand {child subcommand name} { if {[string match ~* $name]} { set name ./$name } - tailcall ::interp invokehidden $slave tcl:file:$subcommand $name + tailcall ::interp invokehidden $child tcl:file:$subcommand $name } # AliasGlob is the target of the "glob" alias in safe interpreters. -proc ::safe::AliasGlob {slave args} { - Log $slave "GLOB ! $args" NOTICE +proc ::safe::AliasGlob {child args} { + Log $child "GLOB ! $args" NOTICE set cmd {} set at 0 array set got { @@ -789,7 +789,7 @@ proc ::safe::AliasGlob {slave args} { incr at } -* { - Log $slave "Safe base rejecting glob option '$opt'" + Log $child "Safe base rejecting glob option '$opt'" return -code error "Safe base rejecting glob option '$opt'" } default { @@ -800,14 +800,14 @@ proc ::safe::AliasGlob {slave args} { } # Get the real path from the virtual one and check that the path is in the - # access path of that slave. Done after basic argument processing so that + # access path of that child. Done after basic argument processing so that # we know if -nocomplain is set. if {$got(-directory)} { try { - set dir [TranslatePath $slave $virtualdir] - DirInAccessPath $slave $dir + set dir [TranslatePath $child $virtualdir] + DirInAccessPath $child $dir } on error msg { - Log $slave $msg + Log $child $msg if {$got(-nocomplain)} return return -code error "permission denied" } @@ -820,7 +820,7 @@ proc ::safe::AliasGlob {slave args} { # The code after this "if ... else" block would conspire to return with # no results in this case, if it were allowed to proceed. Instead, # return now and reduce the number of cases to be considered later. - Log $slave {option -directory must be supplied} + Log $child {option -directory must be supplied} if {$got(-nocomplain)} return return -code error "permission denied" } @@ -846,11 +846,11 @@ proc ::safe::AliasGlob {slave args} { # after removing any subdir that are not in the access path. if {($thedir eq "*") && ($thefile eq "pkgIndex.tcl")} { set mapped 0 - foreach d [glob -directory [TranslatePath $slave $virtualdir] \ + foreach d [glob -directory [TranslatePath $child $virtualdir] \ -types d -tails *] { catch { - DirInAccessPath $slave \ - [TranslatePath $slave [file join $virtualdir $d]] + DirInAccessPath $child \ + [TranslatePath $child [file join $virtualdir $d]] lappend cmd [file join $d $thefile] set mapped 1 } @@ -876,17 +876,17 @@ proc ::safe::AliasGlob {slave args} { # - Bug [3529949] relates to unwanted expansion of ~${foo} and this is # how the present code avoids the bug. All tests safe-16.* relate. try { - DirInAccessPath $slave [TranslatePath $slave \ + DirInAccessPath $child [TranslatePath $child \ [file join $virtualdir $thedir]] } on error msg { - Log $slave $msg + Log $child $msg if {$got(-nocomplain)} continue return -code error "permission denied" } lappend cmd $opt } - Log $slave "GLOB = $cmd" NOTICE + Log $child "GLOB = $cmd" NOTICE if {$got(-nocomplain) && [llength $cmd] eq $firstPattern} { return @@ -899,17 +899,17 @@ proc ::safe::AliasGlob {slave args} { # which are a list of names each with tail pkgIndex.tcl. The purpose # of the call to glob is to remove the names for which the file does # not exist. - set entries [::interp invokehidden $slave glob {*}$cmd] + set entries [::interp invokehidden $child glob {*}$cmd] } on error msg { # This is the only place that a call with -nocomplain and no invalid # "dash-options" can return an error. - Log $slave $msg + Log $child $msg return -code error "script error" } - Log $slave "GLOB < $entries" NOTICE + Log $child "GLOB < $entries" NOTICE - # Translate path back to what the slave should see. + # Translate path back to what the child should see. set res {} set l [string length $dir] foreach p $entries { @@ -919,13 +919,13 @@ proc ::safe::AliasGlob {slave args} { lappend res $p } - Log $slave "GLOB > $res" NOTICE + Log $child "GLOB > $res" NOTICE return $res } # AliasSource is the target of the "source" alias in safe interpreters. -proc ::safe::AliasSource {slave args} { +proc ::safe::AliasSource {child args} { set argc [llength $args] # Extended for handling of Tcl Modules to allow not only "source # filename", but "source -encoding E filename" as well. @@ -934,7 +934,7 @@ proc ::safe::AliasSource {slave args} { set encoding [lindex $args 1] set at 2 if {$encoding eq "identity"} { - Log $slave "attempt to use the identity encoding" + Log $child "attempt to use the identity encoding" return -code error "permission denied" } } else { @@ -943,24 +943,24 @@ proc ::safe::AliasSource {slave args} { } if {$argc != 1} { set msg "wrong # args: should be \"source ?-encoding E? fileName\"" - Log $slave "$msg ($args)" + Log $child "$msg ($args)" return -code error $msg } set file [lindex $args $at] # get the real path from the virtual one. if {[catch { - set realfile [TranslatePath $slave $file] + set realfile [TranslatePath $child $file] } msg]} { - Log $slave $msg + Log $child $msg return -code error "permission denied" } - # check that the path is in the access path of that slave + # check that the path is in the access path of that child if {[catch { - FileInAccessPath $slave $realfile + FileInAccessPath $child $realfile } msg]} { - Log $slave $msg + Log $child $msg return -code error "permission denied" } @@ -969,16 +969,16 @@ proc ::safe::AliasSource {slave args} { # to tclLog. Has no effect on other callers of ::source, which are in # "package ifneeded" scripts. if {[catch { - CheckFileName $slave $realfile + CheckFileName $child $realfile } msg]} { - Log $slave "$realfile:$msg" + Log $child "$realfile:$msg" return -code error -errorcode {POSIX EACCES} $msg } # Passed all the tests, lets source it. Note that we do this all manually - # because we want to control [info script] in the slave so information + # because we want to control [info script] in the child so information # doesn't leak so much. [Bug 2913625] - set old [::interp eval $slave {info script}] + set old [::interp eval $child {info script}] set replacementMsg "script error" set code [catch { set f [open $realfile] @@ -988,17 +988,17 @@ proc ::safe::AliasSource {slave args} { } set contents [read $f] close $f - ::interp eval $slave [list info script $file] + ::interp eval $child [list info script $file] } msg opt] if {$code == 0} { - set code [catch {::interp eval $slave $contents} msg opt] + set code [catch {::interp eval $child $contents} msg opt] set replacementMsg $msg } - catch {interp eval $slave [list info script $old]} + catch {interp eval $child [list info script $old]} # Note that all non-errors are fine result codes from [source], so we must # take a little care to do it properly. [Bug 2923613] if {$code == 1} { - Log $slave $msg + Log $child $msg return -code error $replacementMsg } return -code $code -options $opt $msg @@ -1006,18 +1006,18 @@ proc ::safe::AliasSource {slave args} { # AliasLoad is the target of the "load" alias in safe interpreters. -proc ::safe::AliasLoad {slave file args} { +proc ::safe::AliasLoad {child file args} { set argc [llength $args] if {$argc > 2} { set msg "load error: too many arguments" - Log $slave "$msg ($argc) {$file $args}" + Log $child "$msg ($argc) {$file $args}" return -code error $msg } # package name (can be empty if file is not). set package [lindex $args 0] - namespace upvar ::safe [VarName $slave] state + namespace upvar ::safe [VarName $child] state # Determine where to load. load use a relative interp path and {} # means self, so we can directly and safely use passed arg. @@ -1026,7 +1026,7 @@ proc ::safe::AliasLoad {slave file args} { # we will try to load into a sub sub interp; check that we want to # authorize that. if {!$state(nestedok)} { - Log $slave "loading to a sub interp (nestedok)\ + Log $child "loading to a sub interp (nestedok)\ disabled (trying to load $package to $target)" return -code error "permission denied (nested load)" } @@ -1037,11 +1037,11 @@ proc ::safe::AliasLoad {slave file args} { # static package loading if {$package eq ""} { set msg "load error: empty filename and no package name" - Log $slave $msg + Log $child $msg return -code error $msg } if {!$state(staticsok)} { - Log $slave "static packages loading disabled\ + Log $child "static packages loading disabled\ (trying to load $package to $target)" return -code error "permission denied (static package)" } @@ -1050,23 +1050,23 @@ proc ::safe::AliasLoad {slave file args} { # get the real path from the virtual one. try { - set file [TranslatePath $slave $file] + set file [TranslatePath $child $file] } on error msg { - Log $slave $msg + Log $child $msg return -code error "permission denied" } # check the translated path try { - FileInAccessPath $slave $file + FileInAccessPath $child $file } on error msg { - Log $slave $msg + Log $child $msg return -code error "permission denied (path)" } } try { - return [::interp invokehidden $slave load $file $package $target] + return [::interp invokehidden $child load $file $package $target] } on error msg { # Some packages return no error message. set msg0 "load of binary library for package $package failed" @@ -1075,18 +1075,18 @@ proc ::safe::AliasLoad {slave file args} { } else { set msg "$msg0: $msg" } - Log $slave $msg + Log $child $msg return -code error $msg } } # FileInAccessPath raises an error if the file is not found in the list of -# directories contained in the (parent side recorded) slave's access path. +# directories contained in the (parent side recorded) child's access path. # the security here relies on "file dirname" answering the proper # result... needs checking ? -proc ::safe::FileInAccessPath {slave file} { - namespace upvar ::safe [VarName $slave] state +proc ::safe::FileInAccessPath {child file} { + namespace upvar ::safe [VarName $child] state set access_path $state(access_path) if {[file isdirectory $file]} { @@ -1098,14 +1098,14 @@ proc ::safe::FileInAccessPath {slave file} { # potential pathname anomalies. set norm_parent [file normalize $parent] - namespace upvar ::safe [VarName $slave] state + namespace upvar ::safe [VarName $child] state if {$norm_parent ni $state(access_path,norm)} { return -code error "\"$file\": not in access_path" } } -proc ::safe::DirInAccessPath {slave dir} { - namespace upvar ::safe [VarName $slave] state +proc ::safe::DirInAccessPath {child dir} { + namespace upvar ::safe [VarName $child] state set access_path $state(access_path) if {[file isfile $dir]} { @@ -1116,7 +1116,7 @@ proc ::safe::DirInAccessPath {slave dir} { # potential pathname anomalies. set norm_dir [file normalize $dir] - namespace upvar ::safe [VarName $slave] state + namespace upvar ::safe [VarName $child] state if {$norm_dir ni $state(access_path,norm)} { return -code error "\"$dir\": not in access_path" } @@ -1125,16 +1125,16 @@ proc ::safe::DirInAccessPath {slave dir} { # This procedure is used to report an attempt to use an unsafe member of an # ensemble command. -proc ::safe::BadSubcommand {slave command subcommand args} { +proc ::safe::BadSubcommand {child command subcommand args} { set msg "not allowed to invoke subcommand $subcommand of $command" - Log $slave $msg + Log $child $msg return -code error -errorcode {TCL SAFE SUBCOMMAND} $msg } # AliasEncoding is the target of the "encoding" alias in safe interpreters. -proc ::safe::AliasEncoding {slave option args} { - # Note that [encoding dirs] is not supported in safe slaves at all +proc ::safe::AliasEncoding {child option args} { + # Note that [encoding dirs] is not supported in safe children at all set subcommands {convertfrom convertto names system} try { set option [tcl::prefix match -error [list -level 1 -errorcode \ @@ -1145,15 +1145,15 @@ proc ::safe::AliasEncoding {slave option args} { "wrong # args: should be \"encoding system\"" } } on error {msg options} { - Log $slave $msg + Log $child $msg return -options $options $msg } - tailcall ::interp invokehidden $slave encoding $option {*}$args + tailcall ::interp invokehidden $child encoding $option {*}$args } # Various minor hiding of platform features. [Bug 2913625] -proc ::safe::AliasExeName {slave} { +proc ::safe::AliasExeName {child} { return "" } @@ -1184,17 +1184,17 @@ proc ::safe::AliasExeName {slave} { # fails. # So we choose (a). # (7) The command -# namespace upvar ::safe S$slave state +# namespace upvar ::safe S$child state # becomes -# namespace upvar ::safe [VarName $slave] state +# namespace upvar ::safe [VarName $child] state # ------------------------------------------------------------------------------ -proc ::safe::RejectExcessColons {slave} { - set stripped [regsub -all -- {:::*} $slave ::] +proc ::safe::RejectExcessColons {child} { + set stripped [regsub -all -- {:::*} $child ::] if {[string range $stripped end-1 end] eq {::}} { return -code error {interpreter name must not end in "::"} } - if {$stripped ne $slave} { + if {$stripped ne $child} { set msg {interpreter name has excess colons in namespace separators} return -code error $msg } @@ -1204,9 +1204,9 @@ proc ::safe::RejectExcessColons {slave} { return } -proc ::safe::VarName {slave} { - # return S$slave - return S[string map {:: @N @ @A} $slave] +proc ::safe::VarName {child} { + # return S$child + return S[string map {:: @N @ @A} $child] } proc ::safe::Setup {} { @@ -1267,20 +1267,20 @@ namespace eval ::safe { # Log command, set via 'setLogCmd'. Logging is disabled when empty. variable Log {} - # The package maintains a state array per slave interp under its + # The package maintains a state array per child interp under its # control. The name of this array is S. This array is # brought into scope where needed, using 'namespace upvar'. The S - # prefix is used to avoid that a slave interp called "Log" smashes + # prefix is used to avoid that a child interp called "Log" smashes # the "Log" variable. # # The array's elements are: # - # access_path : List of paths accessible to the slave. + # access_path : List of paths accessible to the child. # access_path,norm : Ditto, in normalized form. - # access_path,slave : Ditto, as the path tokens as seen by the slave. + # access_path,slave : Ditto, as the path tokens as seen by the child. # access_path,map : dict ( token -> path ) # access_path,remap : dict ( path -> token ) - # tm_path_slave : List of TM root directories, as tokens seen by the slave. + # tm_path_slave : List of TM root directories, as tokens seen by the child. # staticsok : Value of option -statics # nestedok : Value of option -nested # cleanupHook : Value of option -deleteHook diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 8d961ae..898d076 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -2109,13 +2109,13 @@ test iocmd-32.2 {delete interp of reflected chan} { # Bug 3034840 # Run this test in an interp with memory debugging to panic # on the double free - interp create slave - slave eval { + interp create child + child eval { proc no-op args {} proc driver {sub args} {return {initialize finalize watch read}} chan event [chan create read driver] readable no-op } - interp delete slave + interp delete child } {} # ### ### ### ######### ######### ######### diff --git a/tests/ioTrans.test b/tests/ioTrans.test index 2872fbb..f185117 100644 --- a/tests/ioTrans.test +++ b/tests/ioTrans.test @@ -1244,16 +1244,16 @@ test iortrans-11.1 {origin interpreter of moved transform destroyed during acces tempdone } -result {Owner lost} test iortrans-11.2 {delete interp of reflected transform} -setup { - interp create slave - # Magic to get the test* commands into the slave - load {} Tcltest slave + interp create child + # Magic to get the test* commands into the child + load {} Tcltest child } -constraints {testchannel} -body { - # Get base channel into the slave + # Get base channel into the child set c [tempchan] testchannel cut $c - interp eval slave [list testchannel splice $c] - interp eval slave [list set c $c] - slave eval { + interp eval child [list testchannel splice $c] + interp eval child [list set c $c] + child eval { proc no-op args {} proc driver {c sub args} { return {initialize finalize read write} @@ -1261,7 +1261,7 @@ test iortrans-11.2 {delete interp of reflected transform} -setup { set t [chan push $c [list driver $c]] chan event $c readable no-op } - interp delete slave + interp delete child } -cleanup { tempdone } -result {} diff --git a/tests/oo.test b/tests/oo.test index 94537b7..43aa608 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -1370,16 +1370,16 @@ test oo-7.8 {OO: next at the end of the method chain} -setup { } -result {foo2 foo 1 {no next method implementation}} test oo-7.9 {OO: defining inheritance in namespaces} -setup { set ::result {} - oo::class create ::master + oo::class create ::parent namespace eval ::foo { - oo::class create mixin {superclass ::master} + oo::class create mixin {superclass ::parent} } } -cleanup { - ::master destroy + ::parent destroy namespace delete ::foo } -body { namespace eval ::foo { - oo::class create bar {superclass master} + oo::class create bar {superclass parent} oo::class create boo oo::define boo {superclass bar} oo::define boo {mixin mixin} @@ -2066,18 +2066,18 @@ test oo-14.5 {OO and mixins and filters - advanced case} -setup { mix destroy } -result >>foobar<< test oo-14.6 {OO and mixins of mixins - Bug 1960703} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create A { - superclass master + superclass parent method egg {} { return chicken } } oo::class create B { - superclass master + superclass parent mixin A method bar {} { # mixin from A @@ -2085,7 +2085,7 @@ test oo-14.6 {OO and mixins of mixins - Bug 1960703} -setup { } } oo::class create C { - superclass master + superclass parent mixin B method foo {} { # mixin from B @@ -2095,12 +2095,12 @@ test oo-14.6 {OO and mixins of mixins - Bug 1960703} -setup { [C new] foo } -result chicken test oo-14.7 {OO and filters from mixins of mixins} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create A { - superclass master + superclass parent method egg {} { return chicken } @@ -2111,7 +2111,7 @@ test oo-14.7 {OO and filters from mixins of mixins} -setup { } } oo::class create B { - superclass master + superclass parent mixin A filter f method bar {} { @@ -2120,7 +2120,7 @@ test oo-14.7 {OO and filters from mixins of mixins} -setup { } } oo::class create C { - superclass master + superclass parent mixin B filter f method foo {} { @@ -2132,18 +2132,18 @@ test oo-14.7 {OO and filters from mixins of mixins} -setup { } -result {(foo) (bar) (egg) chicken (egg) (bar) (foo)} test oo-14.8 {OO: class mixin order - Bug 1998221} -setup { set ::result {} - oo::class create master { + oo::class create parent { method test {} {} } } -cleanup { - master destroy + parent destroy } -body { oo::class create mix { - superclass master + superclass parent method test {} {lappend ::result mix; next; return $::result} } oo::class create cls { - superclass master + superclass parent mixin mix method test {} {lappend ::result cls; next; return $::result} } @@ -2778,13 +2778,13 @@ test oo-18.7 {OO: objdefine command support} -setup { invoked from within "oo::objdefine inst {rename ::inst ::INST;error foo}"}} test oo-18.8 {OO: define/self command support} -setup { - oo::class create master - oo::class create ::foo {superclass master} + oo::class create parent + oo::class create ::foo {superclass parent} } -body { catch {oo::define foo {rename ::foo ::bar; self {error foobar}}} msg opt dict get $opt -errorinfo } -cleanup { - master destroy + parent destroy } -result {foobar while executing "error foobar" @@ -2795,15 +2795,15 @@ test oo-18.8 {OO: define/self command support} -setup { invoked from within "oo::define foo {rename ::foo ::bar; self {error foobar}}"} test oo-18.9 {OO: define/self command support} -setup { - oo::class create master + oo::class create parent set c [oo::class create now_this_is_a_very_very_long_class_name_indeed { - superclass master + superclass parent }] } -body { catch {oo::define $c {error err}} msg opt dict get $opt -errorinfo } -cleanup { - master destroy + parent destroy } -result {err while executing "error err" @@ -2811,13 +2811,13 @@ test oo-18.9 {OO: define/self command support} -setup { invoked from within "oo::define $c {error err}"} test oo-18.10 {OO: define/self command support} -setup { - oo::class create master - oo::class create ::foo {superclass master} + oo::class create parent + oo::class create ::foo {superclass parent} } -body { catch {oo::define foo {self {rename ::foo {}; error foobar}}} msg opt dict get $opt -errorinfo } -cleanup { - master destroy + parent destroy } -result {foobar while executing "error foobar" @@ -2828,13 +2828,13 @@ test oo-18.10 {OO: define/self command support} -setup { invoked from within "oo::define foo {self {rename ::foo {}; error foobar}}"} test oo-18.11 {OO: define/self command support} -setup { - oo::class create master - oo::class create ::foo {superclass master} + oo::class create parent + oo::class create ::foo {superclass parent} } -body { catch {oo::define foo {rename ::foo {}; self {error foobar}}} msg opt dict get $opt -errorinfo } -cleanup { - master destroy + parent destroy } -result {this command cannot be called when the object has been deleted while executing "self {error foobar}" @@ -3457,12 +3457,12 @@ test oo-27.2 {variables declaration - object introspection} -setup { info object variables foo } -result {a b c} test oo-27.3 {variables declaration - basic behaviour} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x! constructor {} {set x! 1} method y {} {incr x!} @@ -3472,13 +3472,13 @@ test oo-27.3 {variables declaration - basic behaviour} -setup { bar y } -result 3 test oo-27.4 {variables declaration - destructors too} -setup { - oo::class create master + oo::class create parent set result bad! } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x! constructor {} {set x! 1} method y {} {incr x!} @@ -3503,12 +3503,12 @@ test oo-27.5 {variables declaration - object-bound variables} -setup { foo y } -result 2 test oo-27.6 {variables declaration - non-interference of levels} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x! constructor {} {set x! 1} method y {} {incr x!} @@ -3523,12 +3523,12 @@ test oo-27.6 {variables declaration - non-interference of levels} -setup { list [bar y] [lsort [info object vars bar]] [bar eval {info vars *!}] } -result {{3 2 y! {}} {x! y!} {x! y!}} test oo-27.7 {variables declaration - one underlying variable space} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x! constructor {} {set x! 1} method y {} {incr x!} @@ -3555,12 +3555,12 @@ test oo-27.9 {variables declaration - error cases - arrays} -body { oo::define oo::object variable bad(var) } -returnCodes error -result {invalid declared variable name "bad(var)": must not refer to an array element} test oo-27.10 {variables declaration - no instance var leaks with class resolvers} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable clsvar constructor {} { set clsvar 0 @@ -3583,12 +3583,12 @@ test oo-27.10 {variables declaration - no instance var leaks with class resolver list [inst1 value] [inst2 value] } -result {3 2} test oo-27.11 {variables declaration - no instance var leaks with class resolvers} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable clsvar constructor {} { set clsvar 0 @@ -3656,12 +3656,12 @@ test oo-27.13 {variables declaration: Bug 3185009: require refcount management} foo destroy } -result {0 7 1 7 {} 0 1 {can't read "x": no such variable}} test oo-27.14 {variables declaration - multiple use} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x variable y method boo {} { @@ -3672,12 +3672,12 @@ test oo-27.14 {variables declaration - multiple use} -setup { list [bar boo] [bar boo] } -result {1,1 2,2} test oo-27.15 {variables declaration - multiple use} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable variable x y method boo {} { @@ -3688,12 +3688,12 @@ test oo-27.15 {variables declaration - multiple use} -setup { list [bar boo] [bar boo] } -result {1,1 2,2} test oo-27.16 {variables declaration - multiple use} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x variable -clear variable y @@ -3705,12 +3705,12 @@ test oo-27.16 {variables declaration - multiple use} -setup { list [bar boo] [bar boo] } -result {1,1 1,2} test oo-27.17 {variables declaration - multiple use} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x variable -set y method boo {} { @@ -3721,12 +3721,12 @@ test oo-27.17 {variables declaration - multiple use} -setup { list [bar boo] [bar boo] } -result {1,1 1,2} test oo-27.18 {variables declaration - multiple use} -setup { - oo::class create master + oo::class create parent } -cleanup { - master destroy + parent destroy } -body { oo::class create foo { - superclass master + superclass parent variable x variable -? y method boo {} { @@ -3824,12 +3824,12 @@ test oo-27.22 {variables declaration uniqueifies: Bug 3396896} -setup { } -result {v t} test oo-27.23 {variable resolver leakage: Bug 1493a43044} -setup { oo::class create Super - oo::class create Master { + oo::class create parent { superclass Super variable member1 member2 constructor {} { - set member1 master1 - set member2 master2 + set member1 parent1 + set member2 parent2 } method getChild {} { Child new [self] @@ -3850,10 +3850,10 @@ test oo-27.23 {variable resolver leakage: Bug 1493a43044} -setup { method result {} {return $result} } } -body { - [[Master new] getChild] result + [[parent new] getChild] result } -cleanup { Super destroy -} -result {master1 master2 master1 master2 master1 master2 master1 master2} +} -result {parent1 parent2 parent1 parent2 parent1 parent2 parent1 parent2} # A feature that's not supported because the mechanism may change without # warning, but is supposed to work... diff --git a/tests/ooNext2.test b/tests/ooNext2.test index 84a2bdd..0ec7cdd 100644 --- a/tests/ooNext2.test +++ b/tests/ooNext2.test @@ -882,9 +882,9 @@ test oo-call-3.4 {current call introspection: in destructors} -setup { # caller set testopts { -setup { - oo::class create Master + oo::class create Parent oo::class create Foo { - superclass Master + superclass Parent method bar {} { puts abc tailcall puts hi @@ -892,11 +892,11 @@ set testopts { } } oo::class create Foo2 { - superclass Master + superclass Parent } } -cleanup { - Master destroy + Parent destroy } } diff --git a/tests/safe.test b/tests/safe.test index eb4bfaf..b91da86 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -901,7 +901,7 @@ test safe-9.20 {check module loading} -setup { {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\ TESTSDIR/auto0/modules/mod2} -- res0 res1 res2} # - The command safe::InterpSetConfig adds the parent's [tcl::tm::list] in -# tokenized form to the slave's access path, and then adds all the +# tokenized form to the child's access path, and then adds all the # descendants, discovered recursively by using glob. # - The order of the directories in the list returned by glob is system-dependent, # and therefore this is true also for (a) the order of token assignment to diff --git a/tests/socket.test b/tests/socket.test index 4f1a198..5198f4f 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -1838,12 +1838,12 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { } } tcltest::DebugPuts 1 "== test \[$::localhost\]:$port $testmode ==" - set ::master [thread::id] - # helper thread creating async connection and initiating transfer (detach) to master: + set ::parent [thread::id] + # helper thread creating async connection and initiating transfer (detach) to parent: set ::helper [thread::create] thread::send -async $::helper [list \ - lassign [list $::master $::localhost $port $testmode] \ - ::master ::localhost ::port ::testmode + lassign [list $::parent $::localhost $port $testmode] \ + ::parent ::localhost ::port ::testmode ] thread::send -async $::helper { set ::helper [thread::id] @@ -1852,29 +1852,29 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { if {"helper-writable" in $::testmode} {;# to test both sides during connect fileevent $fd writable [list apply {{fd} { if {[thread::id] ne $::helper} { - thread::send -async $::master {set ::count "ERROR: invalid thread, $::helper is expecting"} + thread::send -async $::parent {set ::count "ERROR: invalid thread, $::helper is expecting"} close $fd return } }} $fd] };# thread::detach $fd - thread::send -async $::master [list transf_master $fd {*}$args] + thread::send -async $::parent [list transf_parent $fd {*}$args] } iteration first } - # master proc commiting transfer attempt (attach) and checking acquire was successful: - proc transf_master {fd args} { + # parent proc commiting transfer attempt (attach) and checking acquire was successful: + proc transf_parent {fd args} { tcltest::DebugPuts 1 "** trma / $::count ** $args **" thread::attach $fd - if {"master-close" in $::testmode} {;# to test close during connect + if {"parent-close" in $::testmode} {;# to test close during connect set ::count $::count close $fd return };# fileevent $fd writable [list apply {{fd} { - if {[thread::id] ne $::master} { - thread::send -async $::master {set ::count "ERROR: invalid thread, $::master is expecting"} + if {[thread::id] ne $::parent} { + thread::send -async $::parent {set ::count "ERROR: invalid thread, $::parent is expecting"} close $fd return } @@ -1902,7 +1902,7 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { if {$srvsock ne {}} {close $srvsock} if {[info exists ::helper]} {thread::release -wait $::helper} tcltest::DebugPuts 1 "== stop / $::count ==" - unset -nocomplain ::count ::testmode ::master ::helper + unset -nocomplain ::count ::testmode ::parent ::helper } } test socket_$af-13.2.tr1 {Testing socket transfer between threads during async connect} -body { @@ -1912,12 +1912,12 @@ test socket_$af-13.2.tr2 {Testing socket transfer between threads during async c transf_test {transfer helper-writable} 100 } -result 100 -constraints [list socket supported_$af thread] test socket_$af-13.2.cl1 {Testing socket transfer between threads during async connect} -body { - transf_test {master-close} 100 + transf_test {parent-close} 100 } -result 100 -constraints [list socket supported_$af thread] test socket_$af-13.2.cl2 {Testing socket transfer between threads during async connect} -body { - transf_test {master-close helper-writable} 100 + transf_test {parent-close helper-writable} 100 } -result 100 -constraints [list socket supported_$af thread] -catch {rename transf_master {}} +catch {rename transf_parent {}} rename transf_test {} # ---------------------------------------------------------------------- -- cgit v0.12 From 618c49af4d299c9f0d776e604a1c81dd186b3b2d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 5 Sep 2020 21:33:49 +0000 Subject: Backout [c1a376375e0e6488]: imported namespace ensemble command name distorted during deletion trace on the import. According to Travis, there's a memory leak which needs to be fixed first. --- generic/tclBasic.c | 20 +++++------ generic/tclCompile.c | 2 +- generic/tclEnsemble.c | 8 ++--- generic/tclExecute.c | 20 ++++------- generic/tclInt.h | 38 +++++--------------- generic/tclNamesp.c | 34 +++++++++--------- generic/tclOO.c | 2 +- generic/tclObj.c | 2 +- tests/namespace.test | 96 --------------------------------------------------- 9 files changed, 48 insertions(+), 174 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 75f8527..4cc579b 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -2785,8 +2785,6 @@ TclCreateObjCommandInNs( Command *refCmdPtr = oldRefPtr->importedCmdPtr; dataPtr = (ImportedCmdData*)refCmdPtr->objClientData; - cmdPtr->refCount++; - TclCleanupCommandMacro(dataPtr->realCmdPtr); dataPtr->realCmdPtr = cmdPtr; oldRefPtr = oldRefPtr->nextPtr; } @@ -3376,7 +3374,7 @@ Tcl_GetCommandFullName( * separator, and the command name. */ - if ((cmdPtr != NULL) && TclRoutineHasName(cmdPtr)) { + if (cmdPtr != NULL) { if (cmdPtr->nsPtr != NULL) { Tcl_AppendToObj(objPtr, cmdPtr->nsPtr->fullName, -1); if (cmdPtr->nsPtr != iPtr->globalNsPtr) { @@ -3466,7 +3464,7 @@ Tcl_DeleteCommandFromToken( * and skip nested deletes. */ - if (cmdPtr->flags & CMD_DYING) { + if (cmdPtr->flags & CMD_IS_DELETED) { /* * Another deletion is already in progress. Remove the hash table * entry now, but don't invoke a callback or free the command @@ -3498,7 +3496,7 @@ Tcl_DeleteCommandFromToken( * be ignored. */ - cmdPtr->flags |= CMD_DYING; + cmdPtr->flags |= CMD_IS_DELETED; /* * Call trace functions for the command being deleted. Then delete its @@ -3528,7 +3526,7 @@ Tcl_DeleteCommandFromToken( } /* - * The list of commands exported from the namespace might have changed. + * The list of command exported from the namespace might have changed. * However, we do not need to recompute this just yet; next time we need * the info will be soon enough. */ @@ -3663,7 +3661,7 @@ CallCommandTraces( * While a rename trace is active, we will not process any more rename * traces; while a delete trace is active we will never reach here - * because Tcl_DeleteCommandFromToken checks for the condition - * (cmdPtr->flags & CMD_DYING) and returns immediately when a + * (cmdPtr->flags & CMD_IS_DELETED) and returns immediately when a * command deletion is in progress. For all other traces, delete * traces will not be invoked but a call to TraceCommandProc will * ensure that tracePtr->clientData is freed whenever the command @@ -5216,7 +5214,7 @@ TEOV_RunLeaveTraces( int length; const char *command = TclGetStringFromObj(commandPtr, &length); - if (!(cmdPtr->flags & CMD_DYING)) { + if (!(cmdPtr->flags & CMD_IS_DELETED)) { if (cmdPtr->flags & CMD_HAS_EXEC_TRACES) { traceCode = TclCheckExecutionTraces(interp, command, length, cmdPtr, result, TCL_TRACE_LEAVE_EXEC, objc, objv); @@ -6462,7 +6460,7 @@ TclNREvalObjEx( /* * Shimmer protection! Always pass an unshared obj. The caller could * incr the refCount of objPtr AFTER calling us! To be completely safe - * we always make a copy. The callback takes care of the refCounts for + * we always make a copy. The callback takes care od the refCounts for * both listPtr and objPtr. * * TODO: Create a test to demo this need, or eliminate it. @@ -9515,7 +9513,7 @@ NRCoroutineCallerCallback( SAVE_CONTEXT(corPtr->running); RESTORE_CONTEXT(corPtr->caller); - if (cmdPtr->flags & CMD_DYING) { + if (cmdPtr->flags & CMD_IS_DELETED) { /* * The command was deleted while it was running: wind down the * execEnv, this will do the complete cleanup. RewindCoroutine will @@ -10284,7 +10282,7 @@ TclInfoCoroutineCmd( return TCL_ERROR; } - if (corPtr && !(corPtr->cmdPtr->flags & CMD_DYING)) { + if (corPtr && !(corPtr->cmdPtr->flags & CMD_IS_DELETED)) { Tcl_Obj *namePtr; TclNewObj(namePtr); diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 7d67e12..fd63da3 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1834,7 +1834,7 @@ CompileCmdLiteral( bytes = TclGetStringFromObj(cmdObj, &numBytes); cmdLitIdx = TclRegisterLiteral(envPtr, bytes, numBytes, extraLiteralFlags); - if (cmdPtr && TclRoutineHasName(cmdPtr)) { + if (cmdPtr) { TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr); } TclEmitPush(cmdLitIdx, envPtr); diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 16bf8f7..3c99631 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -3161,7 +3161,7 @@ TclCompileEnsemble( } /* - * Now that the mapping process is done we actually try to compile. + * Now we've done the mapping process, can now actually try to compile. * If there is a subcommand compiler and that successfully produces code, * we'll use that. Otherwise, we fall back to generating opcodes to do the * invoke at runtime. @@ -3261,9 +3261,9 @@ TclAttemptCompileProc( /* * Advance parsePtr->tokenPtr so that it points at the last subcommand. - * This will be wrong but it will not matter, and it will put the - * tokens for the arguments in the right place without the need to - * allocate a synthetic Tcl_Parse struct or copy tokens around. + * This will be wrong, but it will not matter, and it will put the + * tokens for the arguments in the right place without the needed to + * allocate a synthetic Tcl_Parse struct, or copy tokens around. */ for (i = 0; i < depth - 1; i++) { diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 786fffb..0f1c2cc 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4464,7 +4464,7 @@ TEBCresume( CoroutineData *corPtr = iPtr->execEnvPtr->corPtr; TclNewObj(objResultPtr); - if (corPtr && !(corPtr->cmdPtr->flags & CMD_DYING)) { + if (corPtr && !(corPtr->cmdPtr->flags & CMD_IS_DELETED)) { Tcl_GetCommandFullName(interp, (Tcl_Command) corPtr->cmdPtr, objResultPtr); } @@ -4524,18 +4524,6 @@ TEBCresume( TRACE(("\"%.30s\" => ", O2S(OBJ_AT_TOS))); cmd = Tcl_GetCommandFromObj(interp, OBJ_AT_TOS); if (cmd == NULL) { - goto instOriginError; - } - origCmd = TclGetOriginalCommand(cmd); - if (origCmd == NULL) { - origCmd = cmd; - } - - TclNewObj(objResultPtr); - Tcl_GetCommandFullName(interp, origCmd, objResultPtr); - if (TclCheckEmptyString(objResultPtr) == TCL_EMPTYSTRING_YES ) { - Tcl_DecrRefCount(objResultPtr); - instOriginError: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid command name \"%s\"", TclGetString(OBJ_AT_TOS))); DECACHE_STACK_INFO(); @@ -4545,6 +4533,12 @@ TEBCresume( TRACE_APPEND(("ERROR: not command\n")); goto gotError; } + origCmd = TclGetOriginalCommand(cmd); + if (origCmd == NULL) { + origCmd = cmd; + } + TclNewObj(objResultPtr); + Tcl_GetCommandFullName(interp, origCmd, objResultPtr); TRACE_APPEND(("\"%.30s\"", O2S(OBJ_AT_TOS))); NEXT_INST_F(1, 1, 1); } diff --git a/generic/tclInt.h b/generic/tclInt.h index 2f12b8f..792b675 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1707,18 +1707,18 @@ typedef struct Command { /* * Flag bits for commands. * - * CMD_DYING - If 1 the command is in the process of + * CMD_IS_DELETED - Means that the command is in the process of * being deleted (its deleteProc is currently * executing). Other attempts to delete the * command should be ignored. - * CMD_TRACE_ACTIVE - If 1 the trace processing is currently + * CMD_TRACE_ACTIVE - 1 means that trace processing is currently * underway for a rename/delete change. See the * two flags below for which is currently being * processed. - * CMD_HAS_EXEC_TRACES - If 1 means that this command has at least one + * CMD_HAS_EXEC_TRACES - 1 means that this command has at least one * execution trace (as opposed to simple * delete/rename traces) in its tracePtr list. - * CMD_COMPILES_EXPANDED - If 1 this command has a compiler that + * CMD_COMPILES_EXPANDED - 1 means that this command has a compiler that * can handle expansion (provided it is not the * first word). * TCL_TRACE_RENAME - A rename trace is in progress. Further @@ -1728,7 +1728,7 @@ typedef struct Command { * (these last two flags are defined in tcl.h) */ -#define CMD_DYING 0x01 +#define CMD_IS_DELETED 0x01 #define CMD_TRACE_ACTIVE 0x02 #define CMD_HAS_EXEC_TRACES 0x04 #define CMD_COMPILES_EXPANDED 0x08 @@ -4960,30 +4960,10 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; * the internal stubs, but the core can use the macro instead. */ -#define TclCleanupCommandMacro(cmdPtr) \ - do { \ - if ((cmdPtr)->refCount-- <= 1) { \ - ckfree(cmdPtr); \ - } \ - } while (0) - - -/* - * inside this routine crement refCount first incase cmdPtr is replacing itself - */ -#define TclRoutineAssign(location, cmdPtr) \ - do { \ - (cmdPtr)->refCount++; \ - if ((location) != NULL \ - && (location--) <= 1) { \ - ckfree(((location))); \ - } \ - (location) = (cmdPtr); \ - } while (0) - - -#define TclRoutineHasName(cmdPtr) \ - ((cmdPtr)->hPtr != NULL) +#define TclCleanupCommandMacro(cmdPtr) \ + if ((cmdPtr)->refCount-- <= 1) { \ + ckfree(cmdPtr);\ + } /* *---------------------------------------------------------------- diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 673acb0..26dca62 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -1770,8 +1770,6 @@ DoImport( TclInvokeImportedCmd, InvokeImportedNRCmd, dataPtr, DeleteImportedCmd); dataPtr->realCmdPtr = cmdPtr; - /* corresponding decrement is in DeleteImportedCmd */ - cmdPtr->refCount++; dataPtr->selfPtr = (Command *) importedCmd; dataPtr->selfPtr->compileProc = cmdPtr->compileProc; Tcl_DStringFree(&ds); @@ -2079,7 +2077,6 @@ DeleteImportedCmd( prevPtr->nextPtr = refPtr->nextPtr; } ckfree(refPtr); - TclCleanupCommandMacro(realCmdPtr); ckfree(dataPtr); return; } @@ -3891,7 +3888,7 @@ NamespaceOriginCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tcl_Command cmd, origCmd; + Tcl_Command command, origCommand; Tcl_Obj *resultPtr; if (objc != 2) { @@ -3899,29 +3896,30 @@ NamespaceOriginCmd( return TCL_ERROR; } - cmd = Tcl_GetCommandFromObj(interp, objv[1]); - if (cmd == NULL) { - goto namespaceOriginError; - } - origCmd = TclGetOriginalCommand(cmd); - if (origCmd == NULL) { - origCmd = cmd; - } - TclNewObj(resultPtr); - Tcl_GetCommandFullName(interp, origCmd, resultPtr); - if (TclCheckEmptyString(resultPtr) == TCL_EMPTYSTRING_YES ) { - Tcl_DecrRefCount(resultPtr); - namespaceOriginError: + command = Tcl_GetCommandFromObj(interp, objv[1]); + if (command == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid command name \"%s\"", TclGetString(objv[1]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND", TclGetString(objv[1]), NULL); return TCL_ERROR; } + origCommand = TclGetOriginalCommand(command); + TclNewObj(resultPtr); + if (origCommand == NULL) { + /* + * The specified command isn't an imported command. Return the + * command's name qualified by the full name of the namespace it was + * defined in. + */ + + Tcl_GetCommandFullName(interp, command, resultPtr); + } else { + Tcl_GetCommandFullName(interp, origCommand, resultPtr); + } Tcl_SetObjResult(interp, resultPtr); return TCL_OK; } - /* *---------------------------------------------------------------------- diff --git a/generic/tclOO.c b/generic/tclOO.c index 21018ac..85f4470 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -1177,7 +1177,7 @@ ObjectNamespaceDeleted( * freed memory. */ - if (((Command *) oPtr->command)->flags && CMD_DYING) { + if (((Command *) oPtr->command)->flags && CMD_IS_DELETED) { /* * Something has already started the command deletion process. We can * go ahead and clean up the the namespace, diff --git a/generic/tclObj.c b/generic/tclObj.c index 44b2785..dbe6686 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4667,7 +4667,7 @@ SetCmdNameFromAny( * report the failure to find the command as an error. */ - if (cmdPtr == NULL || !TclRoutineHasName(cmdPtr)) { + if (cmdPtr == NULL) { return TCL_ERROR; } diff --git a/tests/namespace.test b/tests/namespace.test index d09a853..8209cf3 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -618,102 +618,6 @@ test namespace-13.2 {DeleteImportedCmd, Bug a4494e28ed} { namespace delete src } {} - -test namespace-13.3 { - deleting origin of import in trace on deletion of import -} -setup { - namespace eval ns0 { - namespace export * - variable res {} - - proc traced {oldname newname op} { - variable res - - lappend res {Is oldname the name of the imported routine?} - set expected [namespace qualifiers [namespace current]::fake]::ns2::ns1 - if {$oldname eq $expected} { - lappend res 1 - } else { - lappend res 0 - } - - lappend res {[namespace which] finds the old name} - set which [namespace which $oldname] - if {$which eq $expected} { - lappend res 1 - } else { - lappend res $which - } - - lappend res {Is origin name correct} - catch { - namespace origin $oldname - } cres copts - set expected [namespace qualifiers [namespace current]::fake]::ns1 - if {$cres eq $expected} { - lappend res 1 - } else { - lappend res $cres - } - - set origin $cres - rename $origin {} - - lappend res {After deletion of the origin is it an error to ask for the origin (compiled)?} - set status [catch { - namespace origin $oldname - } cres copts] - if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { - lappend res 1 - } else { - lappend res $cres - } - - lappend res {After deletion of the origin is it an error to ask for the origin (uncompiled)?} - set status [catch { - namespace eval [namespace current] "namespace origin $oldname" - } cres copts] - if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { - lappend res 1 - } else { - lappend res $cres - } - - lappend res {after deletion of origin, [namespace which] on the imported routine returns the empty string} - set which [namespace which $oldname] - if {$which eq {}} { - lappend res 1 - } else { - lappend res $which - } - - return - } - - } -} -body { - namespace eval ns0::ns1 { - namespace ensemble create - } - - namespace eval ns0::ns2 { - namespace import [namespace parent]::ns1 - trace add command ns1 delete [namespace parent]::traced - rename ns1 {} - } - return $ns0::res -} -cleanup { - namespace delete ns0 -} -result [list \ - {Is oldname the name of the imported routine?} 1 \ - {[namespace which] finds the old name} 1 \ - {Is origin name correct} 1 \ - {After deletion of the origin is it an error to ask for the origin (compiled)?} 1 \ - {After deletion of the origin is it an error to ask for the origin (uncompiled)?} 1 \ - {after deletion of origin, [namespace which] on the imported routine returns the empty string} 1 \ -] - - test namespace-14.1 {TclGetNamespaceForQualName, absolute names} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} variable v 10 -- cgit v0.12 From 264c574c2318f22417646a35593e266af7053952 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 5 Sep 2020 22:10:31 +0000 Subject: ckfree -> Tcl_Free --- generic/tclInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index fc86c21..4632887 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4912,7 +4912,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; #define TclCleanupCommandMacro(cmdPtr) \ if ((cmdPtr)->refCount-- <= 1) { \ - ckfree(cmdPtr);\ + Tcl_Free(cmdPtr);\ } /* -- cgit v0.12 From a7f1b76ad23c4ab5075e330f0034ecfe928fc006 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 7 Sep 2020 11:56:51 +0000 Subject: Backport genStubs.tcl from 8.7. This adds support for MP_WUR, not actually used by Tcl. But could be used in (libtommath-related) extensions --- tools/genStubs.tcl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index 4516010..a4a73ba 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -479,6 +479,8 @@ proc genStubs::makeDecl {name decl index} { if {[info exists stubs($name,deprecated,$index)]} { append text "[string toupper $libraryName]_DEPRECATED(\"$stubs($name,deprecated,$index)\")\n" set line "$rtype" + } elseif {[string range $rtype end-5 end] eq "MP_WUR"} { + set line "$scspec [string trim [string range $rtype 0 end-6]]" } else { set line "$scspec $rtype" } @@ -550,6 +552,9 @@ proc genStubs::makeDecl {name decl index} { append line ")" } } + if {[string range $rtype end-5 end] eq "MP_WUR"} { + append line " MP_WUR" + } return "$text$line;\n" } @@ -613,6 +618,8 @@ proc genStubs::makeSlot {name decl index} { append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") " } elseif {[string range $rtype 0 11] eq "TCL_NORETURN"} { append text "TCL_NORETURN1 " [string trim [string range $rtype 12 end]] " (*" $lfname ") " + } elseif {[string range $rtype end-5 end] eq "MP_WUR"} { + append text [string trim [string range $rtype 0 end-6]] " (*" $lfname ") " } else { append text $rtype " (*" $lfname ") " } @@ -650,6 +657,9 @@ proc genStubs::makeSlot {name decl index} { } } + if {[string range $rtype end-5 end] eq "MP_WUR"} { + append text " MP_WUR" + } append text "; /* $index */\n" return $text } -- cgit v0.12 From 60fde1d90fb5711ebedac2d1429649235c62c844 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 7 Sep 2020 15:11:19 +0000 Subject: Fix "make install" on MacOSX: interp: make-manpage-section: ignoring .VS "TIP 581" after .TP --- doc/interp.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/interp.n b/doc/interp.n index 61aa151..f0a6c5e 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -376,8 +376,8 @@ interpreter is destroyed. Returns a Tcl list of the names of all the child interpreters associated with the interpreter identified by \fIpath\fR. If \fIpath\fR is omitted, the invoking interpreter is used. -.TP .VS "TIP 581" +.TP \fBinterp\fR \fBchildren\fR ?\fIpath\fR? . Synonym for . \fBinterp\fR \fBslaves\fR ?\fIpath\fR? -- cgit v0.12 From f4d0f6366c3f05177907320d459e4df57a3bbe04 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 9 Sep 2020 06:37:45 +0000 Subject: Rename safe-stock86.test to safe-stock.test --- tests/safe-stock.test | 109 +++++++++++++++++++++++++++++++++++++++++++++ tests/safe-stock86.test | 114 ------------------------------------------------ 2 files changed, 109 insertions(+), 114 deletions(-) create mode 100644 tests/safe-stock.test delete mode 100644 tests/safe-stock86.test diff --git a/tests/safe-stock.test b/tests/safe-stock.test new file mode 100644 index 0000000..7be483e --- /dev/null +++ b/tests/safe-stock.test @@ -0,0 +1,109 @@ +# safe-stock.test -- +# +# This file contains tests for safe Tcl that were previously in the file +# safe.test, and use files and packages of stock Tcl 8.6 to perform the tests. +# These files may be changed or disappear in future revisions of Tcl, +# for example package http 1.0 will be removed from Tcl 8.7. +# +# The tests are replaced in safe.tcl with tests that use files provided in the +# tests directory. Test numbering is for comparison with similar tests in +# safe.test. +# +# Sourcing this file into tcl runs the tests and generates output for errors. +# No output means no errors were found. +# +# Copyright (c) 1995-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +if {"::tcltest" ni [namespace children]} { + package require tcltest 2.5 + namespace import -force ::tcltest::* +} + +foreach i [interp children] { + interp delete $i +} + +set SaveAutoPath $::auto_path +set ::auto_path [info library] +set TestsDir [file normalize [file dirname [info script]]] +set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] + +proc mapList {map listIn} { + set listOut {} + foreach element $listIn { + lappend listOut [string map $map $element] + } + return $listOut +} + +# Force actual loading of the safe package because we use un-exported (and +# thus un-autoindexed) APIs in this test result arguments: +catch {safe::interpConfigure} + +# high level general test +test safe-stock-7.1 {tests that everything works at high level, uses http 2} -body { + set i [safe::interpCreate] + # no error shall occur: + # (because the default access_path shall include 1st level sub dirs so + # package require in a child works like in the parent) + set v [interp eval $i {package require http 2}] + # no error shall occur: + interp eval $i {http::config} + safe::interpDelete $i + set v +} -match glob -result 2.* +test safe-stock-7.2 {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p1 + set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # an error shall occur (http is not anymore in the secure 0-level + # provided deep path) + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ + {TCLLIB */dummy/unixlike/test/path} -- {}} +test safe-stock-7.4 {tests specific path and positive search, uses http1.0} -body { + set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] + # should not add anything (p0) + set token1 [safe::interpAddToAccessPath $i [info library]] + # should add as p1 + set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] + set confA [safe::interpConfigure $i] + set mappA [mapList $PathMapp [dict get $confA -accessPath]] + # this time, unlike test safe-stock-7.2, http should be found + list $token1 $token2 -- \ + [catch {interp eval $i {package require http 1}} msg] $msg -- \ + $mappA -- [safe::interpDelete $i] +} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}} + +# The following test checks whether the definition of tcl_endOfWord can be +# obtained from auto_loading. It was previously test "safe-5.1". +test safe-stock-9.8 {test auto-loading in safe interpreters, was test 5.1} -setup { + catch {safe::interpDelete a} + safe::interpCreate a +} -body { + interp eval a {tcl_endOfWord "" 0} +} -cleanup { + safe::interpDelete a +} -result -1 + +set ::auto_path $SaveAutoPath +unset SaveAutoPath TestsDir PathMapp +rename mapList {} + +# cleanup +::tcltest::cleanupTests +return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/safe-stock86.test b/tests/safe-stock86.test deleted file mode 100644 index 402ea31..0000000 --- a/tests/safe-stock86.test +++ /dev/null @@ -1,114 +0,0 @@ -# safe-stock86.test -- -# -# This file contains tests for safe Tcl that were previously in the file -# safe.test, and use files and packages of stock Tcl 8.6 to perform the tests. -# These files may be changed or disappear in future revisions of Tcl, -# for example package http 1.0 will be removed from Tcl 8.7. -# -# The tests are replaced in safe.tcl with tests that use files provided in the -# tests directory. Test numbering is for comparison with similar tests in -# safe.test. -# -# Sourcing this file into tcl runs the tests and generates output for errors. -# No output means no errors were found. -# -# Copyright (c) 1995-1996 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. -# -# See the file "license.terms" for information on usage and redistribution of -# this file, and for a DISCLAIMER OF ALL WARRANTIES. - -if {"::tcltest" ni [namespace children]} { - package require tcltest 2.5 - namespace import -force ::tcltest::* -} - -foreach i [interp children] { - interp delete $i -} - -set SaveAutoPath $::auto_path -set ::auto_path [info library] -set TestsDir [file normalize [file dirname [info script]]] -set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR] - -proc mapList {map listIn} { - set listOut {} - foreach element $listIn { - lappend listOut [string map $map $element] - } - return $listOut -} - -# Force actual loading of the safe package because we use un-exported (and -# thus un-autoindexed) APIs in this test result arguments: -catch {safe::interpConfigure} - -# testing that nested and statics do what is advertised (we use a static -# package - Tcltest - but it might be absent if we're in standard tclsh) - -testConstraint TcltestPackage [expr {![catch {package require Tcltest}]}] - -# high level general test -test safe-stock86-7.1 {tests that everything works at high level, uses http 2} -body { - set i [safe::interpCreate] - # no error shall occur: - # (because the default access_path shall include 1st level sub dirs so - # package require in a child works like in the parent) - set v [interp eval $i {package require http 2}] - # no error shall occur: - interp eval $i {http::config} - safe::interpDelete $i - set v -} -match glob -result 2.* -test safe-stock86-7.2 {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 - set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # an error shall occur (http is not anymore in the secure 0-level - # provided deep path) - list $token1 $token2 -- \ - [catch {interp eval $i {package require http 1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\ - {TCLLIB */dummy/unixlike/test/path} -- {}} -test safe-stock86-7.4 {tests specific path and positive search, uses http1.0} -body { - set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]] - # should not add anything (p0) - set token1 [safe::interpAddToAccessPath $i [info library]] - # should add as p1 - set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]] - set confA [safe::interpConfigure $i] - set mappA [mapList $PathMapp [dict get $confA -accessPath]] - # this time, unlike test safe-stock86-7.2, http should be found - list $token1 $token2 -- \ - [catch {interp eval $i {package require http 1}} msg] $msg -- \ - $mappA -- [safe::interpDelete $i] -} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}} - -# The following test checks whether the definition of tcl_endOfWord can be -# obtained from auto_loading. It was previously test "safe-5.1". -test safe-stock86-9.8 {test auto-loading in safe interpreters, was test 5.1} -setup { - catch {safe::interpDelete a} - safe::interpCreate a -} -body { - interp eval a {tcl_endOfWord "" 0} -} -cleanup { - safe::interpDelete a -} -result -1 - -set ::auto_path $SaveAutoPath -unset SaveAutoPath TestsDir PathMapp -rename mapList {} - -# cleanup -::tcltest::cleanupTests -return - -# Local Variables: -# mode: tcl -# End: -- cgit v0.12 From 2592b1e93b713440a2fab51b01df4ad31bb21f7d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Sep 2020 10:28:46 +0000 Subject: Don't use sizeof() for structs containing a flexible array as last element. Lesson from [https://core.tcl-lang.org/tk/info/3bc0f44ef3|3bc0f44ef3]. Use TclOffset in stead. --- generic/tclCompCmds.c | 20 ++++++++++---------- generic/tclEncoding.c | 2 +- generic/tclStringRep.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 607521d..c8970ce 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -403,9 +403,9 @@ TclCompileArraySetCmd( keyVar = AnonymousLocal(envPtr); valVar = AnonymousLocal(envPtr); - infoPtr = ckalloc(sizeof(ForeachInfo)); + infoPtr = ckalloc(TclOffset(ForeachInfo, varLists) + sizeof(ForeachVarList *)); infoPtr->numLists = 1; - infoPtr->varLists[0] = ckalloc(sizeof(ForeachVarList) + sizeof(int)); + infoPtr->varLists[0] = ckalloc(TclOffset(ForeachVarList, varIndexes) + 2 * sizeof(int)); infoPtr->varLists[0]->numVars = 2; infoPtr->varLists[0]->varIndexes[0] = keyVar; infoPtr->varLists[0]->varIndexes[1] = valVar; @@ -1776,7 +1776,7 @@ TclCompileDictUpdateCmd( * that are to be used. */ - duiPtr = ckalloc(sizeof(DictUpdateInfo) + sizeof(int) * (numVars - 1)); + duiPtr = ckalloc(TclOffset(DictUpdateInfo, varIndices) + sizeof(int) * numVars); duiPtr->length = numVars; keyTokenPtrs = TclStackAlloc(interp, sizeof(Tcl_Token *) * numVars); tokenPtr = TokenAfter(dictVarTokenPtr); @@ -2258,7 +2258,7 @@ DupDictUpdateInfo( unsigned len; dui1Ptr = clientData; - len = sizeof(DictUpdateInfo) + sizeof(int) * (dui1Ptr->length - 1); + len = TclOffset(DictUpdateInfo, varIndices) + sizeof(int) * dui1Ptr->length; dui2Ptr = ckalloc(len); memcpy(dui2Ptr, dui1Ptr, len); return dui2Ptr; @@ -2712,8 +2712,8 @@ CompileEachloopCmd( */ numLists = (numWords - 2)/2; - infoPtr = ckalloc(sizeof(ForeachInfo) - + (numLists - 1) * sizeof(ForeachVarList *)); + infoPtr = ckalloc(TclOffset(ForeachInfo, varLists) + + numLists * sizeof(ForeachVarList *)); infoPtr->numLists = 0; /* Count this up as we go */ /* @@ -2746,8 +2746,8 @@ CompileEachloopCmd( goto done; } - varListPtr = ckalloc(sizeof(ForeachVarList) - + (numVars - 1) * sizeof(int)); + varListPtr = ckalloc(TclOffset(ForeachVarList, varIndexes) + + numVars * sizeof(int)); varListPtr->numVars = numVars; infoPtr->varLists[i/2] = varListPtr; infoPtr->numLists++; @@ -2882,7 +2882,7 @@ DupForeachInfo( ForeachVarList *srcListPtr, *dupListPtr; int numVars, i, j, numLists = srcPtr->numLists; - dupPtr = ckalloc(sizeof(ForeachInfo) + dupPtr = ckalloc(TclOffset(ForeachInfo, varLists) + numLists * sizeof(ForeachVarList *)); dupPtr->numLists = numLists; dupPtr->firstValueTemp = srcPtr->firstValueTemp; @@ -2891,7 +2891,7 @@ DupForeachInfo( for (i = 0; i < numLists; i++) { srcListPtr = srcPtr->varLists[i]; numVars = srcListPtr->numVars; - dupListPtr = ckalloc(sizeof(ForeachVarList) + dupListPtr = ckalloc(TclOffset(ForeachVarList, varIndexes) + numVars * sizeof(int)); dupListPtr->numVars = numVars; for (j = 0; j < numVars; j++) { diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 5c7aab8..6377ad8 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2039,7 +2039,7 @@ LoadEscapeEncoding( Tcl_DStringFree(&lineString); } - size = sizeof(EscapeEncodingData) - sizeof(EscapeSubTable) + size = TclOffset(EscapeEncodingData, subTables) + Tcl_DStringLength(&escapeData); dataPtr = (EscapeEncodingData *)ckalloc(size); dataPtr->initLen = strlen(init); diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index 227e6bc..6d179ba 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -65,9 +65,9 @@ typedef struct String { } String; #define STRING_MAXCHARS \ - (int)(((size_t)UINT_MAX - sizeof(String))/sizeof(Tcl_UniChar)) + (int)(((size_t)UINT_MAX - 1 - TclOffset(String, unicode))/sizeof(Tcl_UniChar)) #define STRING_SIZE(numChars) \ - (sizeof(String) + ((numChars) * sizeof(Tcl_UniChar))) + (TclOffset(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar))) #define stringCheckLimits(numChars) \ do { \ if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \ -- cgit v0.12 From f5ac592def2fc9aed2314cfa3015e377247d599c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Sep 2020 16:47:30 +0000 Subject: Somehow GIT cannot remove tests/safe-stock86.test from (earlier) core-8-6-branch, so we do it. --- unix/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/unix/Makefile.in b/unix/Makefile.in index 4362933..b65cc5a 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -866,6 +866,7 @@ SHELL_ENV = @LD_LIBRARY_PATH_VAR@=`pwd`:${@LD_LIBRARY_PATH_VAR@} \ TCL_LIBRARY="${TCL_BUILDTIME_LIBRARY}" ${TCLTEST_EXE}: ${TCLTEST_OBJS} ${TCL_LIB_FILE} ${TCL_STUB_LIB_FILE} ${BUILD_DLTEST} + rm -rf $(TOP_DIR)/tests/safe-stock86.test $(MAKE) tcltest-real LIB_RUNTIME_DIR="`pwd`" tcltest-real: -- cgit v0.12 From f796d623675cfb8a59b1c190470f785c61b90a8e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 07:28:14 +0000 Subject: Use $index<0 in stead of $index==-1 consistantly --- library/http/http.tcl | 2 +- library/init.tcl | 4 ++-- library/safe.tcl | 2 +- library/tcltest/tcltest.tcl | 6 +++--- tests/httpTest.tcl | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index 192867e..4117f44 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -544,7 +544,7 @@ proc http::CloseSocket {s {token {}}} { } else { set map [array get socketMapping] set ndx [lsearch -exact $map $s] - if {$ndx != -1} { + if {$ndx >= 0} { incr ndx -1 set connId [lindex $map $ndx] } diff --git a/library/init.tcl b/library/init.tcl index e62d05d..94f65cf 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -245,7 +245,7 @@ proc unknown args { set errInfo [string range $errInfo 0 $last-1] set tail "\"$cinfo\"" set last [string last $tail $errInfo] - if {$last + [string length $tail] != [string length $errInfo]} { + if {$last < 0 || $last + [string length $tail] != [string length $errInfo]} { return -code error -errorcode $errCode \ -errorinfo $errInfo $msg } @@ -742,7 +742,7 @@ proc tcl::CopyDirectory {action src dest} { } } } else { - if {[string first $nsrc $ndest] != -1} { + if {[string first $nsrc $ndest] >= 0} { set srclen [expr {[llength [file split $nsrc]] - 1}] set ndest [lindex [file split $ndest] $srclen] if {$ndest eq [file tail $nsrc]} { diff --git a/library/safe.tcl b/library/safe.tcl index c6e653f..6090a46 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -318,7 +318,7 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} { # Make sure that tcl_library is in auto_path and at the first # position (needed by setAccessPath) set where [lsearch -exact $access_path [info library]] - if {$where == -1} { + if {$where < 0} { # not found, add it. set access_path [linsert $access_path 0 [info library]] Log $child "tcl_library was not in auto_path,\ diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index c894ff1..2af79bc 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -640,7 +640,7 @@ namespace eval tcltest { proc IsVerbose {level} { variable Option - return [expr {[lsearch -exact $Option(-verbose) $level] != -1}] + return [expr {[lsearch -exact $Option(-verbose) $level] >= 0}] } # Default verbosity is to show bodies of failed tests @@ -3107,7 +3107,7 @@ proc tcltest::removeFile {name {directory ""}} { set fullName [file join $directory $name] DebugPuts 3 "[lindex [info level 0] 0]: removing $fullName" set idx [lsearch -exact $filesMade $fullName] - if {$idx == -1} { + if {$idx < 0} { DebugDo 1 { Warn "removeFile removing \"$fullName\":\n not created by makeFile" } @@ -3184,7 +3184,7 @@ proc tcltest::removeDirectory {name {directory ""}} { DebugPuts 3 "[lindex [info level 0] 0]: deleting $fullName" set idx [lsearch -exact $filesMade $fullName] set filesMade [lreplace $filesMade $idx $idx] - if {$idx == -1} { + if {$idx < 0} { DebugDo 1 { Warn "removeDirectory removing \"$fullName\":\n not created\ by makeDirectory" diff --git a/tests/httpTest.tcl b/tests/httpTest.tcl index 4345845..7491fb4 100644 --- a/tests/httpTest.tcl +++ b/tests/httpTest.tcl @@ -153,7 +153,7 @@ proc httpTest::TestOverlaps {someResults n term msg badTrans notPiped} { set myStart [lsearch -exact $someResults [list B $i]] set myEnd [lsearch -exact $someResults [list $term $i]] - if {($myStart == -1 || $myEnd == -1)} { + if {($myStart < 0 || $myEnd < 0)} { set res "Cannot find positions of transaction $i" append msg $res \n Puts $res -- cgit v0.12 From 0715d88019e40aa514b3b2d3ba691ab7d0a96eb2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 08:09:20 +0000 Subject: Use $index<0 in stead of $index==-1 consistantly --- library/http/http.tcl | 2 +- library/init.tcl | 4 ++-- library/safe.tcl | 2 +- library/tcltest/tcltest.tcl | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index 9d3e5ca..6ca3bad 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -531,7 +531,7 @@ proc http::CloseSocket {s {token {}}} { } else { set map [array get socketMapping] set ndx [lsearch -exact $map $s] - if {$ndx != -1} { + if {$ndx >= 0} { incr ndx -1 set connId [lindex $map $ndx] } diff --git a/library/init.tcl b/library/init.tcl index e6964e0..1028b9e 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -313,7 +313,7 @@ proc unknown args { set errInfo [string range $errInfo 0 $last-1] set tail "\"$cinfo\"" set last [string last $tail $errInfo] - if {$last + [string length $tail] != [string length $errInfo]} { + if {$last < 0 || $last + [string length $tail] != [string length $errInfo]} { return -code error -errorcode $errCode \ -errorinfo $errInfo $msg } @@ -797,7 +797,7 @@ proc tcl::CopyDirectory {action src dest} { } } } else { - if {[string first $nsrc $ndest] != -1} { + if {[string first $nsrc $ndest] >= 0} { set srclen [expr {[llength [file split $nsrc]] - 1}] set ndest [lindex [file split $ndest] $srclen] if {$ndest eq [file tail $nsrc]} { diff --git a/library/safe.tcl b/library/safe.tcl index 48cb0de..5e04453 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -318,7 +318,7 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} { # Make sure that tcl_library is in auto_path and at the first # position (needed by setAccessPath) set where [lsearch -exact $access_path [info library]] - if {$where == -1} { + if {$where < 0} { # not found, add it. set access_path [linsert $access_path 0 [info library]] Log $child "tcl_library was not in auto_path,\ diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index c894ff1..2af79bc 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -640,7 +640,7 @@ namespace eval tcltest { proc IsVerbose {level} { variable Option - return [expr {[lsearch -exact $Option(-verbose) $level] != -1}] + return [expr {[lsearch -exact $Option(-verbose) $level] >= 0}] } # Default verbosity is to show bodies of failed tests @@ -3107,7 +3107,7 @@ proc tcltest::removeFile {name {directory ""}} { set fullName [file join $directory $name] DebugPuts 3 "[lindex [info level 0] 0]: removing $fullName" set idx [lsearch -exact $filesMade $fullName] - if {$idx == -1} { + if {$idx < 0} { DebugDo 1 { Warn "removeFile removing \"$fullName\":\n not created by makeFile" } @@ -3184,7 +3184,7 @@ proc tcltest::removeDirectory {name {directory ""}} { DebugPuts 3 "[lindex [info level 0] 0]: deleting $fullName" set idx [lsearch -exact $filesMade $fullName] set filesMade [lreplace $filesMade $idx $idx] - if {$idx == -1} { + if {$idx < 0} { DebugDo 1 { Warn "removeDirectory removing \"$fullName\":\n not created\ by makeDirectory" -- cgit v0.12 From 7f62b768876fc8b0779d10ae3fcba1fc7aeaba04 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 12:31:48 +0000 Subject: Fix [https://core.tcl-lang.org/tk/tktview?name=3bc0f44ef3|3bc0f44ef3]: UBSan complains about body.chars[] usage. (Yes, I know, this one is for Tk, but Tcl was using the same construct too ....) --- generic/tclBinary.c | 10 ++++----- generic/tclCompile.h | 6 +++--- generic/tclEncoding.c | 2 +- generic/tclIO.h | 2 +- generic/tclInt.h | 10 +++++++-- generic/tclObj.c | 56 +++++++++++++++++++++++++------------------------- generic/tclProc.c | 10 ++++----- generic/tclStringRep.h | 2 +- 8 files changed, 52 insertions(+), 46 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index f66aff7..78cdd42 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -199,7 +199,7 @@ typedef struct ByteArray { * array. */ int allocated; /* The amount of space actually allocated * minus 1 byte. */ - unsigned char bytes[1]; /* The array of bytes. The actual size of this + unsigned char bytes[TCLFLEXARRAY]; /* The array of bytes. The actual size of this * field depends on the 'allocated' field * above. */ } ByteArray; @@ -334,7 +334,7 @@ Tcl_SetByteArrayObj( if (length < 0) { length = 0; } - byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); + byteArrayPtr = (ByteArray *)ckalloc(BYTEARRAY_SIZE(length)); byteArrayPtr->used = length; byteArrayPtr->allocated = length; @@ -460,7 +460,7 @@ SetByteArrayFromAny( src = TclGetStringFromObj(objPtr, &length); srcEnd = src + length; - byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); + byteArrayPtr = (ByteArray *)ckalloc(BYTEARRAY_SIZE(length)); for (dst = byteArrayPtr->bytes; src < srcEnd; ) { src += TclUtfToUniChar(src, &ch); *dst++ = UCHAR(ch); @@ -529,7 +529,7 @@ DupByteArrayInternalRep( srcArrayPtr = GET_BYTEARRAY(srcPtr); length = srcArrayPtr->used; - copyArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); + copyArrayPtr = (ByteArray *)ckalloc(BYTEARRAY_SIZE(length)); copyArrayPtr->used = length; copyArrayPtr->allocated = length; memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length); @@ -588,7 +588,7 @@ UpdateStringOfByteArray( Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } - dst = ckalloc(size + 1); + dst = (char *)ckalloc(size + 1); objPtr->bytes = dst; objPtr->length = size; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 1d657a7..03b4a90 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -966,7 +966,7 @@ typedef struct JumpFixupArray { typedef struct ForeachVarList { int numVars; /* The number of variables in the list. */ - int varIndexes[1]; /* An array of the indexes ("slot numbers") + int varIndexes[TCLFLEXARRAY];/* An array of the indexes ("slot numbers") * for each variable in the procedure's array * of local variables. Only scalar variables * are supported. The actual size of this @@ -990,7 +990,7 @@ typedef struct ForeachInfo { * the loop's iteration count. Used to * determine next value list element to assign * each loop var. */ - ForeachVarList *varLists[1];/* An array of pointers to ForeachVarList + ForeachVarList *varLists[TCLFLEXARRAY];/* An array of pointers to ForeachVarList * structures describing each var list. The * actual size of this field will be large * enough to numVars indexes. THIS MUST BE THE @@ -1021,7 +1021,7 @@ MODULE_SCOPE const AuxDataType tclJumptableInfoType; typedef struct { int length; /* Size of array */ - int varIndices[1]; /* Array of variable indices to manage when + int varIndices[TCLFLEXARRAY]; /* Array of variable indices to manage when * processing the start and end of a [dict * update]. There is really more than one * entry, and the structure is allocated to diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 6377ad8..557f241 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -116,7 +116,7 @@ typedef struct { * entry in this array is 1, otherwise it is * 0. */ int numSubTables; /* Length of following array. */ - EscapeSubTable subTables[1];/* Information about each EscapeSubTable used + EscapeSubTable subTables[TCLFLEXARRAY];/* Information about each EscapeSubTable used * by this encoding type. The actual size is * as large as necessary to hold all * EscapeSubTables. */ diff --git a/generic/tclIO.h b/generic/tclIO.h index ffbfa31..eccc7a9 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -44,7 +44,7 @@ typedef struct ChannelBuffer { int bufLength; /* How big is the buffer? */ struct ChannelBuffer *nextPtr; /* Next buffer in chain. */ - char buf[1]; /* Placeholder for real buffer. The real + char buf[TCLFLEXARRAY]; /* Placeholder for real buffer. The real * buffer occuppies this space + bufSize-1 * bytes. This must be the last field in the * structure. */ diff --git a/generic/tclInt.h b/generic/tclInt.h index 317ae1f..e145925 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -877,6 +877,12 @@ typedef struct VarInHash { *---------------------------------------------------------------- */ +#if defined(__GNUC__) && (__GNUC__ > 2) +# define TCLFLEXARRAY 0 +#else +# define TCLFLEXARRAY 1 +#endif + /* * Forward declaration to prevent an error when the forward reference to * Command is encountered in the Proc and ImportRef types declared below. @@ -920,7 +926,7 @@ typedef struct CompiledLocal { * is marked by a unique ClientData tag during * compilation, and that same tag is used to * find the variable at runtime. */ - char name[1]; /* Name of the local variable starts here. If + char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If * the name is NULL, this will just be '\0'. * The actual size of this field will be large * enough to hold the name. MUST BE THE LAST @@ -1254,7 +1260,7 @@ typedef struct CFWordBC { typedef struct ContLineLoc { int num; /* Number of entries in loc, not counting the * final -1 marker entry. */ - int loc[1]; /* Table of locations, as character offsets. + int loc[TCLFLEXARRAY];/* Table of locations, as character offsets. * The table is allocated as part of the * structure, extending behind the nominal end * of the structure. An entry containing the diff --git a/generic/tclObj.c b/generic/tclObj.c index 28fb3da..a2544ad 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -145,12 +145,12 @@ typedef struct PendingObjData { #define ObjDeletionUnlock(contextPtr) ((contextPtr)->deletionCount--) #define ObjDeletePending(contextPtr) ((contextPtr)->deletionCount > 0) #define ObjOnStack(contextPtr) ((contextPtr)->deletionStack != NULL) -#define PushObjToDelete(contextPtr,objPtr) \ +#define PushObjToDelete(contextPtr,objPtr) \ /* The string rep is already invalidated so we can use the bytes value \ * for our pointer chain: push onto the head of the stack. */ \ (objPtr)->bytes = (char *) ((contextPtr)->deletionStack); \ (contextPtr)->deletionStack = (objPtr) -#define PopObjToDelete(contextPtr,objPtrVar) \ +#define PopObjToDelete(contextPtr,objPtrVar) \ (objPtrVar) = (contextPtr)->deletionStack; \ (contextPtr)->deletionStack = (Tcl_Obj *) (objPtrVar)->bytes @@ -168,7 +168,7 @@ static __thread PendingObjData pendingObjData; #else static Tcl_ThreadDataKey pendingObjDataKey; #define ObjInitDeletionContext(contextPtr) \ - PendingObjData *const contextPtr = \ + PendingObjData *const contextPtr = \ Tcl_GetThreadData(&pendingObjDataKey, sizeof(PendingObjData)) #endif @@ -177,27 +177,27 @@ static Tcl_ThreadDataKey pendingObjDataKey; */ #define PACK_BIGNUM(bignum, objPtr) \ - if ((bignum).used > 0x7FFF) { \ - mp_int *temp = (void *) ckalloc((unsigned) sizeof(mp_int)); \ + if ((bignum).used > 0x7FFF) { \ + mp_int *temp = (mp_int *)ckalloc(sizeof(mp_int)); \ *temp = bignum; \ - (objPtr)->internalRep.twoPtrValue.ptr1 = temp; \ - (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(-1); \ - } else { \ + (objPtr)->internalRep.twoPtrValue.ptr1 = temp; \ + (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(-1); \ + } else { \ if ((bignum).alloc > 0x7FFF) { \ mp_shrink(&(bignum)); \ } \ - (objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (bignum).dp; \ - (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR( ((bignum).sign << 30) \ - | ((bignum).alloc << 15) | ((bignum).used)); \ + (objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(bignum).dp; \ + (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(((bignum).sign << 30) \ + | ((bignum).alloc << 15) | ((bignum).used)); \ } #define UNPACK_BIGNUM(objPtr, bignum) \ - if ((objPtr)->internalRep.twoPtrValue.ptr2 == INT2PTR(-1)) { \ - (bignum) = *((mp_int *) ((objPtr)->internalRep.twoPtrValue.ptr1)); \ + if ((objPtr)->internalRep.twoPtrValue.ptr2 == INT2PTR(-1)) { \ + (bignum) = *((mp_int *) ((objPtr)->internalRep.twoPtrValue.ptr1)); \ } else { \ - (bignum).dp = (objPtr)->internalRep.twoPtrValue.ptr1; \ + (bignum).dp = (objPtr)->internalRep.twoPtrValue.ptr1; \ (bignum).sign = PTR2INT((objPtr)->internalRep.twoPtrValue.ptr2) >> 30; \ - (bignum).alloc = \ + (bignum).alloc = \ (PTR2INT((objPtr)->internalRep.twoPtrValue.ptr2) >> 15) & 0x7FFF; \ (bignum).used = PTR2INT((objPtr)->internalRep.twoPtrValue.ptr2) & 0x7FFF; \ } @@ -541,7 +541,7 @@ TclGetContLineTable(void) ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); if (!tsdPtr->lineCLPtr) { - tsdPtr->lineCLPtr = ckalloc(sizeof(Tcl_HashTable)); + tsdPtr->lineCLPtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(tsdPtr->lineCLPtr, TCL_ONE_WORD_KEYS); Tcl_CreateThreadExitHandler(TclThreadFinalizeContLines,NULL); } @@ -576,7 +576,7 @@ TclContinuationsEnter( ThreadSpecificData *tsdPtr = TclGetContLineTable(); Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry); - ContLineLoc *clLocPtr = ckalloc(sizeof(ContLineLoc) + num*sizeof(int)); + ContLineLoc *clLocPtr = (ContLineLoc *)ckalloc(TclOffset(ContLineLoc, loc) + (num + 1) *sizeof(int)); if (!newEntry) { /* @@ -1079,7 +1079,7 @@ TclDbInitNewObj( ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); if (tsdPtr->objThreadMap == NULL) { - tsdPtr->objThreadMap = ckalloc(sizeof(Tcl_HashTable)); + tsdPtr->objThreadMap = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(tsdPtr->objThreadMap, TCL_ONE_WORD_KEYS); } tablePtr = tsdPtr->objThreadMap; @@ -1092,7 +1092,7 @@ TclDbInitNewObj( * Record the debugging information. */ - objData = ckalloc(sizeof(ObjData)); + objData = (ObjData *)ckalloc(sizeof(ObjData)); objData->objPtr = objPtr; objData->file = file; objData->line = line; @@ -1251,7 +1251,7 @@ TclAllocateFreeObjects(void) * Purify apparently can't figure that out, and fires a false alarm. */ - basePtr = ckalloc(bytesToAlloc); + basePtr = (char *)ckalloc(bytesToAlloc); prevPtr = NULL; objPtr = (Tcl_Obj *) basePtr; @@ -2373,7 +2373,7 @@ UpdateStringOfDouble( Tcl_PrintDouble(NULL, objPtr->internalRep.doubleValue, buffer); len = strlen(buffer); - objPtr->bytes = ckalloc(len + 1); + objPtr->bytes = (char *)ckalloc(len + 1); memcpy(objPtr->bytes, buffer, (unsigned) len + 1); objPtr->length = len; } @@ -2573,7 +2573,7 @@ UpdateStringOfInt( len = TclFormatInt(buffer, objPtr->internalRep.longValue); - objPtr->bytes = ckalloc(len + 1); + objPtr->bytes = (char *)ckalloc(len + 1); memcpy(objPtr->bytes, buffer, (unsigned) len + 1); objPtr->length = len; } @@ -2877,7 +2877,7 @@ UpdateStringOfWideInt( sprintf(buffer, "%" TCL_LL_MODIFIER "d", wideVal); len = strlen(buffer); - objPtr->bytes = ckalloc(len + 1); + objPtr->bytes = (char *)ckalloc(len + 1); memcpy(objPtr->bytes, buffer, len + 1); objPtr->length = len; } @@ -3269,7 +3269,7 @@ UpdateStringOfBignum( Tcl_Panic("UpdateStringOfBignum: string length limit exceeded"); } - stringVal = ckalloc(size); + stringVal = (char *)ckalloc(size); status = mp_to_radix(&bignumVal, stringVal, size, NULL, 10); if (status != MP_OKAY) { Tcl_Panic("conversion failure in UpdateStringOfBignum"); @@ -3942,8 +3942,8 @@ AllocObjEntry( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key to store in the hash table entry. */ { - Tcl_Obj *objPtr = keyPtr; - Tcl_HashEntry *hPtr = ckalloc(sizeof(Tcl_HashEntry)); + Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr; + Tcl_HashEntry *hPtr = (Tcl_HashEntry *)ckalloc(sizeof(Tcl_HashEntry)); hPtr->key.objPtr = objPtr; Tcl_IncrRefCount(objPtr); @@ -4236,7 +4236,7 @@ TclSetCmdNameObj( } cmdPtr->refCount++; - resPtr = ckalloc(sizeof(ResolvedCmdName)); + resPtr = (ResolvedCmdName *)ckalloc(sizeof(ResolvedCmdName)); resPtr->cmdPtr = cmdPtr; resPtr->cmdEpoch = cmdPtr->cmdEpoch; resPtr->refCount = 1; @@ -4422,7 +4422,7 @@ SetCmdNameFromAny( } } else { TclFreeIntRep(objPtr); - resPtr = ckalloc(sizeof(ResolvedCmdName)); + resPtr = (ResolvedCmdName *)ckalloc(sizeof(ResolvedCmdName)); resPtr->refCount = 1; objPtr->internalRep.twoPtrValue.ptr1 = resPtr; objPtr->internalRep.twoPtrValue.ptr2 = NULL; diff --git a/generic/tclProc.c b/generic/tclProc.c index 4600382..a9134f2 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -600,7 +600,7 @@ TclCreateProc( */ localPtr = (CompiledLocal *)ckalloc( - TclOffset(CompiledLocal, name) + fieldValues[0]->length +1); + TclOffset(CompiledLocal, name) + fieldValues[0]->length + 1); if (procPtr->firstLocalPtr == NULL) { procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr; } else { @@ -1305,8 +1305,8 @@ InitLocalCache( * for future calls. */ - localCachePtr = ckalloc(sizeof(LocalCache) - + (localCt - 1) * sizeof(Tcl_Obj *) + localCachePtr = (LocalCache *)ckalloc(TclOffset(LocalCache, varName0) + + localCt * sizeof(Tcl_Obj *) + numArgs * sizeof(Var)); namePtr = &localCachePtr->varName0; @@ -2499,12 +2499,12 @@ SetLambdaFromAny( * location (line of 2nd list element). */ - cfPtr = ckalloc(sizeof(CmdFrame)); + cfPtr = (CmdFrame *)ckalloc(sizeof(CmdFrame)); TclListLines(objPtr, contextPtr->line[1], 2, buf, NULL); cfPtr->level = -1; cfPtr->type = contextPtr->type; - cfPtr->line = ckalloc(sizeof(int)); + cfPtr->line = (int *)ckalloc(sizeof(int)); cfPtr->line[0] = buf[1]; cfPtr->nline = 1; cfPtr->framePtr = NULL; diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index 6d179ba..25b854e 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -59,7 +59,7 @@ typedef struct String { * space allocated for the unicode array. */ int hasUnicode; /* Boolean determining whether the string has * a Unicode representation. */ - Tcl_UniChar unicode[1]; /* The array of Unicode chars. The actual size + Tcl_UniChar unicode[TCLFLEXARRAY]; /* The array of Unicode chars. The actual size * of this field depends on the 'maxChars' * field above. */ } String; -- cgit v0.12 From 6e44927248852ae0356d9d3e1cfa3d69597a66b1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 13:43:49 +0000 Subject: Folow-up to previous commit: ExecStack is a FLEXARRAY too --- generic/tclExecute.c | 6 +++--- generic/tclInt.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index aacf565..4d92468 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -914,8 +914,8 @@ TclCreateExecEnv( * [sizeof(Tcl_Obj*)] */ { ExecEnv *eePtr = ckalloc(sizeof(ExecEnv)); - ExecStack *esPtr = ckalloc(sizeof(ExecStack) - + (size_t) (size-1) * sizeof(Tcl_Obj *)); + ExecStack *esPtr = ckalloc(TclOffset(ExecStack, stackWords) + + size * sizeof(Tcl_Obj *)); eePtr->execStackPtr = esPtr; TclNewBooleanObj(eePtr->constants[0], 0); @@ -1180,7 +1180,7 @@ GrowEvaluationStack( newElems = needed; #endif - newBytes = sizeof(ExecStack) + (newElems-1) * sizeof(Tcl_Obj *); + newBytes = TclOffset(ExecStack, stackWords) + newElems * sizeof(Tcl_Obj *); oldPtr = esPtr; esPtr = ckalloc(newBytes); diff --git a/generic/tclInt.h b/generic/tclInt.h index e145925..fe69b26 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1409,7 +1409,7 @@ typedef struct ExecStack { Tcl_Obj **markerPtr; Tcl_Obj **endPtr; Tcl_Obj **tosPtr; - Tcl_Obj *stackWords[1]; + Tcl_Obj *stackWords[TCLFLEXARRAY]; } ExecStack; /* -- cgit v0.12 From 278837f261adb88e6a802f3ebaf63e232c12e77f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 14:23:14 +0000 Subject: More usage for TclNewWideIntObjFromSize(), TCL_IO_FAILURE -> TCL_INDEX_NONE where appropriate --- generic/tclCmdIL.c | 2 +- generic/tclStringObj.c | 12 ++++-------- unix/tclUnixInit.c | 4 ++-- win/tclWinInit.c | 4 ++-- win/tclWinPipe.c | 4 ++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index c88b4d2..7bad8b5 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3835,7 +3835,7 @@ Tcl_LsearchObjCmd( } Tcl_SetObjResult(interp, itemPtr); } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TclNewWideIntObjFromSize((size_t)index)); } } else if (index < 0) { /* diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index f9b2775..7ba20ec 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3454,8 +3454,7 @@ TclStringFirst( size_t start) { size_t lh = 0, ln = Tcl_GetCharLength(needle); - Tcl_Obj *result; - size_t value = TCL_IO_FAILURE; + size_t value = TCL_INDEX_NONE; Tcl_UniChar *check, *end, *uh, *un; if (start == TCL_INDEX_NONE) { @@ -3532,8 +3531,7 @@ TclStringFirst( } } firstEnd: - TclNewIntObj(result, TclWideIntFromSize(value)); - return result; + return TclNewWideIntObjFromSize(value); } /* @@ -3561,8 +3559,7 @@ TclStringLast( size_t last) { size_t lh = 0, ln = Tcl_GetCharLength(needle); - Tcl_Obj *result; - size_t value = TCL_IO_FAILURE; + size_t value = TCL_INDEX_NONE; Tcl_UniChar *check, *uh, *un; if (ln == 0) { @@ -3619,8 +3616,7 @@ TclStringLast( check--; } lastEnd: - TclNewIntObj(result, TclWideIntFromSize(value)); - return result; + return TclNewWideIntObjFromSize(value); } /* diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index a0a2c30..98c37f5 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -988,7 +988,7 @@ TclpSetVariables( * * Results: * The return value is the index in environ of an entry with the name - * "name", or TCL_IO_FAILURE if there is no such entry. The integer at *lengthPtr is + * "name", or TCL_INDEX_NONE if there is no such entry. The integer at *lengthPtr is * filled in with the length of name (if a matching entry is found) or * the length of the environ array (if no matching entry is found). * @@ -1007,7 +1007,7 @@ TclpFindVariable( * entries in environ (for unsuccessful * searches). */ { - size_t i, result = TCL_IO_FAILURE; + size_t i, result = TCL_INDEX_NONE; const char *env, *p1, *p2; Tcl_DString envString; diff --git a/win/tclWinInit.c b/win/tclWinInit.c index f6c9f83..4726bb3 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -614,7 +614,7 @@ TclpSetVariables( * * Results: * The return value is the index in environ of an entry with the name - * "name", or TCL_IO_FAILURE if there is no such entry. The integer + * "name", or TCL_INDEX_NONE if there is no such entry. The integer * at *lengthPtr is filled in with the length of name (if a matching * entry is found) or the length of the environ array (if no * matching entry is found). @@ -637,7 +637,7 @@ TclpFindVariable( * entries in environ (for unsuccessful * searches). */ { - size_t i, length, result = TCL_IO_FAILURE; + size_t i, length, result = TCL_INDEX_NONE; const WCHAR *env; const char *p1, *p2; char *envUpper, *nameUpper; diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index d0fa84b..2576028 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -851,7 +851,7 @@ TclpCloseFile( * Results: * Returns the process id for the child process. If the pid was not known * by Tcl, either because the pid was not created by Tcl or the child - * process has already been reaped, TCL_IO_FAILURE is returned. + * process has already been reaped, TCL_INDEX_NONE is returned. * * Side effects: * None. @@ -875,7 +875,7 @@ TclpGetPid( } } Tcl_MutexUnlock(&pipeMutex); - return TCL_IO_FAILURE; + return TCL_INDEX_NONE; } /* -- cgit v0.12 From 5bef31d2da2eb4ed8f3261ef8276cb2a3b6f3a1e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Sep 2020 08:52:27 +0000 Subject: Prevent the usage of the term safe/unsafe child. Suggested by Keith Nash. Thanks! --- doc/interp.n | 8 ++++---- generic/tclInterp.c | 4 ++-- library/http/http.tcl | 2 +- library/safe.tcl | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/interp.n b/doc/interp.n index 4be7ef8..35f26d5 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -663,9 +663,9 @@ including itself. .SH "ALIAS INVOCATION" .PP The alias mechanism has been carefully designed so that it can -be used safely when an untrusted script is executing -in a safe child and the target of the alias is a trusted -parent. The most important thing in guaranteeing safety is to +be used safely in an untrusted script which is being executed in a +safe interpreter even if the target of the alias is not a safe +interpreter. The most important thing in guaranteeing safety is to ensure that information passed from the child to the parent is never evaluated or substituted in the parent; if this were to occur, it would enable an evil script in the child to invoke @@ -747,7 +747,7 @@ To help avoid this problem, no substitutions or evaluations are applied to arguments of \fBinterp invokehidden\fR. .PP Safe interpreters are not allowed to invoke hidden commands in themselves -or in their descendants. This prevents safe children from gaining access to +or in their descendants. This prevents them from gaining access to hidden functionality in themselves or their descendants. .PP The set of hidden commands in an interpreter can be manipulated by a trusted diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 42ef1fa..b84c065 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -123,7 +123,7 @@ typedef struct Target { * * NB: the flags field in the interp structure, used with SAFE_INTERP mask * denotes whether the interpreter is safe or not. Safe interpreters have - * restricted functionality, can only create safe child interpreters and can + * restricted functionality, can only create safe interpreters and can * only load safe extensions. */ @@ -3286,7 +3286,7 @@ Tcl_MakeSafe( */ /* - * No env array in a safe child. + * No env array in a safe interpreter. */ Tcl_UnsetVar2(interp, "env", NULL, TCL_GLOBAL_ONLY); diff --git a/library/http/http.tcl b/library/http/http.tcl index 4117f44..21d6671 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -2791,7 +2791,7 @@ proc http::Event {sock token} { # scan any list for "close". if {$tmpHeader in {close keep-alive}} { # The common cases, continue. - } elseif {[string first , $tmpHeader] == -1} { + } elseif {[string first , $tmpHeader] < 0} { # Not a comma-separated list, not "close", # therefore "keep-alive". set tmpHeader keep-alive diff --git a/library/safe.tcl b/library/safe.tcl index 6090a46..1f8c3d2 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -260,7 +260,7 @@ proc ::safe::interpConfigure {args} { # # safe::InterpCreate : doing the real job # -# This procedure creates a safe child and initializes it with the safe +# This procedure creates a safe interpreter and initializes it with the safe # base aliases. # NB: child name must be simple alphanumeric string, no spaces, no (), no # {},... {because the state array is stored as part of the name} @@ -576,7 +576,7 @@ proc ::safe::AddSubDirs {pathList} { return $res } -# This procedure deletes a safe child managed by Safe Tcl and cleans up +# This procedure deletes a safe interpreter managed by Safe Tcl and cleans up # associated state. # - The command will also delete non-Safe-Base interpreters. # - This is regrettable, but to avoid breaking existing code this should be @@ -1133,8 +1133,8 @@ proc ::safe::BadSubcommand {child command subcommand args} { # interpreters. proc ::safe::AliasEncodingSystem {child args} { try { - # Must not pass extra arguments; safe childs may not set the system - # encoding but they may read it. + # Must not pass extra arguments; safe interpreters may not set the + # system encoding but they may read it. if {[llength $args]} { return -code error -errorcode {TCL WRONGARGS} \ "wrong # args: should be \"encoding system\"" -- cgit v0.12 From f0ec68f07293dac2b967d45a3697073b77688970 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Sep 2020 09:22:18 +0000 Subject: Prevent the usage of the term safe/unsafe child. Suggested by Keith Nash. Thanks! More usage of $index<0 in stead of $index==-1 consistantly --- doc/interp.n | 8 ++++---- generic/tclInterp.c | 4 ++-- library/http/http.tcl | 2 +- library/safe.tcl | 4 ++-- tests/chan.test | 2 +- tests/http11.test | 2 +- tests/httpTest.tcl | 12 ++++++------ tests/httpd11.tcl | 2 +- tests/obj.test | 2 +- tests/reg.test | 8 ++++---- tests/socket.test | 2 +- tests/stringObj.test | 4 ++-- tests/thread.test | 4 ++-- tests/unload.test | 4 ++-- tools/mkdepend.tcl | 2 +- tools/uniParse.tcl | 4 ++-- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/doc/interp.n b/doc/interp.n index f0a6c5e..bfbf9fd 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -667,9 +667,9 @@ including itself. .SH "ALIAS INVOCATION" .PP The alias mechanism has been carefully designed so that it can -be used safely when an untrusted script is executing -in a safe child and the target of the alias is a trusted -parent. The most important thing in guaranteeing safety is to +be used safely in an untrusted script which is being executed in a +safe interpreter even if the target of the alias is not a safe +interpreter. The most important thing in guaranteeing safety is to ensure that information passed from the child to the parent is never evaluated or substituted in the parent; if this were to occur, it would enable an evil script in the child to invoke @@ -751,7 +751,7 @@ To help avoid this problem, no substitutions or evaluations are applied to arguments of \fBinterp invokehidden\fR. .PP Safe interpreters are not allowed to invoke hidden commands in themselves -or in their descendants. This prevents safe children from gaining access to +or in their descendants. This prevents them from gaining access to hidden functionality in themselves or their descendants. .PP The set of hidden commands in an interpreter can be manipulated by a trusted diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 80c2534..e1a6d20 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -123,7 +123,7 @@ typedef struct Target { * * NB: the flags field in the interp structure, used with SAFE_INTERP mask * denotes whether the interpreter is safe or not. Safe interpreters have - * restricted functionality, can only create safe child interpreters and can + * restricted functionality, can only create safe interpreters and can * only load safe extensions. */ @@ -3209,7 +3209,7 @@ Tcl_MakeSafe( */ /* - * No env array in a safe child. + * No env array in a safe interpreter. */ Tcl_UnsetVar(interp, "env", TCL_GLOBAL_ONLY); diff --git a/library/http/http.tcl b/library/http/http.tcl index 6ca3bad..cce1828 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -2754,7 +2754,7 @@ proc http::Event {sock token} { # scan any list for "close". if {$tmpHeader in {close keep-alive}} { # The common cases, continue. - } elseif {[string first , $tmpHeader] == -1} { + } elseif {[string first , $tmpHeader] < 0} { # Not a comma-separated list, not "close", # therefore "keep-alive". set tmpHeader keep-alive diff --git a/library/safe.tcl b/library/safe.tcl index 5e04453..b9dd18d 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -260,7 +260,7 @@ proc ::safe::interpConfigure {args} { # # safe::InterpCreate : doing the real job # -# This procedure creates a safe child and initializes it with the safe +# This procedure creates a safe interpreter and initializes it with the safe # base aliases. # NB: child name must be simple alphanumeric string, no spaces, no (), no # {},... {because the state array is stored as part of the name} @@ -578,7 +578,7 @@ proc ::safe::AddSubDirs {pathList} { return $res } -# This procedure deletes a safe child managed by Safe Tcl and cleans up +# This procedure deletes a safe interpreter managed by Safe Tcl and cleans up # associated state. # - The command will also delete non-Safe-Base interpreters. # - This is regrettable, but to avoid breaking existing code this should be diff --git a/tests/chan.test b/tests/chan.test index 4efec11..49afdc6 100644 --- a/tests/chan.test +++ b/tests/chan.test @@ -173,7 +173,7 @@ test chan-16.9 {chan command: pending input subcommand} -setup { lappend ::chan-16.9-data $r $l $e $b $i - if {$r != -1 || $e || $l || !$b || $i > 128} { + if {$r >= 0 || $e || $l || !$b || $i > 128} { set data [read $sock $i] lappend ::chan-16.9-data [string range $data 0 2] lappend ::chan-16.9-data [string range $data end-2 end] diff --git a/tests/http11.test b/tests/http11.test index 7ca57f4..f243e56 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -19,7 +19,7 @@ variable httpd_output proc create_httpd {} { proc httpd_read {chan} { variable httpd_output - if {[gets $chan line] != -1} { + if {[gets $chan line] >= 0} { #puts stderr "read '$line'" set httpd_output $line } diff --git a/tests/httpTest.tcl b/tests/httpTest.tcl index 326b361..6a2226e 100644 --- a/tests/httpTest.tcl +++ b/tests/httpTest.tcl @@ -60,7 +60,7 @@ proc http::Log {args} { variable TestStartTimeInMs set time [expr {[clock milliseconds] - $TestStartTimeInMs}] set txt [list $time {*}$args] - if {[string first ^ $txt] != -1} { + if {[string first ^ $txt] >= 0} { ::httpTest::LogRecord $txt ::httpTest::Puts $txt } elseif {$::httpTest::testOptions(-verbose) > 1} { @@ -82,7 +82,7 @@ proc httpTest::LogRecord {txt} { puts stdout "Fix this call to Log in http-*.tm so it has ^ then\ a letter then a numeral." flush stdout - } elseif {$pos == -1} { + } elseif {$pos < 0} { # Called by mistake. } else { set letter [string index $txt [incr pos]] @@ -149,7 +149,7 @@ proc httpTest::TestOverlaps {someResults n term msg badTrans notPiped} { set myStart [lsearch -exact $someResults [list B $i]] set myEnd [lsearch -exact $someResults [list $term $i]] - if {($myStart == -1 || $myEnd == -1)} { + if {($myStart < 0 || $myEnd < 0)} { set res "Cannot find positions of transaction $i" append msg $res \n Puts $res @@ -370,7 +370,7 @@ proc httpTest::ProcessRetries {someResults n msg skipOverlaps notIncluded notPip variable testOptions set nextRetry [lsearch -glob -index 0 $someResults {[PQR]}] - if {$nextRetry == -1} { + if {$nextRetry < 0} { return [MostAnalysis $someResults $n $msg $skipOverlaps $notIncluded $notPiped] } set badTrans $notIncluded @@ -387,7 +387,7 @@ proc httpTest::ProcessRetries {someResults n msg skipOverlaps notIncluded notPip for {set i 1} {$i <= $n} {incr i} { set first [lsearch -exact $beforeTry [list A $i]] set last [lsearch -exact $beforeTry [list F $i]] - if {$first == -1} { + if {$first < 0} { set res "Transaction $i was not started in connection number $tryCount" # So lappend it to badTrans and don't include it in the call below of MostAnalysis. # append msg $res \n @@ -396,7 +396,7 @@ proc httpTest::ProcessRetries {someResults n msg skipOverlaps notIncluded notPip lappend badTrans $i } else { } - } elseif {$last == -1} { + } elseif {$last < 0} { set res "Transaction $i was started but unfinished in connection number $tryCount" # So lappend it to badTrans and don't include it in the call below of MostAnalysis. # append msg $res \n diff --git a/tests/httpd11.tcl b/tests/httpd11.tcl index 0b02319..89590ec 100644 --- a/tests/httpd11.tcl +++ b/tests/httpd11.tcl @@ -237,7 +237,7 @@ proc Accept {chan addr port} { } proc Control {chan} { - if {[gets $chan line] != -1} { + if {[gets $chan line] >= 0} { if {[string trim $line] eq "quit"} { set ::forever 1 } diff --git a/tests/obj.test b/tests/obj.test index b6b6eb8..e5fec9a 100644 --- a/tests/obj.test +++ b/tests/obj.test @@ -36,7 +36,7 @@ test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} tes string } { set first [string first $t [testobj types]] - set r [expr {$r && ($first != -1)}] + set r [expr {$r && ($first >= 0)}] } set result $r } {1} diff --git a/tests/reg.test b/tests/reg.test index 02677c7..063b091 100644 --- a/tests/reg.test +++ b/tests/reg.test @@ -49,9 +49,9 @@ catch [list package require -exact Tcltest [info patchlevel]] # subexpressions, checking where empty substrings are located, # etc. should be done using expectIndices and expectPartial. -# The flag characters are complex and a bit eclectic. Generally speaking, +# The flag characters are complex and a bit eclectic. Generally speaking, # lowercase letters are compile options, uppercase are expected re_info -# bits, and nonalphabetics are match options, controls for how the test is +# bits, and nonalphabetics are match options, controls for how the test is # run, or testing options. The one small surprise is that AREs are the # default, and you must explicitly request lesser flavors of RE. The flags # are as follows. It is admitted that some are not very mnemonic. @@ -287,7 +287,7 @@ namespace eval RETest { set infoflags [TestInfoFlags $flags] set ccmd [list testregexp -about {*}$f $re] set nsub [expr {[llength $args] - 1}] - if {$nsub == -1} { + if {$nsub < 0} { # didn't tell us number of subexps set ccmd "lreplace \[$ccmd\] 0 0" set info [list $infoflags] @@ -311,7 +311,7 @@ namespace eval RETest { # match expected (full fanciness) # expectIndices testno flags re target mat submat ... proc expectIndices {args} { - MatchExpected -indices {*}$args + MatchExpected -indices {*}$args } # partial match expected diff --git a/tests/socket.test b/tests/socket.test index 5198f4f..ca60588 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -237,7 +237,7 @@ if {$doTestsWithRemoteServer} { # Some tests are run only if we are doing testing against a remote server. testConstraint doTestsWithRemoteServer $doTestsWithRemoteServer if {!$doTestsWithRemoteServer} { - if {[string first s $::tcltest::verbose] != -1} { + if {[string first s $::tcltest::verbose] >= 0} { puts "Skipping tests with remote server. See tests/socket.test for" puts "information on how to run remote server." puts "Reason for not doing remote tests: $noRemoteTestReason" diff --git a/tests/stringObj.test b/tests/stringObj.test index ce19e96..bfe9da1 100644 --- a/tests/stringObj.test +++ b/tests/stringObj.test @@ -27,8 +27,8 @@ testConstraint testdstring [llength [info commands testdstring]] test stringObj-1.1 {string type registration} testobj { set t [testobj types] set first [string first "string" $t] - set result [expr {$first != -1}] -} {1} + set result [expr {$first >= 0}] +} 1 test stringObj-2.1 {Tcl_NewStringObj} testobj { set result "" diff --git a/tests/thread.test b/tests/thread.test index 9f14470..7c7dc27 100644 --- a/tests/thread.test +++ b/tests/thread.test @@ -36,11 +36,11 @@ set threadSuperKillScript { proc getThreadErrorFromInfo { info } { set list [split $info \n] set idx [lsearch -glob $list "*eval*unwound*"] - if {$idx != -1} then { + if {$idx >= 0} then { return [lindex $list $idx] } set idx [lsearch -glob $list "*eval*canceled*"] - if {$idx != -1} then { + if {$idx >= 0} then { return [lindex $list $idx] } return ""; # some other error we do not care about. diff --git a/tests/unload.test b/tests/unload.test index 05a0104..815ff31 100644 --- a/tests/unload.test +++ b/tests/unload.test @@ -156,14 +156,14 @@ test unload-3.3 {unloading of a package that has never been loaded from a safe i 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} { + if {[lsearch -index 1 [info loaded child] Pkgb] < 0} { 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} { + if {[lsearch -index 1 [info loaded child] Pkgua] < 0} { load [file join $testDir pkgua$ext] pkgua child } } -constraints [list $dll $loaded] -body { diff --git a/tools/mkdepend.tcl b/tools/mkdepend.tcl index 3d96a5e..afe123a 100644 --- a/tools/mkdepend.tcl +++ b/tools/mkdepend.tcl @@ -88,7 +88,7 @@ proc readDepends {chan} { set line "" array set depends {} - while {[gets $chan line] != -1} { + while {[gets $chan line] < 0} { if {[regexp {^#line [0-9]+ \"(.*)\"$} $line dummy fname] != 0} { set fname [file normalize $fname] if {![info exists target]} { diff --git a/tools/uniParse.tcl b/tools/uniParse.tcl index a451096..545afc4 100644 --- a/tools/uniParse.tcl +++ b/tools/uniParse.tcl @@ -68,7 +68,7 @@ proc uni::getGroup {value} { variable groups set gIndex [lsearch -exact $groups $value] - if {$gIndex == -1} { + if {$gIndex < 0} { set gIndex [llength $groups] lappend groups $value } @@ -81,7 +81,7 @@ proc uni::addPage {info} { variable shift set pIndex [lsearch -exact $pages $info] - if {$pIndex == -1} { + if {$pIndex < 0} { set pIndex [llength $pages] lappend pages $info } -- cgit v0.12 From 262b6297ea2f920b93647282240008fb6b77b0e9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Sep 2020 12:31:56 +0000 Subject: Eliminate many "register" keywords (which do nothing with modern compilers) Eliminate many unnecessary type-casts to (unsigned) --- generic/tclAlloc.c | 22 +++--- generic/tclBasic.c | 44 +++++------ generic/tclCkalloc.c | 4 +- generic/tclCmdMZ.c | 18 ++--- generic/tclCompCmdsGR.c | 2 +- generic/tclCompile.c | 2 +- generic/tclInt.decls | 2 +- generic/tclInt.h | 4 +- generic/tclLiteral.c | 4 +- generic/tclNamesp.c | 74 +++++++++--------- generic/tclOOCall.c | 16 ++-- generic/tclObj.c | 194 ++++++++++++++++++++++++------------------------ generic/tclRegexp.c | 18 ++--- generic/tclResult.c | 28 +++---- generic/tclTest.c | 18 ++--- generic/tclTimer.c | 12 +-- generic/tclVar.c | 70 ++++++++--------- tests/winFCmd.test | 2 +- tools/mkdepend.tcl | 2 +- 19 files changed, 268 insertions(+), 268 deletions(-) diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c index 39b9395..dd83385 100644 --- a/generic/tclAlloc.c +++ b/generic/tclAlloc.c @@ -253,9 +253,9 @@ char * TclpAlloc( unsigned int numBytes) /* Number of bytes to allocate. */ { - register union overhead *overPtr; - register long bucket; - register unsigned amount; + union overhead *overPtr; + long bucket; + unsigned amount; struct block *bigBlockPtr = NULL; if (!allocInit) { @@ -274,7 +274,7 @@ TclpAlloc( if (numBytes >= MAXMALLOC - OVERHEAD) { if (numBytes <= UINT_MAX - OVERHEAD -sizeof(struct block)) { - bigBlockPtr = (struct block *) TclpSysAlloc((unsigned) + bigBlockPtr = (struct block *) TclpSysAlloc( (sizeof(struct block) + OVERHEAD + numBytes), 0); } if (bigBlockPtr == NULL) { @@ -387,8 +387,8 @@ static void MoreCore( int bucket) /* What bucket to allocat to. */ { - register union overhead *overPtr; - register long size; /* size of desired block */ + union overhead *overPtr; + long size; /* size of desired block */ long amount; /* amount to allocate */ int numBlocks; /* how many blocks we get */ struct block *blockPtr; @@ -405,7 +405,7 @@ MoreCore( numBlocks = amount / size; ASSERT(numBlocks*size == amount); - blockPtr = (struct block *) TclpSysAlloc((unsigned) + blockPtr = (struct block *) TclpSysAlloc( (sizeof(struct block) + amount), 1); /* no more room! */ if (blockPtr == NULL) { @@ -448,8 +448,8 @@ void TclpFree( char *oldPtr) /* Pointer to memory to free. */ { - register long size; - register union overhead *overPtr; + long size; + union overhead *overPtr; struct block *bigBlockPtr; if (oldPtr == NULL) { @@ -645,8 +645,8 @@ void mstats( char *s) /* Where to write info. */ { - register int i, j; - register union overhead *overPtr; + int i, j; + union overhead *overPtr; int totalFree = 0, totalUsed = 0; Tcl_MutexLock(allocMutexPtr); diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 8b3a1b2..cca87ce 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -1036,7 +1036,7 @@ int TclHideUnsafeCommands( Tcl_Interp *interp) /* Hide commands in this interpreter. */ { - register const CmdInfo *cmdInfoPtr; + const CmdInfo *cmdInfoPtr; if (interp == NULL) { return TCL_ERROR; @@ -2485,7 +2485,7 @@ int TclInvokeStringCommand( ClientData clientData, /* Points to command's Command structure. */ Tcl_Interp *interp, /* Current interpreter. */ - register int objc, /* Number of arguments. */ + int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Command *cmdPtr = clientData; @@ -2534,7 +2534,7 @@ TclInvokeObjectCommand( ClientData clientData, /* Points to command's Command structure. */ Tcl_Interp *interp, /* Current interpreter. */ int argc, /* Number of arguments. */ - register const char **argv) /* Argument strings. */ + const char **argv) /* Argument strings. */ { Command *cmdPtr = clientData; Tcl_Obj *objPtr; @@ -3025,7 +3025,7 @@ Tcl_GetCommandFullName( { Interp *iPtr = (Interp *) interp; - register Command *cmdPtr = (Command *) command; + Command *cmdPtr = (Command *) command; char *name; /* @@ -3302,7 +3302,7 @@ CallCommandTraces( * trigger, either TCL_TRACE_DELETE or * TCL_TRACE_RENAME. */ { - register CommandTrace *tracePtr; + CommandTrace *tracePtr; ActiveCommandTrace active; char *result; Tcl_Obj *oldNamePtr = NULL; @@ -3492,7 +3492,7 @@ CancelEvalProc( void TclCleanupCommand( - register Command *cmdPtr) /* Points to the Command structure to + Command *cmdPtr) /* Points to the Command structure to * be freed. */ { cmdPtr->refCount--; @@ -3877,7 +3877,7 @@ int TclInterpReady( Tcl_Interp *interp) { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; /* * Reset both the interpreter's string and object results and clear out @@ -3949,7 +3949,7 @@ TclResetCancellation( Tcl_Interp *interp, int force) { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; if (iPtr == NULL) { return TCL_ERROR; @@ -3991,7 +3991,7 @@ Tcl_Canceled( Tcl_Interp *interp, int flags) { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; /* * Has the current script in progress for this interpreter been canceled @@ -4720,7 +4720,7 @@ TEOV_NotFound( newObjv[i] = handlerObjv[i]; Tcl_IncrRefCount(newObjv[i]); } - memcpy(newObjv+handlerObjc, objv, sizeof(Tcl_Obj *) * (unsigned)objc); + memcpy(newObjv+handlerObjc, objv, sizeof(Tcl_Obj *) * objc); /* * Look up and invoke the handler (by recursive call to this function). If @@ -5506,7 +5506,7 @@ TclAdvanceLines( const char *start, const char *end) { - register const char *p; + const char *p; for (p = start; p < end; p++) { if (*p == '\n') { @@ -6031,7 +6031,7 @@ int Tcl_EvalObjEx( Tcl_Interp *interp, /* Token for command interpreter (returned by * a previous call to Tcl_CreateInterp). */ - register Tcl_Obj *objPtr, /* Pointer to object containing commands to + Tcl_Obj *objPtr, /* Pointer to object containing commands to * execute. */ int flags) /* Collection of OR-ed bits that control the * evaluation of the script. Supported values @@ -6044,7 +6044,7 @@ int TclEvalObjEx( Tcl_Interp *interp, /* Token for command interpreter (returned by * a previous call to Tcl_CreateInterp). */ - register Tcl_Obj *objPtr, /* Pointer to object containing commands to + Tcl_Obj *objPtr, /* Pointer to object containing commands to * execute. */ int flags, /* Collection of OR-ed bits that control the * evaluation of the script. Supported values @@ -6063,7 +6063,7 @@ int TclNREvalObjEx( Tcl_Interp *interp, /* Token for command interpreter (returned by * a previous call to Tcl_CreateInterp). */ - register Tcl_Obj *objPtr, /* Pointer to object containing commands to + Tcl_Obj *objPtr, /* Pointer to object containing commands to * execute. */ int flags, /* Collection of OR-ed bits that control the * evaluation of the script. Supported values @@ -6371,7 +6371,7 @@ Tcl_ExprLong( const char *exprstring, /* Expression to evaluate. */ long *ptr) /* Where to store result. */ { - register Tcl_Obj *exprPtr; + Tcl_Obj *exprPtr; int result = TCL_OK; if (*exprstring == '\0') { /* @@ -6398,7 +6398,7 @@ Tcl_ExprDouble( const char *exprstring, /* Expression to evaluate. */ double *ptr) /* Where to store result. */ { - register Tcl_Obj *exprPtr; + Tcl_Obj *exprPtr; int result = TCL_OK; if (*exprstring == '\0') { @@ -6478,7 +6478,7 @@ int Tcl_ExprLongObj( Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ - register Tcl_Obj *objPtr, /* Expression to evaluate. */ + Tcl_Obj *objPtr, /* Expression to evaluate. */ long *ptr) /* Where to store long result. */ { Tcl_Obj *resultPtr; @@ -6526,7 +6526,7 @@ int Tcl_ExprDoubleObj( Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ - register Tcl_Obj *objPtr, /* Expression to evaluate. */ + Tcl_Obj *objPtr, /* Expression to evaluate. */ double *ptr) /* Where to store double result. */ { Tcl_Obj *resultPtr; @@ -6562,7 +6562,7 @@ int Tcl_ExprBooleanObj( Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ - register Tcl_Obj *objPtr, /* Expression to evaluate. */ + Tcl_Obj *objPtr, /* Expression to evaluate. */ int *ptr) /* Where to store 0/1 result. */ { Tcl_Obj *resultPtr; @@ -6674,7 +6674,7 @@ TclNRInvoke( int objc, Tcl_Obj *const objv[]) { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; Tcl_HashTable *hTblPtr; /* Table of hidden commands. */ const char *cmdName; /* Name of the command from objv[0]. */ Tcl_HashEntry *hPtr = NULL; @@ -6868,7 +6868,7 @@ Tcl_AddObjErrorInfo( int length) /* The number of bytes in the message. If < 0, * then append all bytes up to a NULL byte. */ { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; /* * If we are just starting to log an error, errorInfo is initialized from @@ -7016,7 +7016,7 @@ Tcl_GlobalEval( * command. */ const char *command) /* Command to evaluate. */ { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; int result; CallFrame *savedVarFramePtr; diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 2730443..0dc1dca 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -406,7 +406,7 @@ Tcl_DbCkalloc( /* Don't let size argument to TclpAlloc overflow */ if (size <= UINT_MAX - HIGH_GUARD_SIZE -sizeof(struct mem_header)) { - result = (struct mem_header *) TclpAlloc((unsigned)size + + result = (struct mem_header *) TclpAlloc(size + sizeof(struct mem_header) + HIGH_GUARD_SIZE); } if (result == NULL) { @@ -496,7 +496,7 @@ Tcl_AttemptDbCkalloc( /* Don't let size argument to TclpAlloc overflow */ if (size <= UINT_MAX - HIGH_GUARD_SIZE - sizeof(struct mem_header)) { - result = (struct mem_header *) TclpAlloc((unsigned)size + + result = (struct mem_header *) TclpAlloc(size + sizeof(struct mem_header) + HIGH_GUARD_SIZE); } if (result == NULL) { diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b9b6b6c..b24cb97 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1231,7 +1231,7 @@ StringFirstCmd( */ if (needleLen > 0 && needleLen <= haystackLen) { - register Tcl_UniChar *p, *end; + Tcl_UniChar *p, *end; end = haystackStr + haystackLen - needleLen + 1; for (p = haystackStr; p < end; p++) { @@ -1712,7 +1712,7 @@ StringIsCmd( const char *elemStart, *nextElem; int lenRemain, elemSize; - register const char *p; + const char *p; string1 = TclGetStringFromObj(objPtr, &length1); end = string1 + length1; @@ -2035,7 +2035,7 @@ StringMapCmd( (Tcl_UniCharToLower(*ustring1) == u2lc[index/2]))) && /* Restrict max compare length. */ (end-ustring1 >= length2) && ((length2 == 1) || - !strCmpFn(ustring2, ustring1, (unsigned) length2))) { + !strCmpFn(ustring2, ustring1, length2))) { if (p != ustring1) { /* * Put the skipped chars onto the result first. @@ -2272,7 +2272,7 @@ StringReptCmd( * Include space for the NUL. */ - string2 = attemptckalloc((unsigned) length2 + 1); + string2 = attemptckalloc(length2 + 1); if (string2 == NULL) { /* * Alloc failed. Note that in this case we try to do an error message @@ -4185,9 +4185,9 @@ Tcl_TimeObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; Tcl_Obj *objs[4]; - register int i, result; + int i, result; int count; double totalMicroSec; #ifndef TCL_WIDE_CLICKS @@ -4286,8 +4286,8 @@ Tcl_TimeRateObjCmd( static double measureOverhead = 0; /* global measure-overhead */ double overhead = -1; /* given measure-overhead */ - register Tcl_Obj *objPtr; - register int result, i; + Tcl_Obj *objPtr; + int result, i; Tcl_Obj *calibrate = NULL, *direct = NULL; TclWideMUInt count = 0; /* Holds repetition count */ Tcl_WideInt maxms = WIDE_MIN; @@ -4301,7 +4301,7 @@ Tcl_TimeRateObjCmd( * zero (i.e., never < 1) */ unsigned short factor = 50; /* Factor (4..50) limiting threshold to avoid * growth of execution time. */ - register Tcl_WideInt start, middle, stop; + Tcl_WideInt start, middle, stop; #ifndef TCL_WIDE_CLICKS Tcl_Time now; #endif /* !TCL_WIDE_CLICKS */ diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 4207df7..16fafad 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -2119,7 +2119,7 @@ TclCompileRegexpCmd( sawLast++; i++; break; - } else if ((len > 1) && (strncmp(str,"-nocase",(unsigned)len) == 0)) { + } else if ((len > 1) && (strncmp(str, "-nocase", len) == 0)) { nocase = 1; } else { /* diff --git a/generic/tclCompile.c b/generic/tclCompile.c index b79d504..6761c09 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -2996,7 +2996,7 @@ TclFindCompiledLocal( char *localName = localPtr->name; if ((nameBytes == localPtr->nameLength) && - (strncmp(name,localName,(unsigned)nameBytes) == 0)) { + (strncmp(name, localName, nameBytes) == 0)) { return i; } } diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 46adc69..b858dfa 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -903,7 +903,7 @@ declare 227 { # Used to be needed for TclOO-extension; unneeded now that TclOO is in the # core and NRE-enabled # declare 228 { -# int TclObjInterpProcCore(register Tcl_Interp *interp, Tcl_Obj *procNameObj, +# int TclObjInterpProcCore(Tcl_Interp *interp, Tcl_Obj *procNameObj, # int skip, ProcErrorProc *errorProc) # } declare 229 { diff --git a/generic/tclInt.h b/generic/tclInt.h index fe69b26..46ba764 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4315,8 +4315,8 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, (objPtr)->bytes = tclEmptyStringRep; \ (objPtr)->length = 0; \ } else { \ - (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \ - memcpy((objPtr)->bytes, (bytePtr), (unsigned) (len)); \ + (objPtr)->bytes = (char *) ckalloc((len) + 1); \ + memcpy((objPtr)->bytes, (bytePtr), (len)); \ (objPtr)->bytes[len] = '\0'; \ (objPtr)->length = (len); \ } diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 55473c1..35c54be 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -213,7 +213,7 @@ TclCreateLiteral( if ((objLength == length) && ((length == 0) || ((objBytes[0] == bytes[0]) - && (memcmp(objBytes, bytes, (unsigned) length) == 0)))) { + && (memcmp(objBytes, bytes, length) == 0)))) { /* * A literal was found: return it */ @@ -418,7 +418,7 @@ TclRegisterLiteral( objPtr = localPtr->objPtr; if ((objPtr->length == length) && ((length == 0) || ((objPtr->bytes[0] == bytes[0]) - && (memcmp(objPtr->bytes, bytes, (unsigned) length) == 0)))) { + && (memcmp(objPtr->bytes, bytes, length) == 0)))) { if ((flags & LITERAL_ON_HEAP)) { ckfree(bytes); } diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index cf4ecc4..bfce6ee 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -225,7 +225,7 @@ TclInitNamespaceSubsystem(void) Tcl_Namespace * Tcl_GetCurrentNamespace( - register Tcl_Interp *interp)/* Interpreter whose current namespace is + Tcl_Interp *interp)/* Interpreter whose current namespace is * being queried. */ { return TclGetCurrentNamespace(interp); @@ -249,7 +249,7 @@ Tcl_GetCurrentNamespace( Tcl_Namespace * Tcl_GetGlobalNamespace( - register Tcl_Interp *interp)/* Interpreter whose global namespace should + Tcl_Interp *interp)/* Interpreter whose global namespace should * be returned. */ { return TclGetGlobalNamespace(interp); @@ -301,8 +301,8 @@ Tcl_PushCallFrame( * variables. */ { Interp *iPtr = (Interp *) interp; - register CallFrame *framePtr = (CallFrame *) callFramePtr; - register Namespace *nsPtr; + CallFrame *framePtr = (CallFrame *) callFramePtr; + Namespace *nsPtr; if (namespacePtr == NULL) { nsPtr = (Namespace *) TclGetCurrentNamespace(interp); @@ -378,8 +378,8 @@ void Tcl_PopCallFrame( Tcl_Interp *interp) /* Interpreter with call frame to pop. */ { - register Interp *iPtr = (Interp *) interp; - register CallFrame *framePtr = iPtr->framePtr; + Interp *iPtr = (Interp *) interp; + CallFrame *framePtr = iPtr->framePtr; Namespace *nsPtr; /* @@ -664,7 +664,7 @@ Tcl_CreateNamespace( * function should be called. */ { Interp *iPtr = (Interp *) interp; - register Namespace *nsPtr, *ancestorPtr; + Namespace *nsPtr, *ancestorPtr; Namespace *parentPtr, *dummy1Ptr, *dummy2Ptr; Namespace *globalNsPtr = iPtr->globalNsPtr; const char *simpleName; @@ -833,7 +833,7 @@ Tcl_CreateNamespace( for (ancestorPtr = nsPtr; ancestorPtr != NULL; ancestorPtr = ancestorPtr->parentPtr) { if (ancestorPtr != globalNsPtr) { - register Tcl_DString *tempPtr = namePtr; + Tcl_DString *tempPtr = namePtr; TclDStringAppendLiteral(buffPtr, "::"); Tcl_DStringAppend(buffPtr, ancestorPtr->name, -1); @@ -861,7 +861,7 @@ Tcl_CreateNamespace( name = Tcl_DStringValue(namePtr); nameLen = Tcl_DStringLength(namePtr); nsPtr->fullName = ckalloc(nameLen + 1); - memcpy(nsPtr->fullName, name, (unsigned) nameLen + 1); + memcpy(nsPtr->fullName, name, nameLen + 1); Tcl_DStringFree(&buffer1); Tcl_DStringFree(&buffer2); @@ -907,7 +907,7 @@ void Tcl_DeleteNamespace( Tcl_Namespace *namespacePtr)/* Points to the namespace to delete. */ { - register Namespace *nsPtr = (Namespace *) namespacePtr; + Namespace *nsPtr = (Namespace *) namespacePtr; Interp *iPtr = (Interp *) nsPtr->interp; Namespace *globalNsPtr = (Namespace *) TclGetGlobalNamespace((Tcl_Interp *) iPtr); @@ -1103,11 +1103,11 @@ TclNamespaceDeleted( void TclTeardownNamespace( - register Namespace *nsPtr) /* Points to the namespace to be dismantled + Namespace *nsPtr) /* Points to the namespace to be dismantled * and unlinked from its parent. */ { Interp *iPtr = (Interp *) nsPtr->interp; - register Tcl_HashEntry *entryPtr; + Tcl_HashEntry *entryPtr; Tcl_HashSearch search; int i; @@ -1296,7 +1296,7 @@ TclTeardownNamespace( static void NamespaceFree( - register Namespace *nsPtr) /* Points to the namespace to free. */ + Namespace *nsPtr) /* Points to the namespace to free. */ { /* * Most of the namespace's contents are freed when the namespace is @@ -1455,7 +1455,7 @@ Tcl_Export( len = strlen(pattern); patternCpy = ckalloc(len + 1); - memcpy(patternCpy, pattern, (unsigned) len + 1); + memcpy(patternCpy, pattern, len + 1); nsPtr->exportArrayPtr[nsPtr->numExportPatterns] = patternCpy; nsPtr->numExportPatterns++; @@ -1572,7 +1572,7 @@ Tcl_Import( { Namespace *nsPtr, *importNsPtr, *dummyPtr; const char *simplePattern; - register Tcl_HashEntry *hPtr; + Tcl_HashEntry *hPtr; Tcl_HashSearch search; /* @@ -1851,7 +1851,7 @@ Tcl_ForgetImport( Namespace *nsPtr, *sourceNsPtr, *dummyPtr; const char *simplePattern; char *cmdName; - register Tcl_HashEntry *hPtr; + Tcl_HashEntry *hPtr; Tcl_HashSearch search; /* @@ -1978,7 +1978,7 @@ TclGetOriginalCommand( Tcl_Command command) /* The imported command for which the original * command should be returned. */ { - register Command *cmdPtr = (Command *) command; + Command *cmdPtr = (Command *) command; ImportedCmdData *dataPtr; if (cmdPtr->deleteProc != DeleteImportedCmd) { @@ -2067,7 +2067,7 @@ DeleteImportedCmd( ImportedCmdData *dataPtr = clientData; Command *realCmdPtr = dataPtr->realCmdPtr; Command *selfPtr = dataPtr->selfPtr; - register ImportRef *refPtr, *prevPtr; + ImportRef *refPtr, *prevPtr; prevPtr = NULL; for (refPtr = realCmdPtr->importRefPtr; refPtr != NULL; @@ -2487,7 +2487,7 @@ Tcl_FindNamespace( * points to namespace in which to resolve * name; if NULL, look up name in the current * namespace. */ - register int flags) /* Flags controlling namespace lookup: an OR'd + int flags) /* Flags controlling namespace lookup: an OR'd * combination of TCL_GLOBAL_ONLY and * TCL_LEAVE_ERR_MSG flags. */ { @@ -2558,8 +2558,8 @@ Tcl_FindCommand( { Interp *iPtr = (Interp *) interp; Namespace *cxtNsPtr; - register Tcl_HashEntry *entryPtr; - register Command *cmdPtr; + Tcl_HashEntry *entryPtr; + Command *cmdPtr; const char *simpleName; int result; @@ -2670,7 +2670,7 @@ Tcl_FindCommand( } } else { Namespace *nsPtr[2]; - register int search; + int search; TclGetNamespaceForQualName(interp, name, cxtNsPtr, flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName); @@ -2744,7 +2744,7 @@ TclResetShadowedCmdRefs( { char *cmdName; Tcl_HashEntry *hPtr; - register Namespace *nsPtr; + Namespace *nsPtr; Namespace *trailNsPtr, *shadowNsPtr; Namespace *globalNsPtr = (Namespace *) TclGetGlobalNamespace(interp); int found, i; @@ -2991,7 +2991,7 @@ NamespaceChildrenCmd( Namespace *globalNsPtr = (Namespace *) TclGetGlobalNamespace(interp); const char *pattern = NULL; Tcl_DString buffer; - register Tcl_HashEntry *entryPtr; + Tcl_HashEntry *entryPtr; Tcl_HashSearch search; Tcl_Obj *listPtr, *elemPtr; @@ -3117,7 +3117,7 @@ NamespaceCodeCmd( { Namespace *currNsPtr; Tcl_Obj *listPtr, *objPtr; - register const char *arg; + const char *arg; int length; if (objc != 2) { @@ -3196,7 +3196,7 @@ NamespaceCurrentCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Namespace *currNsPtr; + Namespace *currNsPtr; if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); @@ -3261,7 +3261,7 @@ NamespaceDeleteCmd( { Tcl_Namespace *namespacePtr; const char *name; - register int i; + int i; if (objc < 1) { Tcl_WrongNumArgs(interp, 1, objv, "?name name...?"); @@ -3616,7 +3616,7 @@ NamespaceForgetCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { const char *pattern; - register int i, result; + int i, result; if (objc < 1) { Tcl_WrongNumArgs(interp, 1, objv, "?pattern pattern...?"); @@ -3682,7 +3682,7 @@ NamespaceImportCmd( { int allowOverwrite = 0; const char *string, *pattern; - register int i, result; + int i, result; int firstArg; if (objc < 1) { @@ -3835,7 +3835,7 @@ NRNamespaceInscopeCmd( cmdObjPtr = objv[2]; } else { Tcl_Obj *concatObjv[2]; - register Tcl_Obj *listPtr; + Tcl_Obj *listPtr; listPtr = Tcl_NewListObj(0, NULL); for (i = 3; i < objc; i++) { @@ -4236,7 +4236,7 @@ NamespaceQualifiersCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register const char *name, *p; + const char *name, *p; int length; if (objc != 2) { @@ -4491,7 +4491,7 @@ NamespaceTailCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register const char *name, *p; + const char *name, *p; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "string"); @@ -4694,7 +4694,7 @@ NamespaceWhichCmd( static void FreeNsNameInternalRep( - register Tcl_Obj *objPtr) /* nsName object with internal representation + Tcl_Obj *objPtr) /* nsName object with internal representation * to free. */ { ResolvedNsName *resNamePtr = objPtr->internalRep.twoPtrValue.ptr1; @@ -4740,7 +4740,7 @@ FreeNsNameInternalRep( static void DupNsNameInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ - register Tcl_Obj *copyPtr) /* Object with internal rep to set. */ + Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { ResolvedNsName *resNamePtr = srcPtr->internalRep.twoPtrValue.ptr1; @@ -4776,11 +4776,11 @@ SetNsNameFromAny( Tcl_Interp *interp, /* Points to the namespace in which to resolve * name. Also used for error reporting if not * NULL. */ - register Tcl_Obj *objPtr) /* The object to convert. */ + Tcl_Obj *objPtr) /* The object to convert. */ { const char *dummy; Namespace *nsPtr, *dummy1Ptr, *dummy2Ptr; - register ResolvedNsName *resNamePtr; + ResolvedNsName *resNamePtr; const char *name; if (interp == NULL) { @@ -4914,7 +4914,7 @@ TclLogCommandInfo( Tcl_Obj **tosPtr) /* Current stack of bytecode execution * context */ { - register const char *p; + const char *p; Interp *iPtr = (Interp *) interp; int overflow, limit = 150; Var *varPtr, *arrayPtr; diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c index cc02c68..65b1e38 100644 --- a/generic/tclOOCall.c +++ b/generic/tclOOCall.c @@ -105,7 +105,7 @@ void TclOODeleteContext( CallContext *contextPtr) { - register Object *oPtr = contextPtr->oPtr; + Object *oPtr = contextPtr->oPtr; TclOODeleteChain(contextPtr->callPtr); if (oPtr != NULL) { @@ -215,7 +215,7 @@ DupMethodNameRep( Tcl_Obj *srcPtr, Tcl_Obj *dstPtr) { - register CallChain *callPtr = srcPtr->internalRep.twoPtrValue.ptr1; + CallChain *callPtr = srcPtr->internalRep.twoPtrValue.ptr1; dstPtr->typePtr = &methodNameType; dstPtr->internalRep.twoPtrValue.ptr1 = callPtr; @@ -226,7 +226,7 @@ static void FreeMethodNameRep( Tcl_Obj *objPtr) { - register CallChain *callPtr = objPtr->internalRep.twoPtrValue.ptr1; + CallChain *callPtr = objPtr->internalRep.twoPtrValue.ptr1; TclOODeleteChain(callPtr); objPtr->typePtr = NULL; @@ -255,7 +255,7 @@ TclOOInvokeContext( int objc, /* The number of arguments. */ Tcl_Obj *const objv[]) /* The arguments as actually seen. */ { - register CallContext *const contextPtr = clientData; + CallContext *const contextPtr = clientData; Method *const mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr; const int isFilter = contextPtr->callPtr->chain[contextPtr->index].isFilter; @@ -487,7 +487,7 @@ TclOOGetSortedMethodList( if (i > 0) { if (i > 1) { - qsort((void *) strings, (unsigned) i, sizeof(char *), CmpStr); + qsort((void *) strings, i, sizeof(char *), CmpStr); } *stringsPtr = strings; } else { @@ -560,7 +560,7 @@ TclOOGetSortedClassMethodList( if (i > 0) { if (i > 1) { - qsort((void *) strings, (unsigned) i, sizeof(char *), CmpStr); + qsort((void *) strings, i, sizeof(char *), CmpStr); } *stringsPtr = strings; } else { @@ -792,7 +792,7 @@ AddMethodToCallChain( * looking to add things from a mixin and have * not passed a mixin. */ { - register CallChain *callPtr = cbPtr->callChainPtr; + CallChain *callPtr = cbPtr->callChainPtr; int i; /* @@ -1463,7 +1463,7 @@ AddSimpleClassChainToCallContext( (char *) methodNameObj); if (hPtr != NULL) { - register Method *mPtr = Tcl_GetHashValue(hPtr); + Method *mPtr = Tcl_GetHashValue(hPtr); if (!(flags & KNOWN_STATE)) { if (flags & PUBLIC_METHOD) { diff --git a/generic/tclObj.c b/generic/tclObj.c index a2544ad..70b2b1e 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -876,7 +876,7 @@ Tcl_AppendAllObjTypes( * name of each registered type is appended as * a list element. */ { - register Tcl_HashEntry *hPtr; + Tcl_HashEntry *hPtr; Tcl_HashSearch search; int numElems; @@ -924,7 +924,7 @@ const Tcl_ObjType * Tcl_GetObjType( const char *typeName) /* Name of Tcl object type to look up. */ { - register Tcl_HashEntry *hPtr; + Tcl_HashEntry *hPtr; const Tcl_ObjType *typePtr = NULL; Tcl_MutexLock(&tableMutex); @@ -1054,10 +1054,10 @@ TclDbDumpActiveObjects( #ifdef TCL_MEM_DEBUG void TclDbInitNewObj( - register Tcl_Obj *objPtr, - register const char *file, /* The name of the source file calling this + Tcl_Obj *objPtr, + const char *file, /* The name of the source file calling this * function; used for debugging. */ - register int line) /* Line number in the source file; used for + int line) /* Line number in the source file; used for * debugging. */ { objPtr->refCount = 0; @@ -1142,7 +1142,7 @@ Tcl_NewObj(void) Tcl_Obj * Tcl_NewObj(void) { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; /* * Use the macro defined in tclInt.h - it will use the correct allocator. @@ -1184,12 +1184,12 @@ Tcl_NewObj(void) Tcl_Obj * Tcl_DbNewObj( - register const char *file, /* The name of the source file calling this + const char *file, /* The name of the source file calling this * function; used for debugging. */ - register int line) /* Line number in the source file; used for + int line) /* Line number in the source file; used for * debugging. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; /* * Use the macro defined in tclInt.h - it will use the correct allocator. @@ -1239,8 +1239,8 @@ TclAllocateFreeObjects(void) { size_t bytesToAlloc = (OBJS_TO_ALLOC_EACH_TIME * sizeof(Tcl_Obj)); char *basePtr; - register Tcl_Obj *prevPtr, *objPtr; - register int i; + Tcl_Obj *prevPtr, *objPtr; + int i; /* * This has been noted by Purify to be a potential leak. The problem is @@ -1291,9 +1291,9 @@ TclAllocateFreeObjects(void) #ifdef TCL_MEM_DEBUG void TclFreeObj( - register Tcl_Obj *objPtr) /* The object to be freed. */ + Tcl_Obj *objPtr) /* The object to be freed. */ { - register const Tcl_ObjType *typePtr = objPtr->typePtr; + const Tcl_ObjType *typePtr = objPtr->typePtr; /* * This macro declares a variable, so must come here... @@ -1416,7 +1416,7 @@ TclFreeObj( void TclFreeObj( - register Tcl_Obj *objPtr) /* The object to be freed. */ + Tcl_Obj *objPtr) /* The object to be freed. */ { /* * Invalidate the string rep first so we can use the bytes value for our @@ -1625,7 +1625,7 @@ TclSetDuplicateObj( char * Tcl_GetString( - register Tcl_Obj *objPtr) /* Object whose string rep byte pointer should + Tcl_Obj *objPtr) /* Object whose string rep byte pointer should * be returned. */ { if (objPtr->bytes != NULL) { @@ -1683,9 +1683,9 @@ Tcl_GetString( char * Tcl_GetStringFromObj( - register Tcl_Obj *objPtr, /* Object whose string rep byte pointer should + Tcl_Obj *objPtr, /* Object whose string rep byte pointer should * be returned. */ - register int *lengthPtr) /* If non-NULL, the location where the string + int *lengthPtr) /* If non-NULL, the location where the string * rep's byte array length should * be stored. * If NULL, no length is stored. */ { @@ -1717,7 +1717,7 @@ Tcl_GetStringFromObj( void Tcl_InvalidateStringRep( - register Tcl_Obj *objPtr) /* Object whose string rep byte pointer should + Tcl_Obj *objPtr) /* Object whose string rep byte pointer should * be freed. */ { TclInvalidateStringRep(objPtr); @@ -1751,7 +1751,7 @@ Tcl_InvalidateStringRep( Tcl_Obj * Tcl_NewBooleanObj( - register int boolValue) /* Boolean used to initialize new object. */ + int boolValue) /* Boolean used to initialize new object. */ { return Tcl_DbNewBooleanObj(boolValue, "unknown", 0); } @@ -1760,9 +1760,9 @@ Tcl_NewBooleanObj( Tcl_Obj * Tcl_NewBooleanObj( - register int boolValue) /* Boolean used to initialize new object. */ + int boolValue) /* Boolean used to initialize new object. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclNewBooleanObj(objPtr, boolValue); return objPtr; @@ -1800,13 +1800,13 @@ Tcl_NewBooleanObj( Tcl_Obj * Tcl_DbNewBooleanObj( - register int boolValue, /* Boolean used to initialize new object. */ + int boolValue, /* Boolean used to initialize new object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for * debugging. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclDbNewObj(objPtr, file, line); objPtr->bytes = NULL; @@ -1820,7 +1820,7 @@ Tcl_DbNewBooleanObj( Tcl_Obj * Tcl_DbNewBooleanObj( - register int boolValue, /* Boolean used to initialize new object. */ + int boolValue, /* Boolean used to initialize new object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for @@ -1851,8 +1851,8 @@ Tcl_DbNewBooleanObj( #undef Tcl_SetBooleanObj void Tcl_SetBooleanObj( - register Tcl_Obj *objPtr, /* Object whose internal rep to init. */ - register int boolValue) /* Boolean used to set object's value. */ + Tcl_Obj *objPtr, /* Object whose internal rep to init. */ + int boolValue) /* Boolean used to set object's value. */ { if (Tcl_IsShared(objPtr)) { Tcl_Panic("%s called with shared object", "Tcl_SetBooleanObj"); @@ -1883,8 +1883,8 @@ Tcl_SetBooleanObj( int Tcl_GetBooleanFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr, /* The object from which to get boolean. */ - register int *boolPtr) /* Place to store resulting boolean. */ + Tcl_Obj *objPtr, /* The object from which to get boolean. */ + int *boolPtr) /* Place to store resulting boolean. */ { do { if (objPtr->typePtr == &tclIntType) { @@ -1950,7 +1950,7 @@ Tcl_GetBooleanFromObj( int TclSetBooleanFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr) /* The object to convert. */ + Tcl_Obj *objPtr) /* The object to convert. */ { /* * For some "pure" numeric Tcl_ObjTypes (no string rep), we can determine @@ -2003,7 +2003,7 @@ TclSetBooleanFromAny( static int ParseBoolean( - register Tcl_Obj *objPtr) /* The object to parse/convert. */ + Tcl_Obj *objPtr) /* The object to parse/convert. */ { int i, length, newBool; char lowerCase[6]; @@ -2144,7 +2144,7 @@ ParseBoolean( Tcl_Obj * Tcl_NewDoubleObj( - register double dblValue) /* Double used to initialize the object. */ + double dblValue) /* Double used to initialize the object. */ { return Tcl_DbNewDoubleObj(dblValue, "unknown", 0); } @@ -2153,9 +2153,9 @@ Tcl_NewDoubleObj( Tcl_Obj * Tcl_NewDoubleObj( - register double dblValue) /* Double used to initialize the object. */ + double dblValue) /* Double used to initialize the object. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclNewDoubleObj(objPtr, dblValue); return objPtr; @@ -2192,13 +2192,13 @@ Tcl_NewDoubleObj( Tcl_Obj * Tcl_DbNewDoubleObj( - register double dblValue, /* Double used to initialize the object. */ + double dblValue, /* Double used to initialize the object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for * debugging. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclDbNewObj(objPtr, file, line); objPtr->bytes = NULL; @@ -2212,7 +2212,7 @@ Tcl_DbNewDoubleObj( Tcl_Obj * Tcl_DbNewDoubleObj( - register double dblValue, /* Double used to initialize the object. */ + double dblValue, /* Double used to initialize the object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for @@ -2242,8 +2242,8 @@ Tcl_DbNewDoubleObj( void Tcl_SetDoubleObj( - register Tcl_Obj *objPtr, /* Object whose internal rep to init. */ - register double dblValue) /* Double used to set the object's value. */ + Tcl_Obj *objPtr, /* Object whose internal rep to init. */ + double dblValue) /* Double used to set the object's value. */ { if (Tcl_IsShared(objPtr)) { Tcl_Panic("%s called with shared object", "Tcl_SetDoubleObj"); @@ -2275,8 +2275,8 @@ Tcl_SetDoubleObj( int Tcl_GetDoubleFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr, /* The object from which to get a double. */ - register double *dblPtr) /* Place to store resulting double. */ + Tcl_Obj *objPtr, /* The object from which to get a double. */ + double *dblPtr) /* Place to store resulting double. */ { do { if (objPtr->typePtr == &tclDoubleType) { @@ -2336,7 +2336,7 @@ Tcl_GetDoubleFromObj( static int SetDoubleFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr) /* The object to convert. */ + Tcl_Obj *objPtr) /* The object to convert. */ { return TclParseNumber(interp, objPtr, "floating-point number", NULL, -1, NULL, 0); @@ -2365,16 +2365,16 @@ SetDoubleFromAny( static void UpdateStringOfDouble( - register Tcl_Obj *objPtr) /* Double obj with string rep to update. */ + Tcl_Obj *objPtr) /* Double obj with string rep to update. */ { char buffer[TCL_DOUBLE_SPACE]; - register int len; + int len; Tcl_PrintDouble(NULL, objPtr->internalRep.doubleValue, buffer); len = strlen(buffer); objPtr->bytes = (char *)ckalloc(len + 1); - memcpy(objPtr->bytes, buffer, (unsigned) len + 1); + memcpy(objPtr->bytes, buffer, len + 1); objPtr->length = len; } @@ -2413,7 +2413,7 @@ UpdateStringOfDouble( Tcl_Obj * Tcl_NewIntObj( - register int intValue) /* Int used to initialize the new object. */ + int intValue) /* Int used to initialize the new object. */ { return Tcl_DbNewLongObj((long)intValue, "unknown", 0); } @@ -2422,9 +2422,9 @@ Tcl_NewIntObj( Tcl_Obj * Tcl_NewIntObj( - register int intValue) /* Int used to initialize the new object. */ + int intValue) /* Int used to initialize the new object. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclNewIntObj(objPtr, intValue); return objPtr; @@ -2452,8 +2452,8 @@ Tcl_NewIntObj( #undef Tcl_SetIntObj void Tcl_SetIntObj( - register Tcl_Obj *objPtr, /* Object whose internal rep to init. */ - register int intValue) /* Integer used to set object's value. */ + Tcl_Obj *objPtr, /* Object whose internal rep to init. */ + int intValue) /* Integer used to set object's value. */ { if (Tcl_IsShared(objPtr)) { Tcl_Panic("%s called with shared object", "Tcl_SetIntObj"); @@ -2494,8 +2494,8 @@ Tcl_SetIntObj( int Tcl_GetIntFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr, /* The object from which to get a int. */ - register int *intPtr) /* Place to store resulting int. */ + Tcl_Obj *objPtr, /* The object from which to get a int. */ + int *intPtr) /* Place to store resulting int. */ { #if (LONG_MAX == INT_MAX) return TclGetLongFromObj(interp, objPtr, (long *) intPtr); @@ -2566,15 +2566,15 @@ SetIntFromAny( static void UpdateStringOfInt( - register Tcl_Obj *objPtr) /* Int object whose string rep to update. */ + Tcl_Obj *objPtr) /* Int object whose string rep to update. */ { char buffer[TCL_INTEGER_SPACE]; - register int len; + int len; len = TclFormatInt(buffer, objPtr->internalRep.longValue); objPtr->bytes = (char *)ckalloc(len + 1); - memcpy(objPtr->bytes, buffer, (unsigned) len + 1); + memcpy(objPtr->bytes, buffer, len + 1); objPtr->length = len; } @@ -2613,7 +2613,7 @@ UpdateStringOfInt( Tcl_Obj * Tcl_NewLongObj( - register long longValue) /* Long integer used to initialize the + long longValue) /* Long integer used to initialize the * new object. */ { return Tcl_DbNewLongObj(longValue, "unknown", 0); @@ -2623,10 +2623,10 @@ Tcl_NewLongObj( Tcl_Obj * Tcl_NewLongObj( - register long longValue) /* Long integer used to initialize the + long longValue) /* Long integer used to initialize the * new object. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclNewLongObj(objPtr, longValue); return objPtr; @@ -2669,14 +2669,14 @@ Tcl_NewLongObj( Tcl_Obj * Tcl_DbNewLongObj( - register long longValue, /* Long integer used to initialize the new + long longValue, /* Long integer used to initialize the new * object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for * debugging. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclDbNewObj(objPtr, file, line); objPtr->bytes = NULL; @@ -2690,7 +2690,7 @@ Tcl_DbNewLongObj( Tcl_Obj * Tcl_DbNewLongObj( - register long longValue, /* Long integer used to initialize the new + long longValue, /* Long integer used to initialize the new * object. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ @@ -2721,8 +2721,8 @@ Tcl_DbNewLongObj( void Tcl_SetLongObj( - register Tcl_Obj *objPtr, /* Object whose internal rep to init. */ - register long longValue) /* Long integer used to initialize the + Tcl_Obj *objPtr, /* Object whose internal rep to init. */ + long longValue) /* Long integer used to initialize the * object's value. */ { if (Tcl_IsShared(objPtr)) { @@ -2756,8 +2756,8 @@ Tcl_SetLongObj( int Tcl_GetLongFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr, /* The object from which to get a long. */ - register long *longPtr) /* Place to store resulting long. */ + Tcl_Obj *objPtr, /* The object from which to get a long. */ + long *longPtr) /* Place to store resulting long. */ { do { if (objPtr->typePtr == &tclIntType) { @@ -2862,11 +2862,11 @@ Tcl_GetLongFromObj( static void UpdateStringOfWideInt( - register Tcl_Obj *objPtr) /* Int object whose string rep to update. */ + Tcl_Obj *objPtr) /* Int object whose string rep to update. */ { char buffer[TCL_INTEGER_SPACE+2]; - register unsigned len; - register Tcl_WideInt wideVal = objPtr->internalRep.wideValue; + unsigned len; + Tcl_WideInt wideVal = objPtr->internalRep.wideValue; /* * Note that sprintf will generate a compiler warning under Mingw claiming @@ -2913,7 +2913,7 @@ UpdateStringOfWideInt( Tcl_Obj * Tcl_NewWideIntObj( - register Tcl_WideInt wideValue) + Tcl_WideInt wideValue) /* Wide integer used to initialize the new * object. */ { @@ -2924,11 +2924,11 @@ Tcl_NewWideIntObj( Tcl_Obj * Tcl_NewWideIntObj( - register Tcl_WideInt wideValue) + Tcl_WideInt wideValue) /* Wide integer used to initialize the new * object. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclNewObj(objPtr); Tcl_SetWideIntObj(objPtr, wideValue); @@ -2972,7 +2972,7 @@ Tcl_NewWideIntObj( Tcl_Obj * Tcl_DbNewWideIntObj( - register Tcl_WideInt wideValue, + Tcl_WideInt wideValue, /* Wide integer used to initialize the new * object. */ const char *file, /* The name of the source file calling this @@ -2980,7 +2980,7 @@ Tcl_DbNewWideIntObj( int line) /* Line number in the source file; used for * debugging. */ { - register Tcl_Obj *objPtr; + Tcl_Obj *objPtr; TclDbNewObj(objPtr, file, line); Tcl_SetWideIntObj(objPtr, wideValue); @@ -2991,7 +2991,7 @@ Tcl_DbNewWideIntObj( Tcl_Obj * Tcl_DbNewWideIntObj( - register Tcl_WideInt wideValue, + Tcl_WideInt wideValue, /* Long integer used to initialize the new * object. */ const char *file, /* The name of the source file calling this @@ -3023,8 +3023,8 @@ Tcl_DbNewWideIntObj( void Tcl_SetWideIntObj( - register Tcl_Obj *objPtr, /* Object w. internal rep to init. */ - register Tcl_WideInt wideValue) + Tcl_Obj *objPtr, /* Object w. internal rep to init. */ + Tcl_WideInt wideValue) /* Wide integer used to initialize the * object's value. */ { @@ -3071,8 +3071,8 @@ Tcl_SetWideIntObj( int Tcl_GetWideIntFromObj( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr, /* Object from which to get a wide int. */ - register Tcl_WideInt *wideIntPtr) + Tcl_Obj *objPtr, /* Object from which to get a wide int. */ + Tcl_WideInt *wideIntPtr) /* Place to store resulting long. */ { do { @@ -3712,7 +3712,7 @@ TclGetNumberFromObj( void Tcl_DbIncrRefCount( - register Tcl_Obj *objPtr, /* The object we are registering a reference + Tcl_Obj *objPtr, /* The object we are registering a reference * to. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ @@ -3775,7 +3775,7 @@ Tcl_DbIncrRefCount( void Tcl_DbDecrRefCount( - register Tcl_Obj *objPtr, /* The object we are releasing a reference + Tcl_Obj *objPtr, /* The object we are releasing a reference * to. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ @@ -3841,7 +3841,7 @@ Tcl_DbDecrRefCount( int Tcl_DbIsShared( - register Tcl_Obj *objPtr, /* The object to test for being shared. */ + Tcl_Obj *objPtr, /* The object to test for being shared. */ const char *file, /* The name of the source file calling this * function; used for debugging. */ int line) /* Line number in the source file; used for @@ -3913,7 +3913,7 @@ Tcl_DbIsShared( void Tcl_InitObjHashTable( - register Tcl_HashTable *tablePtr) + Tcl_HashTable *tablePtr) /* Pointer to table record, which is supplied * by the caller. */ { @@ -3976,8 +3976,8 @@ TclCompareObjKeys( { Tcl_Obj *objPtr1 = keyPtr; Tcl_Obj *objPtr2 = (Tcl_Obj *) hPtr->key.oneWordValue; - register const char *p1, *p2; - register size_t l1, l2; + const char *p1, *p2; + size_t l1, l2; /* * If the object pointers are the same then they match. @@ -4134,13 +4134,13 @@ Tcl_Command Tcl_GetCommandFromObj( Tcl_Interp *interp, /* The interpreter in which to resolve the * command and to report errors. */ - register Tcl_Obj *objPtr) /* The object containing the command's name. + Tcl_Obj *objPtr) /* The object containing the command's name. * If the name starts with "::", will be * looked up in global namespace. Else, looked * up first in the current namespace, then in * global namespace. */ { - register ResolvedCmdName *resPtr; + ResolvedCmdName *resPtr; /* * Get the internal representation, converting to a command type if @@ -4163,13 +4163,13 @@ Tcl_GetCommandFromObj( resPtr = objPtr->internalRep.twoPtrValue.ptr1; if ((objPtr->typePtr == &tclCmdNameType) && (resPtr != NULL)) { - register Command *cmdPtr = resPtr->cmdPtr; + 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 *) + Namespace *refNsPtr = (Namespace *) TclGetCurrentNamespace(interp); if ((resPtr->refNsPtr == NULL) @@ -4218,14 +4218,14 @@ 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 + 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. */ { Interp *iPtr = (Interp *) interp; - register ResolvedCmdName *resPtr; - register Namespace *currNsPtr; + ResolvedCmdName *resPtr; + Namespace *currNsPtr; const char *name; if (objPtr->typePtr == &tclCmdNameType) { @@ -4290,10 +4290,10 @@ TclSetCmdNameObj( static void FreeCmdNameInternalRep( - register Tcl_Obj *objPtr) /* CmdName object with internal + Tcl_Obj *objPtr) /* CmdName object with internal * representation to free. */ { - register ResolvedCmdName *resPtr = objPtr->internalRep.twoPtrValue.ptr1; + ResolvedCmdName *resPtr = objPtr->internalRep.twoPtrValue.ptr1; if (resPtr != NULL) { /* @@ -4340,9 +4340,9 @@ FreeCmdNameInternalRep( static void DupCmdNameInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ - register Tcl_Obj *copyPtr) /* Object with internal rep to set. */ + Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { - register ResolvedCmdName *resPtr = srcPtr->internalRep.twoPtrValue.ptr1; + ResolvedCmdName *resPtr = srcPtr->internalRep.twoPtrValue.ptr1; copyPtr->internalRep.twoPtrValue.ptr1 = resPtr; copyPtr->internalRep.twoPtrValue.ptr2 = NULL; @@ -4376,13 +4376,13 @@ DupCmdNameInternalRep( static int SetCmdNameFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - register Tcl_Obj *objPtr) /* The object to convert. */ + Tcl_Obj *objPtr) /* The object to convert. */ { Interp *iPtr = (Interp *) interp; const char *name; - register Command *cmdPtr; + Command *cmdPtr; Namespace *currNsPtr; - register ResolvedCmdName *resPtr; + ResolvedCmdName *resPtr; if (interp == NULL) { return TCL_ERROR; diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 19ff8fd..2070956 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -64,7 +64,7 @@ #define NUM_REGEXPS 30 -typedef struct ThreadSpecificData { +typedef struct { int initialized; /* Set to 1 when the module is initialized. */ char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled regular * expression patterns. NULL means that this @@ -245,7 +245,7 @@ Tcl_RegExpRange( if ((size_t) index > regexpPtr->re.re_nsub) { *startPtr = *endPtr = NULL; - } else if (regexpPtr->matches[index].rm_so < 0) { + } else if (regexpPtr->matches[index].rm_so == -1) { *startPtr = *endPtr = NULL; } else { if (regexpPtr->objPtr) { @@ -355,7 +355,7 @@ TclRegExpRangeUniChar( { TclRegexp *regexpPtr = (TclRegexp *) re; - if ((regexpPtr->flags®_EXPECT) && index == -1) { + if ((regexpPtr->flags®_EXPECT) && (index == -1)) { *startPtr = regexpPtr->details.rm_extend.rm_so; *endPtr = regexpPtr->details.rm_extend.rm_eo; } else if ((size_t) index > regexpPtr->re.re_nsub) { @@ -510,9 +510,9 @@ Tcl_RegExpMatchObj( */ if (!(re = Tcl_GetRegExpFromObj(interp, patternObj, - TCL_REG_ADVANCED | TCL_REG_NOSUB)) + TCL_REG_ADVANCED | TCL_REG_NOSUB)) && !(re = Tcl_GetRegExpFromObj(interp, patternObj, TCL_REG_ADVANCED))) { - return -1; + return -1; } return Tcl_RegExpExecObj(interp, re, textObj, 0 /* offset */, 0 /* nmatches */, 0 /* flags */); @@ -912,7 +912,7 @@ CompileRegexp( * This is a new expression, so compile it and add it to the cache. */ - regexpPtr = ckalloc(sizeof(TclRegexp)); + regexpPtr = (TclRegexp*)ckalloc(sizeof(TclRegexp)); regexpPtr->objPtr = NULL; regexpPtr->string = NULL; regexpPtr->details.rm_extend.rm_so = -1; @@ -967,7 +967,7 @@ CompileRegexp( */ regexpPtr->matches = - ckalloc(sizeof(regmatch_t) * (regexpPtr->re.re_nsub + 1)); + (regmatch_t*)ckalloc(sizeof(regmatch_t) * (regexpPtr->re.re_nsub + 1)); /* * Initialize the refcount to one initially, since it is in the cache. @@ -993,8 +993,8 @@ CompileRegexp( tsdPtr->patLengths[i+1] = tsdPtr->patLengths[i]; tsdPtr->regexps[i+1] = tsdPtr->regexps[i]; } - tsdPtr->patterns[0] = ckalloc(length + 1); - memcpy(tsdPtr->patterns[0], string, (unsigned) length + 1); + tsdPtr->patterns[0] = (char *)ckalloc(length + 1); + memcpy(tsdPtr->patterns[0], string, length + 1); tsdPtr->patLengths[0] = length; tsdPtr->regexps[0] = regexpPtr; diff --git a/generic/tclResult.c b/generic/tclResult.c index caad71e..07d0e83 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -411,14 +411,14 @@ void Tcl_SetResult( Tcl_Interp *interp, /* Interpreter with which to associate the * return value. */ - register char *result, /* Value to be returned. If NULL, the result + char *result, /* Value to be returned. If NULL, the result * is set to an empty string. */ Tcl_FreeProc *freeProc) /* Gives information about the string: * TCL_STATIC, TCL_VOLATILE, or the address of * a Tcl_FreeProc such as free. */ { Interp *iPtr = (Interp *) interp; - register Tcl_FreeProc *oldFreeProc = iPtr->freeProc; + Tcl_FreeProc *oldFreeProc = iPtr->freeProc; char *oldResult = iPtr->result; if (result == NULL) { @@ -435,7 +435,7 @@ Tcl_SetResult( iPtr->result = iPtr->resultSpace; iPtr->freeProc = 0; } - memcpy(iPtr->result, result, (unsigned) length+1); + memcpy(iPtr->result, result, length+1); } else { iPtr->result = (char *) result; iPtr->freeProc = freeProc; @@ -481,7 +481,7 @@ Tcl_SetResult( const char * Tcl_GetStringResult( - register Tcl_Interp *interp)/* Interpreter whose result to return. */ + Tcl_Interp *interp)/* Interpreter whose result to return. */ { /* * If the string result is empty, move the object result to the string @@ -520,11 +520,11 @@ void Tcl_SetObjResult( Tcl_Interp *interp, /* Interpreter with which to associate the * return object value. */ - register Tcl_Obj *objPtr) /* Tcl object to be returned. If NULL, the obj + Tcl_Obj *objPtr) /* Tcl object to be returned. If NULL, the obj * result is made an empty string object. */ { - register Interp *iPtr = (Interp *) interp; - register Tcl_Obj *oldObjResult = iPtr->objResultPtr; + Interp *iPtr = (Interp *) interp; + Tcl_Obj *oldObjResult = iPtr->objResultPtr; iPtr->objResultPtr = objPtr; Tcl_IncrRefCount(objPtr); /* since interp result is a reference */ @@ -577,7 +577,7 @@ Tcl_Obj * Tcl_GetObjResult( Tcl_Interp *interp) /* Interpreter whose result to return. */ { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; Tcl_Obj *objResultPtr; int length; @@ -880,9 +880,9 @@ SetupAppendBuffer( void Tcl_FreeResult( - register Tcl_Interp *interp)/* Interpreter for which to free result. */ + Tcl_Interp *interp)/* Interpreter for which to free result. */ { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; if (iPtr->freeProc != NULL) { if (iPtr->freeProc == TCL_DYNAMIC) { @@ -917,9 +917,9 @@ Tcl_FreeResult( void Tcl_ResetResult( - register Tcl_Interp *interp)/* Interpreter for which to clear result. */ + Tcl_Interp *interp)/* Interpreter for which to clear result. */ { - register Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *) interp; ResetObjResult(iPtr); if (iPtr->freeProc != NULL) { @@ -980,10 +980,10 @@ Tcl_ResetResult( static void ResetObjResult( - register Interp *iPtr) /* Points to the interpreter whose result + Interp *iPtr) /* Points to the interpreter whose result * object should be reset. */ { - register Tcl_Obj *objResultPtr = iPtr->objResultPtr; + Tcl_Obj *objResultPtr = iPtr->objResultPtr; if (Tcl_IsShared(objResultPtr)) { TclDecrRefCount(objResultPtr); diff --git a/generic/tclTest.c b/generic/tclTest.c index 297cd11..03f40dd 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -1865,11 +1865,11 @@ TestencodingObjCmd( string = Tcl_GetStringFromObj(objv[3], &length); encodingPtr->toUtfCmd = (char *)ckalloc(length + 1); - memcpy(encodingPtr->toUtfCmd, string, (unsigned) length + 1); + memcpy(encodingPtr->toUtfCmd, string, length + 1); string = Tcl_GetStringFromObj(objv[4], &length); encodingPtr->fromUtfCmd = (char *)ckalloc(length + 1); - memcpy(encodingPtr->fromUtfCmd, string, (unsigned) (length + 1)); + memcpy(encodingPtr->fromUtfCmd, string, length + 1); string = Tcl_GetStringFromObj(objv[2], &length); @@ -1918,7 +1918,7 @@ EncodingToUtfProc( if (len > dstLen) { len = dstLen; } - memcpy(dst, Tcl_GetStringResult(encodingPtr->interp), (unsigned) len); + memcpy(dst, Tcl_GetStringResult(encodingPtr->interp), len); Tcl_ResetResult(encodingPtr->interp); *srcReadPtr = srcLen; @@ -1950,7 +1950,7 @@ EncodingFromUtfProc( if (len > dstLen) { len = dstLen; } - memcpy(dst, Tcl_GetStringResult(encodingPtr->interp), (unsigned) len); + memcpy(dst, Tcl_GetStringResult(encodingPtr->interp), len); Tcl_ResetResult(encodingPtr->interp); *srcReadPtr = srcLen; @@ -5879,7 +5879,7 @@ TestChannelEventCmd( cmd = argv[2]; len = strlen(cmd); - if ((cmd[0] == 'a') && (strncmp(cmd, "add", (unsigned) len) == 0)) { + if ((cmd[0] == 'a') && (strncmp(cmd, "add", len) == 0)) { if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " channelName add eventSpec script\"", NULL); @@ -5914,7 +5914,7 @@ TestChannelEventCmd( return TCL_OK; } - if ((cmd[0] == 'd') && (strncmp(cmd, "delete", (unsigned) len) == 0)) { + if ((cmd[0] == 'd') && (strncmp(cmd, "delete", len) == 0)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " channelName delete index\"", NULL); @@ -5960,7 +5960,7 @@ TestChannelEventCmd( return TCL_OK; } - if ((cmd[0] == 'l') && (strncmp(cmd, "list", (unsigned) len) == 0)) { + if ((cmd[0] == 'l') && (strncmp(cmd, "list", len) == 0)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " channelName list\"", NULL); @@ -5983,7 +5983,7 @@ TestChannelEventCmd( return TCL_OK; } - if ((cmd[0] == 'r') && (strncmp(cmd, "removeall", (unsigned) len) == 0)) { + if ((cmd[0] == 'r') && (strncmp(cmd, "removeall", len) == 0)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " channelName removeall\"", NULL); @@ -6002,7 +6002,7 @@ TestChannelEventCmd( return TCL_OK; } - if ((cmd[0] == 's') && (strncmp(cmd, "set", (unsigned) len) == 0)) { + if ((cmd[0] == 's') && (strncmp(cmd, "set", len) == 0)) { if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " channelName delete index event\"", NULL); diff --git a/generic/tclTimer.c b/generic/tclTimer.c index 106e2f7..d30879f 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -217,7 +217,7 @@ TimerExitProc( Tcl_DeleteEventSource(TimerSetupProc, TimerCheckProc, NULL); if (tsdPtr != NULL) { - register TimerHandler *timerHandlerPtr; + TimerHandler *timerHandlerPtr; timerHandlerPtr = tsdPtr->firstTimerHandlerPtr; while (timerHandlerPtr != NULL) { @@ -294,7 +294,7 @@ TclCreateAbsoluteTimerHandler( Tcl_TimerProc *proc, ClientData clientData) { - register TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr; + TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr; ThreadSpecificData *tsdPtr = InitTimer(); timerHandlerPtr = ckalloc(sizeof(TimerHandler)); @@ -355,7 +355,7 @@ Tcl_DeleteTimerHandler( Tcl_TimerToken token) /* Result previously returned by * Tcl_DeleteTimerHandler. */ { - register TimerHandler *timerHandlerPtr, *prevPtr; + TimerHandler *timerHandlerPtr, *prevPtr; ThreadSpecificData *tsdPtr = InitTimer(); if (token == NULL) { @@ -621,7 +621,7 @@ Tcl_DoWhenIdle( Tcl_IdleProc *proc, /* Function to invoke. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { - register IdleHandler *idlePtr; + IdleHandler *idlePtr; Tcl_Time blockTime; ThreadSpecificData *tsdPtr = InitTimer(); @@ -665,7 +665,7 @@ Tcl_CancelIdleCall( Tcl_IdleProc *proc, /* Function that was previously registered. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { - register IdleHandler *idlePtr, *prevPtr; + IdleHandler *idlePtr, *prevPtr; IdleHandler *nextPtr; ThreadSpecificData *tsdPtr = InitTimer(); @@ -906,7 +906,7 @@ Tcl_AfterObjCmd( tempCommand = Tcl_GetStringFromObj(afterPtr->commandPtr, &tempLength); if ((length == tempLength) - && !memcmp(command, tempCommand, (unsigned) length)) { + && !memcmp(command, tempCommand, length)) { break; } } diff --git a/generic/tclVar.c b/generic/tclVar.c index 7b3db7e..5d8d88c 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -489,7 +489,7 @@ TclLookupVar( Var * TclObjLookupVar( Tcl_Interp *interp, /* Interpreter to use for lookup. */ - register Tcl_Obj *part1Ptr, /* If part2 isn't NULL, this is the name of an + Tcl_Obj *part1Ptr, /* If part2 isn't NULL, this is the name of an * array. Otherwise, this is a full variable * name that could include a parenthesized * array element. */ @@ -561,7 +561,7 @@ TclObjLookupVarEx( * is set to NULL. */ { Interp *iPtr = (Interp *) interp; - register Var *varPtr; /* Points to the variable's in-frame Var + Var *varPtr; /* Points to the variable's in-frame Var * structure. */ const char *part1; int index, len1, len2; @@ -640,7 +640,7 @@ TclObjLookupVarEx( * part1Ptr is possibly an unparsed array element. */ - register int i; + int i; len2 = -1; for (i = 0; i < len1; i++) { @@ -665,7 +665,7 @@ TclObjLookupVarEx( len1 = i; newPart2 = ckalloc(len2 + 1); - memcpy(newPart2, part2, (unsigned) len2); + memcpy(newPart2, part2, len2); *(newPart2+len2) = '\0'; part2 = newPart2; part2Ptr = Tcl_NewStringObj(newPart2, -1); @@ -980,7 +980,7 @@ TclLookupSimpleVar( int localLen; for (i=0 ; iinternalRep.twoPtrValue.ptr1; - register char *elem = objPtr->internalRep.twoPtrValue.ptr2; + Tcl_Obj *arrayPtr = objPtr->internalRep.twoPtrValue.ptr1; + char *elem = objPtr->internalRep.twoPtrValue.ptr2; if (arrayPtr != NULL) { TclDecrRefCount(arrayPtr); @@ -5550,8 +5550,8 @@ DupParsedVarName( Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) { - register Tcl_Obj *arrayPtr = srcPtr->internalRep.twoPtrValue.ptr1; - register char *elem = srcPtr->internalRep.twoPtrValue.ptr2; + Tcl_Obj *arrayPtr = srcPtr->internalRep.twoPtrValue.ptr1; + char *elem = srcPtr->internalRep.twoPtrValue.ptr2; char *elemCopy; unsigned elemLen; @@ -5595,10 +5595,10 @@ UpdateParsedVarName( objPtr->bytes = p; objPtr->length = totalLen; - memcpy(p, part1, (unsigned) len1); + memcpy(p, part1, len1); p += len1; *p++ = '('; - memcpy(p, part2, (unsigned) len2); + memcpy(p, part2, len2); p += len2; *p++ = ')'; *p = '\0'; @@ -5684,7 +5684,7 @@ ObjFindNamespaceVar( Namespace *nsPtr[2], *cxtNsPtr; const char *simpleName; Var *varPtr; - register int search; + int search; int result; Tcl_Var var; Tcl_Obj *simpleNamePtr; @@ -6311,8 +6311,8 @@ CompareVarKeys( { Tcl_Obj *objPtr1 = keyPtr; Tcl_Obj *objPtr2 = hPtr->key.objPtr; - register const char *p1, *p2; - register int l1, l2; + const char *p1, *p2; + int l1, l2; /* * If the object pointers are the same then they match. diff --git a/tests/winFCmd.test b/tests/winFCmd.test index 6d87319..517a56b 100644 --- a/tests/winFCmd.test +++ b/tests/winFCmd.test @@ -401,7 +401,7 @@ proc MakeFiles {dirname} { set f [open $filename w] close $f file stat $filename stat - if {[set n [lsearch -exact -integer $inodes $stat(ino)]] != -1} { + if {[set n [lsearch -exact -integer $inodes $stat(ino)]] < 0} { return [list [file join $dirname Test$n] $filename] } lappend inodes $stat(ino) diff --git a/tools/mkdepend.tcl b/tools/mkdepend.tcl index afe123a..b1ad076 100644 --- a/tools/mkdepend.tcl +++ b/tools/mkdepend.tcl @@ -88,7 +88,7 @@ proc readDepends {chan} { set line "" array set depends {} - while {[gets $chan line] < 0} { + while {[gets $chan line] >= 0} { if {[regexp {^#line [0-9]+ \"(.*)\"$} $line dummy fname] != 0} { set fname [file normalize $fname] if {![info exists target]} { -- cgit v0.12 From fa3cf75311fd2cf309675dacf20c723963b8fb19 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Sep 2020 12:48:10 +0000 Subject: Add .bmp to .gitattributes. Simplify .fossil-settings/binary-glob --- .fossil-settings/binary-glob | 17 ++++++++++------- .gitattributes | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.fossil-settings/binary-glob b/.fossil-settings/binary-glob index ec574be..7e8f357 100644 --- a/.fossil-settings/binary-glob +++ b/.fossil-settings/binary-glob @@ -1,9 +1,12 @@ -compat/zlib/win32/zdll.lib -compat/zlib/win32/zlib1.dll -compat/zlib/win64/zdll.lib -compat/zlib/win64/zlib1.dll -compat/zlib/win64/libz.dll.a -compat/zlib/zlib.3.pdf +*.a *.bmp +*.dll +*.exe *.gif -*.png \ No newline at end of file +*.gz +*.jpg +*.lib +*.pdf +*.png +*.xlsx +*.zip diff --git a/.gitattributes b/.gitattributes index e9a67c8..8a49592 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,6 +27,7 @@ # Denote all files that are truly binary and should not be modified. *.a binary +*.bmp binary *.dll binary *.exe binary *.gif binary -- cgit v0.12 From 52f93c85fd4b12afc887e78f895f6dd7e33983db Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Sep 2020 12:58:26 +0000 Subject: Unbreak winFCmd-1.38 testcase on Windows --- tests/winFCmd.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/winFCmd.test b/tests/winFCmd.test index 517a56b..7c81e81 100644 --- a/tests/winFCmd.test +++ b/tests/winFCmd.test @@ -401,7 +401,7 @@ proc MakeFiles {dirname} { set f [open $filename w] close $f file stat $filename stat - if {[set n [lsearch -exact -integer $inodes $stat(ino)]] < 0} { + if {[set n [lsearch -exact -integer $inodes $stat(ino)]] >= 0} { return [list [file join $dirname Test$n] $filename] } lappend inodes $stat(ino) -- cgit v0.12 From 2238887c088e88d799e6cde81ea201c00155ff94 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 15 Sep 2020 15:51:00 +0000 Subject: Add test for [string replace] troubles. --- tests/string.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/string.test b/tests/string.test index ba0780a..eca1d33 100644 --- a/tests/string.test +++ b/tests/string.test @@ -1665,6 +1665,9 @@ test stringComp-14.24.$noComp {Bug 1af8de570511} { test stringComp-14.25.$noComp {} { string length [string replace [string repeat a\xFE 2] 3 end {}] } 3 +test stringComp-14.26.$noComp {} { + run {string replace abcd 0x10000000000000000-0xffffffffffffffff 2 e} +} aed test string-15.1.$noComp {string tolower too few args} { list [catch {run {string tolower}} msg] $msg -- cgit v0.12 From 929fdafe13779bc173fe3b80069405044044171c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Sep 2020 06:51:36 +0000 Subject: Little tweak to makeHeader.tcl, not depending on lsearch returning -1 any more --- tools/makeHeader.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/makeHeader.tcl b/tools/makeHeader.tcl index e9b7ed1..dd2f199 100644 --- a/tools/makeHeader.tcl +++ b/tools/makeHeader.tcl @@ -70,7 +70,7 @@ namespace eval makeHeader { set from [lsearch -glob $data $BEGIN] set to [lsearch -glob $data $END] - if {$from == -1 || $to == -1 || $from >= $to} { + if {$from < 0 || $to < 0 || $from >= $to} { throw BAD "not a template" } -- cgit v0.12 From 1dc3124160fd7c59519c640c0704be7ba6bf7259 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Sep 2020 12:17:54 +0000 Subject: Proposed solution for [835c93c000]: TIP #525 only implemented for non-singleproc case --- library/tcltest/tcltest.tcl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 2af79bc..e7f4288 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -2798,7 +2798,6 @@ proc tcltest::runAllTests { {shell ""} } { variable numTests variable failFiles variable DefaultValue - set failFilesAccum {} FillFilesExisted if {[llength [info level 0]] == 1} { @@ -2854,8 +2853,18 @@ proc tcltest::runAllTests { {shell ""} } { flush [outputChannel] if {[singleProcess]} { - incr numTestFiles - uplevel 1 [list ::source $file] + if {[catch { + incr numTestFiles + uplevel 1 [list ::source $file] + } msg]} { + puts [outputChannel] "Test file error: $msg" + # append the name of the test to a list to be reported + # later + lappend testFileFailures $file + } + if {$numTests(Failed) > 0} { + set failFilesSet 1 + } } else { # Pass along our configuration to the child processes. # EXCEPT for the -outfile, because the parent process @@ -2888,7 +2897,7 @@ proc tcltest::runAllTests { {shell ""} } { } if {$Failed > 0} { lappend failFiles $testFile - lappend failFilesAccum $testFile + set failFilesSet 1 } } elseif {[regexp [join { {^Number of tests skipped } @@ -2935,7 +2944,7 @@ proc tcltest::runAllTests { {shell ""} } { puts [outputChannel] "" puts [outputChannel] [string repeat ~ 44] } - return [expr {[info exists testFileFailures] || [llength $failFilesAccum]}] + return [expr {[info exists testFileFailures] || [info exists failFilesSet]}] } ##################################################################### -- cgit v0.12 From e14285c3a1d7dd2d7407fda5a5c841ccb5cae488 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 17 Sep 2020 08:37:09 +0000 Subject: Tcl 8.6 should not be tested with "package prefer latest" any more: All included packages are supposed to be stable. Not to be merged to 8.7 (which still contains unstable packages) --- tests/all.tcl | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/all.tcl b/tests/all.tcl index 52c8763..5ac2abb 100644 --- a/tests/all.tcl +++ b/tests/all.tcl @@ -10,7 +10,6 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package prefer latest package require Tcl 8.5- package require tcltest 2.5 namespace import ::tcltest::* -- cgit v0.12 From 733b7a43a45ee6be75ccd99172f66b35b69841c5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 17 Sep 2020 13:48:12 +0000 Subject: Eliminate many usages of Tcl_NewObj (-> TclNewObj) and Tcl_NewIntObj (-> TclNewIntObj or Tcl_NewWideIntObj) --- generic/tclAssembly.c | 3 ++- generic/tclBasic.c | 15 +++++++-------- generic/tclBinary.c | 15 ++++++++------- generic/tclCmdIL.c | 44 +++++++++++++++++++++++++------------------- generic/tclCmdMZ.c | 38 ++++++++++++++++++++++---------------- generic/tclCompCmds.c | 47 ++++++++++++++++++++++++----------------------- generic/tclCompCmdsGR.c | 19 ++++++++++--------- generic/tclCompCmdsSZ.c | 18 ++++++++++-------- generic/tclCompExpr.c | 19 ++++++++++++------- generic/tclCompile.c | 5 +++-- generic/tclDictObj.c | 6 +++--- generic/tclDisassemble.c | 47 +++++++++++++++++++++++++---------------------- generic/tclEncoding.c | 6 ++++-- generic/tclEnsemble.c | 8 +++++--- generic/tclExecute.c | 8 ++++---- generic/tclFCmd.c | 2 +- generic/tclFileName.c | 9 ++++++--- generic/tclIO.c | 4 ++-- generic/tclIOCmd.c | 20 ++++++++++---------- generic/tclIORTrans.c | 2 +- generic/tclIOUtil.c | 11 ++++++----- generic/tclIndexObj.c | 2 +- generic/tclIntPlatDecls.h | 2 +- generic/tclInterp.c | 10 ++++++---- generic/tclLink.c | 10 +++++----- generic/tclListObj.c | 8 +++++--- generic/tclLoad.c | 4 ++-- generic/tclMain.c | 11 ++++++----- generic/tclNamesp.c | 10 ++++++---- generic/tclOO.c | 2 +- generic/tclOOBasic.c | 2 +- generic/tclOODefineCmds.c | 18 +++++++++--------- generic/tclOOInfo.c | 42 +++++++++++++++++++++--------------------- generic/tclOOMethod.c | 7 ++++--- generic/tclPathObj.c | 8 ++++---- generic/tclPipe.c | 2 +- generic/tclPkg.c | 9 +++++---- generic/tclProcess.c | 12 ++++++------ generic/tclRegexp.c | 6 +++--- generic/tclResult.c | 20 +++++++++++--------- generic/tclScan.c | 6 +++--- generic/tclStringObj.c | 14 +++++++------- generic/tclStubInit.c | 2 +- generic/tclThreadTest.c | 2 +- generic/tclTimer.c | 6 ++++-- generic/tclTrace.c | 6 +++--- generic/tclUtil.c | 2 +- generic/tclVar.c | 9 +++++---- generic/tclZipfs.c | 2 +- generic/tclZlib.c | 7 ++++--- 50 files changed, 318 insertions(+), 269 deletions(-) diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 9e5e947..2102e84 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -2098,8 +2098,9 @@ GetNextOperand( * with \-substitutions done. */ { Tcl_Interp* interp = (Tcl_Interp*) assemEnvPtr->envPtr->iPtr; - Tcl_Obj* operandObj = Tcl_NewObj(); + Tcl_Obj* operandObj; + TclNewObj(operandObj); if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) { Tcl_DecrRefCount(operandObj); if (assemEnvPtr->flags & TCL_EVAL_DIRECT) { diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 75f8527..4e2bcb1 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -708,7 +708,7 @@ Tcl_CreateInterp(void) #endif iPtr->freeProc = NULL; iPtr->errorLine = 0; - iPtr->objResultPtr = Tcl_NewObj(); + TclNewObj(iPtr->objResultPtr); Tcl_IncrRefCount(iPtr->objResultPtr); iPtr->handle = TclHandleCreate(iPtr); iPtr->globalNsPtr = NULL; @@ -796,8 +796,7 @@ Tcl_CreateInterp(void) iPtr->activeInterpTracePtr = NULL; iPtr->assocData = NULL; iPtr->execEnvPtr = NULL; /* Set after namespaces initialized. */ - iPtr->emptyObjPtr = Tcl_NewObj(); - /* Another empty object. */ + TclNewObj(iPtr->emptyObjPtr); /* Another empty object. */ Tcl_IncrRefCount(iPtr->emptyObjPtr); #ifndef TCL_NO_DEPRECATED iPtr->resultSpace[0] = 0; @@ -863,7 +862,7 @@ Tcl_CreateInterp(void) * TIP #285, Script cancellation support. */ - iPtr->asyncCancelMsg = Tcl_NewObj(); + TclNewObj(iPtr->asyncCancelMsg); cancelInfo = (CancelInfo *)ckalloc(sizeof(CancelInfo)); cancelInfo->interp = interp; @@ -2990,7 +2989,7 @@ TclRenameCommand( } cmdNsPtr = cmdPtr->nsPtr; - oldFullName = Tcl_NewObj(); + TclNewObj(oldFullName); Tcl_IncrRefCount(oldFullName); Tcl_GetCommandFullName(interp, cmd, oldFullName); @@ -4043,7 +4042,7 @@ OldMathFuncProc( if (funcResult.type == TCL_INT) { TclNewIntObj(valuePtr, funcResult.intValue); } else if (funcResult.type == TCL_WIDE_INT) { - valuePtr = Tcl_NewWideIntObj(funcResult.wideValue); + TclNewIntObj(valuePtr, funcResult.wideValue); } else { return CheckDoubleResult(interp, funcResult.doubleValue); } @@ -4202,7 +4201,7 @@ Tcl_ListMathFuncs( if (TCL_OK == Tcl_EvalObjEx(interp, script, 0)) { result = Tcl_DuplicateObj(Tcl_GetObjResult(interp)); } else { - result = Tcl_NewObj(); + TclNewObj(result); } Tcl_DecrRefCount(script); Tcl_RestoreInterpState(interp, state); @@ -9961,7 +9960,7 @@ InjectHandler( * I don't think this is reachable... */ - Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewIntObj(nargs)); + Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewWideIntObj(nargs)); } Tcl_ListObjAppendElement(NULL, listPtr, Tcl_GetObjResult(interp)); } diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 168d399..f53c707 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -1163,7 +1163,7 @@ BinaryFormatCmd( * bytes and filling with nulls. */ - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); buffer = Tcl_SetByteArrayLength(resultPtr, length); memset(buffer, 0, length); @@ -1595,7 +1595,7 @@ BinaryScanCmd( } } src = buffer + offset; - valuePtr = Tcl_NewObj(); + TclNewObj(valuePtr); Tcl_SetObjLength(valuePtr, count); dest = TclGetString(valuePtr); @@ -1650,7 +1650,7 @@ BinaryScanCmd( } } src = buffer + offset; - valuePtr = Tcl_NewObj(); + TclNewObj(valuePtr); Tcl_SetObjLength(valuePtr, count); dest = TclGetString(valuePtr); @@ -1734,7 +1734,7 @@ BinaryScanCmd( if ((length - offset) < (count * size)) { goto done; } - valuePtr = Tcl_NewObj(); + TclNewObj(valuePtr); src = buffer + offset; for (i = 0; i < count; i++) { elementPtr = ScanNumber(src, cmd, flags, &numberCachePtr); @@ -2376,8 +2376,9 @@ ScanNumber( return (Tcl_Obj *)Tcl_GetHashValue(hPtr); } if (tablePtr->numEntries <= BINARY_SCAN_MAX_CACHE) { - Tcl_Obj *objPtr = Tcl_NewWideIntObj(value); + Tcl_Obj *objPtr; + TclNewIntObj(objPtr, value); Tcl_IncrRefCount(objPtr); Tcl_SetHashValue(hPtr, objPtr); return objPtr; @@ -2761,7 +2762,7 @@ BinaryEncode64( maxlen = 0; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); data = Tcl_GetByteArrayFromObj(objv[objc - 1], &count); if (count > 0) { unsigned char *cursor = NULL; @@ -2913,7 +2914,7 @@ BinaryEncodeUu( * enough". */ - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); offset = 0; data = Tcl_GetByteArrayFromObj(objv[objc - 1], &count); rawLength = (lineLength - 1) * 3 / 4; diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 3de976e..df2decb 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -691,7 +691,7 @@ InfoCommandsCmd( if (entryPtr != NULL) { if (specificNsInPattern) { cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr); - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, cmd, elemObjPtr); } else { cmdName = (const char *)Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr); @@ -742,7 +742,7 @@ InfoCommandsCmd( || Tcl_StringMatch(cmdName, simplePattern)) { if (specificNsInPattern) { cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr); - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, cmd, elemObjPtr); } else { elemObjPtr = Tcl_NewStringObj(cmdName, -1); @@ -969,8 +969,9 @@ InfoDefaultCmd( } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(1)); } else { - Tcl_Obj *nullObjPtr = Tcl_NewObj(); + Tcl_Obj *nullObjPtr; + TclNewObj(nullObjPtr); valueObjPtr = Tcl_ObjSetVar2(interp, objv[3], NULL, nullObjPtr, TCL_LEAVE_ERR_MSG); if (valueObjPtr == NULL) { @@ -1885,7 +1886,7 @@ InfoProcsCmd( } else { simpleProcOK: if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, elemObjPtr); } else { @@ -1906,15 +1907,15 @@ InfoProcsCmd( if (!TclIsProc(cmdPtr)) { realCmdPtr = (Command *) - TclGetOriginalCommand((Tcl_Command) cmdPtr); + TclGetOriginalCommand((Tcl_Command)cmdPtr); if (realCmdPtr != NULL && TclIsProc(realCmdPtr)) { goto procOK; } } else { procOK: if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); - Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, + TclNewObj(elemObjPtr); + Tcl_GetCommandFullName(interp, (Tcl_Command)cmdPtr, elemObjPtr); } else { elemObjPtr = Tcl_NewStringObj(cmdName, -1); @@ -2142,7 +2143,7 @@ InfoCmdTypeCmd( } /* - * There's one special case: safe child interpreters can't see aliases as + * There's one special case: safe interpreters can't see aliases as * aliases as they're part of the security mechanisms. */ @@ -2217,7 +2218,7 @@ Tcl_JoinObjCmd( } else { int i; - resObjPtr = Tcl_NewObj(); + TclNewObj(resObjPtr); for (i = 0; i < listLen; i++) { if (i > 0) { @@ -3513,7 +3514,8 @@ Tcl_LsearchObjCmd( if (allMatches || inlineReturn) { Tcl_ResetResult(interp); } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-1)); + TclNewIntObj(itemPtr, -1); + Tcl_SetObjResult(interp, itemPtr); } goto done; } @@ -3802,10 +3804,11 @@ Tcl_LsearchObjCmd( } else if (returnSubindices) { int j; - itemPtr = Tcl_NewWideIntObj(i+groupOffset); + TclNewIntObj(itemPtr, i+groupOffset); for (j=0 ; jpayload.index; for (j = 0; j < groupSize; j++) { if (indices) { - objPtr = Tcl_NewWideIntObj(idx + j - groupOffset); + TclNewIntObj(objPtr, idx + j - groupOffset); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } else { @@ -4426,7 +4432,7 @@ Tcl_LsortObjCmd( } } else if (indices) { for (i=0; elementPtr != NULL ; elementPtr = elementPtr->nextPtr) { - objPtr = Tcl_NewWideIntObj(elementPtr->payload.index); + TclNewIntObj(objPtr, elementPtr->payload.index); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index f95dd12..b321fec 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -357,7 +357,7 @@ Tcl_RegexpObjCmd( objc = info.nsubs + 1; if (all <= 1) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } } for (i = 0; i < objc; i++) { @@ -389,8 +389,8 @@ Tcl_RegexpObjCmd( end = -1; } - objs[0] = Tcl_NewWideIntObj(start); - objs[1] = Tcl_NewWideIntObj(end); + TclNewIntObj(objs[0], start); + TclNewIntObj(objs[1], end); newPtr = Tcl_NewListObj(2, objs); } else { @@ -399,7 +399,7 @@ Tcl_RegexpObjCmd( offset + info.matches[i].start, offset + info.matches[i].end - 1); } else { - newPtr = Tcl_NewObj(); + TclNewObj(newPtr); } } if (doinline) { @@ -788,7 +788,7 @@ Tcl_RegsubObjCmd( args[idx + numParts] = Tcl_NewUnicodeObj( wstring + offset + subStart, subEnd - subStart); } else { - args[idx + numParts] = Tcl_NewObj(); + TclNewObj(args[idx + numParts]); } Tcl_IncrRefCount(args[idx + numParts]); } @@ -1194,7 +1194,7 @@ Tcl_SplitObjCmd( stringPtr = TclGetStringFromObj(objv[1], &stringLen); end = stringPtr + stringLen; - listPtr = Tcl_NewObj(); + TclNewObj(listPtr); if (stringLen == 0) { /* @@ -1906,10 +1906,11 @@ StringIsCmd( */ str_is_done: - if ((result == 0) && (failVarObj != NULL) && - Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewWideIntObj(failat), - TCL_LEAVE_ERR_MSG) == NULL) { - return TCL_ERROR; + if ((result == 0) && (failVarObj != NULL)) { + TclNewIntObj(objPtr, failat); + if (Tcl_ObjSetVar2(interp, failVarObj, NULL, objPtr, TCL_LEAVE_ERR_MSG) == NULL) { + return TCL_ERROR; + } } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; @@ -2501,6 +2502,7 @@ StringStartCmd( int ch; const char *p, *string; int cur, index, length, numChars; + Tcl_Obj *obj; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2540,7 +2542,8 @@ StringStartCmd( cur += 1; } } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); + TclNewIntObj(obj, cur); + Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -2571,6 +2574,7 @@ StringEndCmd( int ch; const char *p, *end, *string; int cur, index, length, numChars; + Tcl_Obj *obj; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2601,7 +2605,8 @@ StringEndCmd( } else { cur = numChars; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); + TclNewIntObj(obj, cur); + Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -3770,10 +3775,11 @@ TclNRSwitchObjCmd( Tcl_Obj *rangeObjAry[2]; if (info.matches[j].end > 0) { - rangeObjAry[0] = Tcl_NewWideIntObj(info.matches[j].start); - rangeObjAry[1] = Tcl_NewWideIntObj(info.matches[j].end-1); + TclNewIntObj(rangeObjAry[0], info.matches[j].start); + TclNewIntObj(rangeObjAry[1], info.matches[j].end-1); } else { - rangeObjAry[0] = rangeObjAry[1] = Tcl_NewWideIntObj(-1); + TclNewIntObj(rangeObjAry[1], -1); + rangeObjAry[0] = rangeObjAry[1]; } /* @@ -4714,7 +4720,7 @@ TclNRTryObjCmd( return TCL_ERROR; } bodyObj = objv[1]; - handlersObj = Tcl_NewObj(); + TclNewObj(handlersObj); bodyShared = 0; haveHandlers = 0; for (i=2 ; itokenPtr); dataTokenPtr = TokenAfter(varTokenPtr); - literalObj = Tcl_NewObj(); + TclNewObj(literalObj); isDataLiteral = TclWordKnownAtCompileTime(dataTokenPtr, literalObj); isDataValid = (isDataLiteral && Tcl_ListObjLength(NULL, literalObj, &len) == TCL_OK); @@ -875,10 +875,10 @@ TclCompileConcatCmd( * implement with a simple push. */ - listObj = Tcl_NewObj(); + TclNewObj(listObj); for (i = 1, tokenPtr = parsePtr->tokenPtr; i < parsePtr->numWords; i++) { tokenPtr = TokenAfter(tokenPtr); - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); if (!TclWordKnownAtCompileTime(tokenPtr, objPtr)) { Tcl_DecrRefCount(objPtr); Tcl_DecrRefCount(listObj); @@ -1301,10 +1301,10 @@ TclCompileDictCreateCmd( */ tokenPtr = TokenAfter(parsePtr->tokenPtr); - dictObj = Tcl_NewObj(); + TclNewObj(dictObj); Tcl_IncrRefCount(dictObj); for (i=1 ; inumWords ; i+=2) { - keyObj = Tcl_NewObj(); + TclNewObj(keyObj); Tcl_IncrRefCount(keyObj); if (!TclWordKnownAtCompileTime(tokenPtr, keyObj)) { Tcl_DecrRefCount(keyObj); @@ -1312,7 +1312,7 @@ TclCompileDictCreateCmd( goto nonConstant; } tokenPtr = TokenAfter(tokenPtr); - valueObj = Tcl_NewObj(); + TclNewObj(valueObj); Tcl_IncrRefCount(valueObj); if (!TclWordKnownAtCompileTime(tokenPtr, valueObj)) { Tcl_DecrRefCount(keyObj); @@ -2311,11 +2311,12 @@ DisassembleDictUpdateInfo( { DictUpdateInfo *duiPtr = (DictUpdateInfo *)clientData; int i; - Tcl_Obj *variables = Tcl_NewObj(); + Tcl_Obj *variables; + TclNewObj(variables); for (i=0 ; ilength ; i++) { Tcl_ListObjAppendElement(NULL, variables, - Tcl_NewIntObj(duiPtr->varIndices[i])); + Tcl_NewWideIntObj(duiPtr->varIndices[i])); } Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("variables", -1), variables); @@ -2731,7 +2732,7 @@ CompileEachloopCmd( * a scalar, or if any var list needs substitutions. */ - varListObj = Tcl_NewObj(); + TclNewObj(varListObj); for (i = 0, tokenPtr = parsePtr->tokenPtr; i < numWords-1; i++, tokenPtr = TokenAfter(tokenPtr)) { @@ -3050,10 +3051,10 @@ DisassembleForeachInfo( * Data stores. */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); for (i=0 ; inumLists ; i++) { Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(infoPtr->firstValueTemp + i)); + Tcl_NewWideIntObj(infoPtr->firstValueTemp + i)); } Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("data", -1), objPtr); @@ -3062,19 +3063,19 @@ DisassembleForeachInfo( */ Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("loop", -1), - Tcl_NewIntObj(infoPtr->loopCtTemp)); + Tcl_NewWideIntObj(infoPtr->loopCtTemp)); /* * Assignment targets. */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); for (i=0 ; inumLists ; i++) { - innerPtr = Tcl_NewObj(); + TclNewObj(innerPtr); varsPtr = infoPtr->varLists[i]; for (j=0 ; jnumVars ; j++) { Tcl_ListObjAppendElement(NULL, innerPtr, - Tcl_NewIntObj(varsPtr->varIndexes[j])); + Tcl_NewWideIntObj(varsPtr->varIndexes[j])); } Tcl_ListObjAppendElement(NULL, objPtr, innerPtr); } @@ -3098,19 +3099,19 @@ DisassembleNewForeachInfo( */ Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("jumpOffset", -1), - Tcl_NewIntObj(infoPtr->loopCtTemp)); + Tcl_NewWideIntObj(infoPtr->loopCtTemp)); /* * Assignment targets. */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); for (i=0 ; inumLists ; i++) { - innerPtr = Tcl_NewObj(); + TclNewObj(innerPtr); varsPtr = infoPtr->varLists[i]; for (j=0 ; jnumVars ; j++) { Tcl_ListObjAppendElement(NULL, innerPtr, - Tcl_NewIntObj(varsPtr->varIndexes[j])); + Tcl_NewWideIntObj(varsPtr->varIndexes[j])); } Tcl_ListObjAppendElement(NULL, objPtr, innerPtr); } @@ -3163,7 +3164,7 @@ TclCompileFormatCmd( * a case we can handle by compiling to a constant. */ - formatObj = Tcl_NewObj(); + TclNewObj(formatObj); Tcl_IncrRefCount(formatObj); tokenPtr = TokenAfter(tokenPtr); if (!TclWordKnownAtCompileTime(tokenPtr, formatObj)) { @@ -3174,7 +3175,7 @@ TclCompileFormatCmd( objv = (Tcl_Obj **)ckalloc((parsePtr->numWords-2) * sizeof(Tcl_Obj *)); for (i=0 ; i+2 < parsePtr->numWords ; i++) { tokenPtr = TokenAfter(tokenPtr); - objv[i] = Tcl_NewObj(); + TclNewObj(objv[i]); Tcl_IncrRefCount(objv[i]); if (!TclWordKnownAtCompileTime(tokenPtr, objv[i])) { goto checkForStringConcatCase; @@ -3266,7 +3267,7 @@ TclCompileFormatCmd( start = Tcl_GetString(formatObj); /* The start of the currently-scanned literal * in the format string. */ - tmpObj = Tcl_NewObj(); /* The buffer used to accumulate the literal + TclNewObj(tmpObj); /* The buffer used to accumulate the literal * being built. */ for (bytes = start ; *bytes ; bytes++) { if (*bytes == '%') { @@ -3284,7 +3285,7 @@ TclCompileFormatCmd( if (len > 0) { PushLiteral(envPtr, b, len); Tcl_DecrRefCount(tmpObj); - tmpObj = Tcl_NewObj(); + TclNewObj(tmpObj); i++; } diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 3361d7f..221ac3a 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -53,9 +53,10 @@ TclGetIndexFromToken( int after, int *indexPtr) { - Tcl_Obj *tmpObj = Tcl_NewObj(); + Tcl_Obj *tmpObj; int result = TCL_ERROR; + TclNewObj(tmpObj); if (TclWordKnownAtCompileTime(tokenPtr, tmpObj)) { result = TclIndexEncode(NULL, tmpObj, before, after, indexPtr); } @@ -598,7 +599,7 @@ TclCompileInfoCommandsCmd( return TCL_ERROR; } tokenPtr = TokenAfter(parsePtr->tokenPtr); - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); if (!TclWordKnownAtCompileTime(tokenPtr, objPtr)) { goto notCompilable; @@ -1169,9 +1170,9 @@ TclCompileListCmd( numWords = parsePtr->numWords; valueTokenPtr = TokenAfter(parsePtr->tokenPtr); - listObj = Tcl_NewObj(); + TclNewObj(listObj); for (i = 1; i < numWords && listObj != NULL; i++) { - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); if (TclWordKnownAtCompileTime(valueTokenPtr, objPtr)) { (void) Tcl_ListObjAppendElement(NULL, listObj, objPtr); } else { @@ -2264,7 +2265,7 @@ TclCompileRegsubCmd( Tcl_DStringInit(&pattern); tokenPtr = TokenAfter(tokenPtr); - patternObj = Tcl_NewObj(); + TclNewObj(patternObj); if (!TclWordKnownAtCompileTime(tokenPtr, patternObj)) { goto done; } @@ -2275,7 +2276,7 @@ TclCompileRegsubCmd( } tokenPtr = TokenAfter(tokenPtr); Tcl_DecrRefCount(patternObj); - patternObj = Tcl_NewObj(); + TclNewObj(patternObj); if (!TclWordKnownAtCompileTime(tokenPtr, patternObj)) { goto done; } @@ -2290,7 +2291,7 @@ TclCompileRegsubCmd( stringTokenPtr = TokenAfter(tokenPtr); tokenPtr = TokenAfter(stringTokenPtr); - replacementObj = Tcl_NewObj(); + TclNewObj(replacementObj); if (!TclWordKnownAtCompileTime(tokenPtr, replacementObj)) { goto done; } @@ -2440,7 +2441,7 @@ TclCompileReturnCmd( */ for (objc = 0; objc < numOptionWords; objc++) { - objv[objc] = Tcl_NewObj(); + TclNewObj(objv[objc]); Tcl_IncrRefCount(objv[objc]); if (!TclWordKnownAtCompileTime(wordTokenPtr, objv[objc])) { /* @@ -2659,7 +2660,7 @@ TclCompileUpvarCmd( * Push the frame index if it is known at compile time */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); tokenPtr = TokenAfter(parsePtr->tokenPtr); if (TclWordKnownAtCompileTime(tokenPtr, objPtr)) { CallFrame *framePtr; diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 81c01e0..c9e2add 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -241,7 +241,7 @@ TclCompileStringCatCmd( folded = NULL; wordTokenPtr = TokenAfter(parsePtr->tokenPtr); for (i = 1; i < numWords; i++) { - obj = Tcl_NewObj(); + TclNewObj(obj); if (TclWordKnownAtCompileTime(wordTokenPtr, obj)) { if (folded) { Tcl_AppendObjToObj(folded, obj); @@ -526,7 +526,7 @@ TclCompileStringIsCmd( if (parsePtr->numWords < 3 || parsePtr->numWords > 6) { return TCL_ERROR; } - isClass = Tcl_NewObj(); + TclNewObj(isClass); if (!TclWordKnownAtCompileTime(tokenPtr, isClass)) { Tcl_DecrRefCount(isClass); return TCL_ERROR; @@ -930,7 +930,7 @@ TclCompileStringMapCmd( } mapTokenPtr = TokenAfter(parsePtr->tokenPtr); stringTokenPtr = TokenAfter(mapTokenPtr); - mapObj = Tcl_NewObj(); + TclNewObj(mapObj); Tcl_IncrRefCount(mapObj); if (!TclWordKnownAtCompileTime(mapTokenPtr, mapObj)) { Tcl_DecrRefCount(mapObj); @@ -1461,7 +1461,7 @@ TclCompileSubstCmd( objv = (Tcl_Obj **)TclStackAlloc(interp, /*numArgs*/ numOpts * sizeof(Tcl_Obj *)); for (objc = 0; objc < /*numArgs*/ numOpts; objc++) { - objv[objc] = Tcl_NewObj(); + TclNewObj(objv[objc]); Tcl_IncrRefCount(objv[objc]); if (!TclWordKnownAtCompileTime(wordTokenPtr, objv[objc])) { objc++; @@ -2610,18 +2610,19 @@ DisassembleJumptableInfo( TCL_UNUSED(unsigned int)) { JumptableInfo *jtPtr = (JumptableInfo *)clientData; - Tcl_Obj *mapping = Tcl_NewObj(); + Tcl_Obj *mapping; Tcl_HashEntry *hPtr; Tcl_HashSearch search; const char *keyPtr; - int offset; + size_t offset; + TclNewObj(mapping); hPtr = Tcl_FirstHashEntry(&jtPtr->hashTable, &search); for (; hPtr ; hPtr = Tcl_NextHashEntry(&search)) { keyPtr = (const char *)Tcl_GetHashKey(&jtPtr->hashTable, hPtr); offset = PTR2INT(Tcl_GetHashValue(hPtr)); Tcl_DictObjPut(NULL, mapping, Tcl_NewStringObj(keyPtr, -1), - Tcl_NewIntObj(offset)); + Tcl_NewWideIntObj(offset)); } Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("mapping", -1), mapping); } @@ -3623,8 +3624,9 @@ TclCompileUnsetCmd( */ for (i=1,varTokenPtr=parsePtr->tokenPtr ; inumWords ; i++) { - Tcl_Obj *leadingWord = Tcl_NewObj(); + Tcl_Obj *leadingWord; + TclNewObj(leadingWord); varTokenPtr = TokenAfter(varTokenPtr); if (!TclWordKnownAtCompileTime(varTokenPtr, leadingWord)) { TclDecrRefCount(leadingWord); diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 74610c7..476ff14 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -1836,11 +1836,13 @@ Tcl_ParseExpr( { int code; OpNode *opTree = NULL; /* Will point to the tree of operators. */ - Tcl_Obj *litList = Tcl_NewObj(); /* List to hold the literals. */ - Tcl_Obj *funcList = Tcl_NewObj(); /* List to hold the functon names. */ + Tcl_Obj *litList; /* List to hold the literals. */ + Tcl_Obj *funcList; /* List to hold the functon names. */ Tcl_Parse *exprParsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse)); /* Holds the Tcl_Tokens of substitutions. */ + TclNewObj(litList); + TclNewObj(funcList); if (numBytes < 0) { numBytes = (start ? strlen(start) : 0); } @@ -2040,7 +2042,7 @@ ParseLexeme( break; } - literal = Tcl_NewObj(); + TclNewObj(literal); if (TclParseNumber(NULL, literal, NULL, start, numBytes, &end, TCL_PARSE_NO_WHITESPACE) == TCL_OK) { if (end < start + numBytes && !TclIsBareword(*end)) { @@ -2154,12 +2156,15 @@ TclCompileExpr( int optimize) /* 0 for one-off expressions. */ { OpNode *opTree = NULL; /* Will point to the tree of operators */ - Tcl_Obj *litList = Tcl_NewObj(); /* List to hold the literals */ - Tcl_Obj *funcList = Tcl_NewObj(); /* List to hold the functon names*/ + Tcl_Obj *litList; /* List to hold the literals */ + Tcl_Obj *funcList; /* List to hold the functon names*/ Tcl_Parse *parsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse)); /* Holds the Tcl_Tokens of substitutions */ + int code; - int code = ParseExpr(interp, script, numBytes, &opTree, litList, + TclNewObj(litList); + TclNewObj(funcList); + code = ParseExpr(interp, script, numBytes, &opTree, litList, funcList, parsePtr, 0 /* parseOnly */); if (code == TCL_OK) { @@ -2711,7 +2716,7 @@ TclVariadicOpCmd( int code; if (objc < 2) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(occdPtr->i.identity)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(occdPtr->i.identity)); return TCL_OK; } diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 7d67e12..2ab92da 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1746,7 +1746,7 @@ TclWordKnownAtCompileTime( } tokenPtr++; if (valuePtr != NULL) { - tempPtr = Tcl_NewObj(); + TclNewObj(tempPtr); Tcl_IncrRefCount(tempPtr); } while (numComponents--) { @@ -2035,7 +2035,7 @@ CompileCommandTokens( Interp *iPtr = (Interp *) interp; Tcl_Token *tokenPtr = parsePtr->tokenPtr; ExtCmdLoc *eclPtr = envPtr->extCmdMapPtr; - Tcl_Obj *cmdObj = Tcl_NewObj(); + Tcl_Obj *cmdObj; Command *cmdPtr = NULL; int code = TCL_ERROR; int cmdKnown, expand = -1; @@ -2050,6 +2050,7 @@ CompileCommandTokens( /* Pre-Compile */ + TclNewObj(cmdObj); envPtr->numCommands++; EnterCmdStartData(envPtr, cmdIdx, parsePtr->commandStart - envPtr->source, startCodeOffset); diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index f63d60d..116dd6d 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -2037,7 +2037,7 @@ DictSizeCmd( } result = Tcl_DictObjSize(interp, objv[1], &size); if (result == TCL_OK) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(size)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(size)); } return result; } @@ -2212,7 +2212,7 @@ DictIncrCmd( Tcl_DictObjPut(NULL, dictPtr, objv[2], objv[3]); } } else { - Tcl_DictObjPut(NULL, dictPtr, objv[2], Tcl_NewIntObj(1)); + Tcl_DictObjPut(NULL, dictPtr, objv[2], Tcl_NewWideIntObj(1)); } } else { /* @@ -2226,7 +2226,7 @@ DictIncrCmd( if (objc == 4) { code = TclIncrObj(interp, valuePtr, objv[3]); } else { - Tcl_Obj *incrPtr = Tcl_NewIntObj(1); + Tcl_Obj *incrPtr = Tcl_NewWideIntObj(1); Tcl_IncrRefCount(incrPtr); code = TclIncrObj(interp, valuePtr, incrPtr); diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index e066adf..8ccc303 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -804,8 +804,9 @@ Tcl_Obj * TclNewInstNameObj( unsigned char inst) { - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); TclInvalidateStringRep(objPtr); InstNameSetIntRep(objPtr, (long) inst); @@ -950,7 +951,7 @@ DisassembleByteCodeAsDicts( * Get the literals from the bytecode. */ - literals = Tcl_NewObj(); + TclNewObj(literals); for (i=0 ; inumLitObjects ; i++) { Tcl_ListObjAppendElement(NULL, literals, codePtr->objArrayPtr[i]); } @@ -959,7 +960,7 @@ DisassembleByteCodeAsDicts( * Get the variables from the bytecode. */ - variables = Tcl_NewObj(); + TclNewObj(variables); if (codePtr->procPtr) { int localCount = codePtr->procPtr->numCompiledLocals; CompiledLocal *localPtr = codePtr->procPtr->firstLocalPtr; @@ -967,7 +968,7 @@ DisassembleByteCodeAsDicts( for (i=0 ; inextPtr) { Tcl_Obj *descriptor[2]; - descriptor[0] = Tcl_NewObj(); + TclNewObj(descriptor[0]); if (!(localPtr->flags & (VAR_ARRAY|VAR_LINK))) { Tcl_ListObjAppendElement(NULL, descriptor[0], Tcl_NewStringObj("scalar", -1)); @@ -1007,12 +1008,12 @@ DisassembleByteCodeAsDicts( * Get the instructions from the bytecode. */ - instructions = Tcl_NewObj(); + TclNewObj(instructions); for (pc=codePtr->codeStart; pccodeStart+codePtr->numCodeBytes;){ const InstructionDesc *instDesc = &tclInstructionTable[*pc]; int address = pc - codePtr->codeStart; - inst = Tcl_NewObj(); + TclNewObj(inst); Tcl_ListObjAppendElement(NULL, inst, Tcl_NewStringObj( instDesc->name, -1)); opnd = pc + 1; @@ -1034,7 +1035,7 @@ DisassembleByteCodeAsDicts( val = TclGetUInt4AtPtr(opnd); opnd += 4; formatNumber: - Tcl_ListObjAppendElement(NULL, inst, Tcl_NewIntObj(val)); + Tcl_ListObjAppendElement(NULL, inst, Tcl_NewWideIntObj(val)); break; case OPERAND_OFFSET1: @@ -1102,7 +1103,7 @@ DisassembleByteCodeAsDicts( Tcl_Panic("opcode %d with more than zero 'no' operands", *pc); } } - Tcl_DictObjPut(NULL, instructions, Tcl_NewIntObj(address), inst); + Tcl_DictObjPut(NULL, instructions, Tcl_NewWideIntObj(address), inst); pc += instDesc->numBytes; } @@ -1110,21 +1111,23 @@ DisassembleByteCodeAsDicts( * Get the auxiliary data from the bytecode. */ - aux = Tcl_NewObj(); + TclNewObj(aux); for (i=0 ; inumAuxDataItems ; i++) { AuxData *auxData = &codePtr->auxDataArrayPtr[i]; Tcl_Obj *auxDesc = Tcl_NewStringObj(auxData->type->name, -1); if (auxData->type->disassembleProc) { - Tcl_Obj *desc = Tcl_NewObj(); + Tcl_Obj *desc; + TclNewObj(desc); Tcl_DictObjPut(NULL, desc, Tcl_NewStringObj("name", -1), auxDesc); auxDesc = desc; auxData->type->disassembleProc(auxData->clientData, auxDesc, codePtr, 0); } else if (auxData->type->printProc) { - Tcl_Obj *desc = Tcl_NewObj(); + Tcl_Obj *desc; + TclNewObj(desc); auxData->type->printProc(auxData->clientData, desc, codePtr, 0); Tcl_ListObjAppendElement(NULL, auxDesc, desc); } @@ -1135,7 +1138,7 @@ DisassembleByteCodeAsDicts( * Get the exception ranges from the bytecode. */ - exn = Tcl_NewObj(); + TclNewObj(exn); for (i=0 ; inumExceptRanges ; i++) { ExceptionRange *rangePtr = &codePtr->exceptArrayPtr[i]; @@ -1170,7 +1173,7 @@ DisassembleByteCodeAsDicts( ? ((ptr)+=5 , TclGetInt4AtPtr((ptr)-4)) \ : ((ptr)+=1 , TclGetInt1AtPtr((ptr)-1))) - commands = Tcl_NewObj(); + TclNewObj(commands); codeOffPtr = codePtr->codeDeltaStart; codeLenPtr = codePtr->codeLengthStart; srcOffPtr = codePtr->srcDeltaStart; @@ -1183,11 +1186,11 @@ DisassembleByteCodeAsDicts( codeLength = Decode(codeLenPtr); sourceOffset += Decode(srcOffPtr); sourceLength = Decode(srcLenPtr); - cmd = Tcl_NewObj(); + TclNewObj(cmd); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codefrom", -1), - Tcl_NewIntObj(codeOffset)); + Tcl_NewWideIntObj(codeOffset)); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codeto", -1), - Tcl_NewIntObj(codeOffset + codeLength - 1)); + Tcl_NewWideIntObj(codeOffset + codeLength - 1)); /* * Convert byte offsets to character offsets; important if multibyte @@ -1195,10 +1198,10 @@ DisassembleByteCodeAsDicts( */ Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptfrom", -1), - Tcl_NewIntObj(Tcl_NumUtfChars(codePtr->source, + Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source, sourceOffset))); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptto", -1), - Tcl_NewIntObj(Tcl_NumUtfChars(codePtr->source, + Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source, sourceOffset + sourceLength - 1))); Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("script", -1), Tcl_NewStringObj(codePtr->source+sourceOffset, sourceLength)); @@ -1218,7 +1221,7 @@ DisassembleByteCodeAsDicts( * Build the overall result. */ - description = Tcl_NewObj(); + TclNewObj(description); Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("literals", -1), literals); Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("variables", -1), @@ -1234,13 +1237,13 @@ DisassembleByteCodeAsDicts( Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("namespace", -1), Tcl_NewStringObj(codePtr->nsPtr->fullName, -1)); Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("stackdepth", -1), - Tcl_NewIntObj(codePtr->maxStackDepth)); + Tcl_NewWideIntObj(codePtr->maxStackDepth)); Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("exceptdepth", -1), - Tcl_NewIntObj(codePtr->maxExceptDepth)); + Tcl_NewWideIntObj(codePtr->maxExceptDepth)); if (line >= 0) { Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("initiallinenumber", -1), - Tcl_NewIntObj(line)); + Tcl_NewWideIntObj(line)); } if (file) { Tcl_DictObjPut(NULL, description, diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 3efbb74..48ab3cf 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -469,12 +469,13 @@ FillEncodingFileMap(void) */ int j, numFiles; - Tcl_Obj *directory, *matchFileList = Tcl_NewObj(); + Tcl_Obj *directory, *matchFileList; Tcl_Obj **filev; Tcl_GlobTypeData readableFiles = { TCL_GLOB_TYPE_FILE, TCL_GLOB_PERM_R, NULL, NULL }; + TclNewObj(matchFileList); Tcl_ListObjIndex(NULL, searchPath, i, &directory); Tcl_IncrRefCount(directory); Tcl_IncrRefCount(matchFileList); @@ -915,10 +916,11 @@ Tcl_GetEncodingNames( Tcl_HashTable table; Tcl_HashSearch search; Tcl_HashEntry *hPtr; - Tcl_Obj *map, *name, *result = Tcl_NewObj(); + Tcl_Obj *map, *name, *result; Tcl_DictSearch mapSearch; int dummy, done = 0; + TclNewObj(result); Tcl_InitObjHashTable(&table); /* diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 16bf8f7..23516f8 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -2909,7 +2909,7 @@ TclCompileEnsemble( DefineLineInformation; Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); Tcl_Obj *mapObj, *subcmdObj, *targetCmdObj, *listObj, **elems; - Tcl_Obj *replaced = Tcl_NewObj(), *replacement; + Tcl_Obj *replaced, *replacement; Tcl_Command ensemble = (Tcl_Command) cmdPtr; Command *oldCmdPtr = cmdPtr, *newCmdPtr; int len, result, flags = 0, i, depth = 1, invokeAnyway = 0; @@ -2917,6 +2917,7 @@ TclCompileEnsemble( unsigned numBytes; const char *word; + TclNewObj(replaced); Tcl_IncrRefCount(replaced); if (parsePtr->numWords < depth + 1) { goto failed; @@ -3420,7 +3421,7 @@ CompileToInvokedCommand( * the implementation. */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr); bytes = TclGetString(objPtr); if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) { @@ -3459,8 +3460,9 @@ CompileBasicNArgCommand( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr); TclCompileInvocation(interp, parsePtr->tokenPtr, objPtr, diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 09fda64..13f328c 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5076,7 +5076,7 @@ TEBCresume( if (toIdx == TCL_INDEX_NONE) { emptyList: - objResultPtr = Tcl_NewObj(); + TclNewObj(objResultPtr); TRACE_APPEND(("\"%.30s\"", O2S(objResultPtr))); NEXT_INST_F(9, 1, 1); } @@ -5336,7 +5336,7 @@ TEBCresume( * practical use. */ if (ch == -1) { - objResultPtr = Tcl_NewObj(); + TclNewObj(objResultPtr); } else { length = Tcl_UniCharToUtf(ch, buf); if ((ch >= 0xD800) && (length < 3)) { @@ -7046,7 +7046,7 @@ TEBCresume( break; } if (valuePtr == NULL) { - Tcl_DictObjPut(NULL, dictPtr, OBJ_AT_TOS,Tcl_NewIntObj(opnd)); + Tcl_DictObjPut(NULL, dictPtr, OBJ_AT_TOS, Tcl_NewWideIntObj(opnd)); } else { TclNewIntObj(value2Ptr, opnd); Tcl_IncrRefCount(value2Ptr); @@ -9719,7 +9719,7 @@ EvalStatsCmd( #define Percent(a,b) ((a) * 100.0 / (b)) - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); numInstructions = 0.0; diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index d6a152a..f9636d8 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -904,7 +904,7 @@ FileBasename( } } if (resultPtr == NULL) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } Tcl_IncrRefCount(resultPtr); Tcl_DecrRefCount(splitPtr); diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 187003d..6d8b751 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -644,12 +644,13 @@ SplitUnixPath( { int length; const char *origPath = path, *elementStart; - Tcl_Obj *result = Tcl_NewObj(); + Tcl_Obj *result; /* * Deal with the root directory as a special case. */ + TclNewObj(result); if (*path == '/') { Tcl_Obj *rootElt; ++path; @@ -735,9 +736,10 @@ SplitWinPath( const char *p, *elementStart; Tcl_PathType type = TCL_PATH_ABSOLUTE; Tcl_DString buf; - Tcl_Obj *result = Tcl_NewObj(); + Tcl_Obj *result; Tcl_DStringInit(&buf); + TclNewObj(result); p = ExtractWinRoot(path, &buf, 0, &type); /* @@ -977,7 +979,7 @@ Tcl_JoinPath( Tcl_DString *resultPtr) /* Pointer to previously initialized DString */ { int i, len; - Tcl_Obj *listObj = Tcl_NewObj(); + Tcl_Obj *listObj; Tcl_Obj *resultObj; const char *resultStr; @@ -985,6 +987,7 @@ Tcl_JoinPath( * Build the list of paths. */ + TclNewObj(listObj); for (i = 0; i < argc; i++) { Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewStringObj(argv[i], -1)); diff --git a/generic/tclIO.c b/generic/tclIO.c index 7af6aa0..a4bec5d 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -11130,7 +11130,7 @@ FixLevelCode( if (0 == strcmp(TclGetString(lv[i]), "-level")) { if (newlevel >= 0) { lvn[j++] = lv[i]; - lvn[j++] = Tcl_NewIntObj(newlevel); + lvn[j++] = Tcl_NewWideIntObj(newlevel); newlevel = -1; lignore = 1; continue; @@ -11140,7 +11140,7 @@ FixLevelCode( } else if (0 == strcmp(TclGetString(lv[i]), "-code")) { if (newcode >= 0) { lvn[j++] = lv[i]; - lvn[j++] = Tcl_NewIntObj(newcode); + lvn[j++] = Tcl_NewWideIntObj(newcode); newcode = -1; cignore = 1; continue; diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 508a991..41ee9bd 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -314,7 +314,7 @@ Tcl_GetsObjCmd( } TclChannelPreserve(chan); - linePtr = Tcl_NewObj(); + TclNewObj(linePtr); lineLen = Tcl_GetsObj(chan, linePtr); if (lineLen < 0) { if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) { @@ -343,7 +343,7 @@ Tcl_GetsObjCmd( code = TCL_ERROR; goto done; } - Tcl_SetObjResult(interp, Tcl_NewIntObj(lineLen)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(lineLen)); } else { Tcl_SetObjResult(interp, linePtr); } @@ -453,7 +453,7 @@ Tcl_ReadObjCmd( } } - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); Tcl_IncrRefCount(resultPtr); TclChannelPreserve(chan); charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0); @@ -975,7 +975,7 @@ Tcl_ExecObjCmd( return TCL_OK; } - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); if (Tcl_GetChannelHandle(chan, TCL_READABLE, NULL) == TCL_OK) { if (Tcl_ReadChars(chan, resultPtr, -1, 0) == TCL_IO_FAILURE) { /* @@ -1363,7 +1363,7 @@ AcceptCallbackProc( Tcl_ListObjAppendElement(NULL, objv[1], Tcl_NewStringObj( Tcl_GetChannelName(chan), -1)); Tcl_ListObjAppendElement(NULL, objv[1], Tcl_NewStringObj(address, -1)); - Tcl_ListObjAppendElement(NULL, objv[1], Tcl_NewIntObj(port)); + Tcl_ListObjAppendElement(NULL, objv[1], Tcl_NewWideIntObj(port)); script = Tcl_ConcatObj(2, objv); Tcl_IncrRefCount(script); @@ -1825,16 +1825,16 @@ ChanPendingObjCmd( switch ((enum options) index) { case PENDING_INPUT: if (!(mode & TCL_READABLE)) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(-1)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-1)); } else { - Tcl_SetObjResult(interp, Tcl_NewIntObj(Tcl_InputBuffered(chan))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tcl_InputBuffered(chan))); } break; case PENDING_OUTPUT: if (!(mode & TCL_WRITABLE)) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(-1)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-1)); } else { - Tcl_SetObjResult(interp, Tcl_NewIntObj(Tcl_OutputBuffered(chan))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tcl_OutputBuffered(chan))); } break; } @@ -1954,7 +1954,7 @@ ChanPipeObjCmd( channelNames[0] = Tcl_GetChannelName(rchan); channelNames[1] = Tcl_GetChannelName(wchan); - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(channelNames[0], -1)); Tcl_ListObjAppendElement(NULL, resultPtr, diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 9a82cdb..3c5f133 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -1219,7 +1219,7 @@ ReflectInput( } if (Tcl_IsShared(bufObj)) { Tcl_DecrRefCount(bufObj); - bufObj = Tcl_NewObj(); + TclNewObj(bufObj); Tcl_IncrRefCount(bufObj); } Tcl_SetByteArrayLength(bufObj, 0); diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index acc9e40..c413b21 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -1734,7 +1734,7 @@ Tcl_FSEvalFileEx( } } - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); /* @@ -1870,7 +1870,7 @@ TclNREvalFile( } } - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); /* @@ -3765,7 +3765,7 @@ Tcl_Obj * Tcl_FSListVolumes(void) { FilesystemRecord *fsRecPtr; - Tcl_Obj *resultPtr = Tcl_NewObj(); + Tcl_Obj *resultPtr; /* * Call each "listVolumes" function of each registered filesystem in @@ -3773,6 +3773,7 @@ Tcl_FSListVolumes(void) * has succeeded. */ + TclNewObj(resultPtr); fsRecPtr = FsGetFirstFilesystem(); Claim(); while (fsRecPtr != NULL) { @@ -3832,7 +3833,7 @@ FsListMounts( if (fsRecPtr->fsPtr != &tclNativeFilesystem && fsRecPtr->fsPtr->matchInDirectoryProc != NULL) { if (resultPtr == NULL) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } fsRecPtr->fsPtr->matchInDirectoryProc(NULL, resultPtr, pathPtr, pattern, &mountsOnly); @@ -3903,7 +3904,7 @@ Tcl_FSSplitPath( * For example, 'ftp://' is a valid drive name. */ - result = Tcl_NewObj(); + TclNewObj(result); p = Tcl_GetString(pathPtr); Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(p, driveNameLength)); diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index a0a31da..63a9466 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -633,7 +633,7 @@ PrefixMatchObjCmd( } Tcl_ListObjAppendElement(interp, errorPtr, Tcl_NewStringObj("-code", 5)); - Tcl_ListObjAppendElement(interp, errorPtr, Tcl_NewIntObj(result)); + Tcl_ListObjAppendElement(interp, errorPtr, Tcl_NewWideIntObj(result)); return Tcl_SetReturnOptions(interp, errorPtr); } diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index 669baae..de308de 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -602,7 +602,7 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; # endif /* TCL_NO_DEPRECATED */ #else # undef TclpGetPid -# define TclpGetPid(pid) ((unsigned long) (pid)) +# define TclpGetPid(pid) ((int)(size_t)(pid)) #endif #endif /* _TCLINTPLATDECLS */ diff --git a/generic/tclInterp.c b/generic/tclInterp.c index b84c065..6417668 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -1030,7 +1030,7 @@ NRInterpCmd( return TCL_ERROR; } iiPtr = (InterpInfo *) ((Interp *) childInterp)->interpInfo; - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); hPtr = Tcl_FirstHashEntry(&iiPtr->parent.childTable, &hashSearch); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hashSearch)) { string = (char *)Tcl_GetHashKey(&iiPtr->parent.childTable, hPtr); @@ -1757,10 +1757,11 @@ AliasList( { Tcl_HashEntry *entryPtr; Tcl_HashSearch hashSearch; - Tcl_Obj *resultPtr = Tcl_NewObj(); + Tcl_Obj *resultPtr; Alias *aliasPtr; Child *childPtr; + TclNewObj(resultPtr); childPtr = &((InterpInfo *) ((Interp *) childInterp)->interpInfo)->child; entryPtr = Tcl_FirstHashEntry(&childPtr->aliasTable, &hashSearch); @@ -2806,7 +2807,7 @@ ChildDebugCmd( iPtr = (Interp *) childInterp; if (objc == 0) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj("-frame", -1)); Tcl_ListObjAppendElement(NULL, resultPtr, @@ -3075,11 +3076,12 @@ ChildHidden( Tcl_Interp *interp, /* Interp for data return. */ Tcl_Interp *childInterp) /* Interp whose hidden commands to query. */ { - Tcl_Obj *listObjPtr = Tcl_NewObj(); /* Local object pointer. */ + Tcl_Obj *listObjPtr; /* Local object pointer. */ Tcl_HashTable *hTblPtr; /* For local searches. */ Tcl_HashEntry *hPtr; /* For local searches. */ Tcl_HashSearch hSearch; /* For local searches. */ + TclNewObj(listObjPtr); hTblPtr = ((Interp *) childInterp)->hiddenCmdTablePtr; if (hTblPtr != NULL) { for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); diff --git a/generic/tclLink.c b/generic/tclLink.c index c763218..090192e 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -1303,7 +1303,7 @@ ObjValue( return resultObj; } linkPtr->lastValue.i = LinkedVar(int); - return Tcl_NewIntObj(linkPtr->lastValue.i); + return Tcl_NewWideIntObj(linkPtr->lastValue.i); case TCL_LINK_WIDE_INT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); @@ -1355,7 +1355,7 @@ ObjValue( return resultObj; } linkPtr->lastValue.c = LinkedVar(char); - return Tcl_NewIntObj(linkPtr->lastValue.c); + return Tcl_NewWideIntObj(linkPtr->lastValue.c); case TCL_LINK_UCHAR: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); @@ -1368,7 +1368,7 @@ ObjValue( return resultObj; } linkPtr->lastValue.uc = LinkedVar(unsigned char); - return Tcl_NewIntObj(linkPtr->lastValue.uc); + return Tcl_NewWideIntObj(linkPtr->lastValue.uc); case TCL_LINK_SHORT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); @@ -1381,7 +1381,7 @@ ObjValue( return resultObj; } linkPtr->lastValue.s = LinkedVar(short); - return Tcl_NewIntObj(linkPtr->lastValue.s); + return Tcl_NewWideIntObj(linkPtr->lastValue.s); case TCL_LINK_USHORT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); @@ -1394,7 +1394,7 @@ ObjValue( return resultObj; } linkPtr->lastValue.us = LinkedVar(unsigned short); - return Tcl_NewIntObj(linkPtr->lastValue.us); + return Tcl_NewWideIntObj(linkPtr->lastValue.us); case TCL_LINK_UINT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 5a0d45f..332e6aa 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -479,7 +479,9 @@ TclListObjRange( toIdx = listLen-1; } if (fromIdx > toIdx) { - return Tcl_NewObj(); + Tcl_Obj *obj; + TclNewObj(obj); + return obj; } newLen = toIdx - fromIdx + 1; @@ -1379,7 +1381,7 @@ TclLindexFlat( return NULL; } } - listPtr = Tcl_NewObj(); + TclNewObj(listPtr); } else { /* * Extract the pointer to the appropriate element. @@ -1623,7 +1625,7 @@ TclLsetFlat( if (--indexCount) { parentList = subListPtr; if (index == elemCount) { - subListPtr = Tcl_NewObj(); + TclNewObj(subListPtr); } else { subListPtr = elemPtrs[index]; } diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 5fdc116..1ca1950 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -1073,7 +1073,7 @@ TclGetLoadedPackagesEx( Tcl_Obj *resultObj, *pkgDesc[2]; if (targetName == NULL) { - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); Tcl_MutexLock(&packageMutex); for (pkgPtr = firstPackagePtr; pkgPtr != NULL; pkgPtr = pkgPtr->nextPtr) { @@ -1119,7 +1119,7 @@ TclGetLoadedPackagesEx( * interpreter. */ - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) { pkgPtr = ipPtr->pkgPtr; pkgDesc[0] = Tcl_NewStringObj(pkgPtr->fileName, -1); diff --git a/generic/tclMain.c b/generic/tclMain.c index 4f44685..216544a 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -307,7 +307,7 @@ Tcl_MainEx( is.interp = interp; is.prompt = PROMPT_START; - is.commandPtr = Tcl_NewObj(); + TclNewObj(is.commandPtr); /* * If the application has not already set a startup script, parse the @@ -348,7 +348,7 @@ Tcl_MainEx( argc--; argv++; - Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY); argvPtr = Tcl_NewListObj(0, NULL); while (argc--) { @@ -362,7 +362,7 @@ Tcl_MainEx( is.tty = isatty(0); Tcl_SetVar2Ex(interp, "tcl_interactive", NULL, - Tcl_NewIntObj(!path && is.tty), TCL_GLOBAL_ONLY); + Tcl_NewWideIntObj(!path && is.tty), TCL_GLOBAL_ONLY); /* * Invoke application-specific initialization. @@ -522,7 +522,7 @@ Tcl_MainEx( TCL_EVAL_GLOBAL); is.input = Tcl_GetStdChannel(TCL_STDIN); Tcl_DecrRefCount(is.commandPtr); - is.commandPtr = Tcl_NewObj(); + TclNewObj(is.commandPtr); Tcl_IncrRefCount(is.commandPtr); if (code != TCL_OK) { chan = Tcl_GetStdChannel(TCL_STDERR); @@ -790,7 +790,8 @@ StdinProc( code = Tcl_RecordAndEvalObj(interp, commandPtr, TCL_EVAL_GLOBAL); isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN); Tcl_DecrRefCount(commandPtr); - isPtr->commandPtr = commandPtr = Tcl_NewObj(); + TclNewObj(commandPtr); + isPtr->commandPtr = commandPtr; Tcl_IncrRefCount(commandPtr); if (chan != NULL) { Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr); diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 8e138d0..e493db1 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -3546,9 +3546,10 @@ NamespaceExportCmd( */ if (objc == 1) { - Tcl_Obj *listPtr = Tcl_NewObj(); + Tcl_Obj *listPtr; - (void) Tcl_AppendExportList(interp, NULL, listPtr); + TclNewObj(listPtr); + (void)Tcl_AppendExportList(interp, NULL, listPtr); Tcl_SetObjResult(interp, listPtr); return TCL_OK; } @@ -4024,8 +4025,9 @@ NamespacePathCmd( */ if (objc == 1) { - Tcl_Obj *resultObj = Tcl_NewObj(); + Tcl_Obj *resultObj; + TclNewObj(resultObj); for (i=0 ; icommandPathLength ; i++) { if (nsPtr->commandPathArray[i].nsPtr != NULL) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( @@ -5018,7 +5020,7 @@ TclLogCommandInfo( */ Tcl_ListObjAppendElement(NULL, iPtr->errorStack, iPtr->upLiteral); - Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewIntObj( + Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewWideIntObj( iPtr->framePtr->level - iPtr->varFramePtr->level)); } else if (iPtr->framePtr != iPtr->rootFramePtr) { /* diff --git a/generic/tclOO.c b/generic/tclOO.c index 21018ac..b60ab1f 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -3035,7 +3035,7 @@ TclOOObjectName( if (oPtr->cachedNameObj) { return oPtr->cachedNameObj; } - namePtr = Tcl_NewObj(); + TclNewObj(namePtr); Tcl_GetCommandFullName(interp, oPtr->command, namePtr); Tcl_IncrRefCount(namePtr); oPtr->cachedNameObj = namePtr; diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index b866c2c..19f68fc 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -831,7 +831,7 @@ TclOO_Object_VarName( * (including traversing variable links), convert back to a name. */ - varNamePtr = Tcl_NewObj(); + TclNewObj(varNamePtr); if (aryVar != NULL) { Tcl_GetVariableFullName(interp, (Tcl_Var) aryVar, varNamePtr); diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c index 76cf4ed..e1d88ec 100644 --- a/generic/tclOODefineCmds.c +++ b/generic/tclOODefineCmds.c @@ -1050,8 +1050,8 @@ MagicDefinitionInvoke( * comments above for why these contortions are necessary. */ - objPtr = Tcl_NewObj(); - obj2Ptr = Tcl_NewObj(); + TclNewObj(objPtr); + TclNewObj(obj2Ptr); cmd = FindCommand(interp, objv[cmdIndex], nsPtr); if (cmd == NULL) { /* @@ -2338,7 +2338,7 @@ ClassFilterGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(filterObj, oPtr->classPtr->filters) { Tcl_ListObjAppendElement(NULL, resultObj, filterObj); } @@ -2419,7 +2419,7 @@ ClassMixinGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(mixinPtr, oPtr->classPtr->mixins) { Tcl_ListObjAppendElement(NULL, resultObj, TclOOObjectName(interp, mixinPtr->thisPtr)); @@ -2525,7 +2525,7 @@ ClassSuperGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(superPtr, oPtr->classPtr->superclasses) { Tcl_ListObjAppendElement(NULL, resultObj, TclOOObjectName(interp, superPtr->thisPtr)); @@ -2691,7 +2691,7 @@ ClassVarsGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (IsPrivateDefine(interp)) { PrivateVariableMapping *privatePtr; @@ -2800,7 +2800,7 @@ ObjFilterGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(filterObj, oPtr->filters) { Tcl_ListObjAppendElement(NULL, resultObj, filterObj); } @@ -2869,7 +2869,7 @@ ObjMixinGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(mixinPtr, oPtr->mixins) { if (mixinPtr) { Tcl_ListObjAppendElement(NULL, resultObj, @@ -2954,7 +2954,7 @@ ObjVarsGet( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (IsPrivateDefine(interp)) { PrivateVariableMapping *privatePtr; diff --git a/generic/tclOOInfo.c b/generic/tclOOInfo.c index a555d1b..c9e136c 100644 --- a/generic/tclOOInfo.c +++ b/generic/tclOOInfo.c @@ -206,11 +206,11 @@ InfoObjectClassCmd( continue; } if (TclOOIsReachable(o2clsPtr, mixinPtr)) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(1)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(1)); return TCL_OK; } } - Tcl_SetObjResult(interp, Tcl_NewIntObj( + Tcl_SetObjResult(interp, Tcl_NewWideIntObj( TclOOIsReachable(o2clsPtr, oPtr->selfCls))); return TCL_OK; } @@ -270,13 +270,13 @@ InfoObjectDefnCmd( return TCL_ERROR; } - resultObjs[0] = Tcl_NewObj(); + TclNewObj(resultObjs[0]); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { Tcl_Obj *argObj; - argObj = Tcl_NewObj(); + TclNewObj(argObj); Tcl_ListObjAppendElement(NULL, argObj, Tcl_NewStringObj(localPtr->name, -1)); if (localPtr->defValuePtr != NULL) { @@ -320,7 +320,7 @@ InfoObjectFiltersCmd( if (oPtr == NULL) { return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(filterObj, oPtr->filters) { Tcl_ListObjAppendElement(NULL, resultObj, filterObj); @@ -601,7 +601,7 @@ InfoObjectMethodsCmd( } } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (recurse) { const char **names; int i, numNames = TclOOGetSortedMethodList(oPtr, NULL, NULL, flag, @@ -713,7 +713,7 @@ InfoObjectMixinsCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(mixinPtr, oPtr->mixins) { if (!mixinPtr) { continue; @@ -753,7 +753,7 @@ InfoObjectIdCmd( return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewIntObj(oPtr->creationEpoch)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(oPtr->creationEpoch)); return TCL_OK; } @@ -826,7 +826,7 @@ InfoObjectVariablesCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (isPrivate) { PrivateVariableMapping *privatePtr; @@ -878,7 +878,7 @@ InfoObjectVarsCmd( if (objc == 3) { pattern = TclGetString(objv[2]); } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); /* * Extract the information we need from the object's namespace's table of @@ -946,13 +946,13 @@ InfoClassConstrCmd( return TCL_ERROR; } - resultObjs[0] = Tcl_NewObj(); + TclNewObj(resultObjs[0]); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { Tcl_Obj *argObj; - argObj = Tcl_NewObj(); + TclNewObj(argObj); Tcl_ListObjAppendElement(NULL, argObj, Tcl_NewStringObj(localPtr->name, -1)); if (localPtr->defValuePtr != NULL) { @@ -1014,13 +1014,13 @@ InfoClassDefnCmd( return TCL_ERROR; } - resultObjs[0] = Tcl_NewObj(); + TclNewObj(resultObjs[0]); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { Tcl_Obj *argObj; - argObj = Tcl_NewObj(); + TclNewObj(argObj); Tcl_ListObjAppendElement(NULL, argObj, Tcl_NewStringObj(localPtr->name, -1)); if (localPtr->defValuePtr != NULL) { @@ -1158,7 +1158,7 @@ InfoClassFiltersCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(filterObj, clsPtr->filters) { Tcl_ListObjAppendElement(NULL, resultObj, filterObj); } @@ -1252,7 +1252,7 @@ InfoClassInstancesCmd( pattern = TclGetString(objv[2]); } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(oPtr, clsPtr->instances) { Tcl_Obj *tmpObj = TclOOObjectName(interp, oPtr); @@ -1356,7 +1356,7 @@ InfoClassMethodsCmd( } } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (recurse) { const char **names; int i, numNames = TclOOGetSortedClassMethodList(clsPtr, flag, &names); @@ -1463,7 +1463,7 @@ InfoClassMixinsCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(mixinPtr, clsPtr->mixins) { if (!mixinPtr) { continue; @@ -1509,7 +1509,7 @@ InfoClassSubsCmd( pattern = TclGetString(objv[2]); } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(subclassPtr, clsPtr->subclasses) { Tcl_Obj *tmpObj = TclOOObjectName(interp, subclassPtr->thisPtr); @@ -1560,7 +1560,7 @@ InfoClassSupersCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); FOREACH(superPtr, clsPtr->superclasses) { Tcl_ListObjAppendElement(NULL, resultObj, TclOOObjectName(interp, superPtr->thisPtr)); @@ -1605,7 +1605,7 @@ InfoClassVariablesCmd( return TCL_ERROR; } - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); if (isPrivate) { PrivateVariableMapping *privatePtr; diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c index b1b3d8e..f65462e 100644 --- a/generic/tclOOMethod.c +++ b/generic/tclOOMethod.c @@ -394,7 +394,7 @@ TclOONewProcMethod( if (argsObj == NULL) { argsLen = -1; - argsObj = Tcl_NewObj(); + TclNewObj(argsObj); Tcl_IncrRefCount(argsObj); procName = ""; } else if (Tcl_ListObjLength(interp, argsObj, &argsLen) != TCL_OK) { @@ -1315,12 +1315,13 @@ CloneProcedureMethod( * Copy the argument list. */ - argsObj = Tcl_NewObj(); + TclNewObj(argsObj); for (localPtr=pmPtr->procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { - Tcl_Obj *argObj = Tcl_NewObj(); + Tcl_Obj *argObj; + TclNewObj(argObj); Tcl_ListObjAppendElement(NULL, argObj, Tcl_NewStringObj(localPtr->name, -1)); if (localPtr->defValuePtr != NULL) { diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 32b2961..8b1f199 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -722,7 +722,7 @@ TclPathPart( (Tcl_FSGetPathType(pathPtr) == TCL_PATH_RELATIVE))) { Tcl_ListObjIndex(NULL, splitPtr, splitElements-1, &resultPtr); } else { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } } else { /* @@ -760,7 +760,7 @@ GetExtension( tail = TclGetString(pathPtr); extension = TclGetExtension(tail); if (extension == NULL) { - ret = Tcl_NewObj(); + TclNewObj(ret); } else { ret = Tcl_NewStringObj(extension, -1); } @@ -1036,7 +1036,7 @@ TclJoinPath( noQuickReturn: if (res == NULL) { - res = Tcl_NewObj(); + TclNewObj(res); } ptr = TclGetStringFromObj(res, &length); @@ -1272,7 +1272,7 @@ TclNewFSPathObj( return pathPtr; } - pathPtr = Tcl_NewObj(); + TclNewObj(pathPtr); fsPathPtr = (FsPath *)ckalloc(sizeof(FsPath)); /* diff --git a/generic/tclPipe.c b/generic/tclPipe.c index 8d5c0c7..e9ad4e6 100644 --- a/generic/tclPipe.c +++ b/generic/tclPipe.c @@ -334,7 +334,7 @@ TclCleanupChildren( Tcl_Obj *objPtr; Tcl_Seek(errorChan, 0, SEEK_SET); - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); count = Tcl_ReadChars(errorChan, objPtr, -1, 0); if (count < 0) { result = TCL_ERROR; diff --git a/generic/tclPkg.c b/generic/tclPkg.c index bdd9a86..b55ad3e 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -285,7 +285,7 @@ TclPkgFileSeen( Tcl_Obj *list; if (isNew) { - list = Tcl_NewObj(); + TclNewObj(list); Tcl_SetHashValue(entry, list); Tcl_IncrRefCount(list); } else { @@ -1241,7 +1241,7 @@ TclNRPackageObjCmd( } else { Tcl_Obj *resultObj; - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); tablePtr = &iPtr->packageTable; for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { @@ -1481,7 +1481,7 @@ TclNRPackageObjCmd( */ Tcl_SetObjResult(interp, - Tcl_NewIntObj(CompareVersions(iva, ivb, NULL))); + Tcl_NewWideIntObj(CompareVersions(iva, ivb, NULL))); ckfree(iva); ckfree(ivb); break; @@ -1490,8 +1490,9 @@ TclNRPackageObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "package"); return TCL_ERROR; } else { - Tcl_Obj *resultObj = Tcl_NewObj(); + Tcl_Obj *resultObj; + TclNewObj(resultObj); argv2 = TclGetString(objv[2]); hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv2); if (hPtr != NULL) { diff --git a/generic/tclProcess.c b/generic/tclProcess.c index c0f21e3..d4cf717 100644 --- a/generic/tclProcess.c +++ b/generic/tclProcess.c @@ -222,7 +222,7 @@ WaitProcessStatus( * Get process status. */ - if (pid == (Tcl_Pid) -1) { + if (pid == (Tcl_Pid)-1) { /* * POSIX errName msg */ @@ -371,7 +371,7 @@ BuildProcessStatusObj( * Normal exit, return TCL_OK. */ - return Tcl_NewIntObj(TCL_OK); + return Tcl_NewWideIntObj(TCL_OK); } /* @@ -427,7 +427,7 @@ ProcessListObjCmd( entry != NULL; entry = Tcl_NextHashEntry(&search)) { info = (ProcessInfo *) Tcl_GetHashValue(entry); Tcl_ListObjAppendElement(interp, list, - Tcl_NewIntObj(info->resolvedPid)); + Tcl_NewWideIntObj(info->resolvedPid)); } Tcl_MutexUnlock(&infoTablesMutex); Tcl_SetObjResult(interp, list); @@ -523,7 +523,7 @@ ProcessStatusObjCmd( * Add to result. */ - Tcl_DictObjPut(interp, dict, Tcl_NewIntObj(info->resolvedPid), + Tcl_DictObjPut(interp, dict, Tcl_NewWideIntObj(info->resolvedPid), BuildProcessStatusObj(info)); } } @@ -573,7 +573,7 @@ ProcessStatusObjCmd( * Add to result. */ - Tcl_DictObjPut(interp, dict, Tcl_NewIntObj(info->resolvedPid), + Tcl_DictObjPut(interp, dict, Tcl_NewWideIntObj(info->resolvedPid), BuildProcessStatusObj(info)); } } @@ -834,7 +834,7 @@ TclProcessCreated( * Allocate and initialize info structure. */ - info = (ProcessInfo *) ckalloc(sizeof(ProcessInfo)); + info = (ProcessInfo *)ckalloc(sizeof(ProcessInfo)); InitProcessInfo(info, pid, resolvedPid); /* diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 8b88423..99135d3 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -676,9 +676,9 @@ TclRegAbout( * well and Tcl has other limits that constrain things as well... */ - resultObj = Tcl_NewObj(); - Tcl_ListObjAppendElement(NULL, resultObj, - Tcl_NewWideIntObj((Tcl_WideInt) regexpPtr->re.re_nsub)); + TclNewObj(resultObj); + TclNewIntObj(infoObj, regexpPtr->re.re_nsub); + Tcl_ListObjAppendElement(NULL, resultObj, infoObj); /* * Now append a list of all the bit-flags set for the RE. diff --git a/generic/tclResult.c b/generic/tclResult.c index baecf46..4b9df6c 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -248,7 +248,7 @@ Tcl_SaveResult( */ statePtr->objResultPtr = iPtr->objResultPtr; - iPtr->objResultPtr = Tcl_NewObj(); + TclNewObj(iPtr->objResultPtr); Tcl_IncrRefCount(iPtr->objResultPtr); /* @@ -1036,13 +1036,14 @@ Tcl_SetErrorCodeVA( Tcl_Interp *interp, /* Interpreter in which to set errorCode */ va_list argList) /* Variable argument list. */ { - Tcl_Obj *errorObj = Tcl_NewObj(); + Tcl_Obj *errorObj; /* * Scan through the arguments one at a time, appending them to the * errorCode field as list elements. */ + TclNewObj(errorObj); while (1) { char *elem = va_arg(argList, char *); @@ -1395,9 +1396,10 @@ TclMergeReturnOptions( int code = TCL_OK; int level = 1; Tcl_Obj *valuePtr; - Tcl_Obj *returnOpts = Tcl_NewObj(); + Tcl_Obj *returnOpts; Tcl_Obj **keys = GetKeys(); + TclNewObj(returnOpts); for (; objc > 1; objv += 2, objc -= 2) { const char *opt = TclGetString(objv[0]); const char *compare = TclGetString(keys[KEY_OPTIONS]); @@ -1591,19 +1593,19 @@ Tcl_GetReturnOptions( if (iPtr->returnOpts) { options = Tcl_DuplicateObj(iPtr->returnOpts); } else { - options = Tcl_NewObj(); + TclNewObj(options); } if (result == TCL_RETURN) { Tcl_DictObjPut(NULL, options, keys[KEY_CODE], - Tcl_NewIntObj(iPtr->returnCode)); + Tcl_NewWideIntObj(iPtr->returnCode)); Tcl_DictObjPut(NULL, options, keys[KEY_LEVEL], - Tcl_NewIntObj(iPtr->returnLevel)); + Tcl_NewWideIntObj(iPtr->returnLevel)); } else { Tcl_DictObjPut(NULL, options, keys[KEY_CODE], - Tcl_NewIntObj(result)); + Tcl_NewWideIntObj(result)); Tcl_DictObjPut(NULL, options, keys[KEY_LEVEL], - Tcl_NewIntObj(0)); + Tcl_NewWideIntObj(0)); } if (result == TCL_ERROR) { @@ -1616,7 +1618,7 @@ Tcl_GetReturnOptions( if (iPtr->errorInfo) { Tcl_DictObjPut(NULL, options, keys[KEY_ERRORINFO], iPtr->errorInfo); Tcl_DictObjPut(NULL, options, keys[KEY_ERRORLINE], - Tcl_NewIntObj(iPtr->errorLine)); + Tcl_NewWideIntObj(iPtr->errorLine)); } return options; } diff --git a/generic/tclScan.c b/generic/tclScan.c index 4d86382..dfd6b88 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -1068,7 +1068,7 @@ Tcl_ScanObjCmd( * Here no vars were specified, we want a list returned (inline scan) */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); for (i = 0; i < totalVars; i++) { if (objs[i] != NULL) { Tcl_ListObjAppendElement(NULL, objPtr, objs[i]); @@ -1089,12 +1089,12 @@ Tcl_ScanObjCmd( if (code == TCL_OK) { if (underflow && (nconversions == 0)) { if (numVars) { - objPtr = Tcl_NewWideIntObj(-1); + TclNewIntObj(objPtr, -1); } else { if (objPtr) { Tcl_SetListObj(objPtr, 0, NULL); } else { - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); } } } else if (numVars) { diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 81c5c92..7486631 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2133,7 +2133,7 @@ Tcl_AppendFormatToObj( if (l == (long) 0) gotHash = 0; } - segment = Tcl_NewObj(); + TclNewObj(segment); allocSegment = 1; segmentLimit = INT_MAX; Tcl_IncrRefCount(segment); @@ -2308,7 +2308,7 @@ Tcl_AppendFormatToObj( if (numDigits == 0) { numDigits = 1; } - pure = Tcl_NewObj(); + TclNewObj(pure); Tcl_SetObjLength(pure, (int) numDigits); bytes = TclGetString(pure); toAppend = length = (int) numDigits; @@ -2429,7 +2429,7 @@ Tcl_AppendFormatToObj( *p++ = (char) ch; *p = '\0'; - segment = Tcl_NewObj(); + TclNewObj(segment); allocSegment = 1; if (!Tcl_AttemptSetObjLength(segment, length)) { msg = overflow; @@ -3314,7 +3314,7 @@ TclStringCat( /* assert ( length > start ) */ TclFreeIntRep(objResultPtr); } else { - objResultPtr = Tcl_NewObj(); /* PANIC? */ + TclNewObj(objResultPtr); /* PANIC? */ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) { Tcl_DecrRefCount(objResultPtr); if (interp) { @@ -3561,7 +3561,7 @@ TclStringFirst( int lh, ln = Tcl_GetCharLength(needle); Tcl_Obj *result; int value = -1; - Tcl_UniChar *check, *end, *uh, *un; + Tcl_UniChar *check, *end, *uh, *un; if (start < 0) { start = 0; @@ -3668,7 +3668,7 @@ TclStringLast( int lh, ln = Tcl_GetCharLength(needle); Tcl_Obj *result; int value = -1; - Tcl_UniChar *check, *uh, *un; + Tcl_UniChar *check, *uh, *un; if (ln == 0) { /* @@ -3830,7 +3830,7 @@ TclStringReverse( char *to, *from = objPtr->bytes; if (!inPlace || Tcl_IsShared(objPtr)) { - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_SetObjLength(objPtr, numBytes); } to = objPtr->bytes; diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 5d79d7d..36cb9b5 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -450,7 +450,7 @@ void *TclWinGetTclInstance() int TclpGetPid(Tcl_Pid pid) { - return (int) (size_t) pid; + return (int)(size_t)pid; } #if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index b98623c..0bb55e1 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -413,7 +413,7 @@ ThreadObjCmd( Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewIntObj( + Tcl_SetObjResult(interp, Tcl_NewWideIntObj( Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT))); return TCL_OK; } diff --git a/generic/tclTimer.c b/generic/tclTimer.c index 05a80b0..e7fe14b 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -942,8 +942,9 @@ Tcl_AfterObjCmd( break; case AFTER_INFO: if (objc == 2) { - Tcl_Obj *resultObj = Tcl_NewObj(); + Tcl_Obj *resultObj; + TclNewObj(resultObj); for (afterPtr = assocPtr->firstAfterPtr; afterPtr != NULL; afterPtr = afterPtr->nextPtr) { if (assocPtr->interp == interp) { @@ -967,8 +968,9 @@ Tcl_AfterObjCmd( Tcl_SetErrorCode(interp, "TCL","LOOKUP","EVENT", eventStr, NULL); return TCL_ERROR; } else { - Tcl_Obj *resultListPtr = Tcl_NewObj(); + Tcl_Obj *resultListPtr; + TclNewObj(resultListPtr); Tcl_ListObjAppendElement(interp, resultListPtr, afterPtr->commandPtr); Tcl_ListObjAppendElement(interp, resultListPtr, Tcl_NewStringObj( diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 300e0b9..1b59852 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -276,7 +276,7 @@ Tcl_TraceObjCmd( return TCL_ERROR; } - opsList = Tcl_NewObj(); + TclNewObj(opsList); Tcl_IncrRefCount(opsList); flagOps = TclGetStringFromObj(objv[3], &numFlags); if (numFlags == 0) { @@ -320,7 +320,7 @@ Tcl_TraceObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "name"); return TCL_ERROR; } - resultListPtr = Tcl_NewObj(); + TclNewObj(resultListPtr); name = Tcl_GetString(objv[2]); FOREACH_VAR_TRACE(interp, name, clientData) { TraceVarInfo *tvarPtr = (TraceVarInfo *)clientData; @@ -965,7 +965,7 @@ TraceVariableObjCmd( return TCL_ERROR; } - resultListPtr = Tcl_NewObj(); + TclNewObj(resultListPtr); name = Tcl_GetString(objv[3]); FOREACH_VAR_TRACE(interp, name, clientData) { Tcl_Obj *opObjPtr, *eachTraceObjPtr, *elemObjPtr; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 8db6606..f6d815b 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -2040,7 +2040,7 @@ Tcl_ConcatObj( } } if (!resPtr) { - resPtr = Tcl_NewObj(); + TclNewObj(resPtr); } return resPtr; } diff --git a/generic/tclVar.c b/generic/tclVar.c index 2818fc9..3d46790 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -4286,7 +4286,7 @@ ArraySizeCmd( } } - Tcl_SetObjResult(interp, Tcl_NewIntObj(size)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(size)); return TCL_OK; } @@ -5451,7 +5451,8 @@ TclDeleteNamespaceVars( for (varPtr = VarHashFirstVar(tablePtr, &search); varPtr != NULL; varPtr = VarHashFirstVar(tablePtr, &search)) { - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); VarHashRefCount(varPtr)++; /* Make sure we get to remove from * hash. */ Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, objPtr); @@ -6120,7 +6121,7 @@ TclInfoVarsCmd( if (!TclIsVarUndefined(varPtr) || TclIsVarNamespaceVar(varPtr)) { if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, elemObjPtr); } else { @@ -6153,7 +6154,7 @@ TclInfoVarsCmd( if ((simplePattern == NULL) || Tcl_StringMatch(varName, simplePattern)) { if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, elemObjPtr); } else { diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 695c814..ecee366 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3238,7 +3238,7 @@ ZipFSTclLibraryObjCmd( Tcl_Obj *pResult = TclZipfs_TclLibrary(); if (!pResult) { - pResult = Tcl_NewObj(); + TclNewObj(pResult); } Tcl_SetObjResult(interp, pResult); } diff --git a/generic/tclZlib.c b/generic/tclZlib.c index f4cfb07..34bf78d 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -354,7 +354,7 @@ ConvertErrorToList( return Tcl_NewListObj(4, objv); case Z_NEED_DICT: TclNewLiteralStringObj(objv[2], "NEED_DICT"); - objv[3] = Tcl_NewWideIntObj((Tcl_WideInt) adler); + TclNewIntObj(objv[3], (Tcl_WideInt)adler); return Tcl_NewListObj(4, objv); /* @@ -2162,7 +2162,7 @@ ZlibCmd( break; case 1: headerVarObj = objv[i+1]; - headerDictObj = Tcl_NewObj(); + TclNewObj(headerDictObj); break; } } @@ -3484,8 +3484,9 @@ ZlibTransformGetOption( if ((cd->flags & IN_HEADER) && ((optionName == NULL) || (strcmp(optionName, "-header") == 0))) { - Tcl_Obj *tmpObj = Tcl_NewObj(); + Tcl_Obj *tmpObj; + TclNewObj(tmpObj); ExtractHeader(&cd->inHeader.header, tmpObj); if (optionName == NULL) { Tcl_DStringAppendElement(dsPtr, "-header"); -- cgit v0.12 From f0ab6a724c11e0e8083b6152c3968a147507c8b5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 18 Sep 2020 08:33:51 +0000 Subject: New macro TclNewIndexObj() which does the same as TclNewWideIntObjFromSize() but optimized the same way as TclNewIntObj(). --- generic/tclCmdIL.c | 29 ++++++++++++++++++----------- generic/tclCmdMZ.c | 28 +++++++++++++++++----------- generic/tclExecute.c | 4 ++-- generic/tclInt.h | 29 ++++++++++++++--------------- generic/tclRegexp.c | 2 +- generic/tclScan.c | 2 +- generic/tclStringObj.c | 8 ++++++-- generic/tclTest.c | 8 ++++---- 8 files changed, 63 insertions(+), 47 deletions(-) diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 7bad8b5..24e8f39 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3518,7 +3518,8 @@ Tcl_LsearchObjCmd( if (allMatches || inlineReturn) { Tcl_ResetResult(interp); } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-1)); + TclNewIndexObj(itemPtr, -1); + Tcl_SetObjResult(interp, itemPtr); } goto done; } @@ -3648,7 +3649,7 @@ Tcl_LsearchObjCmd( * our first match might not be the first occurrence. * Consider: 0 0 0 1 1 1 2 2 2 * - * To maintain consistancy with standard lsearch semantics, we + * To maintain consistency with standard lsearch semantics, we * must find the leftmost occurrence of the pattern in the * list. Thus we don't just stop searching here. This * variation means that a search always makes log n @@ -3806,10 +3807,12 @@ Tcl_LsearchObjCmd( } else if (returnSubindices) { int j; - itemPtr = TclNewWideIntObjFromSize(i+groupOffset); + TclNewIndexObj(itemPtr, i+groupOffset); for (j=0 ; jpayload.index; for (j = 0; j < groupSize; j++) { if (indices) { - objPtr = TclNewWideIntObjFromSize(idx + j - groupOffset); + TclNewIndexObj(objPtr, idx + j - groupOffset); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } else { @@ -4433,7 +4440,7 @@ Tcl_LsortObjCmd( } } else if (indices) { for (i=0; elementPtr != NULL ; elementPtr = elementPtr->nextPtr) { - objPtr = TclNewWideIntObjFromSize(elementPtr->payload.index); + TclNewIndexObj(objPtr, elementPtr->payload.index); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 738c6e5..43d8a8e 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -389,8 +389,8 @@ Tcl_RegexpObjCmd( end = TCL_INDEX_NONE; } - objs[0] = TclNewWideIntObjFromSize(start); - objs[1] = TclNewWideIntObjFromSize(end); + TclNewIndexObj(objs[0], start); + TclNewIndexObj(objs[1], end); newPtr = Tcl_NewListObj(2, objs); } else { @@ -1909,10 +1909,11 @@ StringIsCmd( */ str_is_done: - if ((result == 0) && (failVarObj != NULL) && - Tcl_ObjSetVar2(interp, failVarObj, NULL, TclNewWideIntObjFromSize(failat), - TCL_LEAVE_ERR_MSG) == NULL) { - return TCL_ERROR; + if ((result == 0) && (failVarObj != NULL)) { + TclNewIndexObj(objPtr, failat); + if (Tcl_ObjSetVar2(interp, failVarObj, NULL, objPtr, TCL_LEAVE_ERR_MSG) == NULL) { + return TCL_ERROR; + } } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; @@ -2506,6 +2507,7 @@ StringStartCmd( int ch; const char *p, *string; size_t numChars, length, cur, index; + Tcl_Obj *obj; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2545,7 +2547,8 @@ StringStartCmd( cur += 1; } } - Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(cur)); + TclNewIndexObj(obj, cur); + Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -2576,6 +2579,7 @@ StringEndCmd( int ch; const char *p, *end, *string; size_t length, numChars, cur, index; + Tcl_Obj *obj; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2606,7 +2610,8 @@ StringEndCmd( } else { cur = numChars + 1; } - Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(cur)); + TclNewIndexObj(obj, cur); + Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -3781,10 +3786,11 @@ TclNRSwitchObjCmd( Tcl_Obj *rangeObjAry[2]; if (info.matches[j].end + 1 > 1) { - rangeObjAry[0] = TclNewWideIntObjFromSize(info.matches[j].start); - rangeObjAry[1] = TclNewWideIntObjFromSize(info.matches[j].end-1); + TclNewIndexObj(rangeObjAry[0], info.matches[j].start); + TclNewIndexObj(rangeObjAry[1], info.matches[j].end-1); } else { - rangeObjAry[0] = rangeObjAry[1] = Tcl_NewWideIntObj(-1); + TclNewIndexObj(rangeObjAry[1], -1); + rangeObjAry[0] = rangeObjAry[1]; } /* diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 40bb351..19bcc22 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5034,7 +5034,7 @@ TEBCresume( case INST_STR_LEN: valuePtr = OBJ_AT_TOS; slength = Tcl_GetCharLength(valuePtr); - objResultPtr = TclNewWideIntObjFromSize(slength); + TclNewIntObj(objResultPtr, slength); TRACE(("\"%.20s\" => %" TCL_Z_MODIFIER "u\n", O2S(valuePtr), slength)); NEXT_INST_F(1, 1, 1); @@ -5178,7 +5178,7 @@ TEBCresume( fromIdx = TclGetInt4AtPtr(pc+1); toIdx = TclGetInt4AtPtr(pc+5); slength = Tcl_GetCharLength(valuePtr); - TRACE(("\"%.20s\" %" TCL_LL_MODIFIER "d %" TCL_LL_MODIFIER "d => ", O2S(valuePtr), TclWideIntFromSize(fromIdx), TclWideIntFromSize(toIdx))); + TRACE(("\"%.20s\" %d %d => ", O2S(valuePtr), (int)(fromIdx), (int)(toIdx))); /* Every range of an empty value is an empty value */ if (slength == 0) { diff --git a/generic/tclInt.h b/generic/tclInt.h index 839c4a5..04a1866 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4810,6 +4810,17 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; TCL_DTRACE_OBJ_CREATE(objPtr); \ } while (0) +#define TclNewIndexObj(objPtr, w) \ + do { \ + TclIncrObjsAllocated(); \ + TclAllocObjStorage(objPtr); \ + (objPtr)->refCount = 0; \ + (objPtr)->bytes = NULL; \ + (objPtr)->internalRep.wideValue = (Tcl_WideInt)((w) + 1) - 1; \ + (objPtr)->typePtr = &tclIntType; \ + TCL_DTRACE_OBJ_CREATE(objPtr); \ + } while (0) + #define TclNewDoubleObj(objPtr, d) \ do { \ TclIncrObjsAllocated(); \ @@ -4835,6 +4846,9 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; #define TclNewIntObj(objPtr, w) \ (objPtr) = Tcl_NewWideIntObj(w) +#define TclNewIndexObj(objPtr, w) \ + (objPtr) = Tcl_NewWideIntObj((Tcl_WideInt)((w) + 1) - 1) + #define TclNewDoubleObj(objPtr, d) \ (objPtr) = Tcl_NewDoubleObj(d) @@ -5022,21 +5036,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; #endif /* TCL_MEM_DEBUG */ /* - * Macros to convert size_t to wide-int (and wide-int object) considering - * platform-related negative value ((size_t)-1), if wide-int and size_t - * have different dimensions (e. g. 32-bit platform). - */ - -#if (!defined(TCL_WIDE_INT_IS_LONG) || (LONG_MAX > UINT_MAX)) && (SIZE_MAX <= UINT_MAX) -# define TclWideIntFromSize(value) (((Tcl_WideInt)(((size_t)(value))+1))-1) -# define TclNewWideIntObjFromSize(value) \ - Tcl_NewWideIntObj(TclWideIntFromSize(value)) -#else -# define TclWideIntFromSize(value) ((Tcl_WideInt)(value)) -# define TclNewWideIntObjFromSize Tcl_NewWideIntObj -#endif - -/* * Support for Clang Static Analyzer */ diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 068b701..f67fcee 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -676,7 +676,7 @@ TclRegAbout( */ TclNewObj(resultObj); - TclNewIntObj(infoObj, regexpPtr->re.re_nsub); + TclNewIndexObj(infoObj, regexpPtr->re.re_nsub); Tcl_ListObjAppendElement(NULL, resultObj, infoObj); /* diff --git a/generic/tclScan.c b/generic/tclScan.c index 6ca76c4..f018b14 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -1089,7 +1089,7 @@ Tcl_ScanObjCmd( if (code == TCL_OK) { if (underflow && (nconversions == 0)) { if (numVars) { - TclNewIntObj(objPtr, -1); + TclNewIndexObj(objPtr, -1); } else { if (objPtr) { Tcl_SetListObj(objPtr, 0, NULL); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 5a16b85..1471ce1 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3456,6 +3456,7 @@ TclStringFirst( size_t lh = 0, ln = Tcl_GetCharLength(needle); size_t value = TCL_INDEX_NONE; Tcl_UniChar *check, *end, *uh, *un; + Tcl_Obj *obj; if (start == TCL_INDEX_NONE) { start = 0; @@ -3531,7 +3532,8 @@ TclStringFirst( } } firstEnd: - return TclNewWideIntObjFromSize(value); + TclNewIndexObj(obj, value); + return obj; } /* @@ -3561,6 +3563,7 @@ TclStringLast( size_t lh = 0, ln = Tcl_GetCharLength(needle); size_t value = TCL_INDEX_NONE; Tcl_UniChar *check, *uh, *un; + Tcl_Obj *obj; if (ln == 0) { /* @@ -3616,7 +3619,8 @@ TclStringLast( check--; } lastEnd: - return TclNewWideIntObjFromSize(value); + TclNewIndexObj(obj, value); + return obj; } /* diff --git a/generic/tclTest.c b/generic/tclTest.c index 3a5f0ef..fcd14b5 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -3905,7 +3905,7 @@ TestregexpObjCmd( varName = Tcl_GetString(objv[2]); TclRegExpRangeUniChar(regExpr, -1, &start, &end); - sprintf(resinfo, "%" TCL_LL_MODIFIER "d %" TCL_LL_MODIFIER "d", TclWideIntFromSize(start), TclWideIntFromSize(end-1)); + sprintf(resinfo, "%d %d", (int)start, (int)(end-1)); value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0); if (value == NULL) { Tcl_AppendResult(interp, "couldn't set variable \"", @@ -3919,7 +3919,7 @@ TestregexpObjCmd( Tcl_RegExpGetInfo(regExpr, &info); varName = Tcl_GetString(objv[2]); - sprintf(resinfo, "%" TCL_LL_MODIFIER "d", TclWideIntFromSize(info.extendStart)); + sprintf(resinfo, "%d", (int)info.extendStart); value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0); if (value == NULL) { Tcl_AppendResult(interp, "couldn't set variable \"", @@ -3967,8 +3967,8 @@ TestregexpObjCmd( end--; } - objs[0] = TclNewWideIntObjFromSize(start); - objs[1] = TclNewWideIntObjFromSize(end); + objs[0] = Tcl_NewIntObj(start); + objs[1] = Tcl_NewIntObj(end); newPtr = Tcl_NewListObj(2, objs); } else { -- cgit v0.12 From 57849b86a1aeba3bfaa8605ee966af4ad76eabbe Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 18 Sep 2020 23:05:34 +0000 Subject: Fix gcc warnings, compiling on 32-bit Linux --- generic/tclCmdMZ.c | 4 ++-- generic/tclListObj.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 43d8a8e..06bd0db 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -195,7 +195,7 @@ Tcl_RegexpObjCmd( if (++i >= objc) { goto endOfForLoop; } - if (TclGetIntForIndexM(interp, objv[i], WIDE_MAX - 1, &temp) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[i], (size_t)WIDE_MAX - 1, &temp) != TCL_OK) { goto optionError; } if (startIndex) { @@ -551,7 +551,7 @@ Tcl_RegsubObjCmd( if (++idx >= (size_t)objc) { goto endOfForLoop; } - if (TclGetIntForIndexM(interp, objv[idx], WIDE_MAX - 1, &temp) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[idx], (size_t)WIDE_MAX - 1, &temp) != TCL_OK) { goto optionError; } if (startIndex) { diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 9918b64..3bba674 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -1246,7 +1246,7 @@ TclLindexList( ListGetIntRep(argPtr, listRepPtr); if ((listRepPtr == NULL) - && TclGetIntForIndexM(NULL , argPtr, WIDE_MAX - 1, &index) == TCL_OK) { + && TclGetIntForIndexM(NULL , argPtr, (size_t)WIDE_MAX - 1, &index) == TCL_OK) { /* * argPtr designates a single index. */ @@ -1352,7 +1352,7 @@ TclLindexFlat( */ while (++i < indexCount) { - if (TclGetIntForIndexM(interp, indexArray[i], WIDE_MAX - 1, &index) + if (TclGetIntForIndexM(interp, indexArray[i], (size_t)WIDE_MAX - 1, &index) != TCL_OK) { Tcl_DecrRefCount(sublistCopy); return NULL; @@ -1416,7 +1416,7 @@ TclLsetList( ListGetIntRep(indexArgPtr, listRepPtr); if (listRepPtr == NULL - && TclGetIntForIndexM(NULL, indexArgPtr, WIDE_MAX - 1, &index) == TCL_OK) { + && TclGetIntForIndexM(NULL, indexArgPtr, (size_t)WIDE_MAX - 1, &index) == TCL_OK) { /* * indexArgPtr designates a single index. */ -- cgit v0.12 From 8da77a52ef534090bd28386cce2d680b8df20ec5 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sat, 19 Sep 2020 14:10:44 +0000 Subject: Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. --- generic/tclProc.c | 45 ++++++++++++++++++++++++++++++++++----------- tests/uplevel.test | 17 +++++++++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/generic/tclProc.c b/generic/tclProc.c index 67c8c41..0e49664 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -905,29 +905,52 @@ TclNRUplevelObjCmd( Interp *iPtr = (Interp *) interp; CmdFrame *invoker = NULL; int word = 0; + int havelevel = 0; int result; CallFrame *savedVarFramePtr, *framePtr; Tcl_Obj *objPtr; if (objc < 2) { + /* to do + * simplify things by interpreting the argument as a command when there + * is only one argument. This requires a TIP since currently a single + * argument is interpreted as a level indicator if possible. + */ uplevelSyntax: Tcl_WrongNumArgs(interp, 1, objv, "?level? command ?arg ...?"); return TCL_ERROR; + } else if (objc == 2) { + int status ,llength; + status = Tcl_ListObjLength(interp, objv[1], &llength); + if (status == TCL_OK && llength > 1) { + /* the first argument can't interpreted as a level. Avoid + * generating a string representation of the script. */ + result = TclGetFrame(interp, "1", &framePtr); + if (result == -1) { + return TCL_ERROR; + } + havelevel = 1; + objc -= 1; + objv += 1; + } } - /* - * Find the level to use for executing the command. - */ + if (!havelevel) { + /* + * Find the level to use for executing the command. + */ - result = TclObjGetFrame(interp, objv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - objc -= result + 1; - if (objc == 0) { - goto uplevelSyntax; + result = TclObjGetFrame(interp, objv[1], &framePtr); + if (result == -1) { + return TCL_ERROR; + } + objc -= result + 1; + if (objc == 0) { + goto uplevelSyntax; + } + objv += result + 1; } - objv += result + 1; + /* * Modify the interpreter state to execute in the given frame. diff --git a/tests/uplevel.test b/tests/uplevel.test index 7ba129a..5dc2806 100644 --- a/tests/uplevel.test +++ b/tests/uplevel.test @@ -304,7 +304,24 @@ test uplevel-7.3 {var access, LVT in upper level} -setup { rename foo {} rename moo {} } -result {3 3 3} + + +test uplevel-8.0 { + string representation isn't generated when there is only one argument +} -body { + set res {} + set script [list lindex 5] + lappend res [apply {script { + uplevel $script + }} $script] + lappend res [string match {value is a list *no string representation*} [ + ::tcl::unsupported::representation $script]] +} -cleanup { + unset script + unset res +} -result {5 1} + # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From ac45c8d85147e6927979c08d95567504148b74cd Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sat, 19 Sep 2020 14:33:24 +0000 Subject: Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. --- generic/tclProc.c | 45 ++++++++++++++++++++++++++++++++++----------- tests/uplevel.test | 17 +++++++++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/generic/tclProc.c b/generic/tclProc.c index a9134f2..0313b29 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -898,29 +898,52 @@ TclNRUplevelObjCmd( Interp *iPtr = (Interp *) interp; CmdFrame *invoker = NULL; int word = 0; + int havelevel = 0; int result; CallFrame *savedVarFramePtr, *framePtr; Tcl_Obj *objPtr; if (objc < 2) { + /* to do + * simplify things by interpreting the argument as a command when there + * is only one argument. This requires a TIP since currently a single + * argument is interpreted as a level indicator if possible. + */ uplevelSyntax: Tcl_WrongNumArgs(interp, 1, objv, "?level? command ?arg ...?"); return TCL_ERROR; + } else if (objc == 2) { + int status ,llength; + status = Tcl_ListObjLength(interp, objv[1], &llength); + if (status == TCL_OK && llength > 1) { + /* the first argument can't interpreted as a level. Avoid + * generating a string representation of the script. */ + result = TclGetFrame(interp, "1", &framePtr); + if (result == -1) { + return TCL_ERROR; + } + havelevel = 1; + objc -= 1; + objv += 1; + } } - /* - * Find the level to use for executing the command. - */ + if (!havelevel) { + /* + * Find the level to use for executing the command. + */ - result = TclObjGetFrame(interp, objv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - objc -= result + 1; - if (objc == 0) { - goto uplevelSyntax; + result = TclObjGetFrame(interp, objv[1], &framePtr); + if (result == -1) { + return TCL_ERROR; + } + objc -= result + 1; + if (objc == 0) { + goto uplevelSyntax; + } + objv += result + 1; } - objv += result + 1; + /* * Modify the interpreter state to execute in the given frame. diff --git a/tests/uplevel.test b/tests/uplevel.test index f44cedc..5f0dd5c 100644 --- a/tests/uplevel.test +++ b/tests/uplevel.test @@ -304,7 +304,24 @@ test uplevel-7.3 {var access, LVT in upper level} -setup { rename foo {} rename moo {} } -result {3 3 3} + + +test uplevel-8.0 { + string representation isn't generated when there is only one argument +} -body { + set res {} + set script [list lindex 5] + lappend res [apply {script { + uplevel $script + }} $script] + lappend res [string match {value is a list *no string representation*} [ + ::tcl::unsupported::representation $script]] +} -cleanup { + unset script + unset res +} -result {5 1} + # cleanup ::tcltest::cleanupTests return -- cgit v0.12 From 7b7d6e211690e9884c7ef6189d5c1e4fe4c3e3ee Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 20 Sep 2020 08:59:39 +0000 Subject: Fix [bf58b04202]: compiler warning in tclEnv.c --- generic/tclEnv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclEnv.c b/generic/tclEnv.c index fc659f1..d0c59f0 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -772,7 +772,7 @@ TclFinalizeEnvironment(void) if (env.cache) { #ifdef PURIFY - int i; + size_t i; for (i = 0; i < env.cacheSize; i++) { Tcl_Free(env.cache[i]); } -- cgit v0.12 From 516be1cd2e22bd4585f3133ce2d2dc990dccff65 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 20 Sep 2020 09:05:38 +0000 Subject: Fix [9ffffcbeee]: compiler warnings in regcomp.c --- generic/regc_lex.c | 2 +- generic/regcomp.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/generic/regc_lex.c b/generic/regc_lex.c index a303ec6..0cd7dd6 100644 --- a/generic/regc_lex.c +++ b/generic/regc_lex.c @@ -894,7 +894,7 @@ lexescape( * Ugly heuristic (first test is "exactly 1 digit?") */ - if (v->now - save == 0 || ((int) c > 0 && (int)c <= v->nsubexp)) { + if (v->now - save == 0 || ((int) c > 0 && (size_t)c <= v->nsubexp)) { NOTE(REG_UBACKREF); RETV(BACKREF, (chr)c); } diff --git a/generic/regcomp.c b/generic/regcomp.c index 1aaaaed..33121a7 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -205,11 +205,11 @@ struct vars { int cflags; /* copy of compile flags */ int lasttype; /* type of previous token */ int nexttype; /* type of next token */ - int nextvalue; /* value (if any) of next token */ + size_t nextvalue; /* value (if any) of next token */ int lexcon; /* lexical context type (see lex.c) */ - int nsubexp; /* subexpression count */ + size_t nsubexp; /* subexpression count */ struct subre **subs; /* subRE pointer vector */ - int nsubs; /* length of vector */ + size_t nsubs; /* length of vector */ struct subre *sub10[10]; /* initial vector, enough for most */ struct nfa *nfa; /* the NFA */ struct colormap *cm; /* character color map */ @@ -222,7 +222,7 @@ struct vars { struct cvec *cv; /* interface cvec */ struct cvec *cv2; /* utility cvec */ struct subre *lacons; /* lookahead-constraint vector */ - int nlacons; /* size of lacons */ + size_t nlacons; /* size of lacons */ size_t spaceused; /* approx. space used for compilation */ }; @@ -287,7 +287,7 @@ compile( { AllocVars(v); struct guts *g; - int i, j; + size_t i, j; FILE *debug = (flags®_PROGRESS) ? stdout : NULL; #define CNOERR() { if (ISERR()) return freev(v, v->err); } @@ -410,7 +410,7 @@ compile( assert(v->nlacons == 0 || v->lacons != NULL); for (i = 1; i < v->nlacons; i++) { if (debug != NULL) { - fprintf(debug, "\n\n\n========= LA%d ==========\n", i); + fprintf(debug, "\n\n\n========= LA%" TCL_Z_MODIFIER "d ==========\n", i); } nfanode(v, &v->lacons[i], debug); } @@ -474,7 +474,7 @@ moresubs( size_t wanted) /* want enough room for this one */ { struct subre **p; - int n; + size_t n; assert(wanted > 0 && wanted >= v->nsubs); n = wanted * 3 / 2 + 1; @@ -794,7 +794,7 @@ parseqatom( struct subre *t; int cap; /* capturing parens? */ int pos; /* positive lookahead? */ - int subno; /* capturing-parens or backref number */ + size_t subno; /* capturing-parens or backref number */ int atomtype; int qprefer; /* quantifier short/long preference */ int f; -- cgit v0.12 From 1a94f57ab672e62630b18fc4daa9a5a9c253bc6b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 20 Sep 2020 10:14:44 +0000 Subject: Backport many (formatting) changes in tools/*. Nothing functional. testest.tcl: Use more uppercase hex. --- library/tcltest/tcltest.tcl | 4 +- tools/checkLibraryDoc.tcl | 31 +++++------ tools/eolFix.tcl | 18 +++--- tools/findBadExternals.tcl | 4 +- tools/genStubs.tcl | 12 ++-- tools/index.tcl | 10 ++-- tools/loadICU.tcl | 12 ++-- tools/makeTestCases.tcl | 132 ++++++++++++++++++++++---------------------- tools/man2help.tcl | 2 +- tools/man2help2.tcl | 40 ++++++++------ tools/man2html.tcl | 8 +-- tools/man2html1.tcl | 18 +++--- tools/man2html2.tcl | 22 ++++---- tools/mkdepend.tcl | 18 +++--- tools/regexpTestLib.tcl | 36 ++++++------ tools/tclZIC.tcl | 10 ++-- tools/tcltk-man2html.tcl | 2 +- tools/uniParse.tcl | 4 +- 18 files changed, 194 insertions(+), 189 deletions(-) diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index e7f4288..4df25e4 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -3242,8 +3242,8 @@ proc tcltest::viewFile {name {directory ""}} { # procedures that are supposed to accept strings with embedded NULL # bytes. # 2. Confirm that a string result has a certain pattern of bytes, for -# instance to confirm that "\xe0\0" in a Tcl script is stored -# internally in UTF-8 as the sequence of bytes "\xc3\xa0\xc0\x80". +# instance to confirm that "\xE0\0" in a Tcl script is stored +# internally in UTF-8 as the sequence of bytes "\xC3\xA0\xC0\x80". # # Generally, it's a bad idea to examine the bytes in a Tcl string or to # construct improperly formed strings in this manner, because it involves diff --git a/tools/checkLibraryDoc.tcl b/tools/checkLibraryDoc.tcl index cd08c2a..224106e 100644 --- a/tools/checkLibraryDoc.tcl +++ b/tools/checkLibraryDoc.tcl @@ -1,9 +1,9 @@ # checkLibraryDoc.tcl -- # -# This script attempts to determine what APIs exist in the source base that -# have not been documented. By grepping through all of the doc/*.3 man +# This script attempts to determine what APIs exist in the source base that +# have not been documented. By grepping through all of the doc/*.3 man # pages, looking for "Pkg_*" (e.g., Tcl_ or Tk_), and comparing this list -# against the list of Pkg_ APIs found in the source (e.g., tcl8.2/*/*.[ch]) +# against the list of Pkg_ APIs found in the source (e.g., tcl8.5/*/*.[ch]) # we create six lists: # 1) APIs in Source not in Docs. # 2) APIs in Docs not in Source. @@ -11,10 +11,10 @@ # 4) Misc APIs and structs that we are not documenting. # 5) Command APIs (e.g., Tcl_ArrayObjCmd.) # 6) Proc pointers (e.g., Tcl_CloseProc.) -# +# # Note: Each list is "a best guess" approximation. If developers write # non-standard code, this script will produce erroneous results. Each -# list should be carefully checked for accuracy. +# list should be carefully checked for accuracy. # # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. @@ -86,7 +86,7 @@ set StructList { Tk_Window \ } -# Misc junk that appears in the comments of the source. This just +# Misc junk that appears in the comments of the source. This just # allows us to filter comments that "fool" the script. set CommentList { @@ -99,14 +99,13 @@ set CommentList { # Main entry point to this script. proc main {} { - global argv0 - global argv + global argv0 + global argv set len [llength $argv] if {($len != 2) && ($len != 3)} { puts "usage: $argv0 pkgName pkgDir \[outFile\]" puts " pkgName == Tcl,Tk" - puts " pkgDir == /home/surles/cvs/tcl8.2" exit 1 } @@ -121,12 +120,12 @@ proc main {} { foreach {c d} [compare [grepCode $dir $pkg] [grepDocs $dir $pkg]] {} filter $c $d $dir $pkg $file - if {$file != "stdout"} { + if {$file ne "stdout"} { close $file } return } - + # Intersect the two list and write out the sets of APIs in one # list that is not in the other. @@ -145,7 +144,7 @@ proc filter {code docs dir pkg {outFile stdout}} { # This list should just be verified for accuracy. set cmds {} - + # A list of proc pointer structs. These are not documented. # This list should just be verified for accuracy. @@ -162,7 +161,7 @@ proc filter {code docs dir pkg {outFile stdout}} { set misc [grepMisc $dir $pkg] set pat1 ".*(${pkg}_\[A-z0-9]+).*$" - + # A list of APIs in the source, not in the docs. # This list should just be verified for accuracy. @@ -196,7 +195,7 @@ proc filter {code docs dir pkg {outFile stdout}} { # Print the list of APIs if the list is not null. proc dump {list title file} { - if {$list != {}} { + if {$list ne ""} { puts $file "" puts $file $title puts $file "---------------------------------------------------------" @@ -240,7 +239,7 @@ proc grepDocs {dir pkg} { # (e.g., Tcl_Export). Return a list of APIs. proc grepDecl {dir pkg} { - set file [file join $dir generic "[string tolower $pkg]IntDecls.h"] + set file [file join $dir generic "[string tolower $pkg]IntDecls.h"] set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_.*" $file] set pat1 ".*(${pkg}_\[A-z0-9]+).*$" @@ -258,7 +257,7 @@ proc grepDecl {dir pkg} { proc grepMisc {dir pkg} { global CommentList global StructList - + set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_Db.*" "${dir}/\*/\*\.\[ch\]"] set pat1 ".*(${pkg}_\[A-z0-9]+).*$" diff --git a/tools/eolFix.tcl b/tools/eolFix.tcl index ed3ec7c..3f35ed4 100644 --- a/tools/eolFix.tcl +++ b/tools/eolFix.tcl @@ -13,16 +13,18 @@ namespace eval ::EOL { variable outMode crlf } -proc EOL::fix {filename {newfilename ""}} { +proc EOL::fix {filename {newfilename {}}} { variable outMode - if {![file exists $filename]} { return } + if {![file exists $filename]} { + return + } puts "EOL Fixing: $filename" file rename ${filename} ${filename}.o set fhnd [open ${filename}.o r] - if {$newfilename != ""} { + if {$newfilename ne ""} { set newfhnd [open ${newfilename} w] } else { set newfhnd [open ${filename} w] @@ -63,12 +65,12 @@ proc EOL::fixall {args} { } if {$tcl_interactive == 0 && $argc > 0} { - if {[string index [lindex $argv 0] 0] == "-"} { + if {[string index [lindex $argv 0] 0] eq "-"} { switch -- [lindex $argv 0] { - -cr { set ::EOL::outMode cr } - -crlf { set ::EOL::outMode crlf } - -lf { set ::EOL::outMode lf } - default { puts stderr "improper mode switch" ; exit 1 } + -cr {set ::EOL::outMode cr} + -crlf {set ::EOL::outMode crlf} + -lf {set ::EOL::outMode lf} + default {puts stderr "improper mode switch"; exit 1} } set argv [lrange $argv 1 end] } diff --git a/tools/findBadExternals.tcl b/tools/findBadExternals.tcl index 7592f17..2228357 100755 --- a/tools/findBadExternals.tcl +++ b/tools/findBadExternals.tcl @@ -1,5 +1,5 @@ # findBadExternals.tcl -- -# +# # This script scans the Tcl load library for exported symbols # that do not begin with 'Tcl' or 'tcl'. It reports them on the # standard output. It is used to make sure that the library does @@ -29,7 +29,7 @@ proc main {argc argv} { macosx { set status [catch { exec nm --extern-only --defined-only [lindex $argv 0] - } result] + } result] } windows { set status [catch { diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index 2eb6638..67b5112 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -382,7 +382,7 @@ proc genStubs::parseDecl {decl} { return } set rtype [string trim $rtype] - if {$args == ""} { + if {$args eq ""} { return [list $rtype $fname {}] } foreach arg [split $args ,] { @@ -430,14 +430,14 @@ proc genStubs::parseDecl {decl} { proc genStubs::parseArg {arg} { if {![regexp {^(.+[ ][*]*)([^][ *]+)(\[\])?$} $arg all type name array]} { - if {$arg == "void"} { + if {$arg eq "void"} { return $arg } else { return } } set result [list [string trim $type] $name] - if {$array != ""} { + if {$array ne ""} { lappend result $array } return $result @@ -460,7 +460,7 @@ proc genStubs::makeDecl {name decl index} { lassign $decl rtype fname args append text "/* $index */\n" - if {$rtype != "void"} { + if {$rtype ne "void"} { regsub -all void $rtype VOID rtype } set line "$scspec $rtype" @@ -640,7 +640,7 @@ proc genStubs::makeSlot {name decl index} { # Returns the formatted declaration string. proc genStubs::makeInit {name decl index} { - if {[lindex $decl 2] == ""} { + if {[lindex $decl 2] eq ""} { append text " &" [lindex $decl 1] ", /* " $index " */\n" } else { append text " " [lindex $decl 1] ", /* " $index " */\n" @@ -982,7 +982,7 @@ proc genStubs::emitHeader {name} { set capName [string toupper [string index $name 0]] append capName [string range $name 1 end] - if {$epoch != ""} { + if {$epoch ne ""} { set CAPName [string toupper $name] append text "\n" append text "#define ${CAPName}_STUBS_EPOCH $epoch\n" diff --git a/tools/index.tcl b/tools/index.tcl index 7b11e3f..71329c2 100644 --- a/tools/index.tcl +++ b/tools/index.tcl @@ -12,7 +12,7 @@ # Global variables used by these scripts: # # state - state variable that controls action of text proc. -# +# # topics - array indexed by (package,section,topic) with value # of topic ID. # @@ -135,7 +135,7 @@ proc macro {name args} { switch $args { NAME { - if {$state == "INIT" } { + if {$state eq "INIT" } { set state NAME } } @@ -144,7 +144,7 @@ proc macro {name args} { KEYWORDS {set state KEY} default {set state OFF} } - + } TH { global state curID curPkg curSect topics keywords @@ -176,7 +176,7 @@ proc macro {name args} { proc dash {} { global state - if {$state == "NAME"} { + if {$state eq "NAME"} { set state DASH } } @@ -185,7 +185,7 @@ proc dash {} { # initGlobals, tab, font, char, macro2 -- # -# These procedures do nothing during the first pass. +# These procedures do nothing during the first pass. # # Arguments: # None. diff --git a/tools/loadICU.tcl b/tools/loadICU.tcl index 1cdd12f..506b6e4 100755 --- a/tools/loadICU.tcl +++ b/tools/loadICU.tcl @@ -432,7 +432,7 @@ proc handleLocaleFile { localeName fileName msgFileName } { if { ![info exists format($localeName,TIME_FORMAT)] } { for { set i 3 } { $i >= 0 } { incr i -1 } { - if { [regexp H [lindex $items(DateTimePatterns) $i]] + if { [regexp H [lindex $items(DateTimePatterns) $i]] && [regexp s [lindex $items(DateTimePatterns) $i]] } { break } @@ -464,7 +464,7 @@ proc handleLocaleFile { localeName fileName msgFileName } { if { ![info exists format($localeName,TIME_FORMAT_12)] } { for { set i 3 } { $i >= 0 } { incr i -1 } { - if { [regexp h [lindex $items(DateTimePatterns) $i]] + if { [regexp h [lindex $items(DateTimePatterns) $i]] && [regexp s [lindex $items(DateTimePatterns) $i]] } { break } @@ -489,7 +489,7 @@ proc handleLocaleFile { localeName fileName msgFileName } { # Date and time... Prefer 24-hour format to 12-hour format. - if { ![info exists format($localeName,DATE_TIME_FORMAT)] + if { ![info exists format($localeName,DATE_TIME_FORMAT)] && [info exists format($localeName,DATE_FORMAT)] && [info exists format($localeName,TIME_FORMAT)]} { set format($localeName,DATE_TIME_FORMAT) \ @@ -497,7 +497,7 @@ proc handleLocaleFile { localeName fileName msgFileName } { append format($localeName,DATE_TIME_FORMAT) \ " " $format($localeName,TIME_FORMAT) " %z" } - if { ![info exists format($localeName,DATE_TIME_FORMAT)] + if { ![info exists format($localeName,DATE_TIME_FORMAT)] && [info exists format($localeName,DATE_FORMAT)] && [info exists format($localeName,TIME_FORMAT_12)]} { set format($localeName,DATE_TIME_FORMAT) \ @@ -517,7 +517,7 @@ proc handleLocaleFile { localeName fileName msgFileName } { # Write the string sets to the file. - foreach key { + foreach key { LOCALE_NUMERALS LOCALE_DATE_FORMAT LOCALE_TIME_FORMAT LOCALE_DATE_TIME_FORMAT LOCALE_ERAS LOCALE_YEAR_FORMAT } { @@ -588,7 +588,7 @@ proc backslashify { string } { set retval {} foreach char [split $string {}] { scan $char %c ccode - if { $ccode >= 0x0020 && $ccode < 0x007F && $char ne "\"" + if { $ccode >= 0x20 && $ccode < 0x7F && $char ne "\"" && $char ne "\{" && $char ne "\}" && $char ne "\[" && $char ne "\]" && $char ne "\\" && $char ne "\$" } { append retval $char diff --git a/tools/makeTestCases.tcl b/tools/makeTestCases.tcl index c230d57..70213e0 100755 --- a/tools/makeTestCases.tcl +++ b/tools/makeTestCases.tcl @@ -40,7 +40,7 @@ namespace eval ::tcl::clock { l li lii liii liv lv lvi lvii lviii lix lx lxi lxii lxiii lxiv lxv lxvi lxvii lxviii lxix lxx lxxi lxxii lxxiii lxxiv lxxv lxxvi lxxvii lxxviii lxxix - lxxx lxxxi lxxxii lxxxiii lxxxiv lxxxv lxxxvi lxxxvii lxxxviii + lxxx lxxxi lxxxii lxxxiii lxxxiv lxxxv lxxxvi lxxxvii lxxxviii lxxxix xc xci xcii xciii xciv xcv xcvi xcvii xcviii xcix c @@ -62,7 +62,7 @@ namespace eval ::tcl::clock { # # Parameters: # startOfYearArray - Name of an array in caller's scope that will -# be initialized as +# be initialized as # Results: # None # @@ -106,7 +106,7 @@ proc listYears { startOfYearArray } { set s $s2 incr y } - + # List years before 1970 set y 1970 @@ -138,7 +138,7 @@ proc listYears { startOfYearArray } { #---------------------------------------------------------------------- # -# processFile - +# processFile - # # Processes the 'clock.test' file, updating the test cases in it. # @@ -153,7 +153,7 @@ proc listYears { startOfYearArray } { proc processFile {d} { # Open two files - + set f1 [open [file join $d tests/clock.test] r] set f2 [open [file join $d tests/clock.new] w] @@ -164,7 +164,7 @@ proc processFile {d} { switch -exact -- $state { {} { puts $f2 $line - if { [regexp "^\# BEGIN (.*)" $line -> cases] + if { [regexp "^\# BEGIN (.*)" $line -> cases] && [string compare {} [info commands $cases]] } { set state inCaseSet $cases $f2 @@ -213,7 +213,7 @@ proc testcases2 { f2 } { listYears startOfYear # Define the roman numerals - + set roman { ? i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix @@ -235,20 +235,20 @@ proc testcases2 { f2 } { } # Names of the months - + set short {{} Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec} set long { {} January February March April May June July August September October November December } - + # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test formatting of Gregorian year, month, day, all formats" puts $f2 "\# Formats tested: %b %B %c %Ec %C %EC %d %Od %e %Oe %h %j %J %m %Om %N %x %Ex %y %Oy %Y %EY" puts $f2 "" - + # Generate the test cases for the first and last day of every month # from 1896 to 2045 @@ -262,7 +262,7 @@ proc testcases2 { f2 } { if { $m == 2 && ( $y%4 == 0 && $y%100 != 0 || $y%400 == 0 ) } { incr hath } - + set b [lindex $short $m] set B [lindex $long $m] set C [format %02d [expr { $y / 100 }]] @@ -271,9 +271,9 @@ proc testcases2 { f2 } { set mm [format %02d $m] set N [format %2d $m] set yy [format %02d [expr { $y % 100 }]] - + set J [expr { ( $s / 86400 ) + 2440588 }] - + set dt $y-$mm-01 set result "" append result $b " " $B " " \ @@ -296,17 +296,17 @@ proc testcases2 { f2 } { puts $f2 "\t-format {%b %B %c %Ec %C %EC %d %Od %e %Oe %h %j %J %m %Om %N %x %Ex %y %Oy %Y} \\" puts $f2 "\t-gmt true -locale en_US_roman" puts $f2 "} {$result}" - + set hm1 [expr { $hath - 1 }] incr s [expr { 86400 * ( $hath - 1 ) }] incr yd $hm1 - + set dd [format %02d $hath] set ee [format %2d $hath] set j [format %03d $yd] - + set J [expr { ( $s / 86400 ) + 2440588 }] - + set dt $y-$mm-$dd set result "" append result $b " " $B " " \ @@ -332,7 +332,7 @@ proc testcases2 { f2 } { puts $f2 "\t-format {%b %B %c %Ec %C %EC %d %Od %e %Oe %h %j %J %m %Om %N %x %Ex %y %Oy %Y} \\" puts $f2 "\t-gmt true -locale en_US_roman" puts $f2 "} {$result}" - + incr s 86400 incr yd } @@ -451,7 +451,7 @@ proc testcases3 { f2 } { testISO $f2 $ym1 52 1 [expr { $secs - 5*86400 }] testISO $f2 $ym1 52 6 $secs testISO $f2 $ym1 52 7 [expr { $secs + 86400 }] - } + } testISO $f2 $y 1 1 [expr { $secs + 2*86400 }] testISO $f2 $y 1 6 [expr { $secs + 7*86400 }] testISO $f2 $y 1 7 [expr { $secs + 8*86400 }] @@ -466,10 +466,10 @@ proc testcases3 { f2 } { proc testISO { f2 G V u secs } { upvar 1 case case - + set longdays {Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday} set shortdays {Sun Mon Tue Wed Thu Fri Sat Sun} - + puts $f2 "test clock-3.[incr case] {ISO week-based calendar [format %04d-W%02d-%d $G $V $u]} {" puts $f2 " clock format $secs -format {%a %A %g %G %u %U %V %w %W} -gmt true; \# $G-W[format %02d $V]-$u" puts $f2 "} {[lindex $shortdays $u] [lindex $longdays $u]\ @@ -478,7 +478,7 @@ proc testISO { f2 G V u secs } { [clock format $secs -format %U -gmt true]\ [format %02d $V] [expr { $u % 7 }]\ [clock format $secs -format %W -gmt true]}" - + } #---------------------------------------------------------------------- @@ -504,15 +504,15 @@ proc testcases4 { f2 } { puts $f2 "\# Test formatting of time of day" puts $f2 "\# Format groups tested: %H %OH %I %OI %k %Ok %l %Ol %M %OM %p %P %r %R %S %OS %T %X %EX %+" puts $f2 {} - + set i 0 set fmt "%H %OH %I %OI %k %Ok %l %Ol %M %OM %p %P %r %R %S %OS %T %X %EX %+" - foreach { h romanH I romanI am } { - 0 ? 12 xii AM - 1 i 1 i AM - 11 xi 11 xi AM - 12 xii 12 xii PM - 13 xiii 1 i PM + foreach { h romanH I romanI am } { + 0 ? 12 xii AM + 1 i 1 i AM + 11 xi 11 xi AM + 12 xii 12 xii PM + 13 xiii 1 i PM 23 xxiii 11 xi PM } { set hh [format %02d $h] @@ -547,7 +547,7 @@ proc testcases4 { f2 } { puts "testcases4: $i test cases." } - + #---------------------------------------------------------------------- # # testcases5 -- @@ -572,9 +572,9 @@ proc testcases5 { f2 } { puts $f2 {} puts $f2 "\# Test formatting of Daylight Saving Time" puts $f2 {} - + set fmt {%H:%M:%S %z %Z} - + set i 0 puts $f2 "test clock-5.[incr i] {does Detroit exist} {" puts $f2 " clock format 0 -format {} -timezone :America/Detroit" @@ -587,7 +587,7 @@ proc testcases5 { f2 } { puts $f2 " concat {ok}" puts $f2 " }" puts $f2 "} ok" - + foreach row $TZData(:America/Detroit) { foreach { t offset isdst tzname } $row break if { $t > -4000000000000 } { @@ -648,12 +648,12 @@ proc testcases5 { f2 } { proc testcases8 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of ccyymmdd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 1971 2000 2001} { foreach month {01 12} { foreach day {02 31} { @@ -670,7 +670,7 @@ proc testcases8 { f2 } { puts $f2 "} $scanned" } } - } + } foreach fmt {%x %D} { set string [clock format $scanned \ -format $fmt \ @@ -708,11 +708,11 @@ proc testcases8 { f2 } { proc testcases11 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test precedence among yyyymmdd and yyyyddd" puts $f2 "" - + array set v { Y 1970 m 01 @@ -771,12 +771,12 @@ proc testcases11 { f2 } { proc testcases12 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of ccyyWwwd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 1971 2000 2001} { foreach month {01 12} { foreach day {02 31} { @@ -817,12 +817,12 @@ proc testcases12 { f2 } { proc testcases14 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of yymmdd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1938 1970 2000 2037} { foreach month {01 12} { foreach day {02 31} { @@ -839,7 +839,7 @@ proc testcases14 { f2 } { puts $f2 "} $scanned" } } - } + } } } } @@ -868,12 +868,12 @@ proc testcases14 { f2 } { proc testcases17 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of yyWwwd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 1971 2000 2001} { foreach month {01 12} { foreach day {02 31} { @@ -914,12 +914,12 @@ proc testcases17 { f2 } { proc testcases19 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of mmdd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1938 1970 2000 2037} { set base [clock scan ${year}0101 -gmt true] foreach month {01 12} { @@ -935,7 +935,7 @@ proc testcases19 { f2 } { puts $f2 " [list clock scan $string -format [list $mm $dd] -locale en_US_roman -base $base -gmt 1]" puts $f2 "} $scanned" } - } + } } } } @@ -964,12 +964,12 @@ proc testcases19 { f2 } { proc testcases22 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of Wwwd" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 1971 2000 2001} { set base [clock scan ${year}0104 -gmt true] foreach month {03 10} { @@ -1011,12 +1011,12 @@ proc testcases22 { f2 } { proc testcases24 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of naked day-of-month" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 2000} { foreach month {01 12} { set base [clock scan ${year}${month}01 -gmt true] @@ -1030,7 +1030,7 @@ proc testcases24 { f2 } { puts $f2 "test clock-24.[incr n] {parse naked day of month} {" puts $f2 " [list clock scan $string -format $dd -locale en_US_roman -base $base -gmt 1]" puts $f2 "} $scanned" - } + } } } } @@ -1059,12 +1059,12 @@ proc testcases24 { f2 } { proc testcases26 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of naked day of week" puts $f2 "" - - set n 0 + + set n 0 foreach year {1970 2001} { foreach week {01 52} { set base [clock scan ${year}W${week}4 \ @@ -1108,7 +1108,7 @@ proc testcases26 { f2 } { proc testcases29 { f2 } { # Put out a header describing the tests - + puts $f2 "" puts $f2 "\# Test parsing of time of day" puts $f2 "" @@ -1172,7 +1172,7 @@ proc testcases29 { f2 } { } } } - + } puts "testcases29: $n test cases" } diff --git a/tools/man2help.tcl b/tools/man2help.tcl index 018fa84..ca29226 100644 --- a/tools/man2help.tcl +++ b/tools/man2help.tcl @@ -36,7 +36,7 @@ proc generateContents {basename version files} { set lastTopic {} foreach topic [getTopics $package $section] { if {[string compare $lastTopic $topic]} { - set id $topics($package,$section,$topic) + set id $topics($package,$section,$topic) puts $fd "2 $topic=$id" set lastTopic $topic } diff --git a/tools/man2help2.tcl b/tools/man2help2.tcl index 75f4249..91c81be 100644 --- a/tools/man2help2.tcl +++ b/tools/man2help2.tcl @@ -12,7 +12,7 @@ # Global variables used by these scripts: # # state - state variable that controls action of text proc. -# +# # topics - array indexed by (package,section,topic) with value # of topic ID. # @@ -157,7 +157,7 @@ proc text {string} { "\t" {\tab } \ '' "\\rdblquote " \ `` "\\ldblquote " \ - "\u00b7" "\\bullet " \ + "\xB7" "\\bullet " \ ] $string] # Check if this is the beginning of an international character string. @@ -176,12 +176,12 @@ proc text {string} { } switch $state(textState) { - REF { + REF { if {$state(inTP) == 0} { set string [insertRef $string] } } - SEE { + SEE { global topics curPkg curSect foreach i [split $string] { if {![regexp -nocase {^[a-z_0-9]+} [string trim $i] i ]} { @@ -231,7 +231,7 @@ proc insertRef {string} { } } - if {($ref != {}) && ($ref != $curID)} { + if {($ref != "") && ($ref != $curID)} { set string [link $string $ref] } return $string @@ -273,7 +273,7 @@ proc macro {name args} { # next page and previous page } br { - lineBreak + lineBreak } BS {} BE {} @@ -388,12 +388,12 @@ proc macro {name args} { set state(noFill) 1 } so { - if {$args != "man.macros"} { + if {$args ne "man.macros"} { puts stderr "Unknown macro: .$name [join $args " "]" } } sp { ;# needs work - if {$args == ""} { + if {$args eq ""} { set count 1 } else { set count [lindex $args 0] @@ -472,14 +472,14 @@ proc font {type} { P - R { endFont - if {$state(textState) == "REF"} { + if {$state(textState) eq "REF"} { set state(textState) INSERT } } C - B { beginFont Code - if {$state(textState) == "INSERT"} { + if {$state(textState) eq "INSERT"} { set state(textState) REF } } @@ -507,7 +507,7 @@ proc font {type} { proc formattedText {text} { global chars - while {$text != ""} { + while {$text ne ""} { set index [string first \\ $text] if {$index < 0} { text $text @@ -709,11 +709,15 @@ proc char {name} { textSetup puts -nonewline $file "\\'a9 " } + {\(mi} { + textSetup + puts -nonewline $file "-" + } {\(mu} { textSetup puts -nonewline $file "\\'d7 " } - {\(em} { + {\(em} - {\(en} { textSetup puts -nonewline $file "-" } @@ -760,7 +764,7 @@ proc SHmacro {argList {style section}} { } # control what the text proc does with text - + switch $args { NAME {set state(textState) NAME} DESCRIPTION {set state(textState) INSERT} @@ -820,10 +824,10 @@ proc IPmacro {argList} { set indent 5 } if {$text == {\(bu}} { - set text "\u00b7" + set text "\xB7" } - set tab [expr $indent * 0.1]i + set tab [expr {$indent * 0.1}]i newPara $tab -$tab set state(sb) 80 setTabs $tab @@ -885,7 +889,7 @@ proc THmacro {argList} { set curVer [lindex $argList 2] ;# 7.4 set curPkg [lindex $argList 3] ;# Tcl set curSect [lindex $argList 4] ;# {Tcl Library Procedures} - + regsub -all {\\ } $curSect { } curSect ;# Clean up for [incr\ Tcl] puts $file "#{\\footnote $curID}" ;# Context string @@ -950,7 +954,7 @@ proc newPara {leftIndent {firstIndent 0i}} { if $state(paragraph) { puts -nonewline $file "\\line\n" } - if {$leftIndent != ""} { + if {$leftIndent ne ""} { set state(leftIndent) [expr {$state(leftMargin) \ + ($state(offset) * $state(nestingLevel)) \ + [getTwips $leftIndent]}] @@ -1020,7 +1024,7 @@ proc incrNestingLevel {} { proc decrNestingLevel {} { global state - + if {$state(nestingLevel) == 0} { puts stderr "Nesting level decremented below 0" } else { diff --git a/tools/man2html.tcl b/tools/man2html.tcl index 444462b..2d03ab6 100644 --- a/tools/man2html.tcl +++ b/tools/man2html.tcl @@ -25,8 +25,8 @@ proc sarray {file args} { if {![array exists array]} { puts "sarray: \"$a\" isn't an array" break - } - + } + foreach name [lsort [array names array]] { regsub -all " " $name "\\ " name1 puts $file "set ${a}($name1) \{$array($name)\}" @@ -139,12 +139,12 @@ proc main {argv} { foreach package $packages { file mkdir $html_dir/$package - + # build hyperlink database arrays: NAME_file and KEY_file # puts "\nScanning man pages in $tcl_dir/$package/doc..." uplevel \#0 [list source $homeDir/man2html1.tcl] - + doDir $tcl_dir/$package/doc # clean up the NAME_file and KEY_file database arrays diff --git a/tools/man2html1.tcl b/tools/man2html1.tcl index a668e1b..64982ff 100644 --- a/tools/man2html1.tcl +++ b/tools/man2html1.tcl @@ -8,7 +8,7 @@ # Global variables used by these scripts: # # state - state variable that controls action of text proc. -# +# # curFile - tail of current man page. # # file - file pointer; for both xref.tcl and contents.html @@ -21,7 +21,7 @@ # # lib - contains package name. Used to label section in contents.html # -# inDT - in dictionary term. +# inDT - in dictionary term. # text -- @@ -30,7 +30,7 @@ # and KEY_file. # # DT: might do this: if first word of $dt matches $name and [llength $name==1] -# and [llength $dt > 1], then add to NAME_file. +# and [llength $dt > 1], then add to NAME_file. # # Arguments: # string - Text to index. @@ -84,7 +84,7 @@ proc macro {name args} { KEYWORDS {set state KEY} default {set state OFF} } - + } TP { global inDT @@ -136,7 +136,7 @@ proc newline {} { # initGlobals, tab, font, char, macro2 -- # -# These procedures do nothing during the first pass. +# These procedures do nothing during the first pass. # # Arguments: # None. @@ -212,9 +212,9 @@ proc doListing {file pattern} { proc doContents {file packageName} { global footer - + set file [open $file w] - + puts $file "$packageName Manual" puts $file "

$packageName

" doListing $file "*.1" @@ -235,8 +235,8 @@ proc doContents {file packageName} { # # This is the toplevel procedure that searches a man page # for hypertext links. It builds a data base consisting of -# two arrays: NAME_file and KEY file. It runs the man2tcl -# program to turn the man page into a script, then it evals +# two arrays: NAME_file and KEY file. It runs the man2tcl +# program to turn the man page into a script, then it evals # that script. # # Arguments: diff --git a/tools/man2html2.tcl b/tools/man2html2.tcl index e4ccedf..8483204 100644 --- a/tools/man2html2.tcl +++ b/tools/man2html2.tcl @@ -114,9 +114,9 @@ proc text string { set pos [string first "\t" $string] if {$pos >= 0} { - text [string range $string 0 [expr $pos-1]] + text [string range $string 0 [expr {$pos-1}]] tab - text [string range $string [expr $pos+1] end] + text [string range $string [expr {$pos+1}] end] return } if {$inTable} { @@ -471,27 +471,27 @@ proc formattedText text { text $text return } - text [string range $text 0 [expr $index-1]] - set c [string index $text [expr $index+1]] + text [string range $text 0 [expr {$index-1}]] + set c [string index $text [expr {$index+1}]] switch -- $c { f { - font [string index $text [expr $index+2]] - set text [string range $text [expr $index+3] end] + font [string index $text [expr {$index+2}]] + set text [string range $text [expr {$index+3}] end] } e { text \\ - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } - { dash - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } | { - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } default { puts stderr "Unknown sequence: \\$c" - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } } } @@ -527,7 +527,7 @@ proc tab {} { global inPRE charCnt tabString file # ? charCnt if {$inPRE == 1} { - set pos [expr $charCnt % [string length $tabString] ] + set pos [expr {$charCnt % [string length $tabString]}] set spaces [string first "1" [string range $tabString $pos end] ] text [format "%*s" [incr spaces] " "] } else { diff --git a/tools/mkdepend.tcl b/tools/mkdepend.tcl index de5fdba..b1ad076 100644 --- a/tools/mkdepend.tcl +++ b/tools/mkdepend.tcl @@ -10,20 +10,20 @@ # above copyright notice and the following two paragraphs appear in # all copies of this software. # -# IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -# SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF -# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED +# IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +# SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF +# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # -# THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" +# THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" # BASIS, AND THE AUTHOR HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, # UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #============================================================================== # # Modified heavily by David Gravereaux about 9/17/2006. -# Original can be found @ +# Original can be found @ # http://web.archive.org/web/20070616205924/http://www.doc.ic.ac.uk/~np2/software/mkdepend.html #============================================================================== @@ -88,7 +88,7 @@ proc readDepends {chan} { set line "" array set depends {} - while {[gets $chan line] != -1} { + while {[gets $chan line] >= 0} { if {[regexp {^#line [0-9]+ \"(.*)\"$} $line dummy fname] != 0} { set fname [file normalize $fname] if {![info exists target]} { @@ -98,7 +98,7 @@ proc readDepends {chan} { } else { # don't include ourselves as a dependency of ourself. if {![string compare $fname $target]} {continue} - # store in an array so multiple occurances are not counted. + # store in an array so multiple occurrences are not counted. set depends($target|$fname) "" } } diff --git a/tools/regexpTestLib.tcl b/tools/regexpTestLib.tcl index 86f2a3e..8379159 100644 --- a/tools/regexpTestLib.tcl +++ b/tools/regexpTestLib.tcl @@ -17,13 +17,13 @@ proc readInputFile {} { set len [string length $line] - if {($len > 0) && ([string index $line [expr $len - 1]] == "\\")} { + if {($len > 0) && ([string index $line [expr {$len - 1}]] == "\\")} { if {[info exists lineArray(c$i)] == 0} { set lineArray(c$i) 1 } else { incr lineArray(c$i) } - set line [string range $line 0 [expr $len - 2]] + set line [string range $line 0 [expr {$len - 2}]] append lineArray($i) $line continue } @@ -43,7 +43,7 @@ proc readInputFile {} { # # strings with embedded @'s are truncated # unpreceeded @'s are replaced by {} -# +# proc removeAts {ls} { set len [llength $ls] set newLs {} @@ -94,7 +94,7 @@ proc writeOutputFile {numLines fcn} { global outFileName global lineArray - # open output file and write file header info to it. + # open output file and write file header info to it. set fileId [open $outFileName w] @@ -133,7 +133,7 @@ proc writeOutputFile {numLines fcn} { puts $fileId $currentLine incr srcLineNum $lineArray(c$lineNum) incr lineNum - continue + continue } set len [llength $currentLine] @@ -144,7 +144,7 @@ proc writeOutputFile {numLines fcn} { puts $fileId "\n" incr srcLineNum $lineArray(c$lineNum) incr lineNum - continue + continue } if {($len < 3)} { puts "warning: test is too short --\n\t$currentLine" @@ -204,26 +204,26 @@ proc convertTestLine {currentLine len lineNum srcLineNum} { # find the test result - set numVars [expr $len - 3] + set numVars [expr {$len - 3}] set vars {} set vals {} set result 0 set v 0 - + if {[regsub {\*} "$flags" "" newFlags] == 1} { # an error is expected - + if {[string compare $str "EMPTY"] == 0} { # empty regexp is not an error # skip this test - + return "\# skipping the empty-re test from line $srcLineNum\n" } set flags $newFlags set result "\{1 \{[convertErrCode $str]\}\}" } elseif {$numVars > 0} { # at least 1 match is made - + if {[regexp {s} $flags] == 1} { set result "\{0 1\}" } else { @@ -240,7 +240,7 @@ proc convertTestLine {currentLine len lineNum srcLineNum} { } } else { # no match is made - + set result "\{0 0\}" } @@ -248,16 +248,16 @@ proc convertTestLine {currentLine len lineNum srcLineNum} { set cmd [prepareCmd $flags $re $str $vars $noBraces] if {$cmd == -1} { - return "\# skipping test with metasyntax from line $srcLineNum\n" + return "\# skipping test with metasyntax from line $srcLineNum\n" } set test "test regexp-1.$srcLineNum \{converted from line $srcLineNum\} \{\n" append test "\tcatch {unset var}\n" - append test "\tlist \[catch \{ \n" - append test "\t\tset match \[$cmd\] \n" - append test "\t\tlist \$match $vals \n" - append test "\t\} msg\] \$msg \n" - append test "\} $result \n" + append test "\tlist \[catch \{\n" + append test "\t\tset match \[$cmd\]\n" + append test "\t\tlist \$match $vals\n" + append test "\t\} msg\] \$msg\n" + append test "\} $result\n" return $test } diff --git a/tools/tclZIC.tcl b/tools/tclZIC.tcl index 1fa34be..85c9ba9 100755 --- a/tools/tclZIC.tcl +++ b/tools/tclZIC.tcl @@ -356,7 +356,7 @@ proc parseON {on} { # third possibility - lastWeekday - field 5 last([[:alpha:]]+) )$ - } $on -> dom1 wday2 dir2 num2 wday3]} then { + } $on -> dom1 wday2 dir2 num2 wday3]} { error "can't parse ON field \"$on\"" } if {$dom1 ne ""} { @@ -507,7 +507,7 @@ proc parseTOD {tod} { (?: ([wsugz]) # field 4 - type indicator )? - } $tod -> hour minute second ind]} then { + } $tod -> hour minute second ind]} { puts stderr "$fileName:$lno:can't parse time field \"$tod\"" incr errorCount } @@ -556,7 +556,7 @@ proc parseOffsetTime {offset} { :([[:digit:]]{2}) # field 4 - second )? )? - } $offset -> signum hour minute second]} then { + } $offset -> signum hour minute second]} { puts stderr "$fileName:$lno:can't parse offset time \"$offset\"" incr errorCount } @@ -938,7 +938,7 @@ proc applyRules {ruleSet year startSecs stdGMTOffset DSTOffset nextGMTOffset if { $earliestSecs > $startSecs && ($until eq "" || $earliestSecs < $untilSecs) - } then { + } { # Test if the initial transition has been done. # If not, do it now. @@ -987,7 +987,7 @@ proc applyRules {ruleSet year startSecs stdGMTOffset DSTOffset nextGMTOffset set date [::tcl::clock::GetJulianDayFromEraYearMonthDay \ [dict create era CE year $year month 1 dayOfMonth 1] 2361222] set startSecs [expr { - [dict get $date julianDay] * wide(86400) - 210866803200 + [dict get $date julianDay] * wide(86400) - 210866803200 - $stdGMTOffset - $DSTOffset }] diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 04891eb..a09bf79 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -1427,7 +1427,7 @@ proc output-directive {line} { } ## ## merge copyright listings -## +## proc merge-copyrights {l1 l2} { set merge {} set re1 {^Copyright +(?:\(c\)|\\\(co|©) +(\w.*?)(?:all rights reserved)?(?:\. )*$} diff --git a/tools/uniParse.tcl b/tools/uniParse.tcl index a451096..545afc4 100644 --- a/tools/uniParse.tcl +++ b/tools/uniParse.tcl @@ -68,7 +68,7 @@ proc uni::getGroup {value} { variable groups set gIndex [lsearch -exact $groups $value] - if {$gIndex == -1} { + if {$gIndex < 0} { set gIndex [llength $groups] lappend groups $value } @@ -81,7 +81,7 @@ proc uni::addPage {info} { variable shift set pIndex [lsearch -exact $pages $info] - if {$pIndex == -1} { + if {$pIndex < 0} { set pIndex [llength $pages] lappend pages $info } -- cgit v0.12 From 107d130ce3db87a24b5136c006f32136b60d079c Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sun, 20 Sep 2020 10:38:41 +0000 Subject: Make the check to avoid generating a string representation in [uplevel] a little less intrusive. --- generic/tclInt.h | 3 +++ generic/tclProc.c | 30 ++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 46ba764..9629709 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4376,6 +4376,9 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, objPtr->bytes = NULL; \ } +#define TclHasStringRep(objPtr) \ + objPtr->bytes != NULL + /* *---------------------------------------------------------------- * Macros used by the Tcl core to grow Tcl_Token arrays. They use the same diff --git a/generic/tclProc.c b/generic/tclProc.c index 0313b29..56757ff 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -898,7 +898,6 @@ TclNRUplevelObjCmd( Interp *iPtr = (Interp *) interp; CmdFrame *invoker = NULL; int word = 0; - int havelevel = 0; int result; CallFrame *savedVarFramePtr, *framePtr; Tcl_Obj *objPtr; @@ -912,7 +911,7 @@ TclNRUplevelObjCmd( uplevelSyntax: Tcl_WrongNumArgs(interp, 1, objv, "?level? command ?arg ...?"); return TCL_ERROR; - } else if (objc == 2) { + } else if (!TclHasStringRep(objv[1]) && objc == 2) { int status ,llength; status = Tcl_ListObjLength(interp, objv[1], &llength); if (status == TCL_OK && llength > 1) { @@ -922,28 +921,27 @@ TclNRUplevelObjCmd( if (result == -1) { return TCL_ERROR; } - havelevel = 1; objc -= 1; objv += 1; + goto havelevel; } } - if (!havelevel) { - /* - * Find the level to use for executing the command. - */ + /* + * Find the level to use for executing the command. + */ - result = TclObjGetFrame(interp, objv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - objc -= result + 1; - if (objc == 0) { - goto uplevelSyntax; - } - objv += result + 1; + result = TclObjGetFrame(interp, objv[1], &framePtr); + if (result == -1) { + return TCL_ERROR; + } + objc -= result + 1; + if (objc == 0) { + goto uplevelSyntax; } + objv += result + 1; + havelevel: /* * Modify the interpreter state to execute in the given frame. -- cgit v0.12 From fb77f1148fc73f9da5350bc2f4681c62a5c3ec6a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 20 Sep 2020 11:17:56 +0000 Subject: Default utf-8 for source command --- doc/FileSystem.3 | 4 ++-- generic/tclIOUtil.c | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/FileSystem.3 b/doc/FileSystem.3 index 681e834..856a05d 100644 --- a/doc/FileSystem.3 +++ b/doc/FileSystem.3 @@ -414,7 +414,7 @@ caller (with a reference count of 0). the encoding identified by \fIencodingName\fR and evaluates its contents as a Tcl script. It returns the same information as \fBTcl_EvalObjEx\fR. -If \fIencodingName\fR is NULL, the system encoding is used for +If \fIencodingName\fR is NULL, the utf-8 encoding is used for reading the file contents. If the file could not be read then a Tcl error is returned to describe why the file could not be read. @@ -430,7 +430,7 @@ or which will be safely substituted by the Tcl interpreter into .QW ^Z . \fBTcl_FSEvalFile\fR is a simpler version of -\fBTcl_FSEvalFileEx\fR that always uses the system encoding +\fBTcl_FSEvalFileEx\fR that always uses utf-8 when reading the file. .PP \fBTcl_FSLoadFile\fR dynamically loads a binary code file into memory and diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 3d6c47e..5811f62 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -1684,7 +1684,7 @@ Tcl_FSEvalFileEx( * Tilde-substitution is performed on this * pathname. */ const char *encodingName) /* Either the name of an encoding or NULL to - use the system encoding. */ + use the utf-8 encoding. */ { size_t length; int result = TCL_ERROR; @@ -1723,16 +1723,16 @@ Tcl_FSEvalFileEx( /* * If the encoding is specified, set the channel to that encoding. - * Otherwise don't touch it, leaving things up to the system encoding. If - * the encoding is unknown report an error. + * Otherwise use utf-8. */ - if (encodingName != NULL) { - if (Tcl_SetChannelOption(interp, chan, "-encoding", encodingName) - != TCL_OK) { - Tcl_CloseEx(interp,chan,0); - return result; - } + if (encodingName == NULL) { + encodingName = "utf-8"; + } + if (Tcl_SetChannelOption(interp, chan, "-encoding", encodingName) + != TCL_OK) { + Tcl_CloseEx(interp,chan,0); + return result; } TclNewObj(objPtr); @@ -1822,7 +1822,7 @@ TclNREvalFile( * evaluate. Tilde-substitution is performed on * this pathname. */ const char *encodingName) /* The name of an encoding to use, or NULL to - * use the system encoding. */ + * use the utf-8 encoding. */ { Tcl_StatBuf statBuf; Tcl_Obj *oldScriptFile, *objPtr; @@ -1859,16 +1859,16 @@ TclNREvalFile( /* * If the encoding is specified, set the channel to that encoding. - * Otherwise don't touch it, leaving things up to the system encoding. If - * the encoding is unknown report an error. + * Otherwise use utf-8. */ - if (encodingName != NULL) { - if (Tcl_SetChannelOption(interp, chan, "-encoding", encodingName) - != TCL_OK) { - Tcl_CloseEx(interp, chan, 0); - return TCL_ERROR; - } + if (encodingName == NULL) { + encodingName = "utf-8"; + } + if (Tcl_SetChannelOption(interp, chan, "-encoding", encodingName) + != TCL_OK) { + Tcl_CloseEx(interp, chan, 0); + return TCL_ERROR; } TclNewObj(objPtr); -- cgit v0.12 From 7a56ff406f3244d777f60d9a5e0da1e5e08f3ef9 Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 20 Sep 2020 15:53:37 +0000 Subject: Silence compiler warning -- fix safety of macro. --- generic/tclInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 9629709..3dbffeb 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4377,7 +4377,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, } #define TclHasStringRep(objPtr) \ - objPtr->bytes != NULL + (objPtr->bytes != NULL) /* *---------------------------------------------------------------- -- cgit v0.12 From 9e43cbb9739ecfd05d38ff31a49050a0eb04505b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 20 Sep 2020 21:32:35 +0000 Subject: Improve TclInvalidateStringRep() macro such that (objPtr) is only evaluated once. Addation brackets in TclHasStringRep() macro --- generic/tcl.h | 2 +- generic/tclInt.h | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 458072a..914f62b 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2517,7 +2517,7 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); # define Tcl_DecrRefCount(objPtr) \ do { \ Tcl_Obj *_objPtr = (objPtr); \ - if ((_objPtr)->refCount-- <= 1) { \ + if (_objPtr->refCount-- <= 1) { \ TclFreeObj(_objPtr); \ } \ } while(0) diff --git a/generic/tclInt.h b/generic/tclInt.h index 3dbffeb..f2f097c 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4369,15 +4369,18 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, */ #define TclInvalidateStringRep(objPtr) \ - if (objPtr->bytes != NULL) { \ - if (objPtr->bytes != tclEmptyStringRep) { \ - ckfree((char *) objPtr->bytes); \ + do { \ + Tcl_Obj *_isobjPtr = (Tcl_Obj *)(objPtr); \ + if (_isobjPtr->bytes != NULL) { \ + if (_isobjPtr->bytes != tclEmptyStringRep) { \ + ckfree((char *)_isobjPtr->bytes); \ + } \ + _isobjPtr->bytes = NULL; \ } \ - objPtr->bytes = NULL; \ - } + } while (0) #define TclHasStringRep(objPtr) \ - (objPtr->bytes != NULL) + ((objPtr)->bytes != NULL) /* *---------------------------------------------------------------- -- cgit v0.12 From a9ba2a08b562e5c0f60b9671df3b4a0c20a23879 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 22 Sep 2020 12:18:17 +0000 Subject: When writing script files (like pkgIndex.tcl), always use -translation lf, so they don't cause problems on non-windows. When reading script files, always use -eofchar \032, as this might be left by Windows editors. --- library/auto.tcl | 4 ++++ library/init.tcl | 1 + library/install.tcl | 3 +++ library/package.tcl | 1 + 4 files changed, 9 insertions(+) diff --git a/library/auto.tcl b/library/auto.tcl index 2deae05..32da97c 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -265,6 +265,7 @@ proc auto_mkindex {dir args} { auto_mkindex_parser::cleanup set fid [open "tclIndex" w] + fconfigure $fid -translation lf puts -nonewline $fid $index close $fid cd $oldDir @@ -291,6 +292,7 @@ proc auto_mkindex_old {dir args} { set f "" set error [catch { set f [open $file] + fconfigure $f -eofchar \032 while {[gets $f line] >= 0} { if {[regexp {^proc[ ]+([^ ]*)} $line match procName]} { set procName [lindex [auto_qualify $procName "::"] 0] @@ -309,6 +311,7 @@ proc auto_mkindex_old {dir args} { set f "" set error [catch { set f [open tclIndex w] + fconfigure $f -translation lf puts -nonewline $f $index close $f cd $oldDir @@ -401,6 +404,7 @@ proc auto_mkindex_parser::mkindex {file} { set scriptFile $file set fid [open $file] + fconfigure $fid -eofchar \032 set contents [read $fid] close $fid diff --git a/library/init.tcl b/library/init.tcl index 94f65cf..16d5d67 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -442,6 +442,7 @@ proc auto_load_index {} { continue } else { set error [catch { + fconfigure $f -eofchar \032 set id [gets $f] if {$id eq "# Tcl autoload index file, version 2.0"} { eval [read $f] diff --git a/library/install.tcl b/library/install.tcl index 227d0b8..26e5e68 100644 --- a/library/install.tcl +++ b/library/install.tcl @@ -35,6 +35,7 @@ proc ::practcl::_pkgindex_directory {path} { # Read the file, and override assumptions as needed ### set fin [open $file r] + fconfigure $fin -eofchar \032 set dat [read $fin] close $fin # Look for a teapot style Package statement @@ -58,6 +59,7 @@ proc ::practcl::_pkgindex_directory {path} { foreach file [glob -nocomplain $path/*.tcl] { if { [file tail $file] == "version_info.tcl" } continue set fin [open $file r] + fconfigure $fin -eofchar \032 set dat [read $fin] close $fin if {![regexp "package provide" $dat]} continue @@ -77,6 +79,7 @@ proc ::practcl::_pkgindex_directory {path} { return $buffer } set fin [open $pkgidxfile r] + fconfigure $fin -eofchar \032 set dat [read $fin] close $fin set trace 0 diff --git a/library/package.tcl b/library/package.tcl index eebe91c..64fac7b 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -409,6 +409,7 @@ proc pkg_mkIndex {args} { } set f [open [file join $dir pkgIndex.tcl] w] + fconfigure $f -translation lf puts $f $index close $f } -- cgit v0.12 From 3ee0402bd5245e265b10cff5f2bdb7c0f135ed6f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Sep 2020 05:57:35 +0000 Subject: Let's see if we can recover from an occasional hickup like happened here: [https://travis-ci.org/github/tcltk/tcl/jobs/729226819] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f93fa0..53e0bac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -332,5 +332,5 @@ install: before_script: - export ERROR_ON_FAILURES=1 script: - - make all tcltest + - make all tcltest || echo "Something wrong, maybe a hickup, let's try again" - make test -- cgit v0.12 From e4fcd7152b8701ae9adbf0cc608572d7f253e2c3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 24 Sep 2020 06:41:04 +0000 Subject: Add gcc-10 build to Travis --- .travis.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53e0bac..ac27dd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: c addons: apt: + sources: + - ubuntu-toolchain-r-test packages: - binutils-mingw-w64-i686 - binutils-mingw-w64-x86-64 @@ -11,7 +13,7 @@ addons: - gcc-multilib jobs: include: -# Testing on Linux with various compilers +# Testing on Linux GCC - name: "Linux/GCC/Shared" os: linux dist: focal @@ -60,29 +62,15 @@ jobs: env: - BUILD_DIR=unix - CFGOPT="--enable-symbols=mem" -# Older versions of GCC... - - name: "Linux/GCC 7/Shared" +# Newer/Older versions of GCC + - name: "Linux/GCC 10/Shared" os: linux dist: focal - compiler: gcc-7 + compiler: gcc-10 addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - - g++-7 - env: - - BUILD_DIR=unix - - name: "Linux/GCC 6/Shared" - os: linux - dist: bionic - compiler: gcc-6 - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-6 + - g++-10 env: - BUILD_DIR=unix - name: "Linux/GCC 5/Shared" @@ -91,13 +79,11 @@ jobs: compiler: gcc-5 addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - g++-5 env: - BUILD_DIR=unix -# Clang +# Testing on Linux Clang - name: "Linux/Clang/Shared" os: linux dist: focal -- cgit v0.12 From abc23e672315cb78ec468f0d96c592d0ea346ac9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 24 Sep 2020 12:54:15 +0000 Subject: TCL_CFGVAL_ENCODING now defaults to "utf-8" as well. No explicit "-encoding utf-8" for "source" any more, since that's the default --- doc/InitSubSyst.3 | 4 ++-- library/clock.tcl | 2 +- library/init.tcl | 4 ++-- library/tm.tcl | 2 +- tests/source.test | 6 +++--- unix/README | 2 +- unix/configure | 4 ++-- unix/tcl.m4 | 4 ++-- unix/tclUnixInit.c | 2 +- win/configure | 3 +-- win/tcl.m4 | 3 +-- 11 files changed, 17 insertions(+), 19 deletions(-) diff --git a/doc/InitSubSyst.3 b/doc/InitSubSyst.3 index 3c138a4..7551145 100644 --- a/doc/InitSubSyst.3 +++ b/doc/InitSubSyst.3 @@ -23,9 +23,9 @@ first thing in the application's main program. .PP \fBTcl_InitSubsystems\fR is very similar in use to \fBTcl_FindExecutable\fR. It can be used when Tcl is -used as utility library, no other encodings than utf8, +used as utility library, no other encodings than utf-8, iso8859-1 or unicode are used, and no interest exists in the value of \fBinfo nameofexecutable\fR. The system encoding will not -be extracted from the environment, but falls back to iso8859-1. +be extracted from the environment, but falls back to utf-8. .SH KEYWORDS binary, executable file diff --git a/library/clock.tcl b/library/clock.tcl index 2e42a98..54919f2 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -3314,7 +3314,7 @@ proc ::tcl::clock::LoadTimeZoneFile { fileName } { "time zone \":$fileName\" not valid" } try { - source -encoding utf-8 [file join $DataDir $fileName] + source [file join $DataDir $fileName] } on error {} { return -code error \ -errorcode [list CLOCK badTimeZone :$fileName] \ diff --git a/library/init.tcl b/library/init.tcl index a13d3eb..f73d9e2 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -112,7 +112,7 @@ if {[interp issafe]} { foreach cmd {add format scan} { proc ::tcl::clock::$cmd args { variable TclLibDir - source -encoding utf-8 [file join $TclLibDir clock.tcl] + source [file join $TclLibDir clock.tcl] return [uplevel 1 [info level 0]] } } @@ -442,7 +442,7 @@ proc auto_load_index {} { continue } else { set error [catch { - fconfigure $f -encoding utf-8 -eofchar \032 + fconfigure $f -eofchar \032 set id [gets $f] if {$id eq "# Tcl autoload index file, version 2.0"} { eval [read $f] diff --git a/library/tm.tcl b/library/tm.tcl index c60084c..3c0ec22 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -267,7 +267,7 @@ proc ::tcl::tm::UnknownHandler {original name args} { # of the package file is the last element in the list. package ifneeded $pkgname $pkgversion \ - "[::list package provide $pkgname $pkgversion];[::list source -encoding utf-8 $file]" + "[::list package provide $pkgname $pkgversion];[::list source $file]" # We abort in this unknown handler only if we got a # satisfying candidate for the requested package. diff --git a/tests/source.test b/tests/source.test index c6cccd6..378d62e 100644 --- a/tests/source.test +++ b/tests/source.test @@ -114,7 +114,7 @@ test source-2.7 {utf-8 with BOM} -setup { puts $out "\ufeffset y new-y" close $out set y old-y - source -encoding utf-8 $sourcefile + source $sourcefile return $y } -cleanup { removeFile $sourcefile @@ -226,7 +226,7 @@ test source-7.1 {source -encoding test} -setup { close $f } -body { set x unset - source -encoding utf-8 $sourcefile + source $sourcefile set x } -cleanup { removeFile source.file @@ -269,7 +269,7 @@ test source-7.5 {source -encoding: correct operation} -setup { puts $f "proc \u20ac {} {return foo}" close $f } -body { - source -encoding utf-8 $sourcefile + source $sourcefile \u20ac } -cleanup { removeFile source.file diff --git a/unix/README b/unix/README index 3340dc6..3c1a207 100644 --- a/unix/README +++ b/unix/README @@ -91,7 +91,7 @@ How To Compile And Install Tcl: for descriptions of the probes made available, see http://wiki.tcl.tk/DTrace for more details --with-encoding=ENCODING Specifies the encoding for compile-time - configuration values. Defaults to iso8859-1, + configuration values. Defaults to utf-8, which is also sufficient for ASCII. --with-tzdata=FLAG Specifies whether to install timezone data. By default, the configure script tries to detect diff --git a/unix/configure b/unix/configure index 464e320..de45627 100755 --- a/unix/configure +++ b/unix/configure @@ -1430,7 +1430,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-encoding encoding for configuration values (default: - iso8859-1) + utf-8) --with-system-libtommath use external libtommath (default: true if available, false otherwise) @@ -3982,7 +3982,7 @@ _ACEOF else -$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h +$as_echo "#define TCL_CFGVAL_ENCODING \"utf-8\"" >>confdefs.h fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index bd22cc8..4cd1d53 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2445,14 +2445,14 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [ AC_DEFUN([SC_TCL_CFG_ENCODING], [ AC_ARG_WITH(encoding, AC_HELP_STRING([--with-encoding], - [encoding for configuration values (default: iso8859-1)]), + [encoding for configuration values (default: utf-8)]), with_tcencoding=${withval}) if test x"${with_tcencoding}" != x ; then AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}", [What encoding should be used for embedded configuration info?]) else - AC_DEFINE(TCL_CFGVAL_ENCODING,"iso8859-1", + AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8", [What encoding should be used for embedded configuration info?]) fi ]) diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 98c37f5..e88b084 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -92,7 +92,7 @@ typedef struct { */ #ifndef TCL_DEFAULT_ENCODING -#define TCL_DEFAULT_ENCODING "iso8859-1" +#define TCL_DEFAULT_ENCODING "utf-8" #endif /* diff --git a/win/configure b/win/configure index c07092b..0ac7710 100755 --- a/win/configure +++ b/win/configure @@ -3747,8 +3747,7 @@ fi _ACEOF else - # Default encoding on windows is not "iso8859-1" - $as_echo "#define TCL_CFGVAL_ENCODING \"cp1252\"" >>confdefs.h + $as_echo "#define TCL_CFGVAL_ENCODING \"utf-8\"" >>confdefs.h fi diff --git a/win/tcl.m4 b/win/tcl.m4 index 0553760..a7276b9 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -1085,8 +1085,7 @@ AC_DEFUN([SC_TCL_CFG_ENCODING], [ if test x"${with_tcencoding}" != x ; then AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}") else - # Default encoding on windows is not "iso8859-1" - AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252") + AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8") fi ]) -- cgit v0.12 From 9d34b872ced6c6713cf84f914f11a017ecd2cd49 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Sep 2020 11:09:08 +0000 Subject: When sourcing script files (even when simulating that through open|read), always set -eofchar \032 just like the source command does. Possible security issue: this could make it possible to evaluate hidden content at the end of pkgIndex files. --- library/auto.tcl | 2 ++ library/init.tcl | 1 + 2 files changed, 3 insertions(+) diff --git a/library/auto.tcl b/library/auto.tcl index 6cb09b6..32a5f52 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -248,6 +248,7 @@ proc auto_mkindex_old {dir args} { set f "" set error [catch { set f [open $file] + fconfigure $f -eofchar \032 while {[gets $f line] >= 0} { if {[regexp {^proc[ ]+([^ ]*)} $line match procName]} { set procName [lindex [auto_qualify $procName "::"] 0] @@ -351,6 +352,7 @@ proc auto_mkindex_parser::mkindex {file} { set scriptFile $file set fid [open $file] + fconfigure $fid -eofchar \032 set contents [read $fid] close $fid diff --git a/library/init.tcl b/library/init.tcl index 0a5e71b..6e4cf89 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -501,6 +501,7 @@ proc auto_load_index {} { continue } else { set error [catch { + fconfigure $f -eofchar \032 set id [gets $f] if {$id eq "# Tcl autoload index file, version 2.0"} { eval [read $f] -- cgit v0.12 -- cgit v0.12 From 29577449a18c6d97285f1f6ba67a00f7c00d2792 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Sep 2020 14:17:14 +0000 Subject: Use utf-8 as default encoding for configuration information --- unix/README | 2 +- unix/configure | 4 ++-- unix/tcl.m4 | 4 ++-- win/configure | 3 +-- win/makefile.vc | 2 +- win/rules.vc | 2 +- win/tcl.m4 | 3 +-- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/unix/README b/unix/README index 3340dc6..3c1a207 100644 --- a/unix/README +++ b/unix/README @@ -91,7 +91,7 @@ How To Compile And Install Tcl: for descriptions of the probes made available, see http://wiki.tcl.tk/DTrace for more details --with-encoding=ENCODING Specifies the encoding for compile-time - configuration values. Defaults to iso8859-1, + configuration values. Defaults to utf-8, which is also sufficient for ASCII. --with-tzdata=FLAG Specifies whether to install timezone data. By default, the configure script tries to detect diff --git a/unix/configure b/unix/configure index d3a4856..d48d687 100755 --- a/unix/configure +++ b/unix/configure @@ -1430,7 +1430,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-encoding encoding for configuration values (default: - iso8859-1) + utf-8) --with-system-libtommath use external libtommath (default: true if available, false otherwise) @@ -3982,7 +3982,7 @@ _ACEOF else -$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h +$as_echo "#define TCL_CFGVAL_ENCODING \"utf-8\"" >>confdefs.h fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 056cf1f..a4824ff 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2445,14 +2445,14 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [ AC_DEFUN([SC_TCL_CFG_ENCODING], [ AC_ARG_WITH(encoding, AC_HELP_STRING([--with-encoding], - [encoding for configuration values (default: iso8859-1)]), + [encoding for configuration values (default: utf-8)]), with_tcencoding=${withval}) if test x"${with_tcencoding}" != x ; then AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}", [What encoding should be used for embedded configuration info?]) else - AC_DEFINE(TCL_CFGVAL_ENCODING,"iso8859-1", + AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8", [What encoding should be used for embedded configuration info?]) fi ]) diff --git a/win/configure b/win/configure index f099510..b08eb15 100755 --- a/win/configure +++ b/win/configure @@ -3749,8 +3749,7 @@ fi _ACEOF else - # Default encoding on windows is not "iso8859-1" - $as_echo "#define TCL_CFGVAL_ENCODING \"cp1252\"" >>confdefs.h + $as_echo "#define TCL_CFGVAL_ENCODING \"utf-8\"" >>confdefs.h fi diff --git a/win/makefile.vc b/win/makefile.vc index e3de98e..0edeac1 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -116,7 +116,7 @@ # # CFG_ENCODING=encoding # name of encoding for configuration information. Defaults -# to cp1252 +# to utf-8 # # Examples: # c:\tcl_src\win\>nmake -f makefile.vc release diff --git a/win/rules.vc b/win/rules.vc index 61df910..33d6075 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -504,7 +504,7 @@ _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -ou !endif !ifndef CFG_ENCODING -CFG_ENCODING = \"cp1252\" +CFG_ENCODING = \"utf-8\" !endif ################################################################ diff --git a/win/tcl.m4 b/win/tcl.m4 index 4824e8e..0fd2271 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -1085,8 +1085,7 @@ AC_DEFUN([SC_TCL_CFG_ENCODING], [ if test x"${with_tcencoding}" != x ; then AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}") else - # Default encoding on windows is not "iso8859-1" - AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252") + AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8") fi ]) -- cgit v0.12 From 67f864dc656ad9a88f134514172bc55a2c73c3d5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Sep 2020 14:24:24 +0000 Subject: It's "utf-8", not "utf8" or "UTF8" --- ChangeLog.2001 | 2 +- ChangeLog.2002 | 2 +- ChangeLog.2004 | 4 ++-- tests/string.test | 6 +++--- tests/stringComp.test | 4 ++-- tests/util.test | 12 ++++++------ tests/winDde.test | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ChangeLog.2001 b/ChangeLog.2001 index 06e7c36..9d6d541 100644 --- a/ChangeLog.2001 +++ b/ChangeLog.2001 @@ -351,7 +351,7 @@ * mac/tclMacFile.c: fixed bug in permission checking code - * mac/tclMacLoad.c: corrected utf8 handling, comparison of package + * mac/tclMacLoad.c: corrected utf-8 handling, comparison of package names to code fragment names changed to only match on the length of package name, this allows for fragment names with version numbers appended. diff --git a/ChangeLog.2002 b/ChangeLog.2002 index 9931657..fa31e42 100644 --- a/ChangeLog.2002 +++ b/ChangeLog.2002 @@ -1753,7 +1753,7 @@ 2002-07-05 Reinhard Max - * generic/tclClock.c (FormatClock): Convert the format string to UTF8 + * generic/tclClock.c (FormatClock): Convert the format string to utf-8 before calling TclpStrftime, so that non-ASCII characters don't get mangled when the result string is being converted back. * tests/clock.test: Added a test for that. diff --git a/ChangeLog.2004 b/ChangeLog.2004 index daf124f..f7da18d 100644 --- a/ChangeLog.2004 +++ b/ChangeLog.2004 @@ -2302,7 +2302,7 @@ 934511]. * doc/CrtCommand.3: Added note that the arguments given to the command - proc of a Tcl_CreateCommand are in utf8 since Tcl 8.1. Closing [Patch + proc of a Tcl_CreateCommand are in utf-8 since Tcl 8.1. Closing [Patch 414778]. * doc/ChnlStack.3: Removed the declaration that the interp argument to @@ -2873,7 +2873,7 @@ 2004-06-02 Jeff Hobbs * win/tclWinFile.c (TclpFindExecutable): when using GetModuleFileNameA - (Win9x), convert from CP_ACP to WCHAR then convert back to utf8. + (Win9x), convert from CP_ACP to WCHAR then convert back to utf-8. Adjunct to 2004-04-07 fix. 2004-06-02 David Gravereaux diff --git a/tests/string.test b/tests/string.test index dabe3a4..12108ca 100644 --- a/tests/string.test +++ b/tests/string.test @@ -71,11 +71,11 @@ test string-2.11 {string compare, unicode} { string compare ab\u7266 ab\u7267 } -1 test string-2.12 {string compare, high bit} { - # This test will fail if the underlying comparaison + # This test will fail if the underlying comparison # is using signed chars instead of unsigned chars. # (like SunOS's default memcmp thus the compat/memcmp.c) string compare "\x80" "@" - # Nb this tests works also in utf8 space because \x80 is + # Nb this tests works also in utf-8 space because \x80 is # translated into a 2 or more bytelength but whose first byte has # the high bit set. } 1 @@ -2034,7 +2034,7 @@ test string-28.12 {tcl::prefix longest} { tcl::prefix longest {apa {} appa} {} } {} test string-28.13 {tcl::prefix longest} { - # Test UTF8 handling + # Test utf-8 handling tcl::prefix longest {ax\x90 bep ax\x91} a } ax diff --git a/tests/stringComp.test b/tests/stringComp.test index 1cd0193..a17390d 100644 --- a/tests/stringComp.test +++ b/tests/stringComp.test @@ -100,11 +100,11 @@ foreach {tname tbody tresult tcode} { {unicode} {string compare \334 \u00fc} -1 {} {unicode} {string compare \334\334\334\374\374 \334\334\334\334\334} 1 {} {high bit} { - # This test will fail if the underlying comparaison + # This test will fail if the underlying comparison # is using signed chars instead of unsigned chars. # (like SunOS's default memcmp thus the compat/memcmp.c) string compare "\x80" "@" - # Nb this tests works also in utf8 space because \x80 is + # Nb this tests works also in utf-8 space because \x80 is # translated into a 2 or more bytelength but whose first byte has # the high bit set. } {1} {} diff --git a/tests/util.test b/tests/util.test index a7d21f1..c8a081b 100644 --- a/tests/util.test +++ b/tests/util.test @@ -472,7 +472,7 @@ test util-7.4 {TclPrecTraceProc - write traces, bogus values} -setup { } -result {1 {can't set "tcl_precision": improper value for precision} 12} # This test always succeeded in the C locale anyway... -test util-8.1 {TclNeedSpace - correct UTF8 handling} { +test util-8.1 {TclNeedSpace - correct utf-8 handling} { # Bug 411825 # Note that this test relies on the fact that # [interp target] calls on Tcl_AppendElement() @@ -486,7 +486,7 @@ test util-8.1 {TclNeedSpace - correct UTF8 handling} { interp delete \u5420 set result } "\u5420 foo" -test util-8.2 {TclNeedSpace - correct UTF8 handling} testdstring { +test util-8.2 {TclNeedSpace - correct utf-8 handling} testdstring { # Bug 411825 # This tests the same bug as the previous test, but # should be more future-proof, as the DString @@ -496,14 +496,14 @@ test util-8.2 {TclNeedSpace - correct UTF8 handling} testdstring { testdstring element foo llength [testdstring get] } 2 -test util-8.3 {TclNeedSpace - correct UTF8 handling} testdstring { +test util-8.3 {TclNeedSpace - correct utf-8 handling} testdstring { # Bug 411825 - new variant reported by Dossy Shiobara testdstring free testdstring append \u00A0 -1 testdstring element foo llength [testdstring get] } 2 -test util-8.4 {TclNeedSpace - correct UTF8 handling} testdstring { +test util-8.4 {TclNeedSpace - correct utf-8 handling} testdstring { # Another bug uncovered while fixing 411825 testdstring free testdstring append {\ } -1 @@ -511,13 +511,13 @@ test util-8.4 {TclNeedSpace - correct UTF8 handling} testdstring { testdstring element foo llength [testdstring get] } 2 -test util-8.5 {TclNeedSpace - correct UTF8 handling} testdstring { +test util-8.5 {TclNeedSpace - correct utf-8 handling} testdstring { testdstring free testdstring append {\\ } -1 testdstring element foo list [llength [testdstring get]] [string length [testdstring get]] } {2 6} -test util-8.6 {TclNeedSpace - correct UTF8 handling} testdstring { +test util-8.6 {TclNeedSpace - correct utf-8 handling} testdstring { testdstring free testdstring append {\\ } -1 testdstring append \{ -1 diff --git a/tests/winDde.test b/tests/winDde.test index 1c3daa5..1238102 100644 --- a/tests/winDde.test +++ b/tests/winDde.test @@ -154,8 +154,8 @@ test winDde-3.5 {DDE request locally} -constraints dde -body { dde request -binary TclEval self \xe1 } -result "foo\x00" # Set variable a to A with diaeresis (unicode C4) by relying on the fact -# that utf8 is sent (e.g. "c3 84" on the wire) -test winDde-3.6 {DDE request utf8} -constraints dde -body { +# that utf-8 is sent (e.g. "c3 84" on the wire) +test winDde-3.6 {DDE request utf-8} -constraints dde -body { set \xe1 "not set" dde execute TclEval self "set \xe1 \xc4" scan [set \xe1] %c -- cgit v0.12 From e6b8f92493a256940ee1e55c0bf5df6a60cb8760 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Sep 2020 15:17:06 +0000 Subject: Build Travis with Xcode 12 and 12u (Universal Apps) --- .travis.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac27dd2..32ccb48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -112,9 +112,9 @@ jobs: - BUILD_DIR=unix - CFGOPT="--enable-symbols=mem" # Testing on Mac, various styles - - name: "macOS/Xcode 11.7/Shared" + - name: "macOS/Xcode 12/Shared" os: osx - osx_image: xcode11.7 + osx_image: xcode12 env: - BUILD_DIR=macosx install: [] @@ -122,34 +122,42 @@ jobs: - make all # The styles=develop avoids some weird problems on OSX - make test styles=develop - - name: "macOS/Xcode 11.7/Shared/Unix-like" + - name: "macOS/Xcode 12/Shared/Unix-like" os: osx - osx_image: xcode11.7 + osx_image: xcode12 env: - BUILD_DIR=unix +# Newer MacOS versions + - name: "macOS 10.15/Xcode 12/Universal Apps/Shared" + os: osx + osx_image: xcode12u + env: + - BUILD_DIR=macosx + install: [] + script: *mactest # Older MacOS versions - - name: "macOS/Xcode 11/Shared" + - name: "macOS 10.15/Xcode 11/Shared" os: osx - osx_image: xcode11 + osx_image: xcode11.7 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS/Xcode 10/Shared" + - name: "macOS 10.14/Xcode 10/Shared" os: osx osx_image: xcode10.3 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS/Xcode 9/Shared" + - name: "macOS 10.13/Xcode 9/Shared" os: osx - osx_image: xcode9.2 + osx_image: xcode9.4 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS/Xcode 8/Shared" + - name: "macOS 10.12/Xcode 8/Shared" os: osx osx_image: xcode8.3 env: -- cgit v0.12 From 636e4d4826142fcd8b3d159eeca1c226ea25e9c6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 26 Sep 2020 18:25:56 +0000 Subject: Tweak xcode labels for Travis build --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32ccb48..5773b5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -128,7 +128,7 @@ jobs: env: - BUILD_DIR=unix # Newer MacOS versions - - name: "macOS 10.15/Xcode 12/Universal Apps/Shared" + - name: "macOS/Xcode 12/Universal Apps/Shared" os: osx osx_image: xcode12u env: @@ -136,28 +136,28 @@ jobs: install: [] script: *mactest # Older MacOS versions - - name: "macOS 10.15/Xcode 11/Shared" + - name: "macOS/Xcode 11/Shared" os: osx osx_image: xcode11.7 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS 10.14/Xcode 10/Shared" + - name: "macOS/Xcode 10/Shared" os: osx osx_image: xcode10.3 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS 10.13/Xcode 9/Shared" + - name: "macOS/Xcode 9/Shared" os: osx osx_image: xcode9.4 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS 10.12/Xcode 8/Shared" + - name: "macOS/Xcode 8/Shared" os: osx osx_image: xcode8.3 env: -- cgit v0.12 From f6bf85fb67eb15e637ecf7c7de4f661dc0557b43 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 28 Sep 2020 10:13:51 +0000 Subject: Make Tcl compile warning-free using -Wshadow --- generic/tclCompCmdsGR.c | 2 +- generic/tclCompExpr.c | 16 +++++++------- generic/tclExecute.c | 34 ++++++++++++++--------------- generic/tclIOUtil.c | 2 +- generic/tclListObj.c | 22 +++++++++---------- generic/tclPathObj.c | 2 +- generic/tclPkg.c | 5 +++-- generic/tclTest.c | 9 ++------ generic/tclTestObj.c | 4 ++-- generic/tclTrace.c | 39 ++++++++++++++++----------------- generic/tclVar.c | 58 ++++++++++++++++++++++++------------------------- win/tclWinFile.c | 4 +--- win/tclWinPipe.c | 2 +- win/tclWinSerial.c | 14 ++++++------ 14 files changed, 103 insertions(+), 110 deletions(-) diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 16fafad..990be2a 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -881,7 +881,7 @@ TclCompileLappendCmd( */ if (numWords > 2) { - Tcl_Token *valueTokenPtr = TokenAfter(varTokenPtr); + valueTokenPtr = TokenAfter(varTokenPtr); CompileWord(envPtr, valueTokenPtr, interp, 2); } diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 0d33821..729ad52 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2424,8 +2424,8 @@ CompileExprTree( if (optimize) { int length; const char *bytes = TclGetStringFromObj(literal, &length); - int index = TclRegisterNewLiteral(envPtr, bytes, length); - Tcl_Obj *objPtr = TclFetchLiteral(envPtr, index); + int idx = TclRegisterNewLiteral(envPtr, bytes, length); + Tcl_Obj *objPtr = TclFetchLiteral(envPtr, idx); if ((objPtr->typePtr == NULL) && (literal->typePtr != NULL)) { /* @@ -2445,7 +2445,7 @@ CompileExprTree( objPtr->internalRep = literal->internalRep; literal->typePtr = NULL; } - TclEmitPush(index, envPtr); + TclEmitPush(idx, envPtr); } else { /* * When optimize==0, we know the expression is a one-off and @@ -2471,7 +2471,7 @@ CompileExprTree( if (ExecConstantExprTree(interp, nodes, next, litObjvPtr) == TCL_OK) { - int index; + int idx; Tcl_Obj *objPtr = Tcl_GetObjResult(interp); /* @@ -2482,9 +2482,9 @@ CompileExprTree( if (objPtr->bytes) { Tcl_Obj *tableValue; - index = TclRegisterNewLiteral(envPtr, objPtr->bytes, + idx = TclRegisterNewLiteral(envPtr, objPtr->bytes, objPtr->length); - tableValue = TclFetchLiteral(envPtr, index); + tableValue = TclFetchLiteral(envPtr, idx); if ((tableValue->typePtr == NULL) && (objPtr->typePtr != NULL)) { /* @@ -2496,9 +2496,9 @@ CompileExprTree( objPtr->typePtr = NULL; } } else { - index = TclAddLiteralObj(envPtr, objPtr, NULL); + idx = TclAddLiteralObj(envPtr, objPtr, NULL); } - TclEmitPush(index, envPtr); + TclEmitPush(idx, envPtr); } else { TclCompileSyntaxError(interp, envPtr); } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 4d92468..b8e9312 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1407,7 +1407,7 @@ int Tcl_ExprObj( Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ - register Tcl_Obj *objPtr, /* Points to Tcl object containing expression + Tcl_Obj *objPtr, /* Points to Tcl object containing expression * to evaluate. */ Tcl_Obj **resultPtrPtr) /* Where the Tcl_Obj* that is the expression * result is stored if no errors occur. */ @@ -1526,7 +1526,7 @@ CompileExprObj( Interp *iPtr = (Interp *) interp; CompileEnv compEnv; /* Compilation environment structure allocated * in frame. */ - register ByteCode *codePtr = NULL; + ByteCode *codePtr = NULL; /* Tcl Internal type of bytecode. Initialized * to avoid compiler warning. */ @@ -1680,8 +1680,8 @@ TclCompileObj( const CmdFrame *invoker, int word) { - register Interp *iPtr = (Interp *) interp; - register ByteCode *codePtr; /* Tcl Internal type of bytecode. */ + Interp *iPtr = (Interp *) interp; + ByteCode *codePtr; /* Tcl Internal type of bytecode. */ Namespace *namespacePtr = iPtr->varFramePtr->nsPtr; /* @@ -6806,8 +6806,8 @@ TEBCresume( if (valuePtr->typePtr == &tclBooleanType) { objResultPtr = TCONST(1); } else { - int result = (TclSetBooleanFromAny(NULL, valuePtr) == TCL_OK); - objResultPtr = TCONST(result); + int res = (TclSetBooleanFromAny(NULL, valuePtr) == TCL_OK); + objResultPtr = TCONST(res); } TRACE_WITH_OBJ(("\"%.30s\" => ", O2S(valuePtr)), objResultPtr); NEXT_INST_F(1, 0, 1); @@ -7000,7 +7000,7 @@ TEBCresume( } { ForeachInfo *infoPtr; - Tcl_Obj *listPtr, **elements, *tmpPtr; + Tcl_Obj *listPtr, **elements; ForeachVarList *varListPtr; int numLists, iterMax, listLen, numVars; int iterTmp, iterNum, listTmpDepth; @@ -7286,8 +7286,8 @@ TEBCresume( case INST_DICT_GET: case INST_DICT_EXISTS: { - register Tcl_Interp *interp2 = interp; - register int found; + Tcl_Interp *interp2 = interp; + int found; opnd = TclGetUInt4AtPtr(pc+1); TRACE(("%u => ", opnd)); @@ -9599,7 +9599,7 @@ TclCompareTwoNumbers( static void PrintByteCodeInfo( - register ByteCode *codePtr) /* The bytecode whose summary is printed to + ByteCode *codePtr) /* The bytecode whose summary is printed to * stdout. */ { Proc *procPtr = codePtr->procPtr; @@ -9663,7 +9663,7 @@ PrintByteCodeInfo( #ifdef TCL_COMPILE_DEBUG static void ValidatePcAndStackTop( - register ByteCode *codePtr, /* The bytecode whose summary is printed to + ByteCode *codePtr, /* The bytecode whose summary is printed to * stdout. */ const unsigned char *pc, /* Points to first byte of a bytecode * instruction. The program counter. */ @@ -9906,7 +9906,7 @@ GetSrcInfoForPc( * of the command containing the pc should * be stored. */ { - register int pcOffset = (pc - codePtr->codeStart); + int pcOffset = (pc - codePtr->codeStart); int numCmds = codePtr->numCommands; unsigned char *codeDeltaNext, *codeLengthNext; unsigned char *srcDeltaNext, *srcLengthNext; @@ -10059,9 +10059,9 @@ GetExceptRangeForPc( { ExceptionRange *rangeArrayPtr; int numRanges = codePtr->numExceptRanges; - register ExceptionRange *rangePtr; + ExceptionRange *rangePtr; int pcOffset = pc - codePtr->codeStart; - register int start; + int start; if (numRanges == 0) { return NULL; @@ -10193,11 +10193,11 @@ TclExprFloatError( int TclLog2( - register int value) /* The integer for which to compute the log + int value) /* The integer for which to compute the log * base 2. */ { - register int n = value; - register int result = 0; + int n = value; + int result = 0; while (n > 1) { n = n >> 1; diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 6e1cb1f..513f1fb 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -3244,7 +3244,7 @@ Tcl_LoadFile( } if (fsPtr->loadFileProc != NULL) { - int retVal = ((Tcl_FSLoadFileProc2 *)(void *)(fsPtr->loadFileProc)) + retVal = ((Tcl_FSLoadFileProc2 *)(void *)(fsPtr->loadFileProc)) (interp, pathPtr, handlePtr, &unloadProcPtr, flags); if (retVal == TCL_OK) { diff --git a/generic/tclListObj.c b/generic/tclListObj.c index e0d7bcc..481cae7 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -420,14 +420,14 @@ TclListObjCopy( int Tcl_ListObjGetElements( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - register Tcl_Obj *listPtr, /* List object for which an element array is + Tcl_Obj *listPtr, /* List object for which an element array is * to be returned. */ int *objcPtr, /* Where to store the count of objects * referenced by objv. */ Tcl_Obj ***objvPtr) /* Where to store the pointer to an array of * pointers to the list's objects. */ { - register List *listRepPtr; + List *listRepPtr; if (listPtr->typePtr != &tclListType) { int result; @@ -481,7 +481,7 @@ Tcl_ListObjGetElements( int Tcl_ListObjAppendList( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - register Tcl_Obj *listPtr, /* List object to append elements to. */ + Tcl_Obj *listPtr, /* List object to append elements to. */ Tcl_Obj *elemListPtr) /* List obj with elements to append. */ { int objc; @@ -543,7 +543,7 @@ Tcl_ListObjAppendElement( Tcl_Obj *listPtr, /* List object to append objPtr to. */ Tcl_Obj *objPtr) /* Object to append to listPtr's list. */ { - register List *listRepPtr, *newPtr = NULL; + List *listRepPtr, *newPtr = NULL; int numElems, numRequired, needGrow, isShared, attempt; if (Tcl_IsShared(listPtr)) { @@ -711,11 +711,11 @@ Tcl_ListObjAppendElement( int Tcl_ListObjIndex( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - register Tcl_Obj *listPtr, /* List object to index into. */ - register int index, /* Index of element to return. */ + Tcl_Obj *listPtr, /* List object to index into. */ + int index, /* Index of element to return. */ Tcl_Obj **objPtrPtr) /* The resulting Tcl_Obj* is stored here. */ { - register List *listRepPtr; + List *listRepPtr; if (listPtr->typePtr != &tclListType) { int result; @@ -766,10 +766,10 @@ Tcl_ListObjIndex( int Tcl_ListObjLength( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - register Tcl_Obj *listPtr, /* List object whose #elements to return. */ - register int *intPtr) /* The resulting int is stored here. */ + Tcl_Obj *listPtr, /* List object whose #elements to return. */ + int *intPtr) /* The resulting int is stored here. */ { - register List *listRepPtr; + List *listRepPtr; if (listPtr->typePtr != &tclListType) { int result; @@ -839,7 +839,7 @@ Tcl_ListObjReplace( * insert. */ { List *listRepPtr; - register Tcl_Obj **elemPtrs; + Tcl_Obj **elemPtrs; int needGrow, numElems, numRequired, numAfterLast, start, i, j, isShared; if (Tcl_IsShared(listPtr)) { diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 0f98881..a41d9fd 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -2617,7 +2617,7 @@ DupFsPathInternalRep( static void UpdateStringOfFsPath( - register Tcl_Obj *pathPtr) /* path obj with string rep to update. */ + Tcl_Obj *pathPtr) /* path obj with string rep to update. */ { FsPath *fsPathPtr = PATHOBJ(pathPtr); int cwdLen; diff --git a/generic/tclPkg.c b/generic/tclPkg.c index 06d6ade..0a0c868 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -1137,9 +1137,10 @@ TclNRPackageObjCmd( Tcl_NRAddCallback(interp, PkgRequireCore, (void *)argv3, INT2PTR(newobjc), newObjvPtr, NULL); return TCL_OK; } else { - int i, newobjc = objc-3; Tcl_Obj *const *newobjv = objv + 3; - if (CheckAllRequirements(interp, objc-3, objv+3) != TCL_OK) { + newobjc = objc - 3; + + if (CheckAllRequirements(interp, objc - 3, objv + 3) != TCL_OK) { return TCL_ERROR; } objvListPtr = Tcl_NewListObj(0, NULL); diff --git a/generic/tclTest.c b/generic/tclTest.c index 03f40dd..f1e3fac 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -7398,8 +7398,6 @@ TestconcatobjCmd( "\n\t* (e) concatObj does not have refCount 0", NULL); } if (concatPtr == tmpPtr) { - int len; - result = TCL_ERROR; Tcl_AppendResult(interp, "\n\t* (e) concatObj is not a new obj ", NULL); @@ -7430,8 +7428,6 @@ TestconcatobjCmd( "\n\t* (f) concatObj does not have refCount 0", NULL); } if (concatPtr == tmpPtr) { - int len; - result = TCL_ERROR; Tcl_AppendResult(interp, "\n\t* (f) concatObj is not a new obj ", NULL); @@ -7463,8 +7459,6 @@ TestconcatobjCmd( "\n\t* (g) concatObj does not have refCount 0", NULL); } if (concatPtr == tmpPtr) { - int len; - result = TCL_ERROR; Tcl_AppendResult(interp, "\n\t* (g) concatObj is not a new obj ", NULL); @@ -7559,7 +7553,7 @@ static int InterpCmdResolver( Tcl_Interp *interp, const char *name, - Tcl_Namespace *context, + Tcl_Namespace *dummy, int flags, Tcl_Command *rPtr) { @@ -7569,6 +7563,7 @@ InterpCmdResolver( varFramePtr->procPtr : NULL; Namespace *callerNsPtr = varFramePtr->nsPtr; Tcl_Command resolvedCmdPtr = NULL; + (void)dummy; /* * Just do something special on a cmd literal "z" in two cases: diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index ba1dda6..3fe9d02 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -53,7 +53,7 @@ static int TeststringobjCmd(ClientData dummy, Tcl_Interp *interp, static void VarPtrDeleteProc(ClientData clientData, Tcl_Interp *interp) { - register int i; + int i; Tcl_Obj **varPtr = (Tcl_Obj **) clientData; for (i = 0; i < NUMBER_OF_OBJECT_VARS; i++) { if (varPtr[i]) Tcl_DecrRefCount(varPtr[i]); @@ -91,7 +91,7 @@ int TclObjTest_Init( Tcl_Interp *interp) { - register int i; + int i; /* * An array of Tcl_Obj pointers used in the commands that operate on or get * the values of Tcl object-valued variables. varPtr[i] is the i-th variable's diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 3178441..0228aff 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -136,7 +136,7 @@ static int StringTraceProc(ClientData clientData, static void StringTraceDeleteProc(ClientData clientData); static void DisposeTraceResult(int flags, char *result); static int TraceVarEx(Tcl_Interp *interp, const char *part1, - const char *part2, register VarTrace *tracePtr); + const char *part2, VarTrace *tracePtr); /* * The following structure holds the client data for string-based @@ -1049,7 +1049,7 @@ Tcl_CommandTraceInfo( * call will return the first trace. */ { Command *cmdPtr; - register CommandTrace *tracePtr; + CommandTrace *tracePtr; cmdPtr = (Command *) Tcl_FindCommand(interp, cmdName, NULL, TCL_LEAVE_ERR_MSG); @@ -1114,7 +1114,7 @@ Tcl_TraceCommand( ClientData clientData) /* Arbitrary argument to pass to proc. */ { Command *cmdPtr; - register CommandTrace *tracePtr; + CommandTrace *tracePtr; cmdPtr = (Command *) Tcl_FindCommand(interp, cmdName, NULL, TCL_LEAVE_ERR_MSG); @@ -1177,10 +1177,10 @@ Tcl_UntraceCommand( Tcl_CommandTraceProc *proc, /* Function assocated with trace. */ ClientData clientData) /* Arbitrary argument to pass to proc. */ { - register CommandTrace *tracePtr; + CommandTrace *tracePtr; CommandTrace *prevPtr; Command *cmdPtr; - Interp *iPtr = (Interp *) interp; + Interp *iPtr = (Interp *)interp; ActiveCommandTrace *activePtr; int hasExecTraces = 0; @@ -1255,7 +1255,6 @@ Tcl_UntraceCommand( */ if (cmdPtr->compileProc != NULL) { - Interp *iPtr = (Interp *) interp; iPtr->compileEpoch++; } } @@ -1672,13 +1671,13 @@ TclCheckInterpTraces( static int CallTraceFunction( Tcl_Interp *interp, /* The current interpreter. */ - register Trace *tracePtr, /* Describes the trace function to call. */ + Trace *tracePtr, /* Describes the trace function to call. */ Command *cmdPtr, /* Points to command's Command struct. */ const char *command, /* Points to the first character of the * command's source before substitutions. */ int numChars, /* The number of characters in the command's * source. */ - register int objc, /* Number of arguments for the command. */ + int objc, /* Number of arguments for the command. */ Tcl_Obj *const objv[]) /* Pointers to Tcl_Obj of each argument. */ { Interp *iPtr = (Interp *) interp; @@ -1920,7 +1919,7 @@ TraceExecutionProc( if ((flags & TCL_TRACE_ENTER_EXEC) && (tcmdPtr->stepTrace == NULL) && (tcmdPtr->flags & (TCL_TRACE_ENTER_DURING_EXEC | TCL_TRACE_LEAVE_DURING_EXEC))) { - register unsigned len = strlen(command) + 1; + unsigned len = strlen(command) + 1; tcmdPtr->startLevel = level; tcmdPtr->startCmd = ckalloc(len); @@ -2065,7 +2064,7 @@ TraceVarProc( } } if (destroy && result != NULL) { - register Tcl_Obj *errMsgObj = (Tcl_Obj *) result; + Tcl_Obj *errMsgObj = (Tcl_Obj *) result; Tcl_DecrRefCount(errMsgObj); result = NULL; @@ -2142,8 +2141,8 @@ Tcl_CreateObjTrace( Tcl_CmdObjTraceDeleteProc *delProc) /* Function to call when trace is deleted */ { - register Trace *tracePtr; - register Interp *iPtr = (Interp *) interp; + Trace *tracePtr; + Interp *iPtr = (Interp *) interp; /* * Test if this trace allows inline compilation of commands. @@ -2342,7 +2341,7 @@ Tcl_DeleteTrace( { Interp *iPtr = (Interp *) interp; Trace *prevPtr, *tracePtr = (Trace *) trace; - register Trace **tracePtr2 = &iPtr->tracePtr; + Trace **tracePtr2 = &iPtr->tracePtr; ActiveInterpTrace *activePtr; /* @@ -2534,7 +2533,7 @@ TclCheckArrayTraces( int TclObjCallVarTraces( Interp *iPtr, /* Interpreter containing variable. */ - register Var *arrayPtr, /* Pointer to array variable that contains the + Var *arrayPtr, /* Pointer to array variable that contains the * variable, or NULL if the variable isn't an * element of an array. */ Var *varPtr, /* Variable whose traces are to be invoked. */ @@ -2568,7 +2567,7 @@ TclObjCallVarTraces( int TclCallVarTraces( Interp *iPtr, /* Interpreter containing variable. */ - register Var *arrayPtr, /* Pointer to array variable that contains the + Var *arrayPtr, /* Pointer to array variable that contains the * variable, or NULL if the variable isn't an * element of an array. */ Var *varPtr, /* Variable whose traces are to be invoked. */ @@ -2581,7 +2580,7 @@ TclCallVarTraces( * error, then leave an error message and * stack trace information in *iPTr. */ { - register VarTrace *tracePtr; + VarTrace *tracePtr; ActiveVarTrace active; char *result; const char *openParen, *p; @@ -2909,7 +2908,7 @@ Tcl_UntraceVar2( Tcl_VarTraceProc *proc, /* Function assocated with trace. */ ClientData clientData) /* Arbitrary argument to pass to proc. */ { - register VarTrace *tracePtr; + VarTrace *tracePtr; VarTrace *prevPtr, *nextPtr; Var *varPtr, *arrayPtr; Interp *iPtr = (Interp *) interp; @@ -3099,7 +3098,7 @@ Tcl_VarTraceInfo2( hPtr = Tcl_FindHashEntry(&iPtr->varTraces, (char *) varPtr); if (hPtr) { - register VarTrace *tracePtr = Tcl_GetHashValue(hPtr); + VarTrace *tracePtr = Tcl_GetHashValue(hPtr); if (prevClientData != NULL) { for (; tracePtr != NULL; tracePtr = tracePtr->nextPtr) { @@ -3195,7 +3194,7 @@ Tcl_TraceVar2( * invoked upon varName. */ ClientData clientData) /* Arbitrary argument to pass to proc. */ { - register VarTrace *tracePtr; + VarTrace *tracePtr; int result; tracePtr = ckalloc(sizeof(VarTrace)); @@ -3240,7 +3239,7 @@ TraceVarEx( const char *part2, /* Name of element within array; NULL means * trace applies to scalar variable or array * as-a-whole. */ - register VarTrace *tracePtr)/* Structure containing flags, traceProc and + VarTrace *tracePtr)/* Structure containing flags, traceProc and * clientData fields. Others should be left * blank. Will be ckfree()d (eventually) if * this function returns TCL_OK, and up to diff --git a/generic/tclVar.c b/generic/tclVar.c index 5d8d88c..b7567a8 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -123,17 +123,17 @@ VarHashNextVar( * access is denied. */ -static const char *noSuchVar = "no such variable"; -static const char *isArray = "variable is array"; -static const char *needArray = "variable isn't array"; -static const char *noSuchElement = "no such element in array"; -static const char *danglingElement = +static const char NOSUCHVAR[] = "no such variable"; +static const char ISARRAY[] = "variable is array"; +static const char NEEDARRAY[] = "variable isn't array"; +static const char NOSUCHELEMENT[] = "no such element in array"; +static const char DANGLINGELEMENT[] = "upvar refers to element in deleted array"; -static const char *danglingVar = +static const char DANGLINGVAR[] = "upvar refers to variable in deleted namespace"; -static const char *badNamespace = "parent namespace doesn't exist"; -static const char *missingName = "missing variable name"; -static const char *isArrayElement = +static const char BADNAMESPACE[] = "parent namespace doesn't exist"; +static const char MISSINGNAME[] = "missing variable name"; +static const char ISARRAYELEMENT[] = "name refers to an element in an array"; /* @@ -613,7 +613,7 @@ TclObjLookupVarEx( if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, msg, - noSuchVar, -1); + NOSUCHVAR, -1); Tcl_SetErrorCode(interp, "TCL", "VALUE", "VARNAME", NULL); } return NULL; @@ -648,7 +648,7 @@ TclObjLookupVarEx( if (part2Ptr != NULL) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, msg, - needArray, -1); + NEEDARRAY, -1); Tcl_SetErrorCode(interp, "TCL", "VALUE", "VARNAME", NULL); } @@ -942,10 +942,10 @@ TclLookupSimpleVar( TclGetNamespaceForQualName(interp, varName, cxtNsPtr, flags, &varNsPtr, &dummy1Ptr, &dummy2Ptr, &tail); if (varNsPtr == NULL) { - *errMsgPtr = badNamespace; + *errMsgPtr = BADNAMESPACE; return NULL; } else if (tail == NULL) { - *errMsgPtr = missingName; + *errMsgPtr = MISSINGNAME; return NULL; } if (tail != varName) { @@ -967,7 +967,7 @@ TclLookupSimpleVar( *indexPtr = -2; } } else { /* Var wasn't found and not to create it. */ - *errMsgPtr = noSuchVar; + *errMsgPtr = NOSUCHVAR; return NULL; } } @@ -1007,7 +1007,7 @@ TclLookupSimpleVar( varPtr = VarHashFindVar(tablePtr, varNamePtr); } if (varPtr == NULL) { - *errMsgPtr = noSuchVar; + *errMsgPtr = NOSUCHVAR; } } } @@ -1087,7 +1087,7 @@ TclLookupArrayElement( if (!createArray) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, arrayNamePtr, elNamePtr, msg, - noSuchVar, index); + NOSUCHVAR, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", arrayNamePtr?TclGetString(arrayNamePtr):NULL, NULL); } @@ -1102,7 +1102,7 @@ TclLookupArrayElement( if (TclIsVarDeadHash(arrayPtr)) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, arrayNamePtr, elNamePtr, msg, - danglingVar, index); + DANGLINGVAR, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", arrayNamePtr?TclGetString(arrayNamePtr):NULL, NULL); } @@ -1121,7 +1121,7 @@ TclLookupArrayElement( TclInitVarHashTable(arrayPtr->value.tablePtr, nsPtr); } else if (!TclIsVarArray(arrayPtr)) { if (flags & TCL_LEAVE_ERR_MSG) { - TclObjVarErrMsg(interp, arrayNamePtr, elNamePtr, msg, needArray, + TclObjVarErrMsg(interp, arrayNamePtr, elNamePtr, msg, NEEDARRAY, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", arrayNamePtr?TclGetString(arrayNamePtr):NULL, NULL); @@ -1143,7 +1143,7 @@ TclLookupArrayElement( if (varPtr == NULL) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, arrayNamePtr, elNamePtr, msg, - noSuchElement, index); + NOSUCHELEMENT, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ELEMENT", TclGetString(elNamePtr), NULL); } @@ -1469,11 +1469,11 @@ TclPtrGetVarIdx( if (flags & TCL_LEAVE_ERR_MSG) { if (TclIsVarUndefined(varPtr) && arrayPtr && !TclIsVarUndefined(arrayPtr)) { - msg = noSuchElement; + msg = NOSUCHELEMENT; } else if (TclIsVarArray(varPtr)) { - msg = isArray; + msg = ISARRAY; } else { - msg = noSuchVar; + msg = NOSUCHVAR; } TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "read", msg, index); } @@ -1887,11 +1887,11 @@ TclPtrSetVarIdx( if (flags & TCL_LEAVE_ERR_MSG) { if (TclIsVarArrayElement(varPtr)) { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "set", - danglingElement, index); + DANGLINGELEMENT, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ELEMENT", NULL); } else { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "set", - danglingVar, index); + DANGLINGVAR, index); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", NULL); } } @@ -1904,7 +1904,7 @@ TclPtrSetVarIdx( if (TclIsVarArray(varPtr)) { if (flags & TCL_LEAVE_ERR_MSG) { - TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "set", isArray,index); + TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "set", ISARRAY,index); Tcl_SetErrorCode(interp, "TCL", "WRITE", "ARRAY", NULL); } goto earlyError; @@ -2502,7 +2502,7 @@ TclPtrUnsetVarIdx( if (result != TCL_OK) { if (flags & TCL_LEAVE_ERR_MSG) { TclObjVarErrMsg(interp, part1Ptr, part2Ptr, "unset", - ((arrayPtr == NULL) ? noSuchVar : noSuchElement), index); + ((arrayPtr == NULL) ? NOSUCHVAR : NOSUCHELEMENT), index); Tcl_SetErrorCode(interp, "TCL", "UNSET", "VARNAME", NULL); } } @@ -3697,7 +3697,7 @@ ArraySetCmd( } if (arrayPtr) { CleanupVar(varPtr, arrayPtr); - TclObjVarErrMsg(interp, arrayNameObj, NULL, "set", needArray, -1); + TclObjVarErrMsg(interp, arrayNameObj, NULL, "set", NEEDARRAY, -1); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", TclGetString(arrayNameObj), NULL); return TCL_ERROR; @@ -3815,7 +3815,7 @@ ArraySetCmd( */ TclObjVarErrMsg(interp, arrayNameObj, NULL, "array set", - needArray, -1); + NEEDARRAY, -1); Tcl_SetErrorCode(interp, "TCL", "WRITE", "ARRAY", NULL); return TCL_ERROR; } @@ -4718,7 +4718,7 @@ Tcl_VariableObjCmd( */ TclObjVarErrMsg(interp, varNamePtr, NULL, "define", - isArrayElement, -1); + ISARRAYELEMENT, -1); Tcl_SetErrorCode(interp, "TCL", "UPVAR", "LOCAL_ELEMENT", NULL); return TCL_ERROR; } diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 752aa0c..6cfeae1 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1091,7 +1091,6 @@ TclpMatchInDirectory( do { const char *utfname; int checkDrive = 0, isDrive; - DWORD attr; native = data.cFileName; attr = data.dwFileAttributes; @@ -1441,7 +1440,6 @@ TclpGetUserHome( int rc = 0; const char *domain; WCHAR *wName, *wHomeDir, *wDomain; - WCHAR buf[MAX_PATH]; Tcl_DStringInit(bufferPtr); @@ -1505,6 +1503,7 @@ TclpGetUserHome( size = lstrlenW(wHomeDir); Tcl_WinTCharToUtf((TCHAR *)wHomeDir, size*sizeof(WCHAR), bufferPtr); } else { + WCHAR buf[MAX_PATH]; /* * User exists but has no home dir. Return * "{GetProfilesDirectory}/". @@ -2801,7 +2800,6 @@ TclpObjNormalizePath( */ int len; - char *path; Tcl_Obj *tmpPathPtr; tmpPathPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 098ead4..204ad85 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -3231,7 +3231,7 @@ TclpOpenTemporaryFile( Tcl_DStringFree(&buf); } else { const WCHAR *baseStr = L"TCL"; - int length = 3 * sizeof(WCHAR); + length = 3 * sizeof(WCHAR); memcpy(namePtr, baseStr, length); namePtr += length; diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 9023928..6946907 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1779,7 +1779,7 @@ SerialSetOptionProc( */ if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) { - int i, result = TCL_OK; + int i, res = TCL_OK; if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) { return TCL_ERROR; @@ -1797,7 +1797,7 @@ SerialSetOptionProc( for (i = 0; i < argc - 1; i += 2) { if (Tcl_GetBoolean(interp, argv[i+1], &flag) == TCL_ERROR) { - result = TCL_ERROR; + res = TCL_ERROR; break; } if (strncasecmp(argv[i], "DTR", strlen(argv[i])) == 0) { @@ -1809,7 +1809,7 @@ SerialSetOptionProc( Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "TTY_SIGNAL", NULL); } - result = TCL_ERROR; + res = TCL_ERROR; break; } } else if (strncasecmp(argv[i], "RTS", strlen(argv[i])) == 0) { @@ -1821,7 +1821,7 @@ SerialSetOptionProc( Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "TTY_SIGNAL", NULL); } - result = TCL_ERROR; + res = TCL_ERROR; break; } } else if (strncasecmp(argv[i], "BREAK", strlen(argv[i])) == 0) { @@ -1833,7 +1833,7 @@ SerialSetOptionProc( Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "TTY_SIGNAL", NULL); } - result = TCL_ERROR; + res = TCL_ERROR; break; } } else { @@ -1844,13 +1844,13 @@ SerialSetOptionProc( Tcl_SetErrorCode(interp, "TCL", "VALUE", "TTY_SIGNAL", NULL); } - result = TCL_ERROR; + res = TCL_ERROR; break; } } ckfree(argv); - return result; + return res; } /* -- cgit v0.12 From 8e25003fbdf3944a74c18de378c302a89d0257b8 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 28 Sep 2020 13:02:46 +0000 Subject: Revert change that made test expr-20.2 fail. --- generic/tclCompExpr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 2f3fecb..476ff14 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2463,7 +2463,7 @@ CompileExprTree( if (optimize) { int length; const char *bytes = TclGetStringFromObj(literal, &length); - int idx = TclRegisterLiteral(envPtr, bytes, length, 0); + int index = TclRegisterLiteral(envPtr, bytes, length, 0); Tcl_Obj *objPtr = TclFetchLiteral(envPtr, index); if ((objPtr->typePtr == NULL) && (literal->typePtr != NULL)) { @@ -2484,7 +2484,7 @@ CompileExprTree( objPtr->internalRep = literal->internalRep; literal->typePtr = NULL; } - TclEmitPush(idx, envPtr); + TclEmitPush(index, envPtr); } else { /* * When optimize==0, we know the expression is a one-off and @@ -2510,7 +2510,7 @@ CompileExprTree( if (ExecConstantExprTree(interp, nodes, next, litObjvPtr) == TCL_OK) { - int idx; + int index; Tcl_Obj *objPtr = Tcl_GetObjResult(interp); /* @@ -2524,8 +2524,8 @@ CompileExprTree( const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes); - idx = TclRegisterLiteral(envPtr, bytes, numBytes, 0); - tableValue = TclFetchLiteral(envPtr, idx); + index = TclRegisterLiteral(envPtr, bytes, numBytes, 0); + tableValue = TclFetchLiteral(envPtr, index); if ((tableValue->typePtr == NULL) && (objPtr->typePtr != NULL)) { /* @@ -2537,9 +2537,9 @@ CompileExprTree( objPtr->typePtr = NULL; } } else { - idx = TclAddLiteralObj(envPtr, objPtr, NULL); + index = TclAddLiteralObj(envPtr, objPtr, NULL); } - TclEmitPush(idx, envPtr); + TclEmitPush(index, envPtr); } else { TclCompileSyntaxError(interp, envPtr); } -- cgit v0.12 From 2a48060425e9950430f17b41d93732318786f5af Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 28 Sep 2020 13:34:57 +0000 Subject: Restore change with correction. --- generic/tclCompExpr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 476ff14..a630ad4 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2463,8 +2463,8 @@ CompileExprTree( if (optimize) { int length; const char *bytes = TclGetStringFromObj(literal, &length); - int index = TclRegisterLiteral(envPtr, bytes, length, 0); - Tcl_Obj *objPtr = TclFetchLiteral(envPtr, index); + int idx = TclRegisterLiteral(envPtr, bytes, length, 0); + Tcl_Obj *objPtr = TclFetchLiteral(envPtr, idx); if ((objPtr->typePtr == NULL) && (literal->typePtr != NULL)) { /* @@ -2484,7 +2484,7 @@ CompileExprTree( objPtr->internalRep = literal->internalRep; literal->typePtr = NULL; } - TclEmitPush(index, envPtr); + TclEmitPush(idx, envPtr); } else { /* * When optimize==0, we know the expression is a one-off and @@ -2510,7 +2510,7 @@ CompileExprTree( if (ExecConstantExprTree(interp, nodes, next, litObjvPtr) == TCL_OK) { - int index; + int idx; Tcl_Obj *objPtr = Tcl_GetObjResult(interp); /* @@ -2524,8 +2524,8 @@ CompileExprTree( const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes); - index = TclRegisterLiteral(envPtr, bytes, numBytes, 0); - tableValue = TclFetchLiteral(envPtr, index); + idx = TclRegisterLiteral(envPtr, bytes, numBytes, 0); + tableValue = TclFetchLiteral(envPtr, idx); if ((tableValue->typePtr == NULL) && (objPtr->typePtr != NULL)) { /* @@ -2537,9 +2537,9 @@ CompileExprTree( objPtr->typePtr = NULL; } } else { - index = TclAddLiteralObj(envPtr, objPtr, NULL); + idx = TclAddLiteralObj(envPtr, objPtr, NULL); } - TclEmitPush(index, envPtr); + TclEmitPush(idx, envPtr); } else { TclCompileSyntaxError(interp, envPtr); } -- cgit v0.12 From 38b30033c88080b592fdbc043f295bc9b4e97b5d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 28 Sep 2020 15:00:02 +0000 Subject: Update internal zlib channel type from TCL_CHANNEL_VERSION_3 to TCL_CHANNEL_VERSION_5. Not actually a change, since supported procs are the same. So all internal channels have the same type --- generic/tclZlib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 604ce64..bdda9bc 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -205,7 +205,7 @@ static void ZlibTransformTimerRun(ClientData clientData); static const Tcl_ChannelType zlibChannelType = { "zlib", - TCL_CHANNEL_VERSION_3, + TCL_CHANNEL_VERSION_5, ZlibTransformClose, ZlibTransformInput, ZlibTransformOutput, @@ -2664,21 +2664,21 @@ ZlibStreamAddCmd( switch ((enum addOptions) index) { case ao_flush: /* -flush */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_SYNC_FLUSH; } break; case ao_fullflush: /* -fullflush */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_FULL_FLUSH; } break; case ao_finalize: /* -finalize */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_FINISH; @@ -2788,21 +2788,21 @@ ZlibStreamPutCmd( switch ((enum putOptions) index) { case po_flush: /* -flush */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_SYNC_FLUSH; } break; case po_fullflush: /* -fullflush */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_FULL_FLUSH; } break; case po_finalize: /* -finalize */ - if (flush > -1) { + if (flush >= 0) { flush = -2; } else { flush = Z_FINISH; @@ -3683,7 +3683,7 @@ ZlibStackChannelTransform( if (cd->inAllocated < cd->readAheadLimit) { cd->inAllocated = cd->readAheadLimit; } - cd->inBuffer = ckalloc(cd->inAllocated); + cd->inBuffer = (char *)ckalloc(cd->inAllocated); if (cd->flags & IN_HEADER) { if (inflateGetHeader(&cd->inStream, &cd->inHeader.header) != Z_OK) { goto error; -- cgit v0.12 From 2342babe990ebbf9e046143ce965996fc5701abc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 29 Sep 2020 07:14:00 +0000 Subject: Add -Wshadow flag to the compiler, so we will be notified when (accidently) shadowing variable names --- macosx/Tcl-Common.xcconfig | 2 +- unix/configure | 2 +- unix/tcl.m4 | 2 +- win/configure | 2 +- win/tcl.m4 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/macosx/Tcl-Common.xcconfig b/macosx/Tcl-Common.xcconfig index 0670479..39301db 100644 --- a/macosx/Tcl-Common.xcconfig +++ b/macosx/Tcl-Common.xcconfig @@ -19,7 +19,7 @@ GCC_NO_COMMON_BLOCKS = YES GCC_DYNAMIC_NO_PIC = YES GCC_VERSION = 4.2 GCC = gcc-$(GCC_VERSION) -WARNING_CFLAGS = -Wall -Wwrite-strings -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-value -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS) +WARNING_CFLAGS = -Wall -Wextra -Wshadow -Wwrite-strings -Wpointer-arith -Wc++-compat -Wdeclaration-after-statement -Winit-self -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS) BINDIR = $(PREFIX)/bin CFLAGS = $(CFLAGS) CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS) diff --git a/unix/configure b/unix/configure index d3a4856..29857ce 100755 --- a/unix/configure +++ b/unix/configure @@ -5036,7 +5036,7 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wwrite-strings -Wpointer-arith" case "${CC}" in *++|*++-*) ;; diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 056cf1f..ea3d968 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -966,7 +966,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g AS_IF([test "$GCC" = yes], [ CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wwrite-strings -Wpointer-arith" case "${CC}" in *++|*++-*) ;; diff --git a/win/configure b/win/configure index f099510..7ad386c 100755 --- a/win/configure +++ b/win/configure @@ -4216,7 +4216,7 @@ $as_echo "using shared flags" >&6; } CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wwrite-strings -Wpointer-arith" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= diff --git a/win/tcl.m4 b/win/tcl.m4 index 4824e8e..989ea76 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -673,7 +673,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wwrite-strings -Wpointer-arith" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= -- cgit v0.12 From 43e27f10a51ad6b206f06c50ea0cd4653bba694a Mon Sep 17 00:00:00 2001 From: oehhar Date: Tue, 29 Sep 2020 08:15:32 +0000 Subject: Ticket [0063cbcada]: check http::geturl -headers parameter to be a dict. --- library/http/http.tcl | 6 ++++-- tests/http.test | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index cce1828..abef596 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -733,6 +733,7 @@ proc http::geturl {url args} { -strict boolean -timeout integer -validate boolean + -headers list } set state(charset) $defaultCharset set options { @@ -747,8 +748,9 @@ proc http::geturl {url args} { if {[regexp -- $pat $flag]} { # Validate numbers if { - [info exists type($flag)] && - ![string is $type($flag) -strict $value] + ([info exists type($flag)] && + ![string is $type($flag) -strict $value]) || + $flag eq "-headers" && [llength $value] %2 != 0 } { unset $token return -code error \ diff --git a/tests/http.test b/tests/http.test index 636a651..bd776c6 100644 --- a/tests/http.test +++ b/tests/http.test @@ -448,6 +448,12 @@ test http-3.33 {http::geturl application/xml is text} -body { } -cleanup { catch { http::cleanup $token } } -result {test 4660 /test} +test http-3.34 {http::geturl -headers not a dict} -returnCodes error -body { + http::geturl http://test/t -headers NoDict +} -result {Bad value for -headers (NoDict), must be list} +test http-3.2 {http::geturl} -returnCodes error -body { + http::geturl http:junk +} -result {Unsupported URL: http:junk} test http-4.1 {http::Event} -body { set token [http::geturl $url -keepalive 0] -- cgit v0.12 From 2b01204e41b60fe88eae701bd56dc28b0f33926e Mon Sep 17 00:00:00 2001 From: oehhar Date: Tue, 29 Sep 2020 16:12:12 +0000 Subject: Remove wrong copy of test case http-3.2 --- tests/http.test | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/http.test b/tests/http.test index bd776c6..15bc37f 100644 --- a/tests/http.test +++ b/tests/http.test @@ -451,9 +451,6 @@ test http-3.33 {http::geturl application/xml is text} -body { test http-3.34 {http::geturl -headers not a dict} -returnCodes error -body { http::geturl http://test/t -headers NoDict } -result {Bad value for -headers (NoDict), must be list} -test http-3.2 {http::geturl} -returnCodes error -body { - http::geturl http:junk -} -result {Unsupported URL: http:junk} test http-4.1 {http::Event} -body { set token [http::geturl $url -keepalive 0] -- cgit v0.12 From 20d206c4c2207a55f0d7bb4f0f81175deef3074f Mon Sep 17 00:00:00 2001 From: oehhar Date: Wed, 30 Sep 2020 12:19:53 +0000 Subject: Ticket [0063cbcada]: From tcl 8.7 on, use "string is dict" instead "string is list" & length %2 == 0 to check for a valid dict --- library/http/http.tcl | 7 +++---- tests/http.test | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index 2dfcb8b..58bbee1 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -746,7 +746,7 @@ proc http::geturl {url args} { -strict boolean -timeout integer -validate boolean - -headers list + -headers dict } set state(charset) $defaultCharset set options { @@ -761,9 +761,8 @@ proc http::geturl {url args} { if {[regexp -- $pat $flag]} { # Validate numbers if { - ([info exists type($flag)] && - ![string is $type($flag) -strict $value]) || - $flag eq "-headers" && [llength $value] %2 != 0 + [info exists type($flag)] && + ![string is $type($flag) -strict $value] } { unset $token return -code error \ diff --git a/tests/http.test b/tests/http.test index b83ddef..a525691 100644 --- a/tests/http.test +++ b/tests/http.test @@ -446,7 +446,7 @@ test http-3.33 {http::geturl application/xml is text} -body { } -result {test 4660 /test} test http-3.34 {http::geturl -headers not a dict} -returnCodes error -body { http::geturl http://test/t -headers NoDict -} -result {Bad value for -headers (NoDict), must be list} +} -result {Bad value for -headers (NoDict), must be dict} test http-4.1 {http::Event} -body { set token [http::geturl $url -keepalive 0] -- cgit v0.12 From 195ea285daa186e7d78e1c8c99e4e5dfe373a603 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 30 Sep 2020 14:29:16 +0000 Subject: TIP #581 tweak: Don't report "slaves" as valid option for "interp" --- generic/tclInterp.c | 29 ++++++++++++++++++++--------- tests/interp.test | 8 ++++---- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 6417668..434d9f4 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -621,30 +621,41 @@ NRInterpCmd( static const char *const options[] = { "alias", "aliases", "bgerror", "cancel", "children", "create", "debug", "delete", + "eval", "exists", "expose", "hide", + "hidden", "issafe", "invokehidden", + "limit", "marktrusted", "recursionlimit", + "share", "slaves", "target", "transfer", + NULL + }; + static const char *const optionsNoSlaves[] = { + "alias", "aliases", "bgerror", "cancel", + "children", "create", "debug", "delete", "eval", "exists", "expose", "hide", "hidden", "issafe", "invokehidden", "limit", "marktrusted", "recursionlimit", - "slaves", "share", "target", "transfer", - NULL + "share", "target", "transfer", NULL }; enum option { OPT_ALIAS, OPT_ALIASES, OPT_BGERROR, OPT_CANCEL, OPT_CHILDREN, OPT_CREATE, OPT_DEBUG, OPT_DELETE, - OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, - OPT_HIDE, OPT_HIDDEN, OPT_ISSAFE, - OPT_INVOKEHID, OPT_LIMIT, OPT_MARKTRUSTED,OPT_RECLIMIT, - OPT_SLAVES, OPT_SHARE, OPT_TARGET, OPT_TRANSFER + OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, OPT_HIDE, + OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHID, + OPT_LIMIT, OPT_MARKTRUSTED,OPT_RECLIMIT, + OPT_SHARE, OPT_SLAVES, OPT_TARGET, OPT_TRANSFER }; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "cmd ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], options, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(NULL, objv[1], options, + "option", 0, &index) != TCL_OK) { + /* Don't report the "slaves" option as possibility */ + Tcl_GetIndexFromObj(interp, objv[1], optionsNoSlaves, + "option", 0, &index); return TCL_ERROR; } - switch ((enum option) index) { + switch ((enum option)index) { case OPT_ALIAS: { Tcl_Interp *parentInterp; diff --git a/tests/interp.test b/tests/interp.test index 4453d90..f428207 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -32,7 +32,7 @@ test interp-1.1 {options for interp command} -returnCodes error -body { } -result {wrong # args: should be "interp cmd ?arg ...?"} test interp-1.2 {options for interp command} -returnCodes error -body { interp frobox -} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "frobox": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer} test interp-1.3 {options for interp command} { interp delete } "" @@ -50,13 +50,13 @@ test interp-1.6 {options for interp command} -returnCodes error -body { } -result {wrong # args: should be "interp children ?path?"} test interp-1.7 {options for interp command} -returnCodes error -body { interp hello -} -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "hello": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer} test interp-1.8 {options for interp command} -returnCodes error -body { interp -froboz -} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer} test interp-1.9 {options for interp command} -returnCodes error -body { interp -froboz -safe -} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, slaves, share, target, or transfer} +} -result {bad option "-froboz": must be alias, aliases, bgerror, cancel, children, create, debug, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, limit, marktrusted, recursionlimit, share, target, or transfer} test interp-1.10 {options for interp command} -returnCodes error -body { interp target } -result {wrong # args: should be "interp target path alias"} -- cgit v0.12 From 1f4f47ccf50b4d6518c3dbfd9fd09c7bbb785929 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 30 Sep 2020 14:49:15 +0000 Subject: (slightly) better error-message for invalid http -headers option. This works for plain 8.6 too --- library/http/http.tcl | 8 +++----- tests/http.test | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/library/http/http.tcl b/library/http/http.tcl index abef596..b0f87de 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -733,7 +733,7 @@ proc http::geturl {url args} { -strict boolean -timeout integer -validate boolean - -headers list + -headers dict } set state(charset) $defaultCharset set options { @@ -747,10 +747,8 @@ proc http::geturl {url args} { foreach {flag value} $args { if {[regexp -- $pat $flag]} { # Validate numbers - if { - ([info exists type($flag)] && - ![string is $type($flag) -strict $value]) || - $flag eq "-headers" && [llength $value] %2 != 0 + if {($flag eq "-headers") ? [catch {dict size $value}] : + ([info exists type($flag)] && ![string is $type($flag) -strict $value]) } { unset $token return -code error \ diff --git a/tests/http.test b/tests/http.test index 15bc37f..97e6cfa 100644 --- a/tests/http.test +++ b/tests/http.test @@ -450,7 +450,7 @@ test http-3.33 {http::geturl application/xml is text} -body { } -result {test 4660 /test} test http-3.34 {http::geturl -headers not a dict} -returnCodes error -body { http::geturl http://test/t -headers NoDict -} -result {Bad value for -headers (NoDict), must be list} +} -result {Bad value for -headers (NoDict), must be dict} test http-4.1 {http::Event} -body { set token [http::geturl $url -keepalive 0] -- cgit v0.12 From b7c4b811ec358b518d9a5ceaf204a84a5e5b59a8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 2 Oct 2020 16:28:09 +0000 Subject: Fix -Wshadow warnings, when compiling with a C++ compiler --- generic/regcomp.c | 32 ++++++++++++++++---------------- generic/tclCmdIL.c | 4 ++-- generic/tclCmdMZ.c | 26 ++++++++++++++------------ generic/tclCompCmdsSZ.c | 4 ++-- generic/tclEvent.c | 4 ++-- generic/tclFileName.c | 4 ++-- generic/tclIOCmd.c | 10 +++++----- generic/tclIndexObj.c | 4 ++-- generic/tclInterp.c | 12 ++++++------ generic/tclLoad.c | 10 +++++----- generic/tclPkg.c | 4 ++-- generic/tclProcess.c | 4 ++-- generic/tclTest.c | 8 ++++---- generic/tclTimer.c | 2 +- generic/tclTrace.c | 4 ++-- generic/tclVar.c | 8 ++++---- generic/tclZlib.c | 4 ++-- 17 files changed, 73 insertions(+), 71 deletions(-) diff --git a/generic/regcomp.c b/generic/regcomp.c index 99dfef1..3be5172 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -56,7 +56,7 @@ static const chr *scanplain(struct vars *); static void onechr(struct vars *, pchr, struct state *, struct state *); static void dovec(struct vars *, struct cvec *, struct state *, struct state *); static void wordchrs(struct vars *); -static struct subre *subre(struct vars *, int, int, struct state *, struct state *); +static struct subre *sub_re(struct vars *, int, int, struct state *, struct state *); static void freesubre(struct vars *, struct subre *); static void freesrnode(struct vars *, struct subre *); static int numst(struct subre *, int); @@ -663,7 +663,7 @@ parse( assert(stopper == ')' || stopper == EOS); - branches = subre(v, '|', LONGER, init, final); + branches = sub_re(v, '|', LONGER, init, final); NOERRN(); branch = branches; firstbranch = 1; @@ -673,7 +673,7 @@ parse( * Need a place to hang the branch. */ - branch->right = subre(v, '|', LONGER, init, final); + branch->right = sub_re(v, '|', LONGER, init, final); NOERRN(); branch = branch->right; } @@ -744,7 +744,7 @@ parsebranch( lp = left; seencontent = 0; - t = subre(v, '=', 0, left, right); /* op '=' is tentative */ + t = sub_re(v, '=', 0, left, right); /* op '=' is tentative */ NOERRN(); while (!SEE('|') && !SEE(stopper) && !SEE(EOS)) { if (seencontent) { /* implicit concat operator */ @@ -977,7 +977,7 @@ parseqatom( NOERR(); if (cap) { v->subs[subno] = atom; - t = subre(v, '(', atom->flags|CAP, lp, rp); + t = sub_re(v, '(', atom->flags|CAP, lp, rp); NOERR(); t->subno = subno; t->left = atom; @@ -995,7 +995,7 @@ parseqatom( INSIST(v->subs[v->nextvalue] != NULL, REG_ESUBREG); NOERR(); assert(v->nextvalue > 0); - atom = subre(v, 'b', BACKR, lp, rp); + atom = sub_re(v, 'b', BACKR, lp, rp); NOERR(); subno = v->nextvalue; atom->subno = subno; @@ -1110,7 +1110,7 @@ parseqatom( */ if (atom == NULL) { - atom = subre(v, '=', 0, lp, rp); + atom = sub_re(v, '=', 0, lp, rp); NOERR(); } @@ -1147,7 +1147,7 @@ parseqatom( * Break remaining subRE into x{...} and what follows. */ - t = subre(v, '.', COMBINE(qprefer, atom->flags), lp, rp); + t = sub_re(v, '.', COMBINE(qprefer, atom->flags), lp, rp); NOERR(); t->left = atom; atomp = &t->left; @@ -1161,7 +1161,7 @@ parseqatom( */ assert(top->op == '=' && top->left == NULL && top->right == NULL); - top->left = subre(v, '=', top->flags, top->begin, lp); + top->left = sub_re(v, '=', top->flags, top->begin, lp); NOERR(); top->op = '.'; top->right = t; @@ -1230,9 +1230,9 @@ parseqatom( assert(m >= 1 && m != DUPINF && n >= 1); repeat(v, s, atom->begin, m-1, (n == DUPINF) ? n : n-1); f = COMBINE(qprefer, atom->flags); - t = subre(v, '.', f, s, atom->end); /* prefix and atom */ + t = sub_re(v, '.', f, s, atom->end); /* prefix and atom */ NOERR(); - t->left = subre(v, '=', PREF(f), s, atom->begin); + t->left = sub_re(v, '=', PREF(f), s, atom->begin); NOERR(); t->right = atom; *atomp = t; @@ -1247,7 +1247,7 @@ parseqatom( dupnfa(v->nfa, atom->begin, atom->end, s, s2); repeat(v, s, s2, m, n); f = COMBINE(qprefer, atom->flags); - t = subre(v, '*', f, s, s2); + t = sub_re(v, '*', f, s, s2); NOERR(); t->min = (short) m; t->max = (short) n; @@ -1265,7 +1265,7 @@ parseqatom( t->right = parsebranch(v, stopper, type, s2, rp, 1); } else { EMPTYARC(s2, rp); - t->right = subre(v, '=', 0, s2, rp); + t->right = sub_re(v, '=', 0, s2, rp); } NOERR(); assert(SEE('|') || SEE(stopper) || SEE(EOS)); @@ -1717,12 +1717,12 @@ wordchrs( } /* - - subre - allocate a subre - ^ static struct subre *subre(struct vars *, int, int, struct state *, + - sub_re - allocate a subre + ^ static struct subre *sub_re(struct vars *, int, int, struct state *, ^ struct state *); */ static struct subre * -subre( +sub_re( struct vars *v, int op, int flags, diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index df2decb..e8e69b2 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3157,7 +3157,7 @@ Tcl_LsearchObjCmd( "-real", "-regexp", "-sorted", "-start", "-stride", "-subindices", NULL }; - enum options { + enum lsearchoptions { LSEARCH_ALL, LSEARCH_ASCII, LSEARCH_BISECT, LSEARCH_DECREASING, LSEARCH_DICTIONARY, LSEARCH_EXACT, LSEARCH_GLOB, LSEARCH_INCREASING, LSEARCH_INDEX, LSEARCH_INLINE, LSEARCH_INTEGER, LSEARCH_NOCASE, @@ -3205,7 +3205,7 @@ Tcl_LsearchObjCmd( result = TCL_ERROR; goto done; } - switch ((enum options) index) { + switch ((enum lsearchoptions) index) { case LSEARCH_ALL: /* -all */ allMatches = 1; break; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b321fec..ce8ba13 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -137,7 +137,7 @@ Tcl_RegexpObjCmd( "-expanded", "-line", "-linestop", "-lineanchor", "-nocase", "-start", "--", NULL }; - enum options { + enum regexpoptions { REGEXP_ALL, REGEXP_ABOUT, REGEXP_INDICES, REGEXP_INLINE, REGEXP_EXPANDED,REGEXP_LINE, REGEXP_LINESTOP,REGEXP_LINEANCHOR, REGEXP_NOCASE, REGEXP_START, REGEXP_LAST @@ -162,7 +162,7 @@ Tcl_RegexpObjCmd( &index) != TCL_OK) { goto optionError; } - switch ((enum options) index) { + switch ((enum regexpoptions) index) { case REGEXP_ALL: all = 1; break; @@ -499,7 +499,7 @@ Tcl_RegsubObjCmd( "-linestop", "-lineanchor", "-nocase", "-start", "--", NULL }; - enum options { + enum regsubobjoptions { REGSUB_ALL, REGSUB_COMMAND, REGSUB_EXPANDED, REGSUB_LINE, REGSUB_LINESTOP, REGSUB_LINEANCHOR, REGSUB_NOCASE, REGSUB_START, REGSUB_LAST @@ -523,7 +523,7 @@ Tcl_RegsubObjCmd( TCL_EXACT, &index) != TCL_OK) { goto optionError; } - switch ((enum options) index) { + switch ((enum regsubobjoptions) index) { case REGSUB_ALL: all = 1; break; @@ -1536,7 +1536,7 @@ StringIsCmd( "space", "true", "upper", "wideinteger", "wordchar", "xdigit", NULL }; - enum isClasses { + enum isClassesEnum { STR_IS_ALNUM, STR_IS_ALPHA, STR_IS_ASCII, STR_IS_CONTROL, STR_IS_BOOL, STR_IS_DICT, STR_IS_DIGIT, STR_IS_DOUBLE, STR_IS_ENTIER, STR_IS_FALSE, STR_IS_GRAPH, STR_IS_INT, @@ -1547,7 +1547,7 @@ StringIsCmd( static const char *const isOptions[] = { "-strict", "-failindex", NULL }; - enum isOptions { + enum isOptionsEnum { OPT_STRICT, OPT_FAILIDX }; @@ -1569,7 +1569,7 @@ StringIsCmd( &idx2) != TCL_OK) { return TCL_ERROR; } - switch ((enum isOptions) idx2) { + switch ((enum isOptionsEnum) idx2) { case OPT_STRICT: strict = 1; break; @@ -1598,7 +1598,7 @@ StringIsCmd( * When entering here, result == 1 and failat == 0. */ - switch ((enum isClasses) index) { + switch ((enum isClassesEnum) index) { case STR_IS_ALNUM: chcomp = Tcl_UniCharIsAlnum; break; @@ -3484,7 +3484,7 @@ TclNRSwitchObjCmd( "-exact", "-glob", "-indexvar", "-matchvar", "-nocase", "-regexp", "--", NULL }; - enum options { + enum switchOptionsEnum { OPT_EXACT, OPT_GLOB, OPT_INDEXV, OPT_MATCHV, OPT_NOCASE, OPT_REGEXP, OPT_LAST }; @@ -3505,7 +3505,7 @@ TclNRSwitchObjCmd( &index) != TCL_OK) { return TCL_ERROR; } - switch ((enum options) index) { + switch ((enum switchOptionsEnum) index) { /* * General options. */ @@ -4171,7 +4171,7 @@ Tcl_TimeRateObjCmd( static const char *const options[] = { "-direct", "-overhead", "-calibrate", "--", NULL }; - enum options { + enum timeRateOptionsEnum { TMRT_EV_DIRECT, TMRT_OVERHEAD, TMRT_CALIBRATE, TMRT_LAST }; NRE_callback *rootPtr; @@ -4188,7 +4188,7 @@ Tcl_TimeRateObjCmd( i++; break; } - switch (index) { + switch ((enum timeRateOptionsEnum)index) { case TMRT_EV_DIRECT: direct = objv[i]; break; @@ -4203,6 +4203,8 @@ Tcl_TimeRateObjCmd( case TMRT_CALIBRATE: calibrate = objv[i]; break; + case TMRT_LAST: + break; } } diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index c9e2add..fe661f8 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -511,7 +511,7 @@ TclCompileStringIsCmd( "true", "upper", "wideinteger", "wordchar", "xdigit", NULL }; - enum isClasses { + enum isClassesEnum { STR_IS_ALNUM, STR_IS_ALPHA, STR_IS_ASCII, STR_IS_CONTROL, STR_IS_BOOL, STR_IS_DICT, STR_IS_DIGIT, STR_IS_DOUBLE, STR_IS_ENTIER, STR_IS_FALSE, STR_IS_GRAPH, STR_IS_INT, STR_IS_LIST, @@ -575,7 +575,7 @@ TclCompileStringIsCmd( CompileWord(envPtr, tokenPtr, interp, parsePtr->numWords-1); - switch ((enum isClasses) t) { + switch ((enum isClassesEnum) t) { case STR_IS_ALNUM: strClassType = STR_CLASS_ALNUM; goto compileStrClass; diff --git a/generic/tclEvent.c b/generic/tclEvent.c index a6d2234..85f76e3 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1502,7 +1502,7 @@ Tcl_UpdateObjCmd( int optionIndex; int flags = 0; /* Initialized to avoid compiler warning. */ static const char *const updateOptions[] = {"idletasks", NULL}; - enum updateOptions {OPT_IDLETASKS}; + enum updateOptionsEnum {OPT_IDLETASKS}; if (objc == 1) { flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; @@ -1511,7 +1511,7 @@ Tcl_UpdateObjCmd( "option", 0, &optionIndex) != TCL_OK) { return TCL_ERROR; } - switch ((enum updateOptions) optionIndex) { + switch ((enum updateOptionsEnum) optionIndex) { case OPT_IDLETASKS: flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; break; diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 6d8b751..4c0125f 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -1237,7 +1237,7 @@ Tcl_GlobObjCmd( "-directory", "-join", "-nocomplain", "-path", "-tails", "-types", "--", NULL }; - enum options { + enum globOptionsEnum { GLOB_DIR, GLOB_JOIN, GLOB_NOCOMPLAIN, GLOB_PATH, GLOB_TAILS, GLOB_TYPE, GLOB_LAST }; @@ -1270,7 +1270,7 @@ Tcl_GlobObjCmd( } } - switch (index) { + switch ((enum globOptionsEnum) index) { case GLOB_NOCOMPLAIN: /* -nocomplain */ globFlags |= TCL_GLOBMODE_NO_COMPLAIN; break; diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 41ee9bd..e28f9de 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -888,7 +888,7 @@ Tcl_ExecObjCmd( static const char *const options[] = { "-ignorestderr", "-keepnewline", "--", NULL }; - enum options { + enum execOptionsEnum { EXEC_IGNORESTDERR, EXEC_KEEPNEWLINE, EXEC_LAST }; @@ -1470,7 +1470,7 @@ Tcl_SocketObjCmd( "-async", "-myaddr", "-myport", "-reuseaddr", "-reuseport", "-server", NULL }; - enum socketOptions { + enum socketOptionsEnum { SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_REUSEADDR, SKT_REUSEPORT, SKT_SERVER }; @@ -1495,7 +1495,7 @@ Tcl_SocketObjCmd( TCL_EXACT, &optionIndex) != TCL_OK) { return TCL_ERROR; } - switch ((enum socketOptions) optionIndex) { + switch ((enum socketOptionsEnum) optionIndex) { case SKT_ASYNC: if (server == 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -1806,7 +1806,7 @@ ChanPendingObjCmd( Tcl_Channel chan; int index, mode; static const char *const options[] = {"input", "output", NULL}; - enum options {PENDING_INPUT, PENDING_OUTPUT}; + enum pendingOptionsEnum {PENDING_INPUT, PENDING_OUTPUT}; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "mode channelId"); @@ -1822,7 +1822,7 @@ ChanPendingObjCmd( return TCL_ERROR; } - switch ((enum options) index) { + switch ((enum pendingOptionsEnum) index) { case PENDING_INPUT: if (!(mode & TCL_READABLE)) { Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-1)); diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 63a9466..6ae2075 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -553,7 +553,7 @@ PrefixMatchObjCmd( static const char *const matchOptions[] = { "-error", "-exact", "-message", NULL }; - enum matchOptions { + enum matchOptionsEnum { PRFMATCH_ERROR, PRFMATCH_EXACT, PRFMATCH_MESSAGE }; @@ -567,7 +567,7 @@ PrefixMatchObjCmd( &index) != TCL_OK) { return TCL_ERROR; } - switch ((enum matchOptions) index) { + switch ((enum matchOptionsEnum) index) { case PRFMATCH_EXACT: flags |= TCL_EXACT; break; diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 434d9f4..f724175 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -635,7 +635,7 @@ NRInterpCmd( "invokehidden", "limit", "marktrusted", "recursionlimit", "share", "target", "transfer", NULL }; - enum option { + enum interpOptionEnum { OPT_ALIAS, OPT_ALIASES, OPT_BGERROR, OPT_CANCEL, OPT_CHILDREN, OPT_CREATE, OPT_DEBUG, OPT_DELETE, OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, OPT_HIDE, @@ -655,7 +655,7 @@ NRInterpCmd( "option", 0, &index); return TCL_ERROR; } - switch ((enum option)index) { + switch ((enum interpOptionEnum)index) { case OPT_ALIAS: { Tcl_Interp *parentInterp; @@ -708,7 +708,7 @@ NRInterpCmd( static const char *const cancelOptions[] = { "-unwind", "--", NULL }; - enum option { + enum optionCancelEnum { OPT_UNWIND, OPT_LAST }; @@ -723,7 +723,7 @@ NRInterpCmd( return TCL_ERROR; } - switch ((enum option) index) { + switch ((enum optionCancelEnum) index) { case OPT_UNWIND: /* * The evaluation stack in the target interp is to be unwound. @@ -2562,7 +2562,7 @@ NRChildCmd( "issafe", "invokehidden", "limit", "marktrusted", "recursionlimit", NULL }; - enum options { + enum childCmdOptionsEnum { OPT_ALIAS, OPT_ALIASES, OPT_BGERROR, OPT_DEBUG, OPT_EVAL, OPT_EXPOSE, OPT_HIDE, OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHIDDEN, OPT_LIMIT, OPT_MARKTRUSTED, @@ -2582,7 +2582,7 @@ NRChildCmd( return TCL_ERROR; } - switch ((enum options) index) { + switch ((enum childCmdOptionsEnum) index) { case OPT_ALIAS: if (objc > 2) { if (objc == 3) { diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 1ca1950..c143d0a 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -137,7 +137,7 @@ Tcl_LoadObjCmd( static const char *const options[] = { "-global", "-lazy", "--", NULL }; - enum options { + enum loadOptionsEnum { LOAD_GLOBAL, LOAD_LAZY, LOAD_LAST }; @@ -150,9 +150,9 @@ Tcl_LoadObjCmd( return TCL_ERROR; } ++objv; --objc; - if (LOAD_GLOBAL == (enum options) index) { + if (LOAD_GLOBAL == (enum loadOptionsEnum) index) { flags |= TCL_LOAD_GLOBAL; - } else if (LOAD_LAZY == (enum options) index) { + } else if (LOAD_LAZY == (enum loadOptionsEnum) index) { flags |= TCL_LOAD_LAZY; } else { break; @@ -559,7 +559,7 @@ Tcl_UnloadObjCmd( static const char *const options[] = { "-nocomplain", "-keeplibrary", "--", NULL }; - enum options { + enum unloadOptionsEnum { UNLOAD_NOCOMPLAIN, UNLOAD_KEEPLIB, UNLOAD_LAST }; @@ -584,7 +584,7 @@ Tcl_UnloadObjCmd( break; } } - switch (index) { + switch ((enum unloadOptionsEnum)index) { case UNLOAD_NOCOMPLAIN: /* -nocomplain */ complain = 0; break; diff --git a/generic/tclPkg.c b/generic/tclPkg.c index cda74b1..89fb0c4 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -1073,7 +1073,7 @@ TclNRPackageObjCmd( "present", "provide", "require", "unknown", "vcompare", "versions", "vsatisfies", NULL }; - enum pkgOptions { + enum pkgOptionsEnum { PKG_FILES, PKG_FORGET, PKG_IFNEEDED, PKG_NAMES, PKG_PREFER, PKG_PRESENT, PKG_PROVIDE, PKG_REQUIRE, PKG_UNKNOWN, PKG_VCOMPARE, PKG_VERSIONS, PKG_VSATISFIES @@ -1099,7 +1099,7 @@ TclNRPackageObjCmd( &optionIndex) != TCL_OK) { return TCL_ERROR; } - switch ((enum pkgOptions) optionIndex) { + switch ((enum pkgOptionsEnum) optionIndex) { case PKG_FILES: { PkgFiles *pkgFiles; diff --git a/generic/tclProcess.c b/generic/tclProcess.c index d4cf717..7bd5e1a 100644 --- a/generic/tclProcess.c +++ b/generic/tclProcess.c @@ -472,7 +472,7 @@ ProcessStatusObjCmd( static const char *const switches[] = { "-wait", "--", NULL }; - enum switches { + enum switchesEnum { STATUS_WAIT, STATUS_LAST }; @@ -485,7 +485,7 @@ ProcessStatusObjCmd( return TCL_ERROR; } ++objv; --objc; - if (STATUS_WAIT == (enum switches) index) { + if (STATUS_WAIT == (enum switchesEnum) index) { options = 0; } else { break; diff --git a/generic/tclTest.c b/generic/tclTest.c index 1523666..a8ca463 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -3206,7 +3206,7 @@ TestlinkarrayCmd( static const char *LinkOption[] = { "update", "remove", "create", NULL }; - enum LinkOption { LINK_UPDATE, LINK_REMOVE, LINK_CREATE }; + enum LinkOptionEnum { LINK_UPDATE, LINK_REMOVE, LINK_CREATE }; static const char *LinkType[] = { "char", "uchar", "short", "ushort", "int", "uint", "long", "ulong", "wide", "uwide", "float", "double", "string", "char*", "binary", NULL @@ -3231,7 +3231,7 @@ TestlinkarrayCmd( &optionIndex) != TCL_OK) { return TCL_ERROR; } - switch ((enum LinkOption) optionIndex) { + switch ((enum LinkOptionEnum) optionIndex) { case LINK_UPDATE: for (i=2; i Date: Tue, 6 Oct 2020 08:44:15 +0000 Subject: Adapt function signatures in compat/string.h to what's normal nowadays --- compat/string.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compat/string.h b/compat/string.h index 42be10c..aa889f2 100644 --- a/compat/string.h +++ b/compat/string.h @@ -21,19 +21,15 @@ #include -#ifdef __APPLE__ extern void * memchr(const void *s, int c, size_t n); -#else -extern char * memchr(const void *s, int c, size_t n); -#endif extern int memcmp(const void *s1, const void *s2, size_t n); -extern char * memcpy(void *t, const void *f, size_t n); +extern void * memcpy(void *t, const void *f, size_t n); #ifdef NO_MEMMOVE #define memmove(d,s,n) (bcopy((s), (d), (n))) #else extern char * memmove(void *t, const void *f, size_t n); #endif -extern char * memset(void *s, int c, size_t n); +extern void * memset(void *s, int c, size_t n); extern int strcasecmp(const char *s1, const char *s2); extern char * strcat(char *dst, const char *src); -- cgit v0.12 From 4dfeb77d2e51ad5d4356797bfe9a6622f76304fc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Oct 2020 13:20:42 +0000 Subject: HAVE_TM_GMTOFF detection doesn't work if CFLAGS contains -Werror. Here's the fix. --- unix/configure | 2 +- unix/tcl.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/configure b/unix/configure index 29857ce..e7f8184 100755 --- a/unix/configure +++ b/unix/configure @@ -8639,7 +8639,7 @@ else int main () { -struct tm tm; tm.tm_gmtoff; +struct tm tm; (void)tm.tm_gmtoff; ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index ea3d968..2cad8fd 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2132,7 +2132,7 @@ AC_DEFUN([SC_TIME_HANDLER], [ fi AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [ - AC_TRY_COMPILE([#include ], [struct tm tm; tm.tm_gmtoff;], + AC_TRY_COMPILE([#include ], [struct tm tm; (void)tm.tm_gmtoff;], tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)]) if test $tcl_cv_member_tm_gmtoff = yes ; then AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?]) -- cgit v0.12 From 17b3cb873919153d931ec2d08282f3853227d5d4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Oct 2020 13:26:07 +0000 Subject: Fix (possible) gcc warnings in unix/dltest/*.c --- unix/dltest/pkga.c | 3 +++ unix/dltest/pkgb.c | 8 ++++++++ unix/dltest/pkgc.c | 5 +++++ unix/dltest/pkgd.c | 5 +++++ unix/dltest/pkgooa.c | 8 +++++++- unix/dltest/pkgua.c | 3 +++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/unix/dltest/pkga.c b/unix/dltest/pkga.c index 5bf3c1e..b2267a7 100644 --- a/unix/dltest/pkga.c +++ b/unix/dltest/pkga.c @@ -50,6 +50,7 @@ Pkga_EqObjCmd( int result; const char *str1, *str2; int len1, len2; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string1 string2"); @@ -91,6 +92,8 @@ Pkga_QuoteObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { + (void)dummy; + if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "value"); return TCL_ERROR; diff --git a/unix/dltest/pkgb.c b/unix/dltest/pkgb.c index f102496..32e2d73 100644 --- a/unix/dltest/pkgb.c +++ b/unix/dltest/pkgb.c @@ -54,6 +54,7 @@ Pkgb_SubObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int first, second; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "num num"); @@ -94,6 +95,10 @@ Pkgb_UnsafeObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + (void)dummy; + (void)objc; + (void)objv; + return Tcl_EvalEx(interp, "list unsafe command invoked", -1, TCL_EVAL_GLOBAL); } @@ -106,6 +111,9 @@ Pkgb_DemoObjCmd( { #if (TCL_MAJOR_VERSION > 8) || (TCL_MINOR_VERSION > 4) Tcl_Obj *first; + (void)dummy; + (void)objc; + (void)objv; if (Tcl_ListObjIndex(NULL, Tcl_GetEncodingSearchPath(), 0, &first) == TCL_OK) { diff --git a/unix/dltest/pkgc.c b/unix/dltest/pkgc.c index 983fcf3..a2c4db1 100644 --- a/unix/dltest/pkgc.c +++ b/unix/dltest/pkgc.c @@ -48,6 +48,7 @@ Pkgc_SubObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int first, second; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "num num"); @@ -85,6 +86,10 @@ Pkgc_UnsafeObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + (void)dummy; + (void)objc; + (void)objv; + Tcl_SetObjResult(interp, Tcl_NewStringObj("unsafe command invoked", -1)); return TCL_OK; } diff --git a/unix/dltest/pkgd.c b/unix/dltest/pkgd.c index c708df0..e0986f7 100644 --- a/unix/dltest/pkgd.c +++ b/unix/dltest/pkgd.c @@ -48,6 +48,7 @@ Pkgd_SubObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int first, second; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "num num"); @@ -85,6 +86,10 @@ Pkgd_UnsafeObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + (void)dummy; + (void)objc; + (void)objv; + Tcl_SetObjResult(interp, Tcl_NewStringObj("unsafe command invoked", -1)); return TCL_OK; } diff --git a/unix/dltest/pkgooa.c b/unix/dltest/pkgooa.c index 5a0b0ef..9aebc3f 100644 --- a/unix/dltest/pkgooa.c +++ b/unix/dltest/pkgooa.c @@ -38,6 +38,8 @@ Pkgooa_StubsOKObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + (void)dummy; + if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, ""); return TCL_ERROR; @@ -76,9 +78,13 @@ static TclOOStubs stubsCopy = { * a function with a different memory address than * the real Tcl_CopyObjectInstance function in Tcl. */ (Tcl_Object (*) (Tcl_Interp *, Tcl_Object, const char *, - const char *t)) Pkgooa_StubsOKObjCmd + const char *t))(void *)Pkgooa_StubsOKObjCmd, /* More entries could be here, but those are not used * for this test-case. So, being NULL is OK. */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; extern DLLEXPORT int diff --git a/unix/dltest/pkgua.c b/unix/dltest/pkgua.c index 9d5a9d9..1c7b46f 100644 --- a/unix/dltest/pkgua.c +++ b/unix/dltest/pkgua.c @@ -125,6 +125,7 @@ PkguaEqObjCmd( int result; const char *str1, *str2; int len1, len2; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string1 string2"); @@ -166,6 +167,8 @@ PkguaQuoteObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { + (void)dummy; + if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "value"); return TCL_ERROR; -- cgit v0.12 From a9405cc25305fbdccd97fd95a57d8f76c9eda0ac Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Oct 2020 13:28:24 +0000 Subject: (cherry-pick): HAVE_TM_GMTOFF detection doesn't work if CFLAGS contains -Werror. Here's the fix. --- unix/configure | 2 +- unix/tcl.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/configure b/unix/configure index 7d40237..9dd612d 100755 --- a/unix/configure +++ b/unix/configure @@ -14030,7 +14030,7 @@ cat >>conftest.$ac_ext <<_ACEOF int main () { -struct tm tm; tm.tm_gmtoff; +struct tm tm; (void)tm.tm_gmtoff; ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 25a01ac..51ac8d9 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2339,7 +2339,7 @@ AC_DEFUN([SC_TIME_HANDLER], [ fi AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [ - AC_TRY_COMPILE([#include ], [struct tm tm; tm.tm_gmtoff;], + AC_TRY_COMPILE([#include ], [struct tm tm; (void)tm.tm_gmtoff;], tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)]) if test $tcl_cv_member_tm_gmtoff = yes ; then AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?]) -- cgit v0.12 From e53cbf77bf43398c097556b24a5c1e6a26e56b40 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 7 Oct 2020 16:34:57 +0000 Subject: xcode12 -> xcode12.2. Prevent build warning about generic/tclStubInit.c --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5773b5b..6447b34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,7 +114,7 @@ jobs: # Testing on Mac, various styles - name: "macOS/Xcode 12/Shared" os: osx - osx_image: xcode12 + osx_image: xcode12.2 env: - BUILD_DIR=macosx install: [] @@ -124,7 +124,7 @@ jobs: - make test styles=develop - name: "macOS/Xcode 12/Shared/Unix-like" os: osx - osx_image: xcode12 + osx_image: xcode12.2 env: - BUILD_DIR=unix # Newer MacOS versions @@ -320,6 +320,7 @@ jobs: - CFGOPT="--enable-threads --enable-symbols=mem" before_install: *makepreinst before_install: + - touch generic/tclStubInit.c - cd ${BUILD_DIR} install: - ./configure ${CFGOPT} --prefix=$HOME || (cat config.log && exit 1) -- cgit v0.12 From 5039e7ce17a9ea6c7352b39a0bd70e31433b7843 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 8 Oct 2020 09:13:57 +0000 Subject: Fix [014ade1d44]: Misleading error message when using "-path" multiple times with "glob" --- generic/tclFileName.c | 10 ++++++++-- tests/fileName.test | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 6cdfa7e..b47035c 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -1281,7 +1281,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-directory\" cannot be used with \"-path\"", -1)); + dir == PATH_DIR + ? "\"-directory\" may only be used once" + : "\"-directory\" cannot be used with \"-path\"", + -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BADOPTIONCOMBINATION", NULL); return TCL_ERROR; @@ -1306,7 +1309,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-path\" cannot be used with \"-directory\"", -1)); + dir == PATH_GENERAL + ? "\"-path\" may only be used once" + : "\"-path\" cannot be used with \"-dictionary\"", + -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BADOPTIONCOMBINATION", NULL); return TCL_ERROR; diff --git a/tests/fileName.test b/tests/fileName.test index 725c1dd..0411ea8 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -1083,6 +1083,12 @@ test filename-11.48 {Tcl_GlobCmd} -returnCodes error -body { test filename-11.49 {Tcl_GlobCmd} -returnCodes error -body { glob -types abcde -path foo -join * * } -result {bad argument to "-types": abcde} +test filename-11.50 {Tcl_GlobCmd} -returnCodes error -body { + glob -path hello -path salut * +} -result {"-path" may only be used once} +test filename-11.51 {Tcl_GlobCmd} -returnCodes error -body { + glob -dir hello -dir salut * +} -result {"-directory" may only be used once} file rename $horribleglobname globTest file delete -force $tildeglobname -- cgit v0.12 From 4a3369807be6e501ec6452edf99a73514c24d861 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 8 Oct 2020 12:11:11 +0000 Subject: Eliminate warnings when compiling with -Wundef --- generic/tclAlloc.c | 2 +- generic/tclCkalloc.c | 2 +- generic/tclEvent.c | 2 +- generic/tclObj.c | 2 +- win/tclWinPort.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c index dd83385..cc683b6 100644 --- a/generic/tclAlloc.c +++ b/generic/tclAlloc.c @@ -24,7 +24,7 @@ #include "tclInt.h" #if !defined(TCL_THREADS) || !defined(USE_THREAD_ALLOC) -#if USE_TCLALLOC +#if defined(USE_TCLALLOC) && USE_TCLALLOC /* * We should really make use of AC_CHECK_TYPE(caddr_t) here, but it can wait diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 0dc1dca..6d661f6 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -1324,7 +1324,7 @@ TclFinalizeMemorySubsystem(void) Tcl_MutexUnlock(ckallocMutexPtr); #endif -#if USE_TCLALLOC +#if defined(USE_TCLALLOC) && USE_TCLALLOC TclFinalizeAllocSubsystem(); #endif } diff --git a/generic/tclEvent.c b/generic/tclEvent.c index ae40850..d8f5119 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1045,7 +1045,7 @@ TclInitSubsystems(void) TclInitThreadStorage(); /* Creates hash table for * thread local storage */ -#if USE_TCLALLOC +#if defined(USE_TCLALLOC) && USE_TCLALLOC TclInitAlloc(); /* Process wide mutex init */ #endif #ifdef TCL_MEM_DEBUG diff --git a/generic/tclObj.c b/generic/tclObj.c index 70b2b1e..2ec5eb8 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -161,7 +161,7 @@ typedef struct PendingObjData { static PendingObjData pendingObjData; #define ObjInitDeletionContext(contextPtr) \ PendingObjData *const contextPtr = &pendingObjData -#elif HAVE_FAST_TSD +#elif defined(HAVE_FAST_TSD) static __thread PendingObjData pendingObjData; #define ObjInitDeletionContext(contextPtr) \ PendingObjData *const contextPtr = &pendingObjData diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 3d61a39..8641e5e 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -297,7 +297,7 @@ typedef DWORD_PTR * PDWORD_PTR; * defined in header files above. */ -#if TCL_UNION_WAIT +#ifdef TCL_UNION_WAIT # define WAIT_STATUS_TYPE union wait #else # define WAIT_STATUS_TYPE int @@ -439,10 +439,10 @@ typedef DWORD_PTR * PDWORD_PTR; * Define pid_t and uid_t if they're not already defined. */ -#if ! TCL_PID_T +#if !defined(TCL_PID_T) # define pid_t int #endif /* !TCL_PID_T */ -#if ! TCL_UID_T +#if !defined(TCL_UID_T) # define uid_t int #endif /* !TCL_UID_T */ -- cgit v0.12 From e250b6f551523bf4b6fb9ae110bac1279d5eb581 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 9 Oct 2020 07:10:22 +0000 Subject: (cherry-pick): Fix [014ade1d44]: Misleading error message when using "-path" multiple times with "glob". Also fix a few (harmless) -Wundef warnings --- generic/tclExecute.c | 16 ++++++------ generic/tclFileName.c | 51 ++++++++++++++++++++---------------- tests/fileName.test | 72 ++++++++++++++++++++++++--------------------------- unix/tclLoadDyld.c | 12 ++++----- win/tclWinPort.h | 6 ++--- 5 files changed, 80 insertions(+), 77 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 7a8bf39..be0d932 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2093,7 +2093,7 @@ TclExecuteByteCode( PUSH_OBJECT(codePtr->objArrayPtr[TclGetUInt1AtPtr(pc+1)]); TRACE_WITH_OBJ(("%u => ", TclGetInt1AtPtr(pc+1)), OBJ_AT_TOS); pc += 2; -#if !TCL_COMPILE_DEBUG +#if !defined(TCL_COMPILE_DEBUG) /* * Runtime peephole optimisation: check if we are pushing again. */ @@ -2124,7 +2124,7 @@ TclExecuteByteCode( */ pc++; -#if !TCL_COMPILE_DEBUG +#if !defined(TCL_COMPILE_DEBUG) if (*pc == INST_START_CMD) { TCL_DTRACE_INST_NEXT(); goto instStartCmdPeephole; @@ -2134,7 +2134,7 @@ TclExecuteByteCode( } case INST_START_CMD: -#if !TCL_COMPILE_DEBUG +#if !defined(TCL_COMPILE_DEBUG) instStartCmdPeephole: #endif /* @@ -2265,7 +2265,7 @@ TclExecuteByteCode( /* TODO: convert panic to error ? */ Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } -#if !TCL_COMPILE_DEBUG +#if !defined(TCL_COMPILE_DEBUG) if (bytes != tclEmptyStringRep && !Tcl_IsShared(objResultPtr)) { TclFreeIntRep(objResultPtr); objResultPtr->typePtr = NULL; @@ -2280,7 +2280,7 @@ TclExecuteByteCode( objResultPtr->bytes = p; objResultPtr->length = length + appendLen; currPtr = &OBJ_AT_DEPTH(opnd - 1); -#if !TCL_COMPILE_DEBUG +#if !defined(TCL_COMPILE_DEBUG) } #endif @@ -7233,7 +7233,7 @@ TclExecuteByteCode( Tcl_Obj *valuePtr; const char *bytes; int length; -#if TCL_COMPILE_DEBUG +#ifdef TCL_COMPILE_DEBUG int opnd; #endif @@ -7244,7 +7244,7 @@ TclExecuteByteCode( */ processExceptionReturn: -#if TCL_COMPILE_DEBUG +#ifdef TCL_COMPILE_DEBUG switch (*pc) { case INST_INVOKE_STK1: opnd = TclGetUInt1AtPtr(pc+1); @@ -7302,7 +7302,7 @@ TclExecuteByteCode( rangePtr->codeOffset, rangePtr->continueOffset)); NEXT_INST_F(0, 0, 0); } -#if TCL_COMPILE_DEBUG +#ifdef TCL_COMPILE_DEBUG } else if (traceInstructions) { if ((result != TCL_ERROR) && (result != TCL_RETURN)) { Tcl_Obj *objPtr = Tcl_GetObjResult(interp); diff --git a/generic/tclFileName.c b/generic/tclFileName.c index be1fdfa..b3879f7 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -578,7 +578,7 @@ Tcl_SplitPath( * plus the argv pointers and the terminating NULL pointer. */ - *argvPtr = (const char **) ckalloc((unsigned) + *argvPtr = (const char **) ckalloc( ((((*argcPtr) + 1) * sizeof(char *)) + size)); /* @@ -590,7 +590,7 @@ Tcl_SplitPath( for (i = 0; i < *argcPtr; i++) { Tcl_ListObjIndex(NULL, resultPtr, i, &eltPtr); str = Tcl_GetStringFromObj(eltPtr, &len); - memcpy(p, str, (size_t) len+1); + memcpy(p, str, len + 1); p += len+1; } @@ -636,12 +636,13 @@ SplitUnixPath( { int length; const char *origPath = path, *elementStart; - Tcl_Obj *result = Tcl_NewObj(); + Tcl_Obj *result; /* * Deal with the root directory as a special case. */ + TclNewObj(result); if (*path == '/') { Tcl_Obj *rootElt; ++path; @@ -727,9 +728,10 @@ SplitWinPath( const char *p, *elementStart; Tcl_PathType type = TCL_PATH_ABSOLUTE; Tcl_DString buf; - Tcl_Obj *result = Tcl_NewObj(); + Tcl_Obj *result; Tcl_DStringInit(&buf); + TclNewObj(result); p = ExtractWinRoot(path, &buf, 0, &type); /* @@ -974,7 +976,7 @@ Tcl_JoinPath( Tcl_DString *resultPtr) /* Pointer to previously initialized DString */ { int i, len; - Tcl_Obj *listObj = Tcl_NewObj(); + Tcl_Obj *listObj; Tcl_Obj *resultObj; const char *resultStr; @@ -982,6 +984,7 @@ Tcl_JoinPath( * Build the list of paths. */ + TclNewObj(listObj); for (i = 0; i < argc; i++) { Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewStringObj(argv[i], -1)); @@ -1069,7 +1072,7 @@ Tcl_TranslateFileName( */ if (tclPlatform == TCL_PLATFORM_WINDOWS) { - register char *p; + char *p; for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) { if (*p == '/') { *p = '\\'; @@ -1212,7 +1215,6 @@ DoTildeSubst( *---------------------------------------------------------------------- */ - /* ARGSUSED */ int Tcl_GlobObjCmd( ClientData dummy, /* Not used. */ @@ -1230,12 +1232,13 @@ Tcl_GlobObjCmd( "-directory", "-join", "-nocomplain", "-path", "-tails", "-types", "--", NULL }; - enum options { + enum globOptionsEnum { GLOB_DIR, GLOB_JOIN, GLOB_NOCOMPLAIN, GLOB_PATH, GLOB_TAILS, GLOB_TYPE, GLOB_LAST }; enum pathDirOptions {PATH_NONE = -1 , PATH_GENERAL = 0, PATH_DIR = 1}; Tcl_GlobTypeData *globTypes = NULL; + (void)dummy; globFlags = 0; join = 0; @@ -1263,7 +1266,7 @@ Tcl_GlobObjCmd( } } - switch (index) { + switch ((enum globOptionsEnum) index) { case GLOB_NOCOMPLAIN: /* -nocomplain */ globFlags |= TCL_GLOBMODE_NO_COMPLAIN; break; @@ -1275,7 +1278,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-directory\" cannot be used with \"-path\"", -1)); + dir == PATH_DIR + ? "\"-directory\" may only be used once" + : "\"-directory\" cannot be used with \"-path\"", + -1)); return TCL_ERROR; } dir = PATH_DIR; @@ -1297,7 +1303,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-path\" cannot be used with \"-directory\"", -1)); + dir == PATH_GENERAL + ? "\"-path\" may only be used once" + : "\"-path\" cannot be used with \"-dictionary\"", + -1)); return TCL_ERROR; } dir = PATH_GENERAL; @@ -1334,7 +1343,7 @@ Tcl_GlobObjCmd( return TCL_ERROR; } - separators = NULL; /* lint. */ + separators = NULL; switch (tclPlatform) { case TCL_PLATFORM_UNIX: separators = "/"; @@ -1439,7 +1448,7 @@ Tcl_GlobObjCmd( if (length <= 0) { goto skipTypes; } - globTypes = (Tcl_GlobTypeData*) + globTypes = (Tcl_GlobTypeData *) TclStackAlloc(interp,sizeof(Tcl_GlobTypeData)); globTypes->type = 0; globTypes->perm = 0; @@ -1666,9 +1675,8 @@ Tcl_GlobObjCmd( * * TclGlob -- * - * This procedure prepares arguments for the DoGlob call. It sets the - * separator string based on the platform, performs * tilde substitution, - * and calls DoGlob. + * Sets the separator string based on the platform, performs tilde + * substitution, and calls DoGlob. * * The interpreter's result, on entry to this function, must be a valid * Tcl list (e.g. it could be empty), since we will lappend any new @@ -1691,7 +1699,6 @@ Tcl_GlobObjCmd( *---------------------------------------------------------------------- */ - /* ARGSUSED */ int TclGlob( Tcl_Interp *interp, /* Interpreter for returning error message or @@ -1710,7 +1717,7 @@ TclGlob( int result; Tcl_Obj *filenamesObj, *savedResultObj; - separators = NULL; /* lint. */ + separators = NULL; switch (tclPlatform) { case TCL_PLATFORM_UNIX: separators = "/"; @@ -1891,7 +1898,7 @@ TclGlob( } /* - * To process a [glob] invokation, this function may be called multiple + * To process a [glob] invocation, this function may be called multiple * times. Each time, the previously discovered filenames are in the * interpreter result. We stash that away here so the result is free for * error messsages. @@ -2045,7 +2052,7 @@ TclGlob( * SkipToChar -- * * This function traverses a glob pattern looking for the next unquoted - * occurance of the specified character at the same braces nesting level. + * occurrence of the specified character at the same braces nesting level. * * Results: * Updates stringPtr to point to the matching character, or to the end of @@ -2064,7 +2071,7 @@ SkipToChar( int match) /* Character to find. */ { int quoted, level; - register char *p; + char *p; quoted = 0; level = 0; @@ -2507,7 +2514,7 @@ DoGlob( Tcl_StatBuf * Tcl_AllocStatBuf(void) { - return (Tcl_StatBuf *) ckalloc(sizeof(Tcl_StatBuf)); + return (Tcl_StatBuf *)ckalloc(sizeof(Tcl_StatBuf)); } /* diff --git a/tests/fileName.test b/tests/fileName.test index 3747fc9..aecca46 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -25,6 +25,7 @@ if {[testConstraint win]} { testConstraint linkDirectory 0 } testConstraint symbolicLinkFile 0 + testConstraint sharedCdrive [expr {![catch {cd //[info hostname]/c}]}] } global env @@ -210,11 +211,9 @@ test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo/bar~/baz } {foo bar~ baz} - if {[testConstraint testsetplatform]} { testsetplatform $platform } - test filename-4.19 {Tcl_SplitPath} { set oldDir [pwd] set res [catch { @@ -438,7 +437,6 @@ test filename-7.19 {[Bug f34cf83dd0]} { file join foo //bar } /bar - test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join a b @@ -515,25 +513,25 @@ test filename-9.19 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win set res {} lappend res \ - [file join {C:\foo\bar}] \ - [file join C:/blah {C:\foo\bar}] \ - [file join C:/blah C:/blah {C:\foo\bar}] + [file join {C:\foo\bar}] \ + [file join C:/blah {C:\foo\bar}] \ + [file join C:/blah C:/blah {C:\foo\bar}] } {C:/foo/bar C:/foo/bar C:/foo/bar} test filename-9.19.1 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win set res {} lappend res \ - [file join {foo\bar}] \ - [file join C:/blah {foo\bar}] \ - [file join C:/blah C:/blah {foo\bar}] + [file join {foo\bar}] \ + [file join C:/blah {foo\bar}] \ + [file join C:/blah C:/blah {foo\bar}] } {foo/bar C:/blah/foo/bar C:/blah/foo/bar} test filename-9.19.2 {Tcl_JoinPath: win} {testsetplatform win} { testsetplatform win set res {} lappend res \ - [file join {foo\bar}] \ - [file join [pwd] {foo\bar}] \ - [file join [pwd] [pwd] {foo\bar}] + [file join {foo\bar}] \ + [file join [pwd] {foo\bar}] \ + [file join [pwd] [pwd] {foo\bar}] set nres {} foreach elt $res { lappend nres [string map [list [pwd] pwd] $elt] @@ -544,26 +542,26 @@ test filename-9.20 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix set res {} lappend res \ - [file join {/foo/bar}] \ - [file join /x {/foo/bar}] \ - [file join /x /x {/foo/bar}] + [file join {/foo/bar}] \ + [file join /x {/foo/bar}] \ + [file join /x /x {/foo/bar}] } {/foo/bar /foo/bar /foo/bar} test filename-9.23 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win set res {} lappend res \ - [file join {foo\bar}] \ - [file join C:/blah {foo\bar}] \ - [file join C:/blah C:/blah {foo\bar}] + [file join {foo\bar}] \ + [file join C:/blah {foo\bar}] \ + [file join C:/blah C:/blah {foo\bar}] string map [list C:/blah ""] $res } {foo/bar /foo/bar /foo/bar} test filename-9.24 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix set res {} lappend res \ - [file join {foo/bar}] \ - [file join /x {foo/bar}] \ - [file join /x /x {foo/bar}] + [file join {foo/bar}] \ + [file join /x {foo/bar}] \ + [file join /x /x {foo/bar}] string map [list /x ""] $res } {foo/bar /foo/bar /foo/bar} @@ -1110,6 +1108,12 @@ test filename-11.48 {Tcl_GlobCmd} { test filename-11.49 {Tcl_GlobCmd} { list [catch {glob -types abcde -path foo -join * *} msg] $msg } {1 {bad argument to "-types": abcde}} +test filename-11.50 {Tcl_GlobCmd} -returnCodes error -body { + glob -path hello -path salut * +} -result {"-path" may only be used once} +test filename-11.51 {Tcl_GlobCmd} -returnCodes error -body { + glob -dir hello -dir salut * +} -result {"-directory" may only be used once} file rename $horribleglobname globTest file delete -force $tildeglobname @@ -1493,13 +1497,7 @@ test filename-16.10 {windows specific globbing} {win} { test filename-16.11 {windows specific globbing} {win} { lsort [glob -nocomplain c:\\\\globTest\\\\*.bat] } {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat} - # some tests require a shared C drive - -if {[testConstraint win]} { - testConstraint sharedCdrive [expr {![catch {cd //[info hostname]/c}]}] -} - test filename-16.12 {windows specific globbing} {win sharedCdrive} { cd //[info hostname]/c glob //[info hostname]/c/*Test @@ -1540,8 +1538,8 @@ if {[testConstraint win]} { test filename-17.1 {windows specific special files} {testsetplatform} { testsetplatform win list [file pathtype com1] [file pathtype con] [file pathtype lpt3] \ - [file pathtype prn] [file pathtype nul] [file pathtype aux] \ - [file pathtype foo] + [file pathtype prn] [file pathtype nul] [file pathtype aux] \ + [file pathtype foo] } {absolute absolute absolute absolute absolute absolute relative} if {[testConstraint testsetplatform]} { testsetplatform $platform @@ -1613,7 +1611,6 @@ test fileName-20.4 {Bug 1750300} -setup { removeFile TAGS $d removeDirectory foo } -result 0 - test fileName-20.5 {Bug 2837800} -setup { set dd [makeDirectory isolate] set d [makeDirectory ./~foo $dd] @@ -1628,7 +1625,6 @@ test fileName-20.5 {Bug 2837800} -setup { removeDirectory ./~foo $dd removeDirectory isolate } -result ~foo/test - test fileName-20.6 {Bug 2837800} -setup { # Recall that we have $env(HOME) set so that references # to ~ point to [temporaryDirectory] @@ -1645,7 +1641,6 @@ test fileName-20.6 {Bug 2837800} -setup { removeDirectory isolate removeFile test ~ } -result {} - test fileName-20.7 {Bug 2806250} -setup { set savewd [pwd] cd [temporaryDirectory] @@ -1658,7 +1653,6 @@ test fileName-20.7 {Bug 2806250} -setup { removeDirectory isolate cd $savewd } -result 1 - test fileName-20.8 {Bug 2806250} -setup { set savewd [pwd] cd [temporaryDirectory] @@ -1671,8 +1665,7 @@ test fileName-20.8 {Bug 2806250} -setup { removeDirectory isolate cd $savewd } -result ./~test - -test fileName-20.9 {} -setup { +test fileName-20.9 {globbing for special chars} -setup { makeFile {} test ~ set d [makeDirectory isolate] set savewd [pwd] @@ -1684,8 +1677,7 @@ test fileName-20.9 {} -setup { removeDirectory isolate removeFile test ~ } -result ~/test - -test fileName-20.10 {} -setup { +test fileName-20.10 {globbing for special chars} -setup { set s [makeDirectory sub ~] makeFile {} fileName-20.10 $s set d [makeDirectory isolate] @@ -1699,7 +1691,7 @@ test fileName-20.10 {} -setup { removeFile fileName-20.10 $s removeDirectory sub ~ } -result ~/sub/fileName-20.10 - + # cleanup catch {file delete -force C:/globTest} cd [temporaryDirectory] @@ -1713,3 +1705,7 @@ if {[testConstraint testsetplatform]} { catch {unset oldhome temp result globPreResult} ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 0a36215..c71727d 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -633,14 +633,14 @@ TclpLoadMemory( uint32_t ms = 0; #ifndef __LP64__ const struct mach_header *mh = NULL; - #define mh_size sizeof(struct mach_header) - #define mh_magic MH_MAGIC - #define arch_abi 0 +# define mh_size sizeof(struct mach_header) +# define mh_magic MH_MAGIC +# define arch_abi 0 #else const struct mach_header_64 *mh = NULL; - #define mh_size sizeof(struct mach_header_64) - #define mh_magic MH_MAGIC_64 - #define arch_abi CPU_ARCH_ABI64 +# define mh_size sizeof(struct mach_header_64) +# define mh_magic MH_MAGIC_64 +# define arch_abi CPU_ARCH_ABI64 #endif if ((size_t) codeSize >= sizeof(struct fat_header) diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 056c7c8..d3dbb1b 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -211,7 +211,7 @@ typedef DWORD_PTR * PDWORD_PTR; * defined in header files above. */ -#if TCL_UNION_WAIT +#ifdef TCL_UNION_WAIT # define WAIT_STATUS_TYPE union wait #else # define WAIT_STATUS_TYPE int @@ -339,10 +339,10 @@ typedef DWORD_PTR * PDWORD_PTR; * Define pid_t and uid_t if they're not already defined. */ -#if ! TCL_PID_T +#if !defined(TCL_PID_T) # define pid_t int #endif /* !TCL_PID_T */ -#if ! TCL_UID_T +#if !defined(TCL_UID_T) # define uid_t int #endif /* !TCL_UID_T */ -- cgit v0.12 From 579cd0b138b020f90e65e83e6bd9f27d473211b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ignacio=20Mar=C3=ADn?= Date: Sat, 10 Oct 2020 20:34:58 +0000 Subject: Update TZ info to tzdata2020b. --- library/tzdata/Africa/Algiers | 2 +- library/tzdata/Africa/Casablanca | 20 ++-- library/tzdata/Africa/El_Aaiun | 20 ++-- library/tzdata/America/Dawson | 3 +- library/tzdata/America/Whitehorse | 3 +- library/tzdata/Antarctica/Casey | 5 + library/tzdata/Antarctica/Macquarie | 181 +++++++++++++++++++++++++++++++++++- library/tzdata/Europe/Budapest | 45 ++++----- library/tzdata/Europe/Monaco | 4 +- library/tzdata/Europe/Paris | 4 +- tools/tclZIC.tcl | 2 +- 11 files changed, 238 insertions(+), 51 deletions(-) diff --git a/library/tzdata/Africa/Algiers b/library/tzdata/Africa/Algiers index fe4de22..b26d31c 100644 --- a/library/tzdata/Africa/Algiers +++ b/library/tzdata/Africa/Algiers @@ -2,7 +2,7 @@ set TZData(:Africa/Algiers) { {-9223372036854775808 732 0 LMT} - {-2486679072 561 0 PMT} + {-2486592732 561 0 PMT} {-1855958961 0 0 WET} {-1689814800 3600 1 WEST} {-1680397200 0 0 WET} diff --git a/library/tzdata/Africa/Casablanca b/library/tzdata/Africa/Casablanca index 05ae49f..cb60740 100644 --- a/library/tzdata/Africa/Casablanca +++ b/library/tzdata/Africa/Casablanca @@ -66,7 +66,7 @@ set TZData(:Africa/Casablanca) { {1648346400 0 1 +01} {1651975200 3600 0 +01} {1679191200 0 1 +01} - {1682215200 3600 0 +01} + {1682820000 3600 0 +01} {1710036000 0 1 +01} {1713060000 3600 0 +01} {1740276000 0 1 +01} @@ -82,7 +82,7 @@ set TZData(:Africa/Casablanca) { {1893290400 0 1 +01} {1896919200 3600 0 +01} {1924135200 0 1 +01} - {1927159200 3600 0 +01} + {1927764000 3600 0 +01} {1954980000 0 1 +01} {1958004000 3600 0 +01} {1985220000 0 1 +01} @@ -98,7 +98,7 @@ set TZData(:Africa/Casablanca) { {2138234400 0 1 +01} {2141863200 3600 0 +01} {2169079200 0 1 +01} - {2172103200 3600 0 +01} + {2172708000 3600 0 +01} {2199924000 0 1 +01} {2202948000 3600 0 +01} {2230164000 0 1 +01} @@ -114,7 +114,7 @@ set TZData(:Africa/Casablanca) { {2383178400 0 1 +01} {2386807200 3600 0 +01} {2414023200 0 1 +01} - {2417047200 3600 0 +01} + {2417652000 3600 0 +01} {2444868000 0 1 +01} {2447892000 3600 0 +01} {2475108000 0 1 +01} @@ -130,7 +130,7 @@ set TZData(:Africa/Casablanca) { {2628122400 0 1 +01} {2631751200 3600 0 +01} {2658967200 0 1 +01} - {2661991200 3600 0 +01} + {2662596000 3600 0 +01} {2689812000 0 1 +01} {2692836000 3600 0 +01} {2720052000 0 1 +01} @@ -146,7 +146,7 @@ set TZData(:Africa/Casablanca) { {2873066400 0 1 +01} {2876695200 3600 0 +01} {2903911200 0 1 +01} - {2906935200 3600 0 +01} + {2907540000 3600 0 +01} {2934756000 0 1 +01} {2937780000 3600 0 +01} {2964996000 0 1 +01} @@ -162,7 +162,7 @@ set TZData(:Africa/Casablanca) { {3118010400 0 1 +01} {3121639200 3600 0 +01} {3148855200 0 1 +01} - {3151879200 3600 0 +01} + {3152484000 3600 0 +01} {3179700000 0 1 +01} {3182724000 3600 0 +01} {3209940000 0 1 +01} @@ -178,7 +178,7 @@ set TZData(:Africa/Casablanca) { {3362954400 0 1 +01} {3366583200 3600 0 +01} {3393799200 0 1 +01} - {3396823200 3600 0 +01} + {3397428000 3600 0 +01} {3424644000 0 1 +01} {3427668000 3600 0 +01} {3454884000 0 1 +01} @@ -188,13 +188,13 @@ set TZData(:Africa/Casablanca) { {3515968800 0 1 +01} {3519597600 3600 0 +01} {3546813600 0 1 +01} - {3549837600 3600 0 +01} + {3550442400 3600 0 +01} {3577658400 0 1 +01} {3580682400 3600 0 +01} {3607898400 0 1 +01} {3611527200 3600 0 +01} {3638743200 0 1 +01} - {3641767200 3600 0 +01} + {3642372000 3600 0 +01} {3669588000 0 1 +01} {3672612000 3600 0 +01} {3699828000 0 1 +01} diff --git a/library/tzdata/Africa/El_Aaiun b/library/tzdata/Africa/El_Aaiun index 8dbbdea..fd3e88f 100644 --- a/library/tzdata/Africa/El_Aaiun +++ b/library/tzdata/Africa/El_Aaiun @@ -55,7 +55,7 @@ set TZData(:Africa/El_Aaiun) { {1648346400 0 1 +01} {1651975200 3600 0 +01} {1679191200 0 1 +01} - {1682215200 3600 0 +01} + {1682820000 3600 0 +01} {1710036000 0 1 +01} {1713060000 3600 0 +01} {1740276000 0 1 +01} @@ -71,7 +71,7 @@ set TZData(:Africa/El_Aaiun) { {1893290400 0 1 +01} {1896919200 3600 0 +01} {1924135200 0 1 +01} - {1927159200 3600 0 +01} + {1927764000 3600 0 +01} {1954980000 0 1 +01} {1958004000 3600 0 +01} {1985220000 0 1 +01} @@ -87,7 +87,7 @@ set TZData(:Africa/El_Aaiun) { {2138234400 0 1 +01} {2141863200 3600 0 +01} {2169079200 0 1 +01} - {2172103200 3600 0 +01} + {2172708000 3600 0 +01} {2199924000 0 1 +01} {2202948000 3600 0 +01} {2230164000 0 1 +01} @@ -103,7 +103,7 @@ set TZData(:Africa/El_Aaiun) { {2383178400 0 1 +01} {2386807200 3600 0 +01} {2414023200 0 1 +01} - {2417047200 3600 0 +01} + {2417652000 3600 0 +01} {2444868000 0 1 +01} {2447892000 3600 0 +01} {2475108000 0 1 +01} @@ -119,7 +119,7 @@ set TZData(:Africa/El_Aaiun) { {2628122400 0 1 +01} {2631751200 3600 0 +01} {2658967200 0 1 +01} - {2661991200 3600 0 +01} + {2662596000 3600 0 +01} {2689812000 0 1 +01} {2692836000 3600 0 +01} {2720052000 0 1 +01} @@ -135,7 +135,7 @@ set TZData(:Africa/El_Aaiun) { {2873066400 0 1 +01} {2876695200 3600 0 +01} {2903911200 0 1 +01} - {2906935200 3600 0 +01} + {2907540000 3600 0 +01} {2934756000 0 1 +01} {2937780000 3600 0 +01} {2964996000 0 1 +01} @@ -151,7 +151,7 @@ set TZData(:Africa/El_Aaiun) { {3118010400 0 1 +01} {3121639200 3600 0 +01} {3148855200 0 1 +01} - {3151879200 3600 0 +01} + {3152484000 3600 0 +01} {3179700000 0 1 +01} {3182724000 3600 0 +01} {3209940000 0 1 +01} @@ -167,7 +167,7 @@ set TZData(:Africa/El_Aaiun) { {3362954400 0 1 +01} {3366583200 3600 0 +01} {3393799200 0 1 +01} - {3396823200 3600 0 +01} + {3397428000 3600 0 +01} {3424644000 0 1 +01} {3427668000 3600 0 +01} {3454884000 0 1 +01} @@ -177,13 +177,13 @@ set TZData(:Africa/El_Aaiun) { {3515968800 0 1 +01} {3519597600 3600 0 +01} {3546813600 0 1 +01} - {3549837600 3600 0 +01} + {3550442400 3600 0 +01} {3577658400 0 1 +01} {3580682400 3600 0 +01} {3607898400 0 1 +01} {3611527200 3600 0 +01} {3638743200 0 1 +01} - {3641767200 3600 0 +01} + {3642372000 3600 0 +01} {3669588000 0 1 +01} {3672612000 3600 0 +01} {3699828000 0 1 +01} diff --git a/library/tzdata/America/Dawson b/library/tzdata/America/Dawson index 1c827ff..c8e3f26 100644 --- a/library/tzdata/America/Dawson +++ b/library/tzdata/America/Dawson @@ -93,5 +93,6 @@ set TZData(:America/Dawson) { {1541322000 -28800 0 PST} {1552212000 -25200 1 PDT} {1572771600 -28800 0 PST} - {1583661600 -25200 0 MST} + {1583661600 -25200 1 PDT} + {1604217600 -25200 0 MST} } diff --git a/library/tzdata/America/Whitehorse b/library/tzdata/America/Whitehorse index da0c0f0..498a203 100644 --- a/library/tzdata/America/Whitehorse +++ b/library/tzdata/America/Whitehorse @@ -93,5 +93,6 @@ set TZData(:America/Whitehorse) { {1541322000 -28800 0 PST} {1552212000 -25200 1 PDT} {1572771600 -28800 0 PST} - {1583661600 -25200 0 MST} + {1583661600 -25200 1 PDT} + {1604217600 -25200 0 MST} } diff --git a/library/tzdata/Antarctica/Casey b/library/tzdata/Antarctica/Casey index aa37480..56935e3 100644 --- a/library/tzdata/Antarctica/Casey +++ b/library/tzdata/Antarctica/Casey @@ -9,4 +9,9 @@ set TZData(:Antarctica/Casey) { {1329843600 28800 0 +08} {1477065600 39600 0 +11} {1520701200 28800 0 +08} + {1538856000 39600 0 +11} + {1552752000 28800 0 +08} + {1570129200 39600 0 +11} + {1583596800 28800 0 +08} + {1601740860 39600 0 +11} } diff --git a/library/tzdata/Antarctica/Macquarie b/library/tzdata/Antarctica/Macquarie index 60bf7a6..e8ed043 100644 --- a/library/tzdata/Antarctica/Macquarie +++ b/library/tzdata/Antarctica/Macquarie @@ -93,5 +93,184 @@ set TZData(:Antarctica/Macquarie) { {1223136000 39600 1 AEDT} {1238860800 36000 0 AEST} {1254585600 39600 1 AEDT} - {1270310400 39600 0 +11} + {1262264400 39600 1 AEDT} + {1293800400 39600 0 AEST} + {1301760000 36000 0 AEST} + {1317484800 39600 1 AEDT} + {1333209600 36000 0 AEST} + {1349539200 39600 1 AEDT} + {1365264000 36000 0 AEST} + {1380988800 39600 1 AEDT} + {1396713600 36000 0 AEST} + {1412438400 39600 1 AEDT} + {1428163200 36000 0 AEST} + {1443888000 39600 1 AEDT} + {1459612800 36000 0 AEST} + {1475337600 39600 1 AEDT} + {1491062400 36000 0 AEST} + {1506787200 39600 1 AEDT} + {1522512000 36000 0 AEST} + {1538841600 39600 1 AEDT} + {1554566400 36000 0 AEST} + {1570291200 39600 1 AEDT} + {1586016000 36000 0 AEST} + {1601740800 39600 1 AEDT} + {1617465600 36000 0 AEST} + {1633190400 39600 1 AEDT} + {1648915200 36000 0 AEST} + {1664640000 39600 1 AEDT} + {1680364800 36000 0 AEST} + {1696089600 39600 1 AEDT} + {1712419200 36000 0 AEST} + {1728144000 39600 1 AEDT} + {1743868800 36000 0 AEST} + {1759593600 39600 1 AEDT} + {1775318400 36000 0 AEST} + {1791043200 39600 1 AEDT} + {1806768000 36000 0 AEST} + {1822492800 39600 1 AEDT} + {1838217600 36000 0 AEST} + {1853942400 39600 1 AEDT} + {1869667200 36000 0 AEST} + {1885996800 39600 1 AEDT} + {1901721600 36000 0 AEST} + {1917446400 39600 1 AEDT} + {1933171200 36000 0 AEST} + {1948896000 39600 1 AEDT} + {1964620800 36000 0 AEST} + {1980345600 39600 1 AEDT} + {1996070400 36000 0 AEST} + {2011795200 39600 1 AEDT} + {2027520000 36000 0 AEST} + {2043244800 39600 1 AEDT} + {2058969600 36000 0 AEST} + {2075299200 39600 1 AEDT} + {2091024000 36000 0 AEST} + {2106748800 39600 1 AEDT} + {2122473600 36000 0 AEST} + {2138198400 39600 1 AEDT} + {2153923200 36000 0 AEST} + {2169648000 39600 1 AEDT} + {2185372800 36000 0 AEST} + {2201097600 39600 1 AEDT} + {2216822400 36000 0 AEST} + {2233152000 39600 1 AEDT} + {2248876800 36000 0 AEST} + {2264601600 39600 1 AEDT} + {2280326400 36000 0 AEST} + {2296051200 39600 1 AEDT} + {2311776000 36000 0 AEST} + {2327500800 39600 1 AEDT} + {2343225600 36000 0 AEST} + {2358950400 39600 1 AEDT} + {2374675200 36000 0 AEST} + {2390400000 39600 1 AEDT} + {2406124800 36000 0 AEST} + {2422454400 39600 1 AEDT} + {2438179200 36000 0 AEST} + {2453904000 39600 1 AEDT} + {2469628800 36000 0 AEST} + {2485353600 39600 1 AEDT} + {2501078400 36000 0 AEST} + {2516803200 39600 1 AEDT} + {2532528000 36000 0 AEST} + {2548252800 39600 1 AEDT} + {2563977600 36000 0 AEST} + {2579702400 39600 1 AEDT} + {2596032000 36000 0 AEST} + {2611756800 39600 1 AEDT} + {2627481600 36000 0 AEST} + {2643206400 39600 1 AEDT} + {2658931200 36000 0 AEST} + {2674656000 39600 1 AEDT} + {2690380800 36000 0 AEST} + {2706105600 39600 1 AEDT} + {2721830400 36000 0 AEST} + {2737555200 39600 1 AEDT} + {2753280000 36000 0 AEST} + {2769609600 39600 1 AEDT} + {2785334400 36000 0 AEST} + {2801059200 39600 1 AEDT} + {2816784000 36000 0 AEST} + {2832508800 39600 1 AEDT} + {2848233600 36000 0 AEST} + {2863958400 39600 1 AEDT} + {2879683200 36000 0 AEST} + {2895408000 39600 1 AEDT} + {2911132800 36000 0 AEST} + {2926857600 39600 1 AEDT} + {2942582400 36000 0 AEST} + {2958912000 39600 1 AEDT} + {2974636800 36000 0 AEST} + {2990361600 39600 1 AEDT} + {3006086400 36000 0 AEST} + {3021811200 39600 1 AEDT} + {3037536000 36000 0 AEST} + {3053260800 39600 1 AEDT} + {3068985600 36000 0 AEST} + {3084710400 39600 1 AEDT} + {3100435200 36000 0 AEST} + {3116764800 39600 1 AEDT} + {3132489600 36000 0 AEST} + {3148214400 39600 1 AEDT} + {3163939200 36000 0 AEST} + {3179664000 39600 1 AEDT} + {3195388800 36000 0 AEST} + {3211113600 39600 1 AEDT} + {3226838400 36000 0 AEST} + {3242563200 39600 1 AEDT} + {3258288000 36000 0 AEST} + {3274012800 39600 1 AEDT} + {3289737600 36000 0 AEST} + {3306067200 39600 1 AEDT} + {3321792000 36000 0 AEST} + {3337516800 39600 1 AEDT} + {3353241600 36000 0 AEST} + {3368966400 39600 1 AEDT} + {3384691200 36000 0 AEST} + {3400416000 39600 1 AEDT} + {3416140800 36000 0 AEST} + {3431865600 39600 1 AEDT} + {3447590400 36000 0 AEST} + {3463315200 39600 1 AEDT} + {3479644800 36000 0 AEST} + {3495369600 39600 1 AEDT} + {3511094400 36000 0 AEST} + {3526819200 39600 1 AEDT} + {3542544000 36000 0 AEST} + {3558268800 39600 1 AEDT} + {3573993600 36000 0 AEST} + {3589718400 39600 1 AEDT} + {3605443200 36000 0 AEST} + {3621168000 39600 1 AEDT} + {3636892800 36000 0 AEST} + {3653222400 39600 1 AEDT} + {3668947200 36000 0 AEST} + {3684672000 39600 1 AEDT} + {3700396800 36000 0 AEST} + {3716121600 39600 1 AEDT} + {3731846400 36000 0 AEST} + {3747571200 39600 1 AEDT} + {3763296000 36000 0 AEST} + {3779020800 39600 1 AEDT} + {3794745600 36000 0 AEST} + {3810470400 39600 1 AEDT} + {3826195200 36000 0 AEST} + {3842524800 39600 1 AEDT} + {3858249600 36000 0 AEST} + {3873974400 39600 1 AEDT} + {3889699200 36000 0 AEST} + {3905424000 39600 1 AEDT} + {3921148800 36000 0 AEST} + {3936873600 39600 1 AEDT} + {3952598400 36000 0 AEST} + {3968323200 39600 1 AEDT} + {3984048000 36000 0 AEST} + {4000377600 39600 1 AEDT} + {4016102400 36000 0 AEST} + {4031827200 39600 1 AEDT} + {4047552000 36000 0 AEST} + {4063276800 39600 1 AEDT} + {4079001600 36000 0 AEST} + {4094726400 39600 1 AEDT} } diff --git a/library/tzdata/Europe/Budapest b/library/tzdata/Europe/Budapest index e660ad1..4b92c5f 100644 --- a/library/tzdata/Europe/Budapest +++ b/library/tzdata/Europe/Budapest @@ -2,17 +2,19 @@ set TZData(:Europe/Budapest) { {-9223372036854775808 4580 0 LMT} - {-2500938980 3600 0 CET} + {-2498260580 3600 0 CET} {-1693706400 7200 1 CEST} {-1680483600 3600 0 CET} {-1663455600 7200 1 CEST} {-1650150000 3600 0 CET} {-1640998800 3600 0 CET} - {-1633212000 7200 1 CEST} + {-1632006000 7200 1 CEST} {-1618700400 3600 0 CET} - {-1600466400 7200 1 CEST} - {-1581202800 3600 0 CET} - {-906771600 3600 0 CET} + {-1600470000 7200 1 CEST} + {-1587250800 3600 0 CET} + {-1569711600 7200 1 CEST} + {-1555196400 3600 0 CET} + {-906775200 3600 0 CET} {-857257200 3600 0 CET} {-844556400 7200 1 CEST} {-828226800 3600 0 CET} @@ -20,33 +22,32 @@ set TZData(:Europe/Budapest) { {-796777200 3600 0 CET} {-788922000 3600 0 CET} {-778471200 7200 1 CEST} - {-762660000 3600 0 CET} + {-762656400 3600 0 CET} {-749689200 7200 1 CEST} - {-733359600 3600 0 CET} + {-733276800 3600 0 CET} {-717634800 7200 1 CEST} {-701910000 3600 0 CET} {-686185200 7200 1 CEST} {-670460400 3600 0 CET} {-654130800 7200 1 CEST} {-639010800 3600 0 CET} - {-621990000 7200 1 CEST} - {-605660400 3600 0 CET} {-492656400 7200 1 CEST} {-481168800 3600 0 CET} - {-461120400 7200 1 CEST} - {-449632800 3600 0 CET} - {-428547600 7200 1 CEST} - {-418269600 3600 0 CET} - {-397094400 7200 1 CEST} + {-461199600 7200 1 CEST} + {-449708400 3600 0 CET} + {-428540400 7200 1 CEST} + {-418258800 3600 0 CET} + {-397090800 7200 1 CEST} {-386809200 3600 0 CET} - {323827200 7200 1 CEST} - {338950800 3600 0 CET} - {354675600 7200 1 CEST} - {370400400 3600 0 CET} - {386125200 7200 1 CEST} - {401850000 3600 0 CET} - {417574800 7200 1 CEST} - {433299600 3600 0 CET} + {323823600 7200 1 CEST} + {338943600 3600 0 CET} + {354668400 7200 1 CEST} + {370393200 3600 0 CET} + {386118000 7200 1 CEST} + {401842800 3600 0 CET} + {417567600 7200 1 CEST} + {433292400 3600 0 CET} + {441759600 3600 0 CET} {449024400 7200 1 CEST} {465354000 3600 0 CET} {481078800 7200 1 CEST} diff --git a/library/tzdata/Europe/Monaco b/library/tzdata/Europe/Monaco index f887b0b..7428b2f 100644 --- a/library/tzdata/Europe/Monaco +++ b/library/tzdata/Europe/Monaco @@ -2,8 +2,8 @@ set TZData(:Europe/Monaco) { {-9223372036854775808 1772 0 LMT} - {-2486680172 561 0 PMT} - {-1855958961 0 0 WET} + {-2448318572 561 0 PMT} + {-1854403761 0 0 WET} {-1689814800 3600 1 WEST} {-1680397200 0 0 WET} {-1665363600 3600 1 WEST} diff --git a/library/tzdata/Europe/Paris b/library/tzdata/Europe/Paris index 4b22a09..7208e55 100644 --- a/library/tzdata/Europe/Paris +++ b/library/tzdata/Europe/Paris @@ -2,8 +2,8 @@ set TZData(:Europe/Paris) { {-9223372036854775808 561 0 LMT} - {-2486678901 561 0 PMT} - {-1855958901 0 0 WET} + {-2486592561 561 0 PMT} + {-1855958961 0 0 WET} {-1689814800 3600 1 WEST} {-1680397200 0 0 WET} {-1665363600 3600 1 WEST} diff --git a/tools/tclZIC.tcl b/tools/tclZIC.tcl index 85c9ba9..6282111 100755 --- a/tools/tclZIC.tcl +++ b/tools/tclZIC.tcl @@ -36,7 +36,7 @@ set olsonFiles { africa antarctica asia australasia backward etcetera europe northamerica - pacificnew southamerica systemv + southamerica } # Define the year at which the DST information will stop. -- cgit v0.12 From 81e7623b785648f4b7c7ffdd8f1647c876bd4c45 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 13 Oct 2020 08:48:22 +0000 Subject: Fix warning, doing a static build on Windows --- win/tclAppInit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/tclAppInit.c b/win/tclAppInit.c index 171edff..f78f788 100644 --- a/win/tclAppInit.c +++ b/win/tclAppInit.c @@ -29,7 +29,7 @@ extern Tcl_PackageInitProc Tcltest_Init; extern Tcl_PackageInitProc Tcltest_SafeInit; #endif /* TCL_TEST */ -#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES +#if defined(STATIC_BUILD) && defined(TCL_USE_STATIC_PACKAGES) && TCL_USE_STATIC_PACKAGES extern Tcl_PackageInitProc Registry_Init; extern Tcl_PackageInitProc Dde_Init; extern Tcl_PackageInitProc Dde_SafeInit; @@ -159,7 +159,7 @@ Tcl_AppInit( return TCL_ERROR; } -#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES +#if defined(STATIC_BUILD) && defined(TCL_USE_STATIC_PACKAGES) && TCL_USE_STATIC_PACKAGES if (Registry_Init(interp) == TCL_ERROR) { return TCL_ERROR; } -- cgit v0.12 From 3fc1392c92078e35e6a35efc90ce598c1c2fc192 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 13 Oct 2020 14:59:43 +0000 Subject: More usage of TclNewObj() in stead of Tcl_NewObj() and TclNewIntObj() in stead of Tcl_NewIntObj() --- generic/tclAssembly.c | 7 ++++--- generic/tclCmdIL.c | 23 ++++++++++++----------- generic/tclCmdMZ.c | 11 ++++++----- generic/tclCompExpr.c | 4 ++-- generic/tclDate.c | 18 +++++++++--------- generic/tclDictObj.c | 3 ++- generic/tclExecute.c | 8 ++++---- generic/tclFCmd.c | 2 +- generic/tclGetDate.y | 18 +++++++++--------- generic/tclIORChan.c | 10 ++++++---- generic/tclListObj.c | 4 ++-- generic/tclLoad.c | 4 ++-- generic/tclMain.c | 7 ++++--- generic/tclNamesp.c | 6 ++++-- generic/tclOOBasic.c | 2 +- generic/tclPkg.c | 3 ++- generic/tclScan.c | 12 ++++++------ generic/tclStringObj.c | 19 +++++++++++-------- generic/tclTrace.c | 8 ++++---- generic/tclUtil.c | 2 +- generic/tclVar.c | 9 +++++---- generic/tclZlib.c | 5 +++-- unix/tclLoadDyld.c | 3 ++- unix/tclUnixFCmd.c | 6 +++--- unix/tclUnixInit.c | 2 +- unix/tclUnixPipe.c | 5 +++-- win/tclWinFCmd.c | 2 +- win/tclWinInit.c | 2 +- win/tclWinPipe.c | 2 +- 29 files changed, 112 insertions(+), 95 deletions(-) diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index d154bcf..2f8ab29 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -803,7 +803,7 @@ TclNRAssembleObjCmd( Tcl_AddErrorInfo(interp, "\n (\""); Tcl_AppendObjToErrorInfo(interp, objv[0]); Tcl_AddErrorInfo(interp, "\" body, line "); - backtrace = Tcl_NewIntObj(Tcl_GetErrorLine(interp)); + TclNewIntObj(backtrace, Tcl_GetErrorLine(interp)); Tcl_AppendObjToErrorInfo(interp, backtrace); Tcl_AddErrorInfo(interp, ")"); return TCL_ERROR; @@ -2089,8 +2089,9 @@ GetNextOperand( * with \-substitutions done. */ { Tcl_Interp* interp = (Tcl_Interp*) assemEnvPtr->envPtr->iPtr; - Tcl_Obj* operandObj = Tcl_NewObj(); + Tcl_Obj* operandObj; + TclNewObj(operandObj); if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) { Tcl_DecrRefCount(operandObj); if (assemEnvPtr->flags & TCL_EVAL_DIRECT) { @@ -4260,7 +4261,7 @@ AddBasicBlockRangeToErrorInfo( Tcl_Obj* lineNo; /* Line number in the source */ Tcl_AddErrorInfo(interp, "\n in assembly code between lines "); - lineNo = Tcl_NewIntObj(bbPtr->startLine); + TclNewIntObj(lineNo, bbPtr->startLine); Tcl_IncrRefCount(lineNo); Tcl_AppendObjToErrorInfo(interp, lineNo); Tcl_AddErrorInfo(interp, " and "); diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 8ecd145..c662c22 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -401,7 +401,7 @@ Tcl_IncrObjCmd( if (objc == 3) { incrPtr = objv[2]; } else { - incrPtr = Tcl_NewIntObj(1); + TclNewIntObj(incrPtr, 1); } Tcl_IncrRefCount(incrPtr); newValuePtr = TclIncrObjVar2(interp, objv[1], NULL, @@ -719,7 +719,7 @@ InfoCommandsCmd( if (entryPtr != NULL) { if (specificNsInPattern) { cmd = Tcl_GetHashValue(entryPtr); - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, cmd, elemObjPtr); } else { cmdName = Tcl_GetHashKey(&nsPtr->cmdTable, entryPtr); @@ -770,7 +770,7 @@ InfoCommandsCmd( || Tcl_StringMatch(cmdName, simplePattern)) { if (specificNsInPattern) { cmd = Tcl_GetHashValue(entryPtr); - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, cmd, elemObjPtr); } else { elemObjPtr = Tcl_NewStringObj(cmdName, -1); @@ -997,8 +997,9 @@ InfoDefaultCmd( } Tcl_SetObjResult(interp, Tcl_NewIntObj(1)); } else { - Tcl_Obj *nullObjPtr = Tcl_NewObj(); + Tcl_Obj *nullObjPtr; + TclNewObj(nullObjPtr); valueObjPtr = Tcl_ObjSetVar2(interp, objv[3], NULL, nullObjPtr, TCL_LEAVE_ERR_MSG); if (valueObjPtr == NULL) { @@ -1908,7 +1909,7 @@ InfoProcsCmd( } else { simpleProcOK: if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, elemObjPtr); } else { @@ -1936,7 +1937,7 @@ InfoProcsCmd( } else { procOK: if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, elemObjPtr); } else { @@ -2169,7 +2170,7 @@ Tcl_JoinObjCmd( joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2]; Tcl_IncrRefCount(joinObjPtr); - resObjPtr = Tcl_NewObj(); + TclNewObj(resObjPtr); for (i = 0; i < listLen; i++) { if (i > 0) { @@ -3485,7 +3486,7 @@ Tcl_LsearchObjCmd( } else if (returnSubindices) { int j; - itemPtr = Tcl_NewIntObj(i); + TclNewIntObj(itemPtr, i); for (j=0 ; jpayload.index; for (j = 0; j < groupSize; j++) { if (indices) { - objPtr = Tcl_NewIntObj(idx + j - groupOffset); + TclNewIntObj(objPtr, idx + j - groupOffset); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } else { @@ -4099,7 +4100,7 @@ Tcl_LsortObjCmd( } } else if (indices) { for (i=0; elementPtr != NULL ; elementPtr = elementPtr->nextPtr) { - objPtr = Tcl_NewIntObj(elementPtr->payload.index); + TclNewIntObj(objPtr, elementPtr->payload.index); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b24cb97..081b036 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -357,7 +357,7 @@ Tcl_RegexpObjCmd( objc = info.nsubs + 1; if (all <= 1) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } } for (i = 0; i < objc; i++) { @@ -399,7 +399,7 @@ Tcl_RegexpObjCmd( offset + info.matches[i].start, offset + info.matches[i].end - 1); } else { - newPtr = Tcl_NewObj(); + TclNewObj(newPtr); } } if (doinline) { @@ -1058,7 +1058,7 @@ Tcl_SplitObjCmd( stringPtr = TclGetStringFromObj(objv[1], &stringLen); end = stringPtr + stringLen; - listPtr = Tcl_NewObj(); + TclNewObj(listPtr); if (stringLen == 0) { /* @@ -3915,7 +3915,8 @@ TclNRSwitchObjCmd( rangeObjAry[0] = Tcl_NewLongObj(info.matches[j].start); rangeObjAry[1] = Tcl_NewLongObj(info.matches[j].end-1); } else { - rangeObjAry[0] = rangeObjAry[1] = Tcl_NewIntObj(-1); + TclNewIntObj(rangeObjAry[1], -1); + rangeObjAry[0] = rangeObjAry[1]; } /* @@ -4857,7 +4858,7 @@ TclNRTryObjCmd( return TCL_ERROR; } bodyObj = objv[1]; - handlersObj = Tcl_NewObj(); + TclNewObj(handlersObj); bodyShared = 0; haveHandlers = 0; for (i=2 ; ii.identity); + TclNewIntObj(litObjv[1], occdPtr->i.identity); Tcl_IncrRefCount(litObjv[1]); decrMe = 1; litObjv[0] = objv[1]; @@ -2705,7 +2705,7 @@ TclVariadicOpCmd( if (lexeme == DIVIDE) { litObjv[0] = Tcl_NewDoubleObj(1.0); } else { - litObjv[0] = Tcl_NewIntObj(occdPtr->i.identity); + TclNewIntObj(litObjv[0], occdPtr->i.identity); } Tcl_IncrRefCount(litObjv[0]); litObjv[1] = objv[1]; diff --git a/generic/tclDate.c b/generic/tclDate.c index 5410046..90650ef 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2501,12 +2501,12 @@ TclDateerror( Tcl_AppendToObj(infoPtr->messages, infoPtr->separatrix, -1); Tcl_AppendToObj(infoPtr->messages, s, -1); Tcl_AppendToObj(infoPtr->messages, " (characters ", -1); - t = Tcl_NewIntObj(location->first_column); + TclNewIntObj(t, location->first_column); Tcl_IncrRefCount(t); Tcl_AppendObjToObj(infoPtr->messages, t); Tcl_DecrRefCount(t); Tcl_AppendToObj(infoPtr->messages, "-", -1); - t = Tcl_NewIntObj(location->last_column); + TclNewIntObj(t, location->last_column); Tcl_IncrRefCount(t); Tcl_AppendObjToObj(infoPtr->messages, t); Tcl_DecrRefCount(t); @@ -2788,7 +2788,7 @@ TclClockOldscanObjCmd( yyHaveRel = 0; yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL; - dateInfo.messages = Tcl_NewObj(); + TclNewObj(dateInfo.messages); dateInfo.separatrix = ""; Tcl_IncrRefCount(dateInfo.messages); @@ -2845,8 +2845,8 @@ TclClockOldscanObjCmd( return TCL_ERROR; } - result = Tcl_NewObj(); - resultElement = Tcl_NewObj(); + TclNewObj(result); + TclNewObj(resultElement); if (yyHaveDate) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyYear)); @@ -2864,7 +2864,7 @@ TclClockOldscanObjCmd( Tcl_ListObjAppendElement(interp, result, Tcl_NewObj()); } - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveZone) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) -yyTimezone)); @@ -2873,7 +2873,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveRel) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyRelMonth)); @@ -2884,7 +2884,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveDay && !yyHaveDate) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyDayOrdinal)); @@ -2893,7 +2893,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveOrdinalMonth) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyMonthOrdinal)); diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index a42c123..becc029 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -2142,8 +2142,9 @@ DictIncrCmd( if (objc == 4) { code = TclIncrObj(interp, valuePtr, objv[3]); } else { - Tcl_Obj *incrPtr = Tcl_NewIntObj(1); + Tcl_Obj *incrPtr; + TclNewIntObj(incrPtr, 1); Tcl_IncrRefCount(incrPtr); code = TclIncrObj(interp, valuePtr, incrPtr); TclDecrRefCount(incrPtr); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index b8e9312..0a293bd 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3854,7 +3854,7 @@ TEBCresume( case INST_INCR_SCALAR_STK_IMM: case INST_INCR_STK_IMM: increment = TclGetInt1AtPtr(pc+1); - incrPtr = Tcl_NewIntObj(increment); + TclNewIntObj(incrPtr, increment); Tcl_IncrRefCount(incrPtr); pcAdjustment = 2; @@ -3889,7 +3889,7 @@ TEBCresume( case INST_INCR_ARRAY1_IMM: opnd = TclGetUInt1AtPtr(pc+1); increment = TclGetInt1AtPtr(pc+2); - incrPtr = Tcl_NewIntObj(increment); + TclNewIntObj(incrPtr, increment); Tcl_IncrRefCount(incrPtr); pcAdjustment = 3; @@ -7394,7 +7394,7 @@ TEBCresume( if (valuePtr == NULL) { Tcl_DictObjPut(NULL, dictPtr, OBJ_AT_TOS,Tcl_NewIntObj(opnd)); } else { - value2Ptr = Tcl_NewIntObj(opnd); + TclNewIntObj(value2Ptr, opnd); Tcl_IncrRefCount(value2Ptr); if (Tcl_IsShared(valuePtr)) { valuePtr = Tcl_DuplicateObj(valuePtr); @@ -10248,7 +10248,7 @@ EvalStatsCmd( #define Percent(a,b) ((a) * 100.0 / (b)) - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); numInstructions = 0.0; diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index 99372c5..e2d4164 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -904,7 +904,7 @@ FileBasename( } } if (resultPtr == NULL) { - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); } Tcl_IncrRefCount(resultPtr); Tcl_DecrRefCount(splitPtr); diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 86037d6..65a3f86 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -716,12 +716,12 @@ TclDateerror( Tcl_AppendToObj(infoPtr->messages, infoPtr->separatrix, -1); Tcl_AppendToObj(infoPtr->messages, s, -1); Tcl_AppendToObj(infoPtr->messages, " (characters ", -1); - t = Tcl_NewIntObj(location->first_column); + TclNewIntObj(t, location->first_column); Tcl_IncrRefCount(t); Tcl_AppendObjToObj(infoPtr->messages, t); Tcl_DecrRefCount(t); Tcl_AppendToObj(infoPtr->messages, "-", -1); - t = Tcl_NewIntObj(location->last_column); + TclNewIntObj(t, location->last_column); Tcl_IncrRefCount(t); Tcl_AppendObjToObj(infoPtr->messages, t); Tcl_DecrRefCount(t); @@ -1003,7 +1003,7 @@ TclClockOldscanObjCmd( yyHaveRel = 0; yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL; - dateInfo.messages = Tcl_NewObj(); + TclNewObj(dateInfo.messages); dateInfo.separatrix = ""; Tcl_IncrRefCount(dateInfo.messages); @@ -1060,8 +1060,8 @@ TclClockOldscanObjCmd( return TCL_ERROR; } - result = Tcl_NewObj(); - resultElement = Tcl_NewObj(); + TclNewObj(result); + TclNewObj(resultElement); if (yyHaveDate) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyYear)); @@ -1079,7 +1079,7 @@ TclClockOldscanObjCmd( Tcl_ListObjAppendElement(interp, result, Tcl_NewObj()); } - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveZone) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) -yyTimezone)); @@ -1088,7 +1088,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveRel) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyRelMonth)); @@ -1099,7 +1099,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TcNewObj(resultElement); if (yyHaveDay && !yyHaveDate) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyDayOrdinal)); @@ -1108,7 +1108,7 @@ TclClockOldscanObjCmd( } Tcl_ListObjAppendElement(interp, result, resultElement); - resultElement = Tcl_NewObj(); + TclNewObj(resultElement); if (yyHaveOrdinalMonth) { Tcl_ListObjAppendElement(interp, resultElement, Tcl_NewIntObj((int) yyMonthOrdinal)); diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 9969b87..dd24b0f 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -1318,7 +1318,7 @@ ReflectInput( Tcl_Preserve(rcPtr); - toReadObj = Tcl_NewIntObj(toRead); + TclNewIntObj(toReadObj, toRead); Tcl_IncrRefCount(toReadObj); if (InvokeTclMethod(rcPtr, METH_READ, toReadObj, NULL, &resObj)!=TCL_OK) { @@ -2999,10 +2999,12 @@ ForwardProc( } case ForwardedInput: { - Tcl_Obj *toReadObj = Tcl_NewIntObj(paramPtr->input.toRead); - Tcl_IncrRefCount(toReadObj); + Tcl_Obj *toReadObj; - Tcl_Preserve(rcPtr); + TclNewIntObj(toReadObj, paramPtr->input.toRead); + Tcl_IncrRefCount(toReadObj); + + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_READ, toReadObj, NULL, &resObj)!=TCL_OK){ int code = ErrnoReturn(rcPtr, resObj); diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 481cae7..11726d5 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -1227,7 +1227,7 @@ TclLindexFlat( return NULL; } } - listPtr = Tcl_NewObj(); + TclNewObj(listPtr); } else { /* * Extract the pointer to the appropriate element. @@ -1458,7 +1458,7 @@ TclLsetFlat( if (--indexCount) { parentList = subListPtr; if (index == elemCount) { - subListPtr = Tcl_NewObj(); + TclNewObj(subListPtr); } else { subListPtr = elemPtrs[index]; } diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 5a736de..9ca2e7a 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -1049,7 +1049,7 @@ TclGetLoadedPackages( * Return information about all of the available packages. */ - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); Tcl_MutexLock(&packageMutex); for (pkgPtr = firstPackagePtr; pkgPtr != NULL; pkgPtr = pkgPtr->nextPtr) { @@ -1073,7 +1073,7 @@ TclGetLoadedPackages( return TCL_ERROR; } ipPtr = Tcl_GetAssocData(target, "tclLoad", NULL); - resultObj = Tcl_NewObj(); + TclNewObj(resultObj); for (; ipPtr != NULL; ipPtr = ipPtr->nextPtr) { pkgPtr = ipPtr->pkgPtr; pkgDesc[0] = Tcl_NewStringObj(pkgPtr->fileName, -1); diff --git a/generic/tclMain.c b/generic/tclMain.c index cef4543..f0b2682 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -306,7 +306,7 @@ Tcl_MainEx( is.interp = interp; is.prompt = PROMPT_START; - is.commandPtr = Tcl_NewObj(); + TclNewObj(is.commandPtr); /* * If the application has not already set a startup script, parse the @@ -521,7 +521,7 @@ Tcl_MainEx( TCL_EVAL_GLOBAL); is.input = Tcl_GetStdChannel(TCL_STDIN); Tcl_DecrRefCount(is.commandPtr); - is.commandPtr = Tcl_NewObj(); + TclNewObj(is.commandPtr); Tcl_IncrRefCount(is.commandPtr); if (code != TCL_OK) { chan = Tcl_GetStdChannel(TCL_STDERR); @@ -805,7 +805,8 @@ StdinProc( code = Tcl_RecordAndEvalObj(interp, commandPtr, TCL_EVAL_GLOBAL); isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN); Tcl_DecrRefCount(commandPtr); - isPtr->commandPtr = commandPtr = Tcl_NewObj(); + TclNewObj(commandPtr); + isPtr->commandPtr = commandPtr; Tcl_IncrRefCount(commandPtr); if (chan != NULL) { Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr); diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index bfce6ee..9541828 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -3547,8 +3547,9 @@ NamespaceExportCmd( */ if (objc == 1) { - Tcl_Obj *listPtr = Tcl_NewObj(); + Tcl_Obj *listPtr; + TclNewObj(listPtr); (void) Tcl_AppendExportList(interp, NULL, listPtr); Tcl_SetObjResult(interp, listPtr); return TCL_OK; @@ -4026,8 +4027,9 @@ NamespacePathCmd( */ if (objc == 1) { - Tcl_Obj *resultObj = Tcl_NewObj(); + Tcl_Obj *resultObj; + TclNewObj(resultObj); for (i=0 ; icommandPathLength ; i++) { if (nsPtr->commandPathArray[i].nsPtr != NULL) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index d874cba..0a1e1eb 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -1155,7 +1155,7 @@ TclOOSelfObjCmd( } case SELF_CALL: result[0] = TclOORenderCallChain(interp, contextPtr->callPtr); - result[1] = Tcl_NewIntObj(contextPtr->index); + TclNewIntObj(result[1], contextPtr->index); Tcl_SetObjResult(interp, Tcl_NewListObj(2, result)); return TCL_OK; } diff --git a/generic/tclPkg.c b/generic/tclPkg.c index 0a0c868..2150c31 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -718,8 +718,9 @@ SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) { } } } else if (result != TCL_ERROR) { - Tcl_Obj *codePtr = Tcl_NewIntObj(result); + Tcl_Obj *codePtr; + TclNewIntObj(codePtr, result); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "attempt to provide package %s %s failed:" " bad return code: %s", diff --git a/generic/tclScan.c b/generic/tclScan.c index c599797..6ab17bd 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -721,7 +721,7 @@ Tcl_ScanObjCmd( switch (ch) { case 'n': if (!(flags & SCAN_SUPPRESS)) { - objPtr = Tcl_NewIntObj(string - baseString); + TclNewIntObj(objPtr, string - baseString); Tcl_IncrRefCount(objPtr); CLANG_ASSERT(objs); objs[objIndex++] = objPtr; @@ -884,7 +884,7 @@ Tcl_ScanObjCmd( offset = TclUtfToUCS4(string, &i); string += offset; if (!(flags & SCAN_SUPPRESS)) { - objPtr = Tcl_NewIntObj(i); + TclNewIntObj(objPtr, i); Tcl_IncrRefCount(objPtr); CLANG_ASSERT(objs); objs[objIndex++] = objPtr; @@ -1035,7 +1035,7 @@ Tcl_ScanObjCmd( * Here no vars were specified, we want a list returned (inline scan) */ - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); for (i = 0; i < totalVars; i++) { if (objs[i] != NULL) { Tcl_ListObjAppendElement(NULL, objPtr, objs[i]); @@ -1056,16 +1056,16 @@ Tcl_ScanObjCmd( if (code == TCL_OK) { if (underflow && (nconversions == 0)) { if (numVars) { - objPtr = Tcl_NewIntObj(-1); + TclNewIntObj(objPtr, -1); } else { if (objPtr) { Tcl_SetListObj(objPtr, 0, NULL); } else { - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); } } } else if (numVars) { - objPtr = Tcl_NewIntObj(result); + TclNewIntObj(objPtr, result); } Tcl_SetObjResult(interp, objPtr); } diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 656d6ce..33b2139 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2209,7 +2209,7 @@ Tcl_AppendFormatToObj( isNegative = (l < (long) 0); } - segment = Tcl_NewObj(); + TclNewObj(segment); allocSegment = 1; segmentLimit = INT_MAX; Tcl_IncrRefCount(segment); @@ -2249,7 +2249,7 @@ Tcl_AppendFormatToObj( const char *bytes; if (useShort) { - pure = Tcl_NewIntObj((int) s); + TclNewIntObj(pure, (int) s); #ifndef TCL_WIDE_INT_IS_LONG } else if (useWide) { pure = Tcl_NewWideIntObj(w); @@ -2378,7 +2378,7 @@ Tcl_AppendFormatToObj( if ((numDigits == 0) && !((ch == 'o') && gotHash)) { numDigits = 1; } - pure = Tcl_NewObj(); + TclNewObj(pure); Tcl_SetObjLength(pure, (int) numDigits); bytes = TclGetString(pure); toAppend = length = (int) numDigits; @@ -2497,7 +2497,7 @@ Tcl_AppendFormatToObj( *p++ = (char) ch; *p = '\0'; - segment = Tcl_NewObj(); + TclNewObj(segment); allocSegment = 1; if (!Tcl_AttemptSetObjLength(segment, length)) { msg = overflow; @@ -2605,8 +2605,9 @@ Tcl_Format( Tcl_Obj *const objv[]) { int result; - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); result = Tcl_AppendFormatToObj(interp, objPtr, format, objc, objv); if (result != TCL_OK) { Tcl_DecrRefCount(objPtr); @@ -2634,9 +2635,10 @@ AppendPrintfToObjVA( va_list argList) { int code, objc; - Tcl_Obj **objv, *list = Tcl_NewObj(); + Tcl_Obj **objv, *list; const char *p; + TclNewObj(list); p = format; Tcl_IncrRefCount(list); while (*p != '\0') { @@ -2808,8 +2810,9 @@ Tcl_ObjPrintf( ...) { va_list argList; - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); va_start(argList, format); AppendPrintfToObjVA(objPtr, format, argList); va_end(argList); @@ -2948,7 +2951,7 @@ TclStringReverse( char *to, *from = objPtr->bytes; if (Tcl_IsShared(objPtr)) { - objPtr = Tcl_NewObj(); + TclNewObj(objPtr); Tcl_SetObjLength(objPtr, numBytes); } to = objPtr->bytes; diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 0228aff..c82fc14 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -278,7 +278,7 @@ Tcl_TraceObjCmd( return TCL_ERROR; } - opsList = Tcl_NewObj(); + TclNewObj(opsList); Tcl_IncrRefCount(opsList); flagOps = Tcl_GetStringFromObj(objv[3], &numFlags); if (numFlags == 0) { @@ -322,7 +322,7 @@ Tcl_TraceObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "name"); return TCL_ERROR; } - resultListPtr = Tcl_NewObj(); + TclNewObj(resultListPtr); name = Tcl_GetString(objv[2]); FOREACH_VAR_TRACE(interp, name, clientData) { TraceVarInfo *tvarPtr = clientData; @@ -967,7 +967,7 @@ TraceVariableObjCmd( return TCL_ERROR; } - resultListPtr = Tcl_NewObj(); + TclNewObj(resultListPtr); name = Tcl_GetString(objv[3]); FOREACH_VAR_TRACE(interp, name, clientData) { Tcl_Obj *opObjPtr, *eachTraceObjPtr, *elemObjPtr; @@ -1852,7 +1852,7 @@ TraceExecutionProc( * Append result code. */ - resultCode = Tcl_NewIntObj(code); + TclNewIntObj(resultCode, code); resultCodeStr = Tcl_GetString(resultCode); Tcl_DStringAppendElement(&cmd, resultCodeStr); Tcl_DecrRefCount(resultCode); diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 9efdbc3..d7baedd 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -2036,7 +2036,7 @@ Tcl_ConcatObj( } } if (!resPtr) { - resPtr = Tcl_NewObj(); + TclNewObj(resPtr); } return resPtr; } diff --git a/generic/tclVar.c b/generic/tclVar.c index b7567a8..566e543 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -2216,7 +2216,7 @@ TclPtrIncrObjVarIdx( VarHashRefCount(varPtr)--; } if (varValuePtr == NULL) { - varValuePtr = Tcl_NewIntObj(0); + TclNewIntObj(varValuePtr, 0); } if (Tcl_IsShared(varValuePtr)) { /* Copy on write */ @@ -5140,7 +5140,8 @@ TclDeleteNamespaceVars( for (varPtr = VarHashFirstVar(tablePtr, &search); varPtr != NULL; varPtr = VarHashFirstVar(tablePtr, &search)) { - Tcl_Obj *objPtr = Tcl_NewObj(); + Tcl_Obj *objPtr; + TclNewObj(objPtr); VarHashRefCount(varPtr)++; /* Make sure we get to remove from * hash. */ Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, objPtr); @@ -5875,7 +5876,7 @@ TclInfoVarsCmd( if (!TclIsVarUndefined(varPtr) || TclIsVarNamespaceVar(varPtr)) { if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, elemObjPtr); } else { @@ -5908,7 +5909,7 @@ TclInfoVarsCmd( if ((simplePattern == NULL) || Tcl_StringMatch(varName, simplePattern)) { if (specificNsInPattern) { - elemObjPtr = Tcl_NewObj(); + TclNewObj(elemObjPtr); Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, elemObjPtr); } else { diff --git a/generic/tclZlib.c b/generic/tclZlib.c index bdda9bc..ac19449 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2133,7 +2133,7 @@ ZlibCmd( break; case 1: headerVarObj = objv[i+1]; - headerDictObj = Tcl_NewObj(); + TclNewObj(headerDictObj); break; } } @@ -3432,8 +3432,9 @@ ZlibTransformGetOption( if ((cd->flags & IN_HEADER) && ((optionName == NULL) || (strcmp(optionName, "-header") == 0))) { - Tcl_Obj *tmpObj = Tcl_NewObj(); + Tcl_Obj *tmpObj; + TclNewObj(tmpObj); ExtractHeader(&cd->inHeader.header, tmpObj); if (optionName == NULL) { Tcl_DStringAppendElement(dsPtr, "-header"); diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index e998bf9..7d462da 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -292,8 +292,9 @@ TclpDlopen( *loadHandle = newHandle; result = TCL_OK; } else { - Tcl_Obj *errObj = Tcl_NewObj(); + Tcl_Obj *errObj; + TclNewObj(errObj); if (errMsg != NULL) { Tcl_AppendToObj(errObj, errMsg, -1); } diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index 9abd70a..8660818 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -1369,7 +1369,7 @@ GetGroupAttribute( groupPtr = TclpGetGrGid(statBuf.st_gid); if (groupPtr == NULL) { - *attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_gid); + TclNewIntObj(*attributePtrPtr, (int) statBuf.st_gid); } else { Tcl_DString ds; const char *utf; @@ -1423,7 +1423,7 @@ GetOwnerAttribute( pwPtr = TclpGetPwUid(statBuf.st_uid); if (pwPtr == NULL) { - *attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_uid); + TclNewIntObj(*attributePtrPtr, (int) statBuf.st_uid); } else { Tcl_DString ds; @@ -2341,7 +2341,7 @@ GetUnixFileAttributes( return TCL_ERROR; } - *attributePtrPtr = Tcl_NewIntObj((fileAttributes&attributeArray[objIndex])!=0); + TclNewIntObj(*attributePtrPtr, (fileAttributes&attributeArray[objIndex])!=0); return TCL_OK; } diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index d0f8521..72039ac 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -473,7 +473,7 @@ TclpInitLibraryPath( const char *str; Tcl_DString buffer; - pathPtr = Tcl_NewObj(); + TclNewObj(pathPtr); /* * Look for the library relative to the TCL_LIBRARY env variable. If the diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index b98ea26..d5cb765 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -229,9 +229,10 @@ TclpCreateTempFile( Tcl_Obj * TclpTempFileName(void) { - Tcl_Obj *retVal, *nameObj = Tcl_NewObj(); + Tcl_Obj *retVal, *nameObj; int fd; + TclNewObj(nameObj); Tcl_IncrRefCount(nameObj); fd = TclUnixOpenTemporaryFile(NULL, NULL, NULL, nameObj); if (fd == -1) { @@ -1284,7 +1285,7 @@ Tcl_PidObjCmd( */ pipePtr = Tcl_GetChannelInstanceData(chan); - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); for (i = 0; i < pipePtr->numPids; i++) { Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewIntObj(PTR2INT(TclpGetPid(pipePtr->pidPtr[i])))); diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index a7a98a4..86fea7e 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -1916,7 +1916,7 @@ TclpObjListVolumes(void) int i; char *p; - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); /* * On Win32s: diff --git a/win/tclWinInit.c b/win/tclWinInit.c index b0e08d0..6b8f18a 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -194,7 +194,7 @@ TclpInitLibraryPath( char installLib[LIBRARY_SIZE]; const char *bytes; - pathPtr = Tcl_NewObj(); + TclNewObj(pathPtr); /* * Initialize the substring used when locating the script library. The diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 204ad85..14ca9e3 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -2783,7 +2783,7 @@ Tcl_PidObjCmd( } pipePtr = (PipeInfo *) Tcl_GetChannelInstanceData(chan); - resultPtr = Tcl_NewObj(); + TclNewObj(resultPtr); for (i = 0; i < pipePtr->numPids; i++) { Tcl_ListObjAppendElement(/*interp*/ NULL, resultPtr, Tcl_NewWideIntObj((unsigned) -- cgit v0.12 From e3f7f1bad8178c56aa5e8ddb994c218c30ec0f45 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 14 Oct 2020 06:55:03 +0000 Subject: Fix MSVC++ 6.0 build --- generic/tclIORChan.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 7c4b038..e50c96f 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -3128,16 +3128,17 @@ ForwardProc( case ForwardedSeek: { Tcl_Obj *offObj; + Tcl_Obj *baseObj; TclNewIntObj(offObj, paramPtr->seek.offset); - Tcl_Obj *baseObj = Tcl_NewStringObj( - (paramPtr->seek.seekMode==SEEK_SET) ? "start" : - (paramPtr->seek.seekMode==SEEK_CUR) ? "current" : "end", -1); + baseObj = Tcl_NewStringObj( + (paramPtr->seek.seekMode==SEEK_SET) ? "start" : + (paramPtr->seek.seekMode==SEEK_CUR) ? "current" : "end", -1); - Tcl_IncrRefCount(offObj); - Tcl_IncrRefCount(baseObj); + Tcl_IncrRefCount(offObj); + Tcl_IncrRefCount(baseObj); - Tcl_Preserve(rcPtr); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_SEEK, offObj, baseObj, &resObj)!=TCL_OK){ ForwardSetObjError(paramPtr, resObj); paramPtr->seek.offset = -1; -- cgit v0.12 From f3ae2684eb9584f9f0ca5e6bdcaabd75347e3224 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 15 Oct 2020 09:19:29 +0000 Subject: Something strange going on on Travis with (long-gone) safe-stock86.test --- .travis.yml | 1 + tests/safe.test | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8712ebf..2630474 100644 --- a/.travis.yml +++ b/.travis.yml @@ -361,6 +361,7 @@ jobs: script: - make dist before_install: + - rm -rf tests/safe-stock8*.test - touch generic/tclStubInit.c generic/tclOOStubInit.c - cd ${BUILD_DIR} install: diff --git a/tests/safe.test b/tests/safe.test index b91da86..1c27c1e 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -13,7 +13,7 @@ # - Tests 5.* test the example packages themselves before they # are used to test Safe Base interpreters. # - Alternative tests using stock packages of Tcl 8.6 are in file -# safe-stock86.test. +# safe-stock.test. # # Copyright (c) 1995-1996 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. @@ -170,7 +170,7 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup { a eval exit } -result "" -# The old test "safe-5.1" has been moved to "safe-stock86-9.8". +# The old test "safe-5.1" has been moved to "safe-stock-9.8". # A replacement test using example files is "safe-9.8". # Tests 5.* test the example files before using them to test safe interpreters. -- cgit v0.12 From 59a788a6c454bbc917cee3d29d17bcec03e0eefc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 15 Oct 2020 11:02:21 +0000 Subject: Fix [53d5155335]: Typo in interp.n --- doc/interp.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/interp.n b/doc/interp.n index bfbf9fd..1127632 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -58,7 +58,7 @@ kernel call) between a child interpreter and its parent. See \fBALIAS INVOCATION\fR, below, for more details on how the alias mechanism works. .PP -A qualified interpreter name is a proper Tcl lists containing a subset of its +A qualified interpreter name is a proper Tcl list containing a subset of its ancestors in the interpreter hierarchy, terminated by the string naming the interpreter in its immediate parent. Interpreter names are relative to the interpreter in which they are used. For example, if -- cgit v0.12 From 546165585c006c1b86a25fbc88ee6843ba15dffb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 15 Oct 2020 13:05:20 +0000 Subject: Remove use of CFG_ENCODING from rules.vc/makefile.vc: It will become obsolete with TIP #587. In stead, move the default handling to tclPkgConfig.c for now --- generic/tclPkgConfig.c | 8 ++++++++ win/makefile.vc | 4 ---- win/rules.vc | 11 ++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/generic/tclPkgConfig.c b/generic/tclPkgConfig.c index 466d535..727e872 100644 --- a/generic/tclPkgConfig.c +++ b/generic/tclPkgConfig.c @@ -35,6 +35,14 @@ #include "tclInt.h" +#ifndef TCL_CFGVAL_ENCODING +# ifdef _WIN32 +# define TCL_CFGVAL_ENCODING "cp1252" +# else +# define TCL_CFGVAL_ENCODING "iso8859-1" +# endif +#endif + /* * Use C preprocessor statements to define the various values for the embedded * configuration information. diff --git a/win/makefile.vc b/win/makefile.vc index acdb3a6..99cae58 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -114,10 +114,6 @@ # TESTPAT= # Reads the tests requested to be run from this file. # -# CFG_ENCODING=encoding -# name of encoding for configuration information. Defaults -# to cp1252 -# # Examples: # c:\tcl_src\win\>nmake -f makefile.vc release # c:\tcl_src\win\>nmake -f makefile.vc test diff --git a/win/rules.vc b/win/rules.vc index 6dca6d9..f3e5439 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -415,9 +415,6 @@ _INSTALLDIR=$(_INSTALLDIR)\lib # NATIVE_ARCH - set to IX86 or AMD64 for the host machine # MACHINE - same as $(ARCH) - legacy # _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed -# CFG_ENCODING - set to an character encoding. -# TBD - this is passed to compiler as TCL_CFGVAL_ENCODING but can't -# see where it is used cc32 = $(CC) # built-in default. link32 = link @@ -503,10 +500,6 @@ _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -ou _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 !endif -!ifndef CFG_ENCODING -CFG_ENCODING = \"cp1252\" -!endif - ################################################################ # 4. Build the nmakehlp program # This is a helper app we need to overcome nmake's limiting @@ -1043,7 +1036,7 @@ BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE) BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER) !endif -!if !$(DEBUG) || $(DEBUG) && $(UNCHECKED) +!if !$(DEBUG) || $(TCL_VERSION) > 86 || $(DEBUG) && $(UNCHECKED) SUFX = $(SUFX:g=) !endif @@ -1292,7 +1285,7 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include # baselibs - minimum Windows libraries required. Parent makefile can # define PRJ_LIBS before including rules.rc if additional libs are needed -OPTDEFINES = /DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) /DSTDC_HEADERS +OPTDEFINES = /DSTDC_HEADERS !if $(VCVERSION) >= 1600 OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1 !else -- cgit v0.12 From 69875ee99d8bc12504eab91f901bd8bfc9272afa Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 16 Oct 2020 15:03:08 +0000 Subject: Fix env.test when running under wine on Linux. Mark other tests with "notWine", which fail currently under wine --- tests/cmdAH.test | 5 +++-- tests/env.test | 4 +++- tests/fCmd.test | 41 +++++++++++++++++++++-------------------- tests/fileName.test | 37 +++++++++++++++++++------------------ tests/registry.test | 5 +++-- tests/socket.test | 11 ++++++----- tests/winDde.test | 3 ++- tests/winFCmd.test | 37 +++++++++++++++++++------------------ tests/winFile.test | 7 ++++--- tests/winPipe.test | 17 ++++++++++------- 10 files changed, 90 insertions(+), 77 deletions(-) diff --git a/tests/cmdAH.test b/tests/cmdAH.test index e1fd920..8f01816 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -30,6 +30,7 @@ testConstraint linkDirectory [expr { ($::tcl_platform(osVersion) >= 5.0 && [lindex [file system [temporaryDirectory]] 1] eq "NTFS") }] +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] global env set cmdAHwd [pwd] @@ -1348,7 +1349,7 @@ 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 { +test cmdAH-25.3.1 {Tcl_FileObjCmd: owned} -constraints {win notWine} -body { if {[info exists env(SystemRoot)]} { file owned $env(SystemRoot) } else { @@ -1538,7 +1539,7 @@ test cmdAH-29.4 {Tcl_FileObjCmd: type} -constraints {unix} -setup { } -cleanup { file delete $linkfile } -result link -test cmdAH-29.4.1 {Tcl_FileObjCmd: type} -constraints {linkDirectory} -setup { +test cmdAH-29.4.1 {Tcl_FileObjCmd: type} -constraints {linkDirectory notWine} -setup { set tempdir [makeDirectory temp] } -body { set linkdir [file join [temporaryDirectory] link.dir] diff --git a/tests/env.test b/tests/env.test index bad9e66..c901148 100644 --- a/tests/env.test +++ b/tests/env.test @@ -104,7 +104,9 @@ variable keep { SHLIB_PATH SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING __CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM - CommonProgramFiles ProgramFiles CommonProgramW6432 ProgramW6432 + CommonProgramFiles CommonProgramFiles(x86) ProgramFiles + ProgramFiles(x86) CommonProgramW6432 ProgramW6432 + WINECONFIGDIR WINEDATADIR WINEDLLDIR0 WINEHOMEDIR } variable printenvScript [makeFile [string map [list @keep@ [list $keep]] { diff --git a/tests/fCmd.test b/tests/fCmd.test index 53313dc..a1e0a6e 100644 --- a/tests/fCmd.test +++ b/tests/fCmd.test @@ -41,6 +41,7 @@ if {[testConstraint win]} { testConstraint reg 1 } } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] set tmpspace /tmp;# default value # Find a group that exists on this Unix system, or else skip tests that @@ -416,7 +417,7 @@ test fCmd-5.4 {TclFileDeleteCmd: multiple files} -constraints notRoot -setup { } -cleanup {cleanup} -result {1 1 1 0 0 0} test fCmd-5.5 {TclFileDeleteCmd: stop at first error} -setup { cleanup -} -constraints {notRoot unixOrWin} -body { +} -constraints {notRoot unixOrWin notWine} -body { createfile tf1 createfile tf2 file mkdir td1 @@ -563,7 +564,7 @@ test fCmd-6.15 {CopyRenameOneFile: TclpRenameFile succeeds} -setup { } -result 1 test fCmd-6.16 {CopyRenameOneFile: TclpCopyRenameOneFile fails} -setup { cleanup -} -constraints {notRoot} -body { +} -constraints {notRoot notWine} -body { file mkdir [file join td1 td2] createfile [file join td1 td2 tf1] file mkdir td2 @@ -572,12 +573,12 @@ test fCmd-6.16 {CopyRenameOneFile: TclpCopyRenameOneFile fails} -setup { [subst {error renaming "td2" to "[file join td1 td2]": file *}] test fCmd-6.17 {CopyRenameOneFile: errno == EINVAL} -setup { cleanup -} -constraints {notRoot} -returnCodes error -body { +} -constraints {notRoot notWine} -returnCodes error -body { file rename -force $root tf1 } -result [subst {error renaming "$root" to "tf1": trying to rename a volume or move a directory into itself}] test fCmd-6.18 {CopyRenameOneFile: errno != EXDEV} -setup { cleanup -} -constraints {notRoot} -body { +} -constraints {notRoot notWine} -body { file mkdir [file join td1 td2] createfile [file join td1 td2 tf1] file mkdir td2 @@ -811,7 +812,7 @@ test fCmd-9.4.b {file rename: comprehensive: dir to new name} -setup { } -result {{td3 td4} 1 0} test fCmd-9.5 {file rename: comprehensive: file to self} -setup { cleanup -} -constraints {notRoot testchmod} -body { +} -constraints {notRoot testchmod notWine} -body { createfile tf1 tf1 createfile tf2 tf2 testchmod 0o444 tf2 @@ -841,7 +842,7 @@ test fCmd-9.6.b {file rename: comprehensive: dir to self} -setup { } -result {{td1 td2} 1 0} test fCmd-9.7 {file rename: comprehensive: file to existing file} -setup { cleanup -} -constraints {notRoot testchmod} -body { +} -constraints {notRoot testchmod notWine} -body { createfile tf1 createfile tf2 createfile tfs1 @@ -902,7 +903,7 @@ test fCmd-9.8 {file rename: comprehensive: dir to empty dir} -setup { # Test can hit EEXIST or EBUSY, depending on underlying filesystem test fCmd-9.9 {file rename: comprehensive: dir to non-empty dir} -setup { cleanup -} -constraints {notRoot testchmod} -body { +} -constraints {notRoot testchmod notWine} -body { file mkdir tds1 file mkdir tds2 file mkdir [file join tdd1 tds1 xxx] @@ -966,14 +967,14 @@ test fCmd-9.12 {file rename: comprehensive: target exists} -setup { # Test can hit EEXIST or EBUSY, depending on underlying filesystem test fCmd-9.13 {file rename: comprehensive: can't overwrite target} -setup { cleanup -} -constraints {notRoot} -body { +} -constraints {notRoot notWine} -body { file mkdir [file join td1 td2] [file join td2 td1 td4] file rename -force td1 td2 } -returnCodes error -match glob -result \ [subst {error renaming "td1" to "[file join td2 td1]": file *}] test fCmd-9.14 {file rename: comprehensive: dir into self} -setup { cleanup -} -constraints {notRoot} -body { +} -constraints {notRoot notWine} -body { file mkdir td1 list [glob td*] [list [catch {file rename td1 td1} msg] $msg] } -result [subst {td1 {1 {error renaming "td1" to "[file join td1 td1]": trying to rename a volume or move a directory into itself}}}] @@ -1068,7 +1069,7 @@ test fCmd-10.3.1 {file copy: comprehensive: dir to new name} -setup { } -result [list {td1 td2 td3 td4} [file join td3 tdx] [file join td4 tdy] 1 1] test fCmd-10.4 {file copy: comprehensive: file to existing file} -setup { cleanup -} -constraints {notRoot testchmod} -body { +} -constraints {notRoot testchmod notWine} -body { createfile tf1 createfile tf2 createfile tfs1 @@ -2401,7 +2402,7 @@ test fCmd-28.10.1 {file link: linking to nonexistent path} -setup { test fCmd-28.11 {file link: success with directory} -setup { cd [temporaryDirectory] file delete -force abc.link -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { file link abc.link abc.dir } -cleanup { cd [workingDirectory] @@ -2409,7 +2410,7 @@ test fCmd-28.11 {file link: success with directory} -setup { test fCmd-28.12 {file link: cd into a link} -setup { cd [temporaryDirectory] file delete -force abc.link -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { file link abc.link abc.dir set orig [pwd] cd abc.link @@ -2435,7 +2436,7 @@ test fCmd-28.12 {file link: cd into a link} -setup { file delete -force abc.link cd [workingDirectory] } -result ok -test fCmd-28.13 {file link} -constraints {linkDirectory} -setup { +test fCmd-28.13 {file link} -constraints {linkDirectory notWine} -setup { cd [temporaryDirectory] file link abc.link abc.dir } -body { @@ -2469,7 +2470,7 @@ test fCmd-28.15.1 {file link: copies link not dir} -setup { test fCmd-28.15.2 {file link: copies link not dir} -setup { cd [temporaryDirectory] file delete -force abc.link -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { file link abc.link abc.dir file copy abc.link abc2.link list [file type abc2.link] [file tail [file link abc2.link]] @@ -2490,7 +2491,7 @@ cd [workingDirectory] test fCmd-28.16 {file link: glob inside link} -setup { cd [temporaryDirectory] file delete -force abc.link -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { file link abc.link abc.dir lsort [glob -dir abc.link -tails *] } -cleanup { @@ -2500,13 +2501,13 @@ test fCmd-28.16 {file link: glob inside link} -setup { test fCmd-28.17 {file link: glob -type l} -setup { cd [temporaryDirectory] file link abc.link abc.dir -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { glob -dir [pwd] -type l -tails abc* } -cleanup { file delete -force abc.link cd [workingDirectory] } -result {abc.link} -test fCmd-28.18 {file link: glob -type d} -constraints linkDirectory -setup { +test fCmd-28.18 {file link: glob -type d} -constraints {linkDirectory notWine} -setup { cd [temporaryDirectory] file link abc.link abc.dir } -body { @@ -2517,7 +2518,7 @@ test fCmd-28.18 {file link: glob -type d} -constraints linkDirectory -setup { } -result [lsort [list abc.link abc.dir abc2.dir]] test fCmd-28.19 {file link: relative paths} -setup { cd [temporaryDirectory] -} -constraints {win linkDirectory} -body { +} -constraints {win linkDirectory notWine} -body { file mkdir d1/d2/d3 file link d1/l2 d1/d2 } -cleanup { @@ -2575,12 +2576,12 @@ test fCmd-30.1 {file writable on 'My Documents'} -setup { } -constraints {win reg} -body { file writable $mydocsname } -result 1 -test fCmd-30.2 {file readable on 'NTUSER.DAT'} -constraints {win} -body { +test fCmd-30.2 {file readable on 'NTUSER.DAT'} -constraints {win notWine} -body { expr {[info exists env(USERPROFILE)] && [file exists $env(USERPROFILE)/NTUSER.DAT] && [file readable $env(USERPROFILE)/NTUSER.DAT]} } -result {1} -test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {win} -body { +test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {win notWine} -body { set r {} if {[info exists env(SystemDrive)]} { set path $env(SystemDrive)/pagefile.sys diff --git a/tests/fileName.test b/tests/fileName.test index c73efac..ac93383 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -31,6 +31,7 @@ if {[testConstraint win]} { testConstraint symbolicLinkFile 0 testConstraint sharedCdrive [expr {![catch {cd //[info hostname]/c}]}] } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] # This match compares the first two words of the result. If the wanted result # is "equal", then this is successful if the words are equal. If the wanted # result is "not equal", then this is successful if the words are different. @@ -789,7 +790,7 @@ test filename-11.17 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.17.1 {Tcl_GlobCmd} {win} { +test filename-11.17.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -directory $globname *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -800,7 +801,7 @@ test filename-11.17.1 {Tcl_GlobCmd} {win} { [file join $globname y1.c] [file join $globname z1.c]]] test filename-11.17.2 {Tcl_GlobCmd} -setup { set dir [pwd] -} -constraints {notRoot linkDirectory} -body { +} -constraints {notRoot linkDirectory notWine} -body { cd $globname file link -symbolic link a1 cd $dir @@ -813,7 +814,7 @@ test filename-11.17.2 {Tcl_GlobCmd} -setup { # Simpler version of the above test to illustrate a given bug. test filename-11.17.3 {Tcl_GlobCmd} -setup { set dir [pwd] -} -constraints {notRoot linkDirectory} -body { +} -constraints {notRoot linkDirectory notWine} -body { cd $globname file link -symbolic link a1 cd $dir @@ -828,7 +829,7 @@ test filename-11.17.3 {Tcl_GlobCmd} -setup { # Make sure the bugfix isn't too simple. We don't want to break 'glob -type l' test filename-11.17.4 {Tcl_GlobCmd} -setup { set dir [pwd] -} -constraints {notRoot linkDirectory} -body { +} -constraints {notRoot linkDirectory notWine} -body { cd $globname file link -symbolic link a1 cd $dir @@ -846,7 +847,7 @@ test filename-11.17.6 {Tcl_GlobCmd} { [list "weird name.c" x,z1.c x1.c y1.c z1.c]]] test filename-11.17.7 {Tcl_GlobCmd: broken link and glob -l} -setup { set dir [pwd] -} -constraints {linkDirectory} -body { +} -constraints {linkDirectory notWine} -body { cd $globname file mkdir nonexistent file link -symbolic link nonexistent @@ -878,7 +879,7 @@ test filename-11.18 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.18.1 {Tcl_GlobCmd} {win} { +test filename-11.18.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -path $globname/ *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -895,7 +896,7 @@ test filename-11.19 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.19.1 {Tcl_GlobCmd} {win} { +test filename-11.19.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -join -path [string range $globname 0 5] * *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -904,7 +905,7 @@ test filename-11.19.1 {Tcl_GlobCmd} {win} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.20 {Tcl_GlobCmd} { +test filename-11.20 {Tcl_GlobCmd} notWine { lsort [glob -type d -dir $globname *] } [lsort [list [file join $globname a1]\ [file join $globname a2]\ @@ -934,7 +935,7 @@ test filename-11.22 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.22.1 {Tcl_GlobCmd} {win} { +test filename-11.22.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -dir $globname *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -951,7 +952,7 @@ test filename-11.23 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.23.1 {Tcl_GlobCmd} {win} { +test filename-11.23.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -path $globname/ *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -968,7 +969,7 @@ test filename-11.24 {Tcl_GlobCmd} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.24.1 {Tcl_GlobCmd} {win} { +test filename-11.24.1 {Tcl_GlobCmd} {win notWine} { lsort [glob -join -path [string range $globname 0 5] * *] } [lsort [list [file join $globname a1] [file join $globname a2]\ [file join $globname .1]\ @@ -977,17 +978,17 @@ test filename-11.24.1 {Tcl_GlobCmd} {win} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-11.25 {Tcl_GlobCmd} { +test filename-11.25 {Tcl_GlobCmd} notWine { lsort [glob -type d -dir $globname *] } [lsort [list [file join $globname a1]\ [file join $globname a2]\ [file join $globname a3]]] -test filename-11.25.1 {Tcl_GlobCmd} { +test filename-11.25.1 {Tcl_GlobCmd} notWine { lsort [glob -type {d r} -dir $globname *] } [lsort [list [file join $globname a1]\ [file join $globname a2]\ [file join $globname a3]]] -test filename-11.25.2 {Tcl_GlobCmd} { +test filename-11.25.2 {Tcl_GlobCmd} notWine { lsort [glob -type {d r w} -dir $globname *] } [lsort [list [file join $globname a1]\ [file join $globname a2]\ @@ -1231,10 +1232,10 @@ test filename-14.5 {asterisks, question marks, and brackets} -setup { test filename-14.7 {asterisks, question marks, and brackets} {unix} { lsort [glob globTest/*] } {globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} -test filename-14.7.1 {asterisks, question marks, and brackets} {win} { +test filename-14.7.1 {asterisks, question marks, and brackets} {win notWine} { lsort [glob globTest/*] } {globTest/.1 globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} -test filename-14.9 {asterisks, question marks, and brackets} {unixOrWin} { +test filename-14.9 {asterisks, question marks, and brackets} {unixOrWin notWine} { lsort [glob globTest/.*] } {globTest/. globTest/.. globTest/.1} test filename-14.11 {asterisks, question marks, and brackets} {unixOrWin} { @@ -1243,7 +1244,7 @@ test filename-14.11 {asterisks, question marks, and brackets} {unixOrWin} { test filename-14.13 {asterisks, question marks, and brackets} {unixOrWin} { lsort [glob {globTest/[xyab]1.*}] } {globTest/x1.c globTest/y1.c} -test filename-14.15 {asterisks, question marks, and brackets} {unixOrWin} { +test filename-14.15 {asterisks, question marks, and brackets} {unixOrWin notWine} { lsort [glob globTest/*/] } {globTest/a1/ globTest/a2/ globTest/a3/} test filename-14.17 {asterisks, question marks, and brackets} -setup { @@ -1283,7 +1284,7 @@ test filename-14.25 {type specific globbing} {unix} { [file join $globname x,z1.c]\ [file join $globname x1.c]\ [file join $globname y1.c] [file join $globname z1.c]]] -test filename-14.25.1 {type specific globbing} {win} { +test filename-14.25.1 {type specific globbing} {win notWine} { lsort [glob -dir globTest -types f *] } [lsort [list \ [file join $globname .1]\ diff --git a/tests/registry.test b/tests/registry.test index 53e48fe..dbf4575 100644 --- a/tests/registry.test +++ b/tests/registry.test @@ -24,6 +24,7 @@ if {[testConstraint win]} { testConstraint reg 1 } } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] # determine the current locale testConstraint english [expr { @@ -673,10 +674,10 @@ test registry-12.2 {BroadcastValue} -constraints {win reg} -body { test registry-12.3 {BroadcastValue} -constraints {win reg} -body { registry broadcast "" - 500 } -returnCodes error -result "wrong # args: should be \"registry broadcast keyName ?-timeout milliseconds?\"" -test registry-12.4 {BroadcastValue} -constraints {win reg} -body { +test registry-12.4 {BroadcastValue} -constraints {win reg notWine} -body { registry broadcast {Environment} } -result {1 0} -test registry-12.5 {BroadcastValue} -constraints {win reg} -body { +test registry-12.5 {BroadcastValue} -constraints {win reg notWine} -body { registry b {} } -result {1 0} diff --git a/tests/socket.test b/tests/socket.test index 868c17a..6a045b1 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -72,6 +72,7 @@ catch [list package require -exact Tcltest [info patchlevel]] if {[expr {[info exists ::env(TRAVIS_OSX_IMAGE)] && [string match xcode* $::env(TRAVIS_OSX_IMAGE)]}]} { return } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] # Some tests require the Thread package or exec command testConstraint thread [expr {0 == [catch {package require Thread 2.7-}]}] @@ -734,7 +735,7 @@ test socket_$af-2.12 {} [list socket stdio supported_$af] { close $f set ::done } 0 -test socket_$af-2.13 {Bug 1758a0b603} {socket stdio} { +test socket_$af-2.13 {Bug 1758a0b603} {socket stdio notWine} { file delete $path(script) set f [open $path(script) w] puts $f { @@ -1543,7 +1544,7 @@ test socket_$af-11.11 {testing spurious events} -setup { after cancel $timer sendCommand {close $server} } -result {0 2690 1} -test socket_$af-11.12 {testing EOF stickyness} -constraints [list socket supported_$af doTestsWithRemoteServer] -setup { +test socket_$af-11.12 {testing EOF stickyness} -constraints [list socket supported_$af doTestsWithRemoteServer notWine] -setup { set counter 0 set done 0 set port [sendCommand { @@ -2101,7 +2102,7 @@ test socket-14.4 {[socket -async] and both, readdable and writable fileevents} \ } -result {{} bye} # FIXME: we should also have an IPv6 counterpart of this test socket-14.5 {[socket -async] which fails before any connect() can be made} \ - -constraints {socket supported_inet} \ + -constraints {socket supported_inet notWine} \ -body { # address from rfc5737 socket -async -myaddr 192.0.2.42 127.0.0.1 [randport] @@ -2436,7 +2437,7 @@ test socket-14.12 {[socket -async] background progress triggered by [fconfigure } -result {connection refused} test socket-14.13 {testing writable event when quick failure} \ - -constraints {socket win supported_inet} \ + -constraints {socket win supported_inet notWine} \ -body { # Test for bug 336441ed59 where a quick background fail was ignored @@ -2520,7 +2521,7 @@ test socket-14.18 {bug c6ed4acfd8: running async socket connect made other conne } -result {} test socket-14.19 {tip 456 -- introduce the -reuseport option} \ - -constraints {socket} \ + -constraints {socket notWine} \ -body { proc accept {channel address port} {} set port [randport] diff --git a/tests/winDde.test b/tests/winDde.test index 99ac8af..78a36f8 100644 --- a/tests/winDde.test +++ b/tests/winDde.test @@ -24,6 +24,7 @@ if {[testConstraint win]} { testConstraint dde 1 } } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] # ------------------------------------------------------------------------- @@ -161,7 +162,7 @@ test winDde-3.6 {DDE request utf-8} -constraints dde -body { } -result 196 # Set variable a to A with diaeresis (unicode C4) using binary execute # and compose utf-8 (e.g. "c3 84" ) manualy -test winDde-3.7 {DDE request binary} -constraints dde -body { +test winDde-3.7 {DDE request binary} -constraints {dde notWine} -body { set \xe1 "not set" dde execute -binary TclEval self [list set \xc3\xa1 \xc3\x84\x00] scan [set \xe1] %c diff --git a/tests/winFCmd.test b/tests/winFCmd.test index ef62cec..70db379 100644 --- a/tests/winFCmd.test +++ b/tests/winFCmd.test @@ -29,6 +29,7 @@ testConstraint cdrom 0 testConstraint exdev 0 testConstraint longFileNames 0 testConstraint knownMsvcBug [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match windows $::env(TRAVIS_OS_NAME)]}] +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] proc createfile {file {string a}} { set f [open $file w] @@ -132,25 +133,25 @@ test winFCmd-1.1 {TclpRenameFile: errno: EACCES} -body { } -constraints {win cdrom testfile} -returnCodes error -result EACCES test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1/td2/td3 file mkdir td2 testfile mv td2 td1/td2 } -returnCodes error -result EEXIST test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { testfile mv / td1 } -returnCodes error -result EINVAL test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 testfile mv td1 td1/td2 } -returnCodes error -result EINVAL test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 createfile tf1 testfile mv tf1 td1 @@ -255,7 +256,7 @@ test winFCmd-1.22 {TclpRenameFile: long dst} -setup { } -returnCodes error -result ENAMETOOLONG test winFCmd-1.23 {TclpRenameFile: move dir into self} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 testfile mv [pwd]/td1 td1/td2 } -returnCodes error -result EINVAL @@ -300,21 +301,21 @@ test winFCmd-1.29 {TclpRenameFile: src is dir} -setup { } -returnCodes error -result ENOTDIR test winFCmd-1.30 {TclpRenameFile: dst is dir} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 file mkdir td2/td2 testfile mv td1 td2 } -returnCodes error -result EEXIST test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 file mkdir td2/td2 testfile mv td1 td2 } -returnCodes error -result EEXIST test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1/td2 file mkdir td2 testfile mv td1 td2 @@ -343,7 +344,7 @@ test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} -setup { } -returnCodes error -result ENOTDIR test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { file mkdir td1 createfile tf1 testfile mv tf1 td1 @@ -394,7 +395,7 @@ proc MakeFiles {dirname} { test winFCmd-1.38 {TclpRenameFile: check rename of conflicting inodes} -setup { cleanup -} -constraints {win winNonZeroInodes knownMsvcBug} -body { +} -constraints {win winNonZeroInodes knownMsvcBug notWine} -body { file mkdir td1 foreach {a b} [MakeFiles td1] break file rename -force $a $b @@ -639,7 +640,7 @@ test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} -setup { test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} -setup { cleanup -} -constraints {winVista testfile testchmod knownMsvcBug} -body { +} -constraints {winVista testfile testchmod knownMsvcBug notWine} -body { file mkdir td1 testchmod 0 td1 testfile rmdir td1 @@ -693,7 +694,7 @@ test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} -setup { } -result {1 {tf1 ENOTDIR}} test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} -setup { cleanup -} -constraints {winVista testfile testchmod knownMsvcBug} -body { +} -constraints {winVista testfile testchmod knownMsvcBug notWine} -body { file mkdir td1 testchmod 0 td1 testfile rmdir td1 @@ -704,14 +705,14 @@ test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} -setup { } -result {td1 EACCES} test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} -setup { cleanup -} -constraints {win testfile} -body { +} -constraints {win testfile notWine} -body { testfile rmdir / # WinXP returns EEXIST, WinNT seems to return EACCES. No policy # decision has been made as to which is correct. } -returnCodes error -match regexp -result {^/ E(ACCES|EXIST)$} test winFCmd-6.13 {TclpRemoveDirectory: write-protected} -setup { cleanup -} -constraints {winVista testfile testchmod knownMsvcBug} -body { +} -constraints {winVista testfile testchmod knownMsvcBug notWine} -body { file mkdir td1 testchmod 0 td1 testfile rmdir td1 @@ -940,7 +941,7 @@ test winFCmd-9.1 {TraversalDelete: DOTREE_F} -setup { } -result {} test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} -setup { cleanup -} -constraints {winVista testfile testchmod knownMsvcBug} -body { +} -constraints {winVista testfile testchmod knownMsvcBug notWine} -body { file mkdir td1/td2 testchmod 0 td1 testfile rmdir -force td1 @@ -1129,7 +1130,7 @@ test winFCmd-15.2 {SetWinFileAttributes - archive} -constraints {win} -setup { } -cleanup { cleanup } -result {{} 1} -test winFCmd-15.3 {SetWinFileAttributes - archive} -constraints {win} -setup { +test winFCmd-15.3 {SetWinFileAttributes - archive} -constraints {win notWine} -setup { cleanup } -body { createfile td1 {} @@ -1137,7 +1138,7 @@ test winFCmd-15.3 {SetWinFileAttributes - archive} -constraints {win} -setup { } -cleanup { cleanup } -result {{} 0} -test winFCmd-15.4 {SetWinFileAttributes - hidden} -constraints {win} -setup { +test winFCmd-15.4 {SetWinFileAttributes - hidden} -constraints {win notWine} -setup { cleanup } -body { createfile td1 {} @@ -1170,7 +1171,7 @@ test winFCmd-15.7 {SetWinFileAttributes - readonly} -setup { } -cleanup { cleanup } -result {{} 0} -test winFCmd-15.8 {SetWinFileAttributes - system} -constraints {win} -setup { +test winFCmd-15.8 {SetWinFileAttributes - system} -constraints {win notWine} -setup { cleanup } -body { createfile td1 {} diff --git a/tests/winFile.test b/tests/winFile.test index d8d1b7c..2c0988a 100644 --- a/tests/winFile.test +++ b/tests/winFile.test @@ -24,6 +24,7 @@ testConstraint notNTFS 0 if {[testConstraint testvolumetype]} { testConstraint notNTFS [expr {[testvolumetype] eq "NTFS"}] } +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] test winFile-1.1 {TclpGetUserHome} -constraints {win} -body { glob ~nosuchuser @@ -150,7 +151,7 @@ if {[testConstraint win]} { test winFile-4.0 { Enhanced NTFS user/group permissions: test no acccess } -constraints { - win notNTFS + win notNTFS notWine } -setup { set owner [getuser $fname] set user $::env(USERDOMAIN)\\$::env(USERNAME) @@ -165,7 +166,7 @@ test winFile-4.0 { test winFile-4.1 { Enhanced NTFS user/group permissions: test readable only } -constraints { - win notNTFS + win notNTFS notWine } -setup { set user $::env(USERDOMAIN)\\$::env(USERNAME) } -body { @@ -176,7 +177,7 @@ test winFile-4.1 { test winFile-4.2 { Enhanced NTFS user/group permissions: test writable only } -constraints { - win notNTFS + win notNTFS notWine } -setup { set user $::env(USERDOMAIN)\\$::env(USERNAME) } -body { diff --git a/tests/winPipe.test b/tests/winPipe.test index 0263823..919e336 100644 --- a/tests/winPipe.test +++ b/tests/winPipe.test @@ -28,6 +28,9 @@ set org_pwd [pwd] set bindir [file join $org_pwd [file dirname [info nameofexecutable]]] set cat32 [file join $bindir cat32.exe] +testConstraint notWine [expr {$::tcl_platform(platform) ne "windows" || ![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}] + + # several test-cases here expect current directory == [temporaryDirectory]: cd [temporaryDirectory] @@ -197,7 +200,7 @@ test winpipe-4.1 {Tcl_WaitPid} {win exec cat32} { vwait x list $result $x [contents $path(stderr)] } "{$big} 1 stderr32" -test winpipe-4.2 {Tcl_WaitPid: return of exception codes, SIGFPE} {win exec testexcept} { +test winpipe-4.2 {Tcl_WaitPid: return of exception codes, SIGFPE} {win exec testexcept notWine} { set f [open "|[list [interpreter]]" w+] set pid [pid $f] puts $f "load $::tcltestlib Tcltest" @@ -205,7 +208,7 @@ test winpipe-4.2 {Tcl_WaitPid: return of exception codes, SIGFPE} {win exec test set status [catch {close $f}] list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2] } {1 1 SIGFPE} -test winpipe-4.3 {Tcl_WaitPid: return of exception codes, SIGSEGV} {win exec testexcept} { +test winpipe-4.3 {Tcl_WaitPid: return of exception codes, SIGSEGV} {win exec testexcept notWine} { set f [open "|[list [interpreter]]" w+] set pid [pid $f] puts $f "load $::tcltestlib Tcltest" @@ -213,7 +216,7 @@ test winpipe-4.3 {Tcl_WaitPid: return of exception codes, SIGSEGV} {win exec tes set status [catch {close $f}] list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2] } {1 1 SIGSEGV} -test winpipe-4.4 {Tcl_WaitPid: return of exception codes, SIGILL} {win exec testexcept} { +test winpipe-4.4 {Tcl_WaitPid: return of exception codes, SIGILL} {win exec testexcept notWine} { set f [open "|[list [interpreter]]" w+] set pid [pid $f] puts $f "load $::tcltestlib Tcltest" @@ -221,7 +224,7 @@ test winpipe-4.4 {Tcl_WaitPid: return of exception codes, SIGILL} {win exec test set status [catch {close $f}] list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2] } {1 1 SIGILL} -test winpipe-4.5 {Tcl_WaitPid: return of exception codes, SIGINT} {win exec testexcept} { +test winpipe-4.5 {Tcl_WaitPid: return of exception codes, SIGINT} {win exec testexcept notWine} { set f [open "|[list [interpreter]]" w+] set pid [pid $f] puts $f "load $::tcltestlib Tcltest" @@ -519,7 +522,7 @@ test winpipe-8.2 {BuildCommandLine/parse_cmdline pass-thru: check injection on s } -result {} test winpipe-8.3 {BuildCommandLine/parse_cmdline pass-thru: check injection on special meta-chars (jointly)} \ --constraints {win exec} -body { +-constraints {win exec notWine} -body { _testExecArgs 0 \ [list START {*}$injectList END] \ [list "START\"" {*}$injectList END] \ @@ -528,7 +531,7 @@ test winpipe-8.3 {BuildCommandLine/parse_cmdline pass-thru: check injection on s } -result {} test winpipe-8.4 {BuildCommandLine/parse_cmdline pass-thru: check injection on special meta-chars (command/jointly args)} \ --constraints {win exec} -body { +-constraints {win exec notWine} -body { _testExecArgs 2 \ [list START {*}$injectList END] \ [list "START\"" {*}$injectList END] \ @@ -537,7 +540,7 @@ test winpipe-8.4 {BuildCommandLine/parse_cmdline pass-thru: check injection on s } -result {} test winpipe-8.5 {BuildCommandLine/parse_cmdline pass-thru: check injection on special meta-chars (random mix)} \ --constraints {win exec} -body { +-constraints {win exec notWine} -body { set lst {} set maps { {\&|^<>!()%} -- cgit v0.12 From 71b64b8e1c447baa06ebd0db32a674d135eaa594 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 16 Oct 2020 16:21:29 +0000 Subject: Still troubles with GIT on Travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2630474..72ecdaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -190,6 +190,8 @@ jobs: - BUILD_DIR=win - VCDIR="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build" before_install: &vcpreinst + - rm -rf tests/safe-stock8*.test + - touch generic/tclStubInit.c generic/tclOOStubInit.c - PATH="$PATH:$VCDIR" - cd ${BUILD_DIR} install: [] @@ -286,6 +288,8 @@ jobs: - BUILD_DIR=win - CFGOPT="--enable-64bit" before_install: &makepreinst + - rm -rf tests/safe-stock8*.test + - touch generic/tclStubInit.c generic/tclOOStubInit.c - choco install -y make - cd ${BUILD_DIR} - name: "Windows/GCC/Shared: UTF_MAX=4" -- cgit v0.12 From 8ce6115cf59c570acf00e2ac58a26235288ad90f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 18 Oct 2020 16:24:41 +0000 Subject: 3 times -1 -> TCL_INDEX_NONE --- generic/tclCmdIL.c | 2 +- generic/tclCmdMZ.c | 2 +- generic/tclScan.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 6a81309..da8dc65 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3514,7 +3514,7 @@ Tcl_LsearchObjCmd( if (allMatches || inlineReturn) { Tcl_ResetResult(interp); } else { - TclNewIntObj(itemPtr, -1); + TclNewIntObj(itemPtr, TCL_INDEX_NONE); Tcl_SetObjResult(interp, itemPtr); } goto done; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 6eb2954..c47490a 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -3778,7 +3778,7 @@ TclNRSwitchObjCmd( TclNewIntObj(rangeObjAry[0], info.matches[j].start); TclNewIntObj(rangeObjAry[1], info.matches[j].end-1); } else { - TclNewIntObj(rangeObjAry[1], -1); + TclNewIntObj(rangeObjAry[1], TCL_INDEX_NONE); rangeObjAry[0] = rangeObjAry[1]; } diff --git a/generic/tclScan.c b/generic/tclScan.c index ee04165..67fe6f3 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -1089,7 +1089,7 @@ Tcl_ScanObjCmd( if (code == TCL_OK) { if (underflow && (nconversions == 0)) { if (numVars) { - TclNewIntObj(objPtr, -1); + TclNewIntObj(objPtr, TCL_INDEX_NONE); } else { if (objPtr) { Tcl_SetListObj(objPtr, 0, NULL); -- cgit v0.12 From 0b669eacf86ed32f444f09285fe816c3c369d923 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Oct 2020 07:21:45 +0000 Subject: Fix [cb458261c3]: Strip comme il faut (without really doing 'il faut' ....). Update 'install-sh' to latest upstream version, but re-add this commit: [b269db5d3e97b67c] --- unix/install-sh | 410 +++++++++++++++++++++++++++----------------------------- 1 file changed, 200 insertions(+), 210 deletions(-) diff --git a/unix/install-sh b/unix/install-sh index 7c34c3f..dc09dbd 100755 --- a/unix/install-sh +++ b/unix/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-04-20.01; # UTC +scriptversion=2020-07-26.22; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,25 +35,21 @@ scriptversion=2011-04-20.01; # UTC # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,22 +64,15 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. mode=0755 +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + chgrpcmd= chmodcmd=$chmodprog chowncmd= @@ -97,7 +86,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -138,45 +127,60 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; -S) stripcmd="$stripprog $2" - shift;; + shift;; - -t) dst_arg=$2 - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -190,6 +194,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -198,12 +206,21 @@ if test $# -eq 0; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 @@ -219,16 +236,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -236,9 +253,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for 'test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -260,185 +277,150 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. + # If destination is a directory, append the input filename. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst - dst=$dstdir/`basename "$src"` + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else - mkdir_mode= + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + trap '' 0;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else - # The umask is ridiculous, or mkdir does not conform to POSIX, + # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - -*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -451,14 +433,25 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -473,15 +466,12 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -494,24 +484,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 @@ -520,9 +510,9 @@ do done # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" -# End: +# End: \ No newline at end of file -- cgit v0.12 From 40c3ec35eed68747b5fcde78f05600dc10a58308 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Oct 2020 07:25:23 +0000 Subject: Improve comment in install-sh, regarding Tcl-specific change --- unix/install-sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/install-sh b/unix/install-sh index dc09dbd..21b733a 100755 --- a/unix/install-sh +++ b/unix/install-sh @@ -109,7 +109,7 @@ Options: -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. - -S $stripprog installed files. + -S OPTION $stripprog installed files using OPTION. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. -- cgit v0.12 From ad823f4eb163905d291dadafb08d8e5a69765379 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 19 Oct 2020 19:22:39 +0000 Subject: Add a make variable to GNUmakefile for building the Tcl.framework for use as a subframework --- macosx/GNUmakefile | 3 +++ macosx/README | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index 56e5500..e55b661 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -150,6 +150,9 @@ install-${PROJECT}: build-${PROJECT} ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_) @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false endif +ifeq (${SUBFRAMEWORK}_${DYLIB_INSTALL_DIR},1_) + @echo "Cannot install-subframework with empty DYLIB_INSTALL_DIR !" && false +endif ifeq (${EMBEDDED_BUILD},1) @rm -rf "${INSTALL_ROOT}${LIBDIR}/Tcl.framework" endif diff --git a/macosx/README b/macosx/README index c944c0a..cb36811 100644 --- a/macosx/README +++ b/macosx/README @@ -165,3 +165,14 @@ If you only want to build and install the debug or optimized build, use the For example, to build and install only the optimized versions: make -C tcl${ver}/macosx deploy sudo make -C tcl${ver}/macosx install-deploy + +- To build a Tcl.framework for use as a subframework in another framework, use the +install-embedded target and set SUBFRAMEWORK=1. Set the DYLIB_INSTALL_DIR +variable to the path which should be the install_name path of the Tcl library, set +the DESTDIR variable to the pathname of a staging directory where the framework +will be written . For example, running this command in the Tcl source directory: + make -C macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcl \ + DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/3.9/Frameworks/Tcl +will produce a Tcl.framework intended for installing as a subframework of the +Python.framework. The framework will be found in /tmp/tcl/Library/Frameworks/ + -- cgit v0.12 From 7f986a59bf53e05fac834aed3b3fb663669adadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ignacio=20Mar=C3=ADn?= Date: Tue, 20 Oct 2020 20:35:59 +0000 Subject: Update TZ info to tzdata2020c. --- library/tzdata/Pacific/Fiji | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/tzdata/Pacific/Fiji b/library/tzdata/Pacific/Fiji index e316b93..a062913 100644 --- a/library/tzdata/Pacific/Fiji +++ b/library/tzdata/Pacific/Fiji @@ -29,7 +29,7 @@ set TZData(:Pacific/Fiji) { {1547301600 43200 0 +12} {1573308000 46800 1 +12} {1578751200 43200 0 +12} - {1604757600 46800 1 +12} + {1608386400 46800 1 +12} {1610805600 43200 0 +12} {1636812000 46800 1 +12} {1642255200 43200 0 +12} -- cgit v0.12 From fd9662ee1c86d86ba0a92a616b5821fd389551e1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 21 Oct 2020 07:48:31 +0000 Subject: Fix [c975939973]: Usage of gnu_printf in latest mingw-w64 --- generic/tcl.h | 2 +- win/tclWinInt.h | 4 ++++ win/tclWinPort.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/generic/tcl.h b/generic/tcl.h index 914f62b..a756a33 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -384,7 +384,7 @@ typedef long LONG; */ #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) -# if defined(_WIN32) +# if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) # define TCL_WIDE_INT_TYPE __int64 # ifdef __BORLANDC__ # define TCL_LL_MODIFIER "L" diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 5f532bc..a44abd9 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -54,7 +54,11 @@ MODULE_SCOPE TclWinProcs tclWinProcs; #endif #ifdef _WIN64 +#if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO +# define TCL_I_MODIFIER "ll" +#else # define TCL_I_MODIFIER "I" +#endif #else # define TCL_I_MODIFIER "" #endif diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 8641e5e..6bfbf0c 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -18,6 +18,10 @@ /* See [Bug 3354324]: file mtime sets wrong time */ # define __MINGW_USE_VC2005_COMPAT #endif +#if !defined(__USE_MINGW_ANSI_STDIO) +/* See [Bug c975939973]: Usage of gnu_printf in latest mingw-w64 */ +# define __USE_MINGW_ANSI_STDIO 0 +#endif /* * We must specify the lower version we intend to support. -- cgit v0.12 From fb10e693b2a8b1d3c30b2de7c9899f0d7a7081a9 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 21 Oct 2020 18:02:31 +0000 Subject: When building a subframework for macOS use a build directory in the staging directory. --- macosx/GNUmakefile | 15 ++++++++++++--- macosx/README | 7 +++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index e55b661..cdeb099 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -32,6 +32,18 @@ MANDIR ?= ${PREFIX}/man # set to non-empty value to install manpages in addition to html help: INSTALL_MANPAGES ?= +# Checks and overrides for subframework builds +ifeq (${SUBFRAMEWORK},1) +ifeq (${DYLIB_INSTALL_DIR},) + @echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false +endif +ifeq (${DESTDIR},) + @echo "Cannot install subframework with empty DESTDIR !" && false +endif +override BUILD_DIR = ${DESTDIR}/build +override INSTALL_PATH = /Frameworks +endif + #------------------------------------------------------------------------------------------------------- # meta targets @@ -150,9 +162,6 @@ install-${PROJECT}: build-${PROJECT} ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_) @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false endif -ifeq (${SUBFRAMEWORK}_${DYLIB_INSTALL_DIR},1_) - @echo "Cannot install-subframework with empty DYLIB_INSTALL_DIR !" && false -endif ifeq (${EMBEDDED_BUILD},1) @rm -rf "${INSTALL_ROOT}${LIBDIR}/Tcl.framework" endif diff --git a/macosx/README b/macosx/README index cb36811..c2bcc42 100644 --- a/macosx/README +++ b/macosx/README @@ -172,7 +172,6 @@ variable to the path which should be the install_name path of the Tcl library, s the DESTDIR variable to the pathname of a staging directory where the framework will be written . For example, running this command in the Tcl source directory: make -C macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcl \ - DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/3.9/Frameworks/Tcl -will produce a Tcl.framework intended for installing as a subframework of the -Python.framework. The framework will be found in /tmp/tcl/Library/Frameworks/ - + DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tcl.framework +will produce a Tcl.framework intended for installing as a subframework of +Some.framework. The framework will be found in /tmp/tcl/Frameworks/ -- cgit v0.12 From c41f6053680bfa7bf4537af890349ddf5b543d33 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 Oct 2020 09:23:49 +0000 Subject: (cherry-pick): Fix [c975939973]: Usage of gnu_printf in latest mingw-w64. Change (internal, windows-only) TCL_I_MODIFIER to TCL_Z_MODIFIER, since that's how it's called in Tcl 8.7 and up --- generic/tcl.h | 2 +- win/tclWin32Dll.c | 2 +- win/tclWinChan.c | 16 ++++++++-------- win/tclWinConsole.c | 2 +- win/tclWinInt.h | 15 +++++++++++---- win/tclWinPipe.c | 10 +++++----- win/tclWinPort.h | 4 ++++ win/tclWinSerial.c | 4 ++-- win/tclWinSock.c | 20 ++++++++++---------- 9 files changed, 43 insertions(+), 32 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index d7d064c..3232734 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -354,7 +354,7 @@ typedef long LONG; */ #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) -# if defined(__WIN32__) +# if defined(__WIN32__) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) # define TCL_WIDE_INT_TYPE __int64 # ifdef __BORLANDC__ # define TCL_LL_MODIFIER "L" diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 560b448..33c29f7 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -543,7 +543,7 @@ TclpGetCStackParams( if (!tsdPtr->stackBound || ((UINT_PTR)&tsdPtr < (UINT_PTR)tsdPtr->stackBound)) { - /* + /* * Either we haven't determined the stack bound in this thread, * or else we've overflowed the bound that we previously * determined. We need to find a new stack bound from diff --git a/win/tclWinChan.c b/win/tclWinChan.c index a271919..6073e2f 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -967,7 +967,7 @@ TclpOpenFileChannel( switch (FileGetType(handle)) { case FILE_TYPE_SERIAL: /* - * Natively named serial ports "com1-9", "\\\\.\\comXX" are + * Natively named serial ports "com1-9", "\\\\.\\comXX" are * already done with the code above. * Here we handle all other serial port names. * @@ -1356,7 +1356,7 @@ TclWinOpenFileChannel( infoPtr->flags = appendMode; infoPtr->handle = handle; infoPtr->dirty = 0; - sprintf(channelName, "file%" TCL_I_MODIFIER "x", (size_t)infoPtr); + sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t)infoPtr); infoPtr->channel = Tcl_CreateChannel(&fileChannelType, channelName, (ClientData) infoPtr, permissions); @@ -1518,8 +1518,8 @@ FileGetType( * NativeIsComPort -- * * Determines if a path refers to a Windows serial port. - * A simple and efficient solution is to use a "name hint" to detect - * COM ports by their filename instead of resorting to a syscall + * A simple and efficient solution is to use a "name hint" to detect + * COM ports by their filename instead of resorting to a syscall * to detect serialness after the fact. * The following patterns cover common serial port names: * COM[1-9]:? @@ -1547,7 +1547,7 @@ NativeIsComPort( * 1. Look for com[1-9]:? */ - if ( (len >= 4) && (len <= 5) + if ( (len >= 4) && (len <= 5) && (_wcsnicmp(p, L"com", 3) == 0) ) { /* * The 4th character must be a digit 1..9 optionally followed by a ":" @@ -1566,7 +1566,7 @@ NativeIsComPort( * 2. Look for //./com[0-9]+ or \\.\com[0-9]+ */ - if ( (len >= 8) && ( + if ( (len >= 8) && ( (_wcsnicmp(p, L"//./com", 7) == 0) || (_wcsnicmp(p, L"\\\\.\\com", 7) == 0) ) ) { @@ -1590,7 +1590,7 @@ NativeIsComPort( * 1. Look for com[1-9]:? */ - if ( (len >= 4) && (len <= 5) + if ( (len >= 4) && (len <= 5) && (strnicmp(p, "com", 3) == 0) ) { /* * The 4th character must be a digit 1..9 optionally followed by a ":" @@ -1609,7 +1609,7 @@ NativeIsComPort( * 2. Look for //./com[0-9]+ or \\.\com[0-9]+ */ - if ( (len >= 8) && ( + if ( (len >= 8) && ( (strnicmp(p, "//./com", 7) == 0) || (strnicmp(p, "\\\\.\\com", 7) == 0) ) ) { diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 361fb3d..a563748 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -1361,7 +1361,7 @@ TclWinOpenConsoleChannel( * for instance). */ - sprintf(channelName, "file%" TCL_I_MODIFIER "x", (size_t)infoPtr); + sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t)infoPtr); infoPtr->channel = Tcl_CreateChannel(&consoleChannelType, channelName, (ClientData) infoPtr, permissions); diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 39790a0..a84d218 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -52,11 +52,18 @@ typedef struct TCLEXCEPTION_REGISTRATION { #define VER_PLATFORM_WIN32_CE 3 #endif -#ifdef _WIN64 -# define TCL_I_MODIFIER "I" -#else -# define TCL_I_MODIFIER "" +#ifndef TCL_Z_MODIFIER +# ifdef _WIN64 +# if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO +# define TCL_Z_MODIFIER "ll" +# else +# define TCL_Z_MODIFIER "I" +# endif +# else +# define TCL_Z_MODIFIER "" +# endif #endif +#define TCL_I_MODIFIER TCL_Z_MODIFIER /* * The following structure keeps track of whether we are using the diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index cdb955f..fd941d7 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1580,10 +1580,10 @@ QuoteCmdLinePart( QuoteCmdLineBackslash(dsPtr, start, *bspos, NULL); start = *bspos; } - /* - * escape all special chars enclosed in quotes like `"..."`, note that here we + /* + * escape all special chars enclosed in quotes like `"..."`, note that here we * don't must escape `\` (with `\`), because it's outside of the main quotes, - * so `\` remains `\`, but important - not at end of part, because results as + * so `\` remains `\`, but important - not at end of part, because results as * before the quote, so `%\%\` should be escaped as `"%\%"\\`). */ Tcl_DStringAppend(dsPtr, "\"", 1); /* opening escape quote-char */ @@ -1738,7 +1738,7 @@ BuildCommandLine( special++; } /* rest of argument (and escape backslashes before closing main quote) */ - QuoteCmdLineBackslash(&ds, start, special, + QuoteCmdLineBackslash(&ds, start, special, (quote & CL_QUOTE) ? bspos : NULL); } if (quote & CL_QUOTE) { @@ -1836,7 +1836,7 @@ TclpCreateCommandChannel( * unique, in case channels share handles (stdin/stdout). */ - sprintf(channelName, "file%" TCL_I_MODIFIER "x", (size_t)infoPtr); + sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t)infoPtr); infoPtr->channel = Tcl_CreateChannel(&pipeChannelType, channelName, (ClientData) infoPtr, infoPtr->validMask); diff --git a/win/tclWinPort.h b/win/tclWinPort.h index d3dbb1b..358398d 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -19,6 +19,10 @@ /* See [Bug 3354324]: file mtime sets wrong time */ # define __MINGW_USE_VC2005_COMPAT #endif +#if !defined(__USE_MINGW_ANSI_STDIO) +/* See [Bug c975939973]: Usage of gnu_printf in latest mingw-w64 */ +# define __USE_MINGW_ANSI_STDIO 0 +#endif #define WIN32_LEAN_AND_MEAN #include diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 83f1866..7bfada7 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1415,7 +1415,7 @@ SerialWriterThread( * Opens or Reopens the serial port with the OVERLAPPED FLAG set * * Results: - * Returns the new handle, or INVALID_HANDLE_VALUE. + * Returns the new handle, or INVALID_HANDLE_VALUE. * If an existing channel is specified it is closed and reopened. * * Side effects: @@ -1502,7 +1502,7 @@ TclWinOpenSerialChannel( * are shared between multiple channels (stdin/stdout). */ - sprintf(channelName, "file%" TCL_I_MODIFIER "x", (size_t)infoPtr); + sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t)infoPtr); infoPtr->channel = Tcl_CreateChannel(&serialChannelType, channelName, (ClientData) infoPtr, permissions); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 11632c4..8a1832a 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -691,7 +691,7 @@ SocketEventProc( if (infoPtr->lastError) { mask |= TCL_READABLE; - + } else { fd_set readFds; struct timeval timeout; @@ -1005,7 +1005,7 @@ CreateSocket( * Register for interest in events in the select mask. Note that this * automatically places the socket into non-blocking mode. */ - + ioctlsocket(sock, (long) FIONBIO, &flag); SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT, (LPARAM) infoPtr); @@ -1056,7 +1056,7 @@ CreateSocket( infoPtr->selectEvents |= FD_CONNECT | FD_READ | FD_WRITE | FD_CLOSE; infoPtr->flags |= SOCKET_ASYNC_CONNECT; - + /* * Free list lock */ @@ -1257,7 +1257,7 @@ WaitForSocketEvent( if ( 0 == (events & FD_CONNECT) ) { SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) UNSELECT, (LPARAM) infoPtr); - + SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT, (LPARAM) infoPtr); } @@ -1329,7 +1329,7 @@ Tcl_OpenTcpClient( return NULL; } - sprintf(channelName, "sock%" TCL_I_MODIFIER "u", (size_t)infoPtr->socket); + sprintf(channelName, "sock%" TCL_Z_MODIFIER "u", (size_t)infoPtr->socket); infoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, (ClientData) infoPtr, (TCL_READABLE | TCL_WRITABLE)); @@ -1394,7 +1394,7 @@ Tcl_MakeTcpClientChannel( SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT, (LPARAM) infoPtr); - sprintf(channelName, "sock%" TCL_I_MODIFIER "u", (size_t)infoPtr->socket); + sprintf(channelName, "sock%" TCL_Z_MODIFIER "u", (size_t)infoPtr->socket); infoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, (ClientData) infoPtr, (TCL_READABLE | TCL_WRITABLE)); Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto crlf"); @@ -1447,7 +1447,7 @@ Tcl_OpenTcpServer( infoPtr->acceptProc = acceptProc; infoPtr->acceptProcData = acceptProcData; - sprintf(channelName, "sock%" TCL_I_MODIFIER "u", (size_t)infoPtr->socket); + sprintf(channelName, "sock%" TCL_Z_MODIFIER "u", (size_t)infoPtr->socket); infoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, (ClientData) infoPtr, 0); @@ -1553,7 +1553,7 @@ TcpAccept( SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT, (LPARAM) newInfoPtr); - sprintf(channelName, "sock%" TCL_I_MODIFIER "u", (size_t)newInfoPtr->socket); + sprintf(channelName, "sock%" TCL_Z_MODIFIER "u", (size_t)newInfoPtr->socket); newInfoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, (ClientData) newInfoPtr, (TCL_READABLE | TCL_WRITABLE)); if (Tcl_SetChannelOption(NULL, newInfoPtr->channel, "-translation", @@ -2619,11 +2619,11 @@ TcpThreadActionProc( WaitForSingleObject(tsdPtr->socketListLock, INFINITE); infoPtr->nextPtr = tsdPtr->socketList; tsdPtr->socketList = infoPtr; - + if (infoPtr == tsdPtr->pendingSocketInfo) { tsdPtr->pendingSocketInfo = NULL; } - + SetEvent(tsdPtr->socketListLock); notifyCmd = SELECT; -- cgit v0.12 From be83197ee590ec252235b5684a13f8d42e35c814 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 Oct 2020 10:52:11 +0000 Subject: TIP #587: One place more where TCL_CFGVAL_ENCODING should fall back to utf-8 --- generic/tclPkgConfig.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/generic/tclPkgConfig.c b/generic/tclPkgConfig.c index 83a00dd..12df68e 100644 --- a/generic/tclPkgConfig.c +++ b/generic/tclPkgConfig.c @@ -36,11 +36,7 @@ #include "tclInt.h" #ifndef TCL_CFGVAL_ENCODING -# ifdef _WIN32 -# define TCL_CFGVAL_ENCODING "cp1252" -# else -# define TCL_CFGVAL_ENCODING "iso8859-1" -# endif +# define TCL_CFGVAL_ENCODING "utf-8" #endif /* -- cgit v0.12 From 1c788e178d149302a1d9d5265bc46120de4f5a6a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 23 Oct 2020 15:36:16 +0000 Subject: Fix warning: /home/jboss/workspace/tcl8.7/generic/tclIO.c:9997:27: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 9997 | RemovePoint(nextPtr)[0] = '\r'; | ^ --- generic/tclIO.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 82eb581..349e717 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -287,9 +287,9 @@ static int WillRead(Channel *chanPtr); #define IsBufferOverflowing(bufPtr) ((bufPtr)->nextAdded>(bufPtr)->bufLength) -#define InsertPoint(bufPtr) ((bufPtr)->buf + (bufPtr)->nextAdded) +#define InsertPoint(bufPtr) (&(bufPtr)->buf[(bufPtr)->nextAdded]) -#define RemovePoint(bufPtr) ((bufPtr)->buf + (bufPtr)->nextRemoved) +#define RemovePoint(bufPtr) (&(bufPtr)->buf[(bufPtr)->nextRemoved]) /* * For working with channel state flag bits. -- cgit v0.12