summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2024-05-28 03:02:13 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2024-05-28 03:02:13 (GMT)
commit6be516b44a873f6ced4a54f374e2eb4be624a6ce (patch)
tree3b7b8cfca0bef90c815c93d85ac285800be6a935
parentc6139c195316122d0e72fde74fcaac9b1f7f9dc5 (diff)
parent978c979608e7c2abc738ff8e3ac4f472dd893316 (diff)
downloadtcl-6be516b44a873f6ced4a54f374e2eb4be624a6ce.zip
tcl-6be516b44a873f6ced4a54f374e2eb4be624a6ce.tar.gz
tcl-6be516b44a873f6ced4a54f374e2eb4be624a6ce.tar.bz2
Merge trunk
-rw-r--r--doc/tclsh.126
-rw-r--r--doc/zipfs.n14
-rw-r--r--generic/tclAssembly.c49
-rw-r--r--generic/tclBasic.c4
-rw-r--r--generic/tclClock.c2
-rw-r--r--generic/tclClockFmt.c2
-rw-r--r--generic/tclCmdAH.c10
-rw-r--r--generic/tclCmdIL.c9
-rw-r--r--generic/tclCmdMZ.c57
-rw-r--r--generic/tclCompCmds.c16
-rw-r--r--generic/tclCompCmdsSZ.c10
-rw-r--r--generic/tclCompExpr.c2
-rw-r--r--generic/tclCompile.c34
-rw-r--r--generic/tclCompile.h5
-rw-r--r--generic/tclConfig.c8
-rw-r--r--generic/tclDictObj.c159
-rw-r--r--generic/tclDisassemble.c149
-rw-r--r--generic/tclEncoding.c12
-rw-r--r--generic/tclEnsemble.c53
-rw-r--r--generic/tclEvent.c48
-rw-r--r--generic/tclExecute.c61
-rw-r--r--generic/tclFCmd.c6
-rw-r--r--generic/tclIOCmd.c3
-rw-r--r--generic/tclInt.h8
-rw-r--r--generic/tclInterp.c54
-rw-r--r--generic/tclListObj.c13
-rw-r--r--generic/tclMain.c8
-rw-r--r--generic/tclOOInfo.c6
-rw-r--r--generic/tclObj.c24
-rw-r--r--generic/tclPipe.c18
-rw-r--r--generic/tclProcess.c4
-rw-r--r--generic/tclStrToD.c4
-rw-r--r--generic/tclTestObj.c10
-rw-r--r--generic/tclTestProcBodyObj.c6
-rw-r--r--generic/tclThreadTest.c12
-rw-r--r--generic/tclUtil.c6
-rw-r--r--generic/tclZipfs.c3
-rw-r--r--generic/tclZlib.c88
-rw-r--r--tests/interp.test76
-rw-r--r--unix/tclUnixChan.c17
-rw-r--r--win/tclWinChan.c17
41 files changed, 581 insertions, 532 deletions
diff --git a/doc/tclsh.1 b/doc/tclsh.1
index 91df79d..c75076f 100644
--- a/doc/tclsh.1
+++ b/doc/tclsh.1
@@ -158,14 +158,22 @@ incomplete commands.
See \fBTcl_StandardChannels\fR for more explanations.
.SH ZIPVFS
.PP
-When a zipfile is concatenated to the end of a \fBtclsh\fR, on
-startup the contents of the zip archive will be mounted as the
-virtual file system /zvfs. If a top level directory tcl8.6 is
-present in the zip archive, it will become the directory loaded
-as env(TCL_LIBRARY). If a file named \fBmain.tcl\fR is present
-in the top level directory of the zip archive, it will be sourced
-instead of the shell's normal command line handing.
+When a zipfile is concatenated to the end of a \fBtclsh\fR, on startup
+the contents of the zip archive will be mounted under the virtual file
+system \fB//zipfs:/\fR. If a top level directory \fBtcl_library\fR is
+present in the zip archive, it will become the directory loaded as
+env(TCL_LIBRARY). If a file named \fBmain.tcl\fR is present in the top
+level directory of the zip archive, it will be sourced instead of the
+shell's normal command line handing.
+.PP
+Only one zipfile can be concatenated to the end of executable image
+(tclsh, or wish). However, if multiple zipfiles are
+concatenated, only the last one is used.
+
+This filesystem is read-only. Files cannot be added or modified within
+this mounted file system. See zipfs(n) for complete details.
+
.SH "SEE ALSO"
-auto_path(n), encoding(n), env(n), fconfigure(n)
+auto_path(n), encoding(n), env(n), fconfigure(n), zipfs(n)
.SH KEYWORDS
-application, argument, interpreter, prompt, script file, shell
+application, argument, interpreter, prompt, script file, shell, zipfs
diff --git a/doc/zipfs.n b/doc/zipfs.n
index d4f97a8..9ac283d 100644
--- a/doc/zipfs.n
+++ b/doc/zipfs.n
@@ -57,7 +57,7 @@ This takes the name of a file, \fIfilename\fR, and produces where it would be
mapped into a zipfs mount as its result. If specified, \fImountpoint\fR says
within which mount the mapping will be done; if omitted, the main root of the
zipfs system is used. The \fIinZipfs\fR argument is a an optional boolean
-which controls whether to fully canonicalise the name; it defaults to true.
+which controls whether to fully canonicalize the name; it defaults to true.
.\" METHOD: exists
.TP
\fBzipfs exists\fI filename\fR
@@ -203,6 +203,18 @@ then the resulting image is an executable that will \fBsource\fR the script in
that \fBmain.tcl\fR after mounting the ZIP archive, and will \fBexit\fR once
that script has been executed.
.PP
+\fBNote:\fR \fBtclsh\fR and \fBwish\fR can be built using either
+dynamic binding or static binding of the core implementation
+libraries. With a dynamic binding, the base application Tcl_Library
+contents are attached to the \fBlibtcl\fR and \fBlibtk\fR shared
+library, respectively. With a static binding, the Tcl_Library
+contents, etc., are attached to the application, \fBtclsh\fR or
+\fBwish\fR. When using \fBmkimg\fR with a statically built tclsh, it is
+the user's responsibility to preserve the attached archive by first
+extracting it to a temporary location, and then add whatever
+additional files desired, before creating and attaching the new
+archive to the new application.
+.PP
\fBCaution:\fR highly experimental, not usable on Android, only partially
tested on Linux and Windows.
.RE
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 7bec144..1d09317 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -922,12 +922,7 @@ CompileAssembleObj(
* Report on what the assembler did.
*/
-#ifdef TCL_COMPILE_DEBUG
- if (tclTraceCompile >= 2) {
- TclPrintByteCodeObj(interp, objPtr);
- fflush(stdout);
- }
-#endif /* TCL_COMPILE_DEBUG */
+ TclDebugPrintByteCodeObj(objPtr);
return codePtr;
}
@@ -1384,7 +1379,7 @@ AssembleOneLine(
if (opnd < 0 || opnd > 3) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operand must be [0..3]", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND<0,>3", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND<0,>3", (char *)NULL);
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, opnd, opnd);
@@ -1625,7 +1620,7 @@ AssembleOneLine(
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("operand must be >=2", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND>=2", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND>=2", (char *)NULL);
}
goto cleanup;
}
@@ -1991,7 +1986,7 @@ CreateMirrorJumpTable(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"jump table must have an even number of list elements",
-1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADJUMPTABLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADJUMPTABLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2022,7 +2017,7 @@ CreateMirrorJumpTable(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"duplicate entry in jump table for \"%s\"",
TclGetString(objv[i])));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "DUPJUMPTABLEENTRY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "DUPJUMPTABLEENTRY", (char *)NULL);
DeleteMirrorJumpTable(jtPtr);
return TCL_ERROR;
}
@@ -2107,7 +2102,7 @@ GetNextOperand(
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"assembly code may not contain substitutions", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOSUBST", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOSUBST", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2330,7 +2325,7 @@ FindLocalVar(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use this instruction to create a variable"
" in a non-proc context", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "LVT", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "LVT", (char *)NULL);
}
return TCL_INDEX_NONE;
}
@@ -2365,7 +2360,7 @@ CheckNamespaceQualifiers(
if ((*p == ':') && (p[1] == ':')) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"variable \"%s\" is not local", name));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONLOCAL", name, (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONLOCAL", name, (char *)NULL);
return TCL_ERROR;
}
}
@@ -2401,7 +2396,7 @@ CheckOneByte(
if (value < 0 || value > 0xFF) {
result = Tcl_NewStringObj("operand does not fit in one byte", -1);
Tcl_SetObjResult(interp, result);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2436,7 +2431,7 @@ CheckSignedOneByte(
if (value > 0x7F || value < -0x80) {
result = Tcl_NewStringObj("operand does not fit in one byte", -1);
Tcl_SetObjResult(interp, result);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2469,7 +2464,7 @@ CheckNonNegative(
if (value < 0) {
result = Tcl_NewStringObj("operand must be nonnegative", -1);
Tcl_SetObjResult(interp, result);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONNEGATIVE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONNEGATIVE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2502,7 +2497,7 @@ CheckStrictlyPositive(
if (value <= 0) {
result = Tcl_NewStringObj("operand must be positive", -1);
Tcl_SetObjResult(interp, result);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "POSITIVE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "POSITIVE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2554,7 +2549,7 @@ DefineLabel(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"duplicate definition of label \"%s\"", labelName));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "DUPLABEL", labelName,
- (void *)NULL);
+ (char *)NULL);
}
return TCL_ERROR;
}
@@ -2955,7 +2950,7 @@ ReportUndefinedLabel(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"undefined label \"%s\"", TclGetString(jumpTarget)));
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOLABEL",
- TclGetString(jumpTarget), (void *)NULL);
+ TclGetString(jumpTarget), (char *)NULL);
Tcl_SetErrorLine(interp, bbPtr->jumpLine);
}
}
@@ -3240,7 +3235,7 @@ CheckNonThrowingBlock(
"a context where an exception has been "
"caught and not disposed of.",
tclInstructionTable[opcode].name));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADTHROW", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADTHROW", (char *)NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
}
return TCL_ERROR;
@@ -3420,7 +3415,7 @@ StackCheckBasicBlock(
*/
Tcl_SetErrorLine(interp, blockPtr->startLine);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3443,7 +3438,7 @@ StackCheckBasicBlock(
if (initialStackDepth + blockPtr->minStackDepth < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("stack underflow", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (char *)NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
@@ -3462,7 +3457,7 @@ StackCheckBasicBlock(
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"code pops stack below level of enclosing catch", -1));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACKINCATCH", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACKINCATCH", (char *)NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
@@ -3590,7 +3585,7 @@ StackCheckExit(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"stack is unbalanced on exit from the code (depth=%d)",
depth));
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3735,7 +3730,7 @@ ProcessCatchesInBasicBlock(
"execution reaches an instruction in inconsistent "
"exception contexts", -1));
Tcl_SetErrorLine(interp, bbPtr->startLine);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADCATCH", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADCATCH", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3794,7 +3789,7 @@ ProcessCatchesInBasicBlock(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"endCatch without a corresponding beginCatch", -1));
Tcl_SetErrorLine(interp, bbPtr->startLine);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADENDCATCH", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADENDCATCH", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3870,7 +3865,7 @@ CheckForUnclosedCatches(
"catch still active on exit from assembly code", -1));
Tcl_SetErrorLine(interp,
assemEnvPtr->curr_bb->enclosingCatch->startLine);
- Tcl_SetErrorCode(interp, "TCL", "ASSEM", "UNCLOSEDCATCH", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ASSEM", "UNCLOSEDCATCH", (char *)NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 209df16..1f1aa2a 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -4461,6 +4461,10 @@ EvalObjvCore(
}
if (TclLimitExceeded(iPtr->limit)) {
+ /* generate error message if not yet already logged at this stage */
+ if (!(iPtr->flags & ERR_ALREADY_LOGGED)) {
+ Tcl_LimitCheck(interp);
+ }
return TCL_ERROR;
}
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 4d7df19..3b07b51 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -3435,7 +3435,7 @@ ClockParseFmtScnArgs(
goto baseOverflow;
}
- Tcl_AppendResult(interp, " or integer", NULL);
+ Tcl_AppendResult(interp, " or integer", (char *)NULL);
i = baseIdx;
goto badOption;
}
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c
index a50b43f..b3401a0 100644
--- a/generic/tclClockFmt.c
+++ b/generic/tclClockFmt.c
@@ -858,7 +858,7 @@ FindOrCreateFmtScnStorage(
if (fss == NULL && interp != NULL) {
Tcl_AppendResult(interp, "retrieve clock format failed \"",
- strFmt ? strFmt : "", "\"", NULL);
+ strFmt ? strFmt : "", "\"", (char *)NULL);
Tcl_SetErrorCode(interp, "TCL", "EINVAL", (char *)NULL);
}
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index ab5fbb0..d6e98a5 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -729,7 +729,7 @@ EncodingDirsObjCmd(
"expected directory list but got \"%s\"",
TclGetString(dirListObj)));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ENCODING", "BADPATH",
- (void *)NULL);
+ (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, dirListObj);
@@ -1922,7 +1922,7 @@ PathFilesystemCmd(
if (fsInfo == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("unrecognised path", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "FILESYSTEM",
- TclGetString(objv[1]), (void *)NULL);
+ TclGetString(objv[1]), (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, fsInfo);
@@ -2072,7 +2072,7 @@ PathSplitCmd(
"could not read \"%s\": no such file or directory",
TclGetString(objv[1])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PATHSPLIT", "NONESUCH",
- (void *)NULL);
+ (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, res);
@@ -2174,7 +2174,7 @@ FilesystemSeparatorCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unrecognised path", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "FILESYSTEM",
- TclGetString(objv[1]), (void *)NULL);
+ TclGetString(objv[1]), (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, separatorObj);
@@ -2824,7 +2824,7 @@ EachloopCmd(
(statePtr->resultList != NULL ? "lmap" : "foreach")));
Tcl_SetErrorCode(interp, "TCL", "OPERATION",
(statePtr->resultList != NULL ? "LMAP" : "FOREACH"),
- "NEEDVARS", (void *)NULL);
+ "NEEDVARS", (char *)NULL);
result = TCL_ERROR;
goto done;
}
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 37c9822..83320cd 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -2638,8 +2638,7 @@ Tcl_LpopObjCmd(
/* empty list, throw the same error as with index "end" */
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index \"end\" out of range", -1));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
- "OUTOFRANGE", (char *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
return TCL_ERROR;
}
@@ -3497,8 +3496,7 @@ Tcl_LsearchObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"index \"%s\" out of range",
TclGetString(indices[j])));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
- "OUTOFRANGE", (char *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
result = TCL_ERROR;
}
if (result == TCL_ERROR) {
@@ -4640,8 +4638,7 @@ Tcl_LsortObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"index \"%s\" out of range",
TclGetString(indexv[j])));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
- "OUTOFRANGE", (char *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
result = TCL_ERROR;
}
if (result == TCL_ERROR) {
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 3effdf1..2a9d316 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -232,7 +232,7 @@ Tcl_RegexpObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"regexp match variables not allowed when using -inline", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "REGEXP",
- "MIX_VAR_INLINE", (void *)NULL);
+ "MIX_VAR_INLINE", (char *)NULL);
goto optionError;
}
@@ -685,7 +685,7 @@ Tcl_RegsubObjCmd(
"command prefix must be a list of at least one element",
-1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "REGSUB",
- "CMDEMPTY", (void *)NULL);
+ "CMDEMPTY", (char *)NULL);
return TCL_ERROR;
}
regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags);
@@ -1975,7 +1975,7 @@ StringMapCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\": must be -nocase", string));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
- string, (void *)NULL);
+ string, (char *)NULL);
return TCL_ERROR;
}
}
@@ -2043,7 +2043,7 @@ StringMapCmd(
Tcl_SetObjResult(interp,
Tcl_NewStringObj("char map list unbalanced", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "MAP",
- "UNBALANCED", (void *)NULL);
+ "UNBALANCED", (char *)NULL);
return TCL_ERROR;
}
}
@@ -2247,7 +2247,7 @@ StringMatchCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\": must be -nocase", string));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
- string, (void *)NULL);
+ string, (char *)NULL);
return TCL_ERROR;
}
}
@@ -2669,7 +2669,7 @@ StringEqualCmd(
"bad option \"%s\": must be -nocase or -length",
string2));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
- string2, (void *)NULL);
+ string2, (char *)NULL);
return TCL_ERROR;
}
}
@@ -2774,7 +2774,7 @@ StringCmpOpts(
"bad option \"%s\": must be -nocase or -length",
string));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
- string, (void *)NULL);
+ string, (char *)NULL);
return TCL_ERROR;
}
}
@@ -3504,7 +3504,7 @@ TclNRSwitchObjCmd(
"bad option \"%s\": %s option already found",
TclGetString(objv[i]), options[mode]));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "DOUBLEOPT", (void *)NULL);
+ "DOUBLEOPT", (char *)NULL);
return TCL_ERROR;
}
foundmode = 1;
@@ -3523,7 +3523,7 @@ TclNRSwitchObjCmd(
"missing variable name argument to %s option",
"-indexvar"));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "NOVAR", (void *)NULL);
+ "NOVAR", (char *)NULL);
return TCL_ERROR;
}
indexVarObj = objv[i];
@@ -3536,7 +3536,7 @@ TclNRSwitchObjCmd(
"missing variable name argument to %s option",
"-matchvar"));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "NOVAR", (void *)NULL);
+ "NOVAR", (char *)NULL);
return TCL_ERROR;
}
matchVarObj = objv[i];
@@ -3555,14 +3555,14 @@ TclNRSwitchObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s option requires -regexp option", "-indexvar"));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "MODERESTRICTION", (void *)NULL);
+ "MODERESTRICTION", (char *)NULL);
return TCL_ERROR;
}
if (matchVarObj != NULL && mode != OPT_REGEXP) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s option requires -regexp option", "-matchvar"));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "MODERESTRICTION", (void *)NULL);
+ "MODERESTRICTION", (char *)NULL);
return TCL_ERROR;
}
@@ -3617,7 +3617,7 @@ TclNRSwitchObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra switch pattern with no body", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH", "BADARM",
- (void *)NULL);
+ (char *)NULL);
/*
* Check if this can be due to a badly placed comment in the switch
@@ -3635,7 +3635,7 @@ TclNRSwitchObjCmd(
" placed outside of a switch body - see the"
" \"switch\" documentation", -1);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH",
- "BADARM", "COMMENT?", (void *)NULL);
+ "BADARM", "COMMENT?", (char *)NULL);
break;
}
}
@@ -3654,7 +3654,7 @@ TclNRSwitchObjCmd(
"no body specified for pattern \"%s\"",
TclGetString(objv[objc-2])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH", "BADARM",
- "FALLTHROUGH", (void *)NULL);
+ "FALLTHROUGH", (char *)NULL);
return TCL_ERROR;
}
@@ -3985,7 +3985,7 @@ Tcl_ThrowObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"type must be non-empty list", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "THROW", "BADEXCEPTION",
- (void *)NULL);
+ (char *)NULL);
return TCL_ERROR;
}
@@ -4725,7 +4725,7 @@ TclNRTryObjCmd(
"finally clause must be last", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
- "NONTERMINAL", (void *)NULL);
+ "NONTERMINAL", (char *)NULL);
return TCL_ERROR;
} else if (i == objc-1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -4733,7 +4733,7 @@ TclNRTryObjCmd(
" \"... finally script\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
- "ARGUMENT", (void *)NULL);
+ "ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
finallyObj = objv[++i];
@@ -4746,7 +4746,7 @@ TclNRTryObjCmd(
" variableList script\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "ON",
- "ARGUMENT", (void *)NULL);
+ "ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
if (TclGetCompletionCodeFromObj(interp, objv[i+1],
@@ -4765,7 +4765,7 @@ TclNRTryObjCmd(
-1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "TRAP",
- "ARGUMENT", (void *)NULL);
+ "ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
code = 1;
@@ -4775,7 +4775,7 @@ TclNRTryObjCmd(
TclGetString(objv[i+1])));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "TRAP",
- "EXNFORMAT", (void *)NULL);
+ "EXNFORMAT", (char *)NULL);
return TCL_ERROR;
}
info[2] = objv[i+1];
@@ -4807,7 +4807,7 @@ TclNRTryObjCmd(
"last non-finally clause must not have a body of \"-\"", -1));
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "BADFALLTHROUGH",
- (void *)NULL);
+ (char *)NULL);
return TCL_ERROR;
}
if (!haveHandlers) {
@@ -4850,16 +4850,13 @@ During(
* release, or NULL if nothing is to be added.
* Designed to be used with Tcl_ObjPrintf. */
{
- Tcl_Obj *during, *options;
+ Tcl_Obj *options;
if (errorInfo != NULL) {
Tcl_AppendObjToErrorInfo(interp, errorInfo);
}
options = Tcl_GetReturnOptions(interp, resultCode);
- TclNewLiteralStringObj(during, "-during");
- Tcl_IncrRefCount(during);
- Tcl_DictObjPut(interp, options, during, oldOptions);
- Tcl_DecrRefCount(during);
+ TclDictPut(interp, options, "-during", oldOptions);
Tcl_IncrRefCount(options);
Tcl_DecrRefCount(oldOptions);
return options;
@@ -4951,12 +4948,10 @@ TryPostBody(
*/
if (code == TCL_ERROR) {
- Tcl_Obj *errorCodeName, *errcode, **bits1, **bits2;
+ Tcl_Obj *errcode, **bits1, **bits2;
Tcl_Size len1, len2, j;
- TclNewLiteralStringObj(errorCodeName, "-errorcode");
- Tcl_DictObjGet(NULL, options, errorCodeName, &errcode);
- Tcl_DecrRefCount(errorCodeName);
+ TclDictGet(NULL, options, "-errorcode", &errcode);
TclListObjGetElements(NULL, info[2], &len1, &bits1);
if (TclListObjGetElements(NULL, errcode, &len2,
&bits2) != TCL_OK) {
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index bad58f6..6d3eabd 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -2397,8 +2397,7 @@ DisassembleDictUpdateInfo(
Tcl_ListObjAppendElement(NULL, variables,
Tcl_NewWideIntObj(duiPtr->varIndices[i]));
}
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("variables", -1),
- variables);
+ TclDictPut(NULL, dictObj, "variables", variables);
}
/*
@@ -3136,14 +3135,13 @@ DisassembleForeachInfo(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewWideIntObj(infoPtr->firstValueTemp + i));
}
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("data", -1), objPtr);
+ TclDictPut(NULL, dictObj, "data", objPtr);
/*
* Loop counter.
*/
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("loop", -1),
- Tcl_NewWideIntObj(infoPtr->loopCtTemp));
+ TclDictPut(NULL, dictObj, "loop", Tcl_NewWideIntObj(infoPtr->loopCtTemp));
/*
* Assignment targets.
@@ -3159,7 +3157,7 @@ DisassembleForeachInfo(
}
Tcl_ListObjAppendElement(NULL, objPtr, innerPtr);
}
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("assign", -1), objPtr);
+ TclDictPut(NULL, dictObj, "assign", objPtr);
}
static void
@@ -3178,8 +3176,8 @@ DisassembleNewForeachInfo(
* Jump offset.
*/
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("jumpOffset", -1),
- Tcl_NewWideIntObj(infoPtr->loopCtTemp));
+ TclDictPut(NULL, dictObj, "jumpOffset",
+ Tcl_NewWideIntObj(infoPtr->loopCtTemp));
/*
* Assignment targets.
@@ -3195,7 +3193,7 @@ DisassembleNewForeachInfo(
}
Tcl_ListObjAppendElement(NULL, objPtr, innerPtr);
}
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("assign", -1), objPtr);
+ TclDictPut(NULL, dictObj, "assign", objPtr);
}
/*
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index bc37155..38fd8d6 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -2628,10 +2628,9 @@ DisassembleJumptableInfo(
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_NewWideIntObj(offset));
+ TclDictPut(NULL, mapping, keyPtr, Tcl_NewWideIntObj(offset));
}
- Tcl_DictObjPut(NULL, dictObj, Tcl_NewStringObj("mapping", -1), mapping);
+ TclDictPut(NULL, dictObj, "mapping", mapping);
}
/*
@@ -2739,11 +2738,10 @@ TclCompileThrowCmd(
codeIsValid = codeIsList && (len != 0);
if (codeIsValid) {
- Tcl_Obj *errPtr, *dictPtr;
+ Tcl_Obj *dictPtr;
- TclNewLiteralStringObj(errPtr, "-errorcode");
TclNewObj(dictPtr);
- Tcl_DictObjPut(NULL, dictPtr, errPtr, objPtr);
+ TclDictPut(NULL, dictPtr, "-errorcode", objPtr);
TclEmitPush(TclAddLiteralObj(envPtr, dictPtr, NULL), envPtr);
}
TclDecrRefCount(objPtr);
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 5c46afd..a2c275e 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1479,7 +1479,7 @@ ParseExpr(
parsePtr->string, (numBytes < limit) ? "" : "..."));
if (errCode) {
Tcl_SetErrorCode(interp, "TCL", "PARSE", "EXPR", errCode,
- subErrCode, (void *)NULL);
+ subErrCode, (char *)NULL);
}
}
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 38070b6..db5a5fd 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -397,17 +397,17 @@ InstructionDesc const tclInstructionTable[] = {
* stktop; op1 is 1 for errors on problems, 0 otherwise */
{"dictExpand", 1, -1, 0, {OPERAND_NONE}},
- /* Probe into a dict and extract it (or a subdict of it) into
- * variables with matched names. Produces list of keys bound as
- * result. Part of [dict with].
+ /* Probe into a dict and extract it (or a subdict of it) into
+ * variables with matched names. Produces list of keys bound as
+ * result. Part of [dict with].
* Stack: ... dict path => ... keyList */
{"dictRecombineStk", 1, -3, 0, {OPERAND_NONE}},
- /* Map variable contents back into a dictionary in a variable. Part of
- * [dict with].
+ /* Map variable contents back into a dictionary in a variable. Part of
+ * [dict with].
* Stack: ... dictVarName path keyList => ... */
{"dictRecombineImm", 5, -2, 1, {OPERAND_LVT4}},
- /* Map variable contents back into a dictionary in the local variable
- * indicated by the LVT index. Part of [dict with].
+ /* Map variable contents back into a dictionary in the local variable
+ * indicated by the LVT index. Part of [dict with].
* Stack: ... path keyList => ... */
{"dictExists", 5, INT_MIN, 1, {OPERAND_UINT4}},
/* The top op4 words (min 1) are a key path into the dictionary just
@@ -637,7 +637,7 @@ InstructionDesc const tclInstructionTable[] = {
* Stack: ... varName list => ... listVarContents */
{"clockRead", 2, +1, 1, {OPERAND_UINT1}},
- /* Read clock out to the stack. Operand is which clock to read
+ /* Read clock out to the stack. Operand is which clock to read
* 0=clicks, 1=microseconds, 2=milliseconds, 3=seconds.
* Stack: ... => ... time */
@@ -900,12 +900,7 @@ TclSetByteCodeFromAny(
if (result == TCL_OK) {
(void) TclInitByteCodeObj(objPtr, &tclByteCodeType, &compEnv);
-#ifdef TCL_COMPILE_DEBUG
- if (tclTraceCompile >= 2) {
- TclPrintByteCodeObj(interp, objPtr);
- fflush(stdout);
- }
-#endif /* TCL_COMPILE_DEBUG */
+ TclDebugPrintByteCodeObj(objPtr);
}
TclFreeCompileEnv(&compEnv);
@@ -1365,12 +1360,7 @@ CompileSubstObj(
codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
codePtr->localCachePtr->refCount++;
}
-#ifdef TCL_COMPILE_DEBUG
- if (tclTraceCompile >= 2) {
- TclPrintByteCodeObj(interp, objPtr);
- fflush(stdout);
- }
-#endif /* TCL_COMPILE_DEBUG */
+ TclDebugPrintByteCodeObj(objPtr);
}
return codePtr;
}
@@ -2514,7 +2504,7 @@ TclCompileTokens(
if (numCL >= maxNumCL) {
maxNumCL *= 2;
clPosition = (Tcl_Size *)Tcl_Realloc(clPosition,
- maxNumCL * sizeof(Tcl_Size));
+ maxNumCL * sizeof(Tcl_Size));
}
clPosition[numCL] = clPos;
numCL ++;
@@ -2827,7 +2817,7 @@ PreventCycle(
*
* NOTE: [Bugs 3392070, 3389764] We make a copy based completely
* on the string value, and do not call Tcl_DuplicateObj() so we
- * can be sure we do not have any lingering cycles hiding in
+ * can be sure we do not have any lingering cycles hiding in
* the internalrep.
*/
Tcl_Size numBytes;
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 18d5ed7..a20f81e 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1173,8 +1173,9 @@ MODULE_SCOPE size_t TclLocalScalarFromToken(Tcl_Token *tokenPtr,
CompileEnv *envPtr);
MODULE_SCOPE void TclOptimizeBytecode(void *envPtr);
#ifdef TCL_COMPILE_DEBUG
-MODULE_SCOPE void TclPrintByteCodeObj(Tcl_Interp *interp,
- Tcl_Obj *objPtr);
+MODULE_SCOPE void TclDebugPrintByteCodeObj(Tcl_Obj *objPtr);
+#else
+#define TclDebugPrintByteCodeObj(objPtr) (void)(objPtr)
#endif
MODULE_SCOPE int TclPrintInstruction(ByteCode *codePtr,
const unsigned char *pc);
diff --git a/generic/tclConfig.c b/generic/tclConfig.c
index 9fb2fa7..a297545 100644
--- a/generic/tclConfig.c
+++ b/generic/tclConfig.c
@@ -127,7 +127,7 @@ Tcl_RegisterConfig(
*/
for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) {
- Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1),
+ TclDictPut(interp, pkgDict, cfg->key,
Tcl_NewByteArrayObj((unsigned char *)cfg->value, strlen(cfg->value)));
}
@@ -229,7 +229,7 @@ QueryConfigObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj("package not known", -1));
Tcl_SetErrorCode(interp, "TCL", "FATAL", "PKGCFG_BASE",
- TclGetString(pkgName), (void *)NULL);
+ TclGetString(pkgName), (char *)NULL);
return TCL_ERROR;
}
@@ -244,7 +244,7 @@ QueryConfigObjCmd(
|| val == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("key not known", -1));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONFIG",
- TclGetString(objv[2]), (void *)NULL);
+ TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
@@ -280,7 +280,7 @@ QueryConfigObjCmd(
if (!listPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"insufficient memory to create list", -1));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
return TCL_ERROR;
}
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 8c34bb8..a0016df 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -718,7 +718,7 @@ SetDictFromAny(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing value to go with key", -1));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "DICTIONARY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "DICTIONARY", (char *)NULL);
}
errorInFindDictElement:
DeleteChainTable(dict);
@@ -813,7 +813,7 @@ TclTraceDictPath(
"key \"%s\" not known in dictionary",
TclGetString(keyv[i])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "DICT",
- TclGetString(keyv[i]), (void *)NULL);
+ TclGetString(keyv[i]), (char *)NULL);
}
return NULL;
}
@@ -1487,6 +1487,153 @@ Tcl_DbNewDictObj(
}
#endif
+/***** START OF FUNCTIONS ACTING AS HELPERS *****/
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclDictGet --
+ *
+ * Given a key, get its value from the dictionary (or NULL if key is not
+ * found in dictionary.)
+ *
+ * Results:
+ * A standard Tcl result. The variable pointed to by valuePtrPtr is
+ * updated with the value for the key. Note that it is not an error for
+ * the key to have no mapping in the dictionary.
+ *
+ * Side effects:
+ * The object pointed to by dictPtr is converted to a dictionary if it is
+ * not already one.
+ *
+ *----------------------------------------------------------------------
+ */
+int
+TclDictGet(
+ Tcl_Interp *interp,
+ Tcl_Obj *dictPtr,
+ const char *key, /* The key in a C string. */
+ Tcl_Obj **valuePtrPtr) /* Where to write the value. */
+{
+ Tcl_Obj *keyPtr = Tcl_NewStringObj(key, -1);
+ int code;
+
+ Tcl_IncrRefCount(keyPtr);
+ code = Tcl_DictObjGet(interp, dictPtr, keyPtr, valuePtrPtr);
+ Tcl_DecrRefCount(keyPtr);
+ return code;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclDictPut --
+ *
+ * Add a key,value pair to a dictionary, or update the value for a key if
+ * that key already has a mapping in the dictionary.
+ *
+ * If valuePtr is a zero-count object and is not written into the
+ * dictionary because of an error, it is freed by this routine. The caller
+ * does NOT need to do reference count management.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * The object pointed to by dictPtr is converted to a dictionary if it is
+ * not already one, and any string representation that it has is
+ * invalidated.
+ *
+ *----------------------------------------------------------------------
+ */
+int
+TclDictPut(
+ Tcl_Interp *interp,
+ Tcl_Obj *dictPtr,
+ const char *key, /* The key in a C string. */
+ Tcl_Obj *valuePtr) /* The value to write in. */
+{
+ Tcl_Obj *keyPtr = Tcl_NewStringObj(key, -1);
+ int code;
+
+ Tcl_IncrRefCount(keyPtr);
+ Tcl_IncrRefCount(valuePtr);
+ code = Tcl_DictObjPut(interp, dictPtr, keyPtr, valuePtr);
+ Tcl_DecrRefCount(keyPtr);
+ Tcl_DecrRefCount(valuePtr);
+ return code;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclDictPutString --
+ *
+ * Add a key,value pair to a dictionary, or update the value for a key if
+ * that key already has a mapping in the dictionary.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * The object pointed to by dictPtr is converted to a dictionary if it is
+ * not already one, and any string representation that it has is
+ * invalidated.
+ *
+ *----------------------------------------------------------------------
+ */
+int
+TclDictPutString(
+ Tcl_Interp *interp,
+ Tcl_Obj *dictPtr,
+ const char *key, /* The key in a C string. */
+ const char *value) /* The value in a C string. */
+{
+ Tcl_Obj *keyPtr = Tcl_NewStringObj(key, -1);
+ Tcl_Obj *valuePtr = Tcl_NewStringObj(value, -1);
+ int code;
+
+ Tcl_IncrRefCount(keyPtr);
+ Tcl_IncrRefCount(valuePtr);
+ code = Tcl_DictObjPut(interp, dictPtr, keyPtr, valuePtr);
+ Tcl_DecrRefCount(keyPtr);
+ Tcl_DecrRefCount(valuePtr);
+ return code;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclDictRemove --
+ *
+ * Remove the key,value pair with the given key from the dictionary; the
+ * key does not need to be present in the dictionary.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * The object pointed to by dictPtr is converted to a dictionary if it is
+ * not already one, and any string representation that it has is
+ * invalidated.
+ *
+ *----------------------------------------------------------------------
+ */
+int
+TclDictRemove(
+ Tcl_Interp *interp,
+ Tcl_Obj *dictPtr,
+ const char *key) /* The key in a C string. */
+{
+ Tcl_Obj *keyPtr = Tcl_NewStringObj(key, -1);
+ int code;
+
+ Tcl_IncrRefCount(keyPtr);
+ code = Tcl_DictObjRemove(interp, dictPtr, keyPtr);
+ Tcl_DecrRefCount(keyPtr);
+ return code;
+}
+
/***** START OF FUNCTIONS IMPLEMENTING TCL COMMANDS *****/
/*
@@ -1625,7 +1772,7 @@ DictGetCmd(
"key \"%s\" not known in dictionary",
TclGetString(objv[objc-1])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "DICT",
- TclGetString(objv[objc-1]), (void *)NULL);
+ TclGetString(objv[objc-1]), (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, valuePtr);
@@ -2556,7 +2703,7 @@ DictForNRCmd(
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
- Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "for", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "for", (char *)NULL);
return TCL_ERROR;
}
searchPtr = (Tcl_DictSearch *)TclStackAlloc(interp, sizeof(Tcl_DictSearch));
@@ -2751,7 +2898,7 @@ DictMapNRCmd(
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
- Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "map", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "map", (char *)NULL);
return TCL_ERROR;
}
storagePtr = (DictMapStorage *)TclStackAlloc(interp, sizeof(DictMapStorage));
@@ -3191,7 +3338,7 @@ DictFilterCmd(
if (varc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must have exactly two variable names", -1));
- Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "filter", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "filter", (char *)NULL);
return TCL_ERROR;
}
keyVarObj = varv[0];
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 5a64ff8..f78666c 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -114,7 +114,7 @@ GetLocationInformation(
/*
*----------------------------------------------------------------------
*
- * TclPrintByteCodeObj --
+ * TclDebugPrintByteCodeObj --
*
* This procedure prints ("disassembles") the instructions of a bytecode
* object to stdout.
@@ -129,14 +129,16 @@ GetLocationInformation(
*/
void
-TclPrintByteCodeObj(
- TCL_UNUSED(Tcl_Interp *), /* Stuck with this in internal stubs */
+TclDebugPrintByteCodeObj(
Tcl_Obj *objPtr) /* The bytecode object to disassemble. */
{
- Tcl_Obj *bufPtr = DisassembleByteCodeObj(objPtr);
+ if (tclTraceCompile >= 2) {
+ Tcl_Obj *bufPtr = DisassembleByteCodeObj(objPtr);
- fprintf(stdout, "\n%s", TclGetString(bufPtr));
- Tcl_DecrRefCount(bufPtr);
+ fprintf(stdout, "\n%s", TclGetString(bufPtr));
+ Tcl_DecrRefCount(bufPtr);
+ fflush(stdout);
+ }
}
/*
@@ -703,8 +705,8 @@ TclGetInnerContext(
case INST_TRY_CVT_TO_NUMERIC:
case INST_EXPAND_STKTOP:
case INST_EXPR_STK:
- objc = 1;
- break;
+ objc = 1;
+ break;
case INST_LIST_IN:
case INST_LIST_NOT_IN: /* Basic list containment operators. */
@@ -731,22 +733,22 @@ TclGetInnerContext(
case INST_SUB:
case INST_DIV:
case INST_MULT:
- objc = 2;
- break;
+ objc = 2;
+ break;
case INST_RETURN_STK:
- /* early pop. TODO: dig out opt dict too :/ */
- objc = 1;
- break;
+ /* early pop. TODO: dig out opt dict too :/ */
+ objc = 1;
+ break;
case INST_SYNTAX:
case INST_RETURN_IMM:
- objc = 2;
- break;
+ objc = 2;
+ break;
case INST_INVOKE_STK4:
objc = TclGetUInt4AtPtr(pc+1);
- break;
+ break;
case INST_INVOKE_STK1:
objc = TclGetUInt1AtPtr(pc+1);
@@ -755,37 +757,37 @@ TclGetInnerContext(
result = iPtr->innerContext;
if (Tcl_IsShared(result)) {
- Tcl_DecrRefCount(result);
- iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL);
- Tcl_IncrRefCount(result);
+ Tcl_DecrRefCount(result);
+ iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL);
+ Tcl_IncrRefCount(result);
} else {
- Tcl_Size len;
+ Tcl_Size len;
- /*
- * Reset while keeping the list internalrep as much as possible.
- */
+ /*
+ * Reset while keeping the list internalrep as much as possible.
+ */
TclListObjLength(interp, result, &len);
- Tcl_ListObjReplace(interp, result, 0, len, 0, NULL);
+ Tcl_ListObjReplace(interp, result, 0, len, 0, NULL);
}
Tcl_ListObjAppendElement(NULL, result, TclNewInstNameObj(*pc));
for (; objc>0 ; objc--) {
- Tcl_Obj *objPtr;
+ Tcl_Obj *objPtr;
- objPtr = tosPtr[1 - objc];
- if (!objPtr) {
- Tcl_Panic("InnerContext: bad tos -- appending null object");
- }
- if ((objPtr->refCount <= 0)
+ objPtr = tosPtr[1 - objc];
+ if (!objPtr) {
+ Tcl_Panic("InnerContext: bad tos -- appending null object");
+ }
+ if ((objPtr->refCount <= 0)
#ifdef TCL_MEM_DEBUG
- || (objPtr->refCount == 0x61616161)
+ || (objPtr->refCount == 0x61616161)
#endif
- ) {
- Tcl_Panic("InnerContext: bad tos -- appending freed object %p",
- objPtr);
- }
- Tcl_ListObjAppendElement(NULL, result, objPtr);
+ ) {
+ Tcl_Panic("InnerContext: bad tos -- appending freed object %p",
+ objPtr);
+ }
+ Tcl_ListObjAppendElement(NULL, result, objPtr);
}
return result;
@@ -836,7 +838,7 @@ UpdateStringOfInstName(
if (inst >= LAST_INST_OPCODE) {
dst = Tcl_InitStringRep(objPtr, NULL, TCL_INTEGER_SPACE + 5);
TclOOM(dst, TCL_INTEGER_SPACE + 5);
- snprintf(dst, TCL_INTEGER_SPACE + 5, "inst_%" TCL_Z_MODIFIER "u", inst);
+ snprintf(dst, TCL_INTEGER_SPACE + 5, "inst_%" TCL_Z_MODIFIER "u", inst);
(void) Tcl_InitStringRep(objPtr, NULL, strlen(dst));
} else {
const char *s = tclInstructionTable[inst].name;
@@ -1121,7 +1123,7 @@ DisassembleByteCodeAsDicts(
Tcl_Obj *desc;
TclNewObj(desc);
- Tcl_DictObjPut(NULL, desc, Tcl_NewStringObj("name", -1), auxDesc);
+ TclDictPut(NULL, desc, "name", auxDesc);
auxDesc = desc;
auxData->type->disassembleProc(auxData->clientData, auxDesc,
codePtr, 0);
@@ -1188,23 +1190,20 @@ DisassembleByteCodeAsDicts(
sourceOffset += Decode(srcOffPtr);
sourceLength = Decode(srcLenPtr);
TclNewObj(cmd);
- Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codefrom", -1),
- Tcl_NewWideIntObj(codeOffset));
- Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("codeto", -1),
- Tcl_NewWideIntObj(codeOffset + codeLength - 1));
+ TclDictPut(NULL, cmd, "codefrom", Tcl_NewWideIntObj(codeOffset));
+ TclDictPut(NULL, cmd, "codeto", Tcl_NewWideIntObj(
+ codeOffset + codeLength - 1));
/*
* Convert byte offsets to character offsets; important if multibyte
* characters are present in the source!
*/
- Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptfrom", -1),
- Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source,
- sourceOffset)));
- Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("scriptto", -1),
- Tcl_NewWideIntObj(Tcl_NumUtfChars(codePtr->source,
- sourceOffset + sourceLength - 1)));
- Tcl_DictObjPut(NULL, cmd, Tcl_NewStringObj("script", -1),
+ TclDictPut(NULL, cmd, "scriptfrom", Tcl_NewWideIntObj(
+ Tcl_NumUtfChars(codePtr->source, sourceOffset)));
+ TclDictPut(NULL, cmd, "scriptto", Tcl_NewWideIntObj(
+ Tcl_NumUtfChars(codePtr->source, sourceOffset + sourceLength - 1)));
+ TclDictPut(NULL, cmd, "script",
Tcl_NewStringObj(codePtr->source+sourceOffset, sourceLength));
Tcl_ListObjAppendElement(NULL, commands, cmd);
}
@@ -1223,32 +1222,26 @@ DisassembleByteCodeAsDicts(
*/
TclNewObj(description);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("literals", -1),
- literals);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("variables", -1),
- variables);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("exception", -1), exn);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("instructions", -1),
- instructions);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("auxiliary", -1), aux);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("commands", -1),
- commands);
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("script", -1),
+ TclDictPut(NULL, description, "literals", literals);
+ TclDictPut(NULL, description, "variables", variables);
+ TclDictPut(NULL, description, "exception", exn);
+ TclDictPut(NULL, description, "instructions", instructions);
+ TclDictPut(NULL, description, "auxiliary", aux);
+ TclDictPut(NULL, description, "commands", commands);
+ TclDictPut(NULL, description, "script",
Tcl_NewStringObj(codePtr->source, codePtr->numSrcBytes));
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("namespace", -1),
+ TclDictPut(NULL, description, "namespace",
Tcl_NewStringObj(codePtr->nsPtr->fullName, -1));
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("stackdepth", -1),
+ TclDictPut(NULL, description, "stackdepth",
Tcl_NewWideIntObj(codePtr->maxStackDepth));
- Tcl_DictObjPut(NULL, description, Tcl_NewStringObj("exceptdepth", -1),
+ TclDictPut(NULL, description, "exceptdepth",
Tcl_NewWideIntObj(codePtr->maxExceptDepth));
if (line >= 0) {
- Tcl_DictObjPut(NULL, description,
- Tcl_NewStringObj("initiallinenumber", -1),
+ TclDictPut(NULL, description, "initiallinenumber",
Tcl_NewWideIntObj(line));
}
if (file) {
- Tcl_DictObjPut(NULL, description,
- Tcl_NewStringObj("sourcefile", -1), file);
+ TclDictPut(NULL, description, "sourcefile", file);
}
return description;
}
@@ -1344,7 +1337,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" isn't a procedure", TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "PROC",
- TclGetString(objv[2]), (void *)NULL);
+ TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
@@ -1394,7 +1387,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" is not a class", TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS",
- TclGetString(objv[2]), (void *)NULL);
+ TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
@@ -1404,7 +1397,7 @@ Tcl_DisassembleObjCmd(
"\"%s\" has no defined constructor",
TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "CONSRUCTOR", (void *)NULL);
+ "CONSRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
@@ -1412,7 +1405,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of constructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "METHODTYPE", (void *)NULL);
+ "METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
@@ -1459,7 +1452,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" is not a class", TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS",
- TclGetString(objv[2]), (void *)NULL);
+ TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
@@ -1469,7 +1462,7 @@ Tcl_DisassembleObjCmd(
"\"%s\" has no defined destructor",
TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "DESRUCTOR", (void *)NULL);
+ "DESRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
@@ -1477,7 +1470,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of destructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "METHODTYPE", (void *)NULL);
+ "METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
@@ -1524,7 +1517,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" is not a class", TclGetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS",
- TclGetString(objv[2]), (void *)NULL);
+ TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
hPtr = Tcl_FindHashEntry(&oPtr->classPtr->classMethods,
@@ -1559,7 +1552,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown method \"%s\"", TclGetString(objv[3])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
- TclGetString(objv[3]), (void *)NULL);
+ TclGetString(objv[3]), (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
@@ -1567,7 +1560,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"body not available for this kind of method", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "METHODTYPE", (void *)NULL);
+ "METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
if (!TclHasInternalRep(procPtr->bodyPtr, &tclByteCodeType)) {
@@ -1604,7 +1597,7 @@ Tcl_DisassembleObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"may not disassemble prebuilt bytecode", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
- "BYTECODE", (void *)NULL);
+ "BYTECODE", (char *)NULL);
return TCL_ERROR;
}
if (clientData) {
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 73b4f54..176838d 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1736,8 +1736,7 @@ OpenEncodingFileChannel(
const char *name) /* The name of the encoding file on disk and
* also the name for new encoding. */
{
- Tcl_Obj *nameObj = Tcl_NewStringObj(name, TCL_INDEX_NONE);
- Tcl_Obj *fileNameObj = Tcl_DuplicateObj(nameObj);
+ Tcl_Obj *fileNameObj = Tcl_ObjPrintf("%s.enc", name);
Tcl_Obj *searchPath = Tcl_DuplicateObj(Tcl_GetEncodingSearchPath());
Tcl_Obj *map = TclGetProcessGlobalValue(&encodingFileMap);
Tcl_Obj **dir, *path, *directory = NULL;
@@ -1745,10 +1744,8 @@ OpenEncodingFileChannel(
Tcl_Size i, numDirs;
TclListObjGetElements(NULL, searchPath, &numDirs, &dir);
- Tcl_IncrRefCount(nameObj);
- Tcl_AppendToObj(fileNameObj, ".enc", TCL_INDEX_NONE);
Tcl_IncrRefCount(fileNameObj);
- Tcl_DictObjGet(NULL, map, nameObj, &directory);
+ TclDictGet(NULL, map, name, &directory);
/*
* Check that any cached directory is still on the encoding search path.
@@ -1777,7 +1774,7 @@ OpenEncodingFileChannel(
*/
map = Tcl_DuplicateObj(map);
- Tcl_DictObjRemove(NULL, map, nameObj);
+ TclDictRemove(NULL, map, name);
TclSetProcessGlobalValue(&encodingFileMap, map);
directory = NULL;
}
@@ -1811,7 +1808,7 @@ OpenEncodingFileChannel(
*/
map = Tcl_DuplicateObj(TclGetProcessGlobalValue(&encodingFileMap));
- Tcl_DictObjPut(NULL, map, nameObj, dir[i]);
+ TclDictPut(NULL, map, name, dir[i]);
TclSetProcessGlobalValue(&encodingFileMap, map);
}
}
@@ -1822,7 +1819,6 @@ OpenEncodingFileChannel(
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, (void *)NULL);
}
Tcl_DecrRefCount(fileNameObj);
- Tcl_DecrRefCount(nameObj);
Tcl_DecrRefCount(searchPath);
return chan;
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 1ff0921..3b7230a 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -172,7 +172,7 @@ TclNamespaceEnsembleCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"tried to manipulate ensemble of deleted namespace",
-1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (char *)NULL);
}
return TCL_ERROR;
}
@@ -291,7 +291,7 @@ TclNamespaceEnsembleCmd(
"ensemble subcommand implementations "
"must be non-empty lists", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
- "EMPTY_TARGET", (void *)NULL);
+ "EMPTY_TARGET", (char *)NULL);
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
@@ -307,7 +307,7 @@ TclNamespaceEnsembleCmd(
Tcl_Obj *newCmd = NewNsObj((Tcl_Namespace *) nsPtr);
if (nsPtr->parentPtr) {
- Tcl_AppendStringsToObj(newCmd, "::", (void *)NULL);
+ Tcl_AppendStringsToObj(newCmd, "::", (char *)NULL);
}
Tcl_AppendObjToObj(newCmd, listv[0]);
Tcl_ListObjReplace(NULL, newList, 0, 1, 1, &newCmd);
@@ -579,7 +579,7 @@ TclNamespaceEnsembleCmd(
"ensemble subcommand implementations "
"must be non-empty lists", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
- "EMPTY_TARGET", (void *)NULL);
+ "EMPTY_TARGET", (char *)NULL);
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
@@ -600,7 +600,7 @@ TclNamespaceEnsembleCmd(
Tcl_Obj *newCmd = NewNsObj((Tcl_Namespace*)nsPtr);
if (nsPtr->parentPtr) {
- Tcl_AppendStringsToObj(newCmd, "::", (void *)NULL);
+ Tcl_AppendStringsToObj(newCmd, "::", (char *)NULL);
}
Tcl_AppendObjToObj(newCmd, listv[0]);
Tcl_ListObjReplace(NULL, newList, 0, 1, 1,
@@ -627,7 +627,7 @@ TclNamespaceEnsembleCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"option -namespace is read-only", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "READ_ONLY",
- (void *)NULL);
+ (char *)NULL);
goto freeMapAndError;
case CONF_PREFIX:
if (Tcl_GetBooleanFromObj(interp, objv[1],
@@ -799,7 +799,7 @@ Tcl_SetEnsembleSubcommandList(
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
return TCL_ERROR;
}
if (subcmdList != NULL) {
@@ -875,7 +875,7 @@ Tcl_SetEnsembleParameterList(
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
return TCL_ERROR;
}
if (paramList == NULL) {
@@ -951,7 +951,7 @@ Tcl_SetEnsembleMappingDict(
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
return TCL_ERROR;
}
if (mapDict != NULL) {
@@ -979,7 +979,7 @@ Tcl_SetEnsembleMappingDict(
"ensemble target is not a fully-qualified command",
-1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
- "UNQUALIFIED_TARGET", (void *)NULL);
+ "UNQUALIFIED_TARGET", (char *)NULL);
Tcl_DictObjDone(&search);
return TCL_ERROR;
}
@@ -1051,7 +1051,7 @@ Tcl_SetEnsembleUnknownHandler(
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
return TCL_ERROR;
}
if (unknownList != NULL) {
@@ -1117,7 +1117,7 @@ Tcl_SetEnsembleFlags(
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
return TCL_ERROR;
}
@@ -1194,7 +1194,7 @@ Tcl_GetEnsembleSubcommandList(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1236,7 +1236,7 @@ Tcl_GetEnsembleParameterList(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1278,7 +1278,7 @@ Tcl_GetEnsembleMappingDict(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1319,7 +1319,7 @@ Tcl_GetEnsembleUnknownHandler(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1360,7 +1360,7 @@ Tcl_GetEnsembleFlags(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1401,7 +1401,7 @@ Tcl_GetEnsembleNamespace(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"command is not an ensemble", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1462,7 +1462,7 @@ Tcl_FindEnsemble(
"\"%s\" is not an ensemble command",
TclGetString(cmdNameObj)));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENSEMBLE",
- TclGetString(cmdNameObj), (void *)NULL);
+ TclGetString(cmdNameObj), (char *)NULL);
}
return NULL;
}
@@ -1613,17 +1613,16 @@ TclMakeEnsemble(
*/
if (ensemble != NULL) {
- Tcl_Obj *mapDict, *fromObj, *toObj;
+ Tcl_Obj *mapDict, *toObj;
Command *cmdPtr;
TclDStringAppendLiteral(&buf, "::");
TclNewObj(mapDict);
for (i=0 ; map[i].name != NULL ; i++) {
- fromObj = Tcl_NewStringObj(map[i].name, -1);
TclNewStringObj(toObj, Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf));
Tcl_AppendToObj(toObj, map[i].name, -1);
- Tcl_DictObjPut(NULL, mapDict, fromObj, toObj);
+ TclDictPut(NULL, mapDict, map[i].name, toObj);
if (map[i].proc || map[i].nreProc) {
/*
@@ -1755,7 +1754,7 @@ NsEnsembleImplementationCmdNR(
if (!Tcl_InterpDeleted(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"ensemble activated for deleted namespace", -1));
- Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (char *)NULL);
}
return TCL_ERROR;
}
@@ -1967,7 +1966,7 @@ NsEnsembleImplementationCmdNR(
Tcl_ResetResult(interp);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "SUBCOMMAND",
- TclGetString(subObj), (void *)NULL);
+ TclGetString(subObj), (char *)NULL);
if (ensemblePtr->subcommandTable.numEntries == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown subcommand \"%s\": namespace %s does not"
@@ -2327,7 +2326,7 @@ EnsembleUnknownCallback(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unknown subcommand handler deleted its ensemble", -1));
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "UNKNOWN_DELETED",
- (void *)NULL);
+ (char *)NULL);
}
result = TCL_ERROR;
}
@@ -2391,7 +2390,7 @@ EnsembleUnknownCallback(
"ensemble unknown subcommand handler: ");
Tcl_AppendObjToErrorInfo(interp, unknownCmd);
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "UNKNOWN_RESULT",
- (void *)NULL);
+ (char *)NULL);
} else {
Tcl_AddErrorInfo(interp,
"\n (ensemble unknown subcommand handler)");
@@ -2725,7 +2724,7 @@ BuildEnsembleConfig(
Tcl_AppendStringsToObj(cmdObj,
ensemblePtr->nsPtr->fullName,
(ensemblePtr->nsPtr->parentPtr ? "::" : ""),
- nsCmdName, (void *)NULL);
+ nsCmdName, (char *)NULL);
cmdPrefixObj = Tcl_NewListObj(1, &cmdObj);
Tcl_SetHashValue(hPtr, cmdPrefixObj);
Tcl_IncrRefCount(cmdPrefixObj);
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 60a8924..028813c 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -275,13 +275,9 @@ HandleBgErrors(
if (errChannel != NULL) {
Tcl_Obj *options = Tcl_GetReturnOptions(interp, code);
- Tcl_Obj *keyPtr, *valuePtr = NULL;
-
- TclNewLiteralStringObj(keyPtr, "-errorinfo");
- Tcl_IncrRefCount(keyPtr);
- Tcl_DictObjGet(NULL, options, keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ Tcl_Obj *valuePtr = NULL;
+ TclDictGet(NULL, options, "-errorinfo", &valuePtr);
Tcl_WriteChars(errChannel,
"error in background error handler:\n", -1);
if (valuePtr) {
@@ -329,7 +325,7 @@ TclDefaultBgErrorHandlerObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tcl_Obj *keyPtr, *valuePtr;
+ Tcl_Obj *valuePtr;
Tcl_Obj *tempObjv[2];
int result, code, level;
Tcl_InterpState saved;
@@ -343,27 +339,21 @@ TclDefaultBgErrorHandlerObjCmd(
* Check for a valid return options dictionary.
*/
- TclNewLiteralStringObj(keyPtr, "-level");
- Tcl_IncrRefCount(keyPtr);
- result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ result = TclDictGet(NULL, objv[2], "-level", &valuePtr);
if (result != TCL_OK || valuePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing return option \"-level\"", -1));
- Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &level) == TCL_ERROR) {
return TCL_ERROR;
}
- TclNewLiteralStringObj(keyPtr, "-code");
- Tcl_IncrRefCount(keyPtr);
- result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ result = TclDictGet(NULL, objv[2], "-code", &valuePtr);
if (result != TCL_OK || valuePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing return option \"-code\"", -1));
- Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &code) == TCL_ERROR) {
@@ -421,18 +411,12 @@ TclDefaultBgErrorHandlerObjCmd(
Tcl_SetObjResult(interp, tempObjv[1]);
}
- TclNewLiteralStringObj(keyPtr, "-errorcode");
- Tcl_IncrRefCount(keyPtr);
- result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ result = TclDictGet(NULL, objv[2], "-errorcode", &valuePtr);
if (result == TCL_OK && valuePtr != NULL) {
Tcl_SetObjErrorCode(interp, valuePtr);
}
- TclNewLiteralStringObj(keyPtr, "-errorinfo");
- Tcl_IncrRefCount(keyPtr);
- result = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ result = TclDictGet(NULL, objv[2], "-errorinfo", &valuePtr);
if (result == TCL_OK && valuePtr != NULL) {
Tcl_AppendObjToErrorInfo(interp, valuePtr);
}
@@ -1579,7 +1563,7 @@ Tcl_VwaitObjCmd(
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"argument required for \"%s\"", vWaitOptionStrings[index]));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "ARGUMENT", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "ARGUMENT", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1591,7 +1575,7 @@ Tcl_VwaitObjCmd(
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"timeout must be positive", -1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "NEGTIME", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "NEGTIME", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1671,7 +1655,7 @@ Tcl_VwaitObjCmd(
TCL_TIMER_EVENTS | TCL_WINDOW_EVENTS)) == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't wait: would block forever", -1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1679,7 +1663,7 @@ Tcl_VwaitObjCmd(
if ((timeout > 0) && ((mask & TCL_TIMER_EVENTS) == 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"timer events disabled with timeout specified", -1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_TIME", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_TIME", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1707,7 +1691,7 @@ Tcl_VwaitObjCmd(
if (vwaitItems[i].mask) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"file events disabled with channel(s) specified", -1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_FILE_EVENT", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_FILE_EVENT", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1746,7 +1730,7 @@ Tcl_VwaitObjCmd(
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj("limit exceeded", -1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "LIMIT", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "LIMIT", (char *)NULL);
break;
}
if ((numItems == 0) && (timeout == 0)) {
@@ -1766,7 +1750,7 @@ Tcl_VwaitObjCmd(
"can't wait: would wait forever" :
"can't wait for variable(s)/channel(s): would wait forever",
-1));
- Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (char *)NULL);
result = TCL_ERROR;
goto done;
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index ef42940..4b0284f 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1466,12 +1466,7 @@ CompileExprObj(
codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
codePtr->localCachePtr->refCount++;
}
-#ifdef TCL_COMPILE_DEBUG
- if (tclTraceCompile == 2) {
- TclPrintByteCodeObj(interp, objPtr);
- fflush(stdout);
- }
-#endif /* TCL_COMPILE_DEBUG */
+ TclDebugPrintByteCodeObj(objPtr);
}
return codePtr;
}
@@ -2380,7 +2375,7 @@ TEBCresume(
"yield can only be called in a coroutine", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -2411,7 +2406,7 @@ TEBCresume(
"yieldto can only be called in a coroutine", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -2422,7 +2417,7 @@ TEBCresume(
"yieldto called in deleted namespace", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -2484,7 +2479,7 @@ TEBCresume(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"tailcall can only be called from a proc or lambda", -1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -3991,7 +3986,7 @@ TEBCresume(
constError:
TclObjVarErrMsg(interp, part1Ptr, NULL, "make constant", msgPart, opnd);
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONST", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONST", (char *)NULL);
TRACE_ERROR(interp);
goto gotError;
}
@@ -4072,7 +4067,7 @@ TEBCresume(
TclObjVarErrMsg(interp, part1Ptr, NULL, "array set",
"variable isn't array", opnd);
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "WRITE", "ARRAY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "WRITE", "ARRAY", (char *)NULL);
CACHE_STACK_INFO();
TRACE_ERROR(interp);
goto gotError;
@@ -4373,7 +4368,7 @@ TEBCresume(
TRACE_ERROR(interp);
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "STACK_LEVEL",
- TclGetString(OBJ_AT_TOS), (void *)NULL);
+ TclGetString(OBJ_AT_TOS), (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4413,7 +4408,7 @@ TEBCresume(
"invalid command name \"%s\"", TclGetString(OBJ_AT_TOS)));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND",
- TclGetString(OBJ_AT_TOS), (void *)NULL);
+ TclGetString(OBJ_AT_TOS), (char *)NULL);
CACHE_STACK_INFO();
TRACE_APPEND(("ERROR: not command\n"));
goto gotError;
@@ -4442,7 +4437,7 @@ TEBCresume(
"self may only be called from inside a method",
-1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4470,7 +4465,7 @@ TEBCresume(
"nextto may only be called from inside a method",
-1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4491,7 +4486,7 @@ TEBCresume(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" is not a class", TclGetString(valuePtr)));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "CLASS_REQUIRED", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "CLASS_REQUIRED", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4543,7 +4538,7 @@ TEBCresume(
methodType, TclGetString(valuePtr)));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "OO", "CLASS_NOT_REACHABLE",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4551,7 +4546,7 @@ TEBCresume(
"%s has no non-filter implementation by \"%s\"",
methodType, TclGetString(valuePtr)));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "CLASS_NOT_THERE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "CLASS_NOT_THERE", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4569,7 +4564,7 @@ TEBCresume(
"next may only be called from inside a method",
-1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
@@ -4598,7 +4593,7 @@ TEBCresume(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no next %s implementation", methodType));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "TCL", "OO", "NOTHING_NEXT", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OO", "NOTHING_NEXT", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
#ifdef TCL_COMPILE_DEBUG
@@ -5954,7 +5949,7 @@ TEBCresume(
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
goto gotError;
@@ -6003,7 +5998,7 @@ TEBCresume(
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
- (void *)NULL);
+ (char *)NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
goto gotError;
@@ -6025,7 +6020,7 @@ TEBCresume(
#ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW",
- "integer value too large to represent", (void *)NULL);
+ "integer value too large to represent", (char *)NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
goto gotError;
@@ -6857,7 +6852,7 @@ TEBCresume(
TclGetString(OBJ_AT_TOS)));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "DICT",
- TclGetString(OBJ_AT_TOS), (void *)NULL);
+ TclGetString(OBJ_AT_TOS), (char *)NULL);
CACHE_STACK_INFO();
TRACE_ERROR(interp);
goto gotError;
@@ -7561,14 +7556,14 @@ TEBCresume(
divideByZero:
Tcl_SetObjResult(interp, Tcl_NewStringObj("divide by zero", -1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", "divide by zero", (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", "divide by zero", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
outOfMemory:
Tcl_SetObjResult(interp, Tcl_NewStringObj("out of memory", -1));
DECACHE_STACK_INFO();
- Tcl_SetErrorCode(interp, "ARITH", "OUTOFMEMORY", "out of memory", (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "OUTOFMEMORY", "out of memory", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
@@ -7582,7 +7577,7 @@ TEBCresume(
"exponentiation of zero by negative power", -1));
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
- "exponentiation of zero by negative power", (void *)NULL);
+ "exponentiation of zero by negative power", (char *)NULL);
CACHE_STACK_INFO();
/*
@@ -9137,7 +9132,7 @@ IllegalExprOperandType(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use %s \"%s\" as operand of \"%s\"", description,
TclGetString(opndPtr), op));
- Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", description, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", description, (char *)NULL);
}
/*
@@ -9515,23 +9510,23 @@ TclExprFloatError(
if ((errno == EDOM) || isnan(value)) {
s = "domain error: argument not in valid range";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
- Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", s, (char *)NULL);
} else if ((errno == ERANGE) || isinf(value)) {
if (value == 0.0) {
s = "floating-point value too small to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
- Tcl_SetErrorCode(interp, "ARITH", "UNDERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "UNDERFLOW", s, (char *)NULL);
} else {
s = "floating-point value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
- Tcl_SetErrorCode(interp, "ARITH", "OVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "OVERFLOW", s, (char *)NULL);
}
} else {
Tcl_Obj *objPtr = Tcl_ObjPrintf(
"unknown floating-point error, errno = %d", errno);
Tcl_SetErrorCode(interp, "ARITH", "UNKNOWN",
- TclGetString(objPtr), (void *)NULL);
+ TclGetString(objPtr), (char *)NULL);
Tcl_SetObjResult(interp, objPtr);
}
}
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index b12162c..4a55f06 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -1115,7 +1115,7 @@ TclFileAttrsCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\", there are no file attributes in this"
" filesystem", TclGetString(objv[0])));
- Tcl_SetErrorCode(interp, "TCL","OPERATION","FATTR","NONE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL","OPERATION","FATTR","NONE", (char *)NULL);
goto end;
}
@@ -1139,7 +1139,7 @@ TclFileAttrsCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\", there are no file attributes in this"
" filesystem", TclGetString(objv[0])));
- Tcl_SetErrorCode(interp, "TCL","OPERATION","FATTR","NONE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL","OPERATION","FATTR","NONE", (char *)NULL);
goto end;
}
@@ -1152,7 +1152,7 @@ TclFileAttrsCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", TclGetString(objv[i])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FATTR",
- "NOVALUE", (void *)NULL);
+ "NOVALUE", (char *)NULL);
goto end;
}
if (Tcl_FSFileAttrsSet(interp, index, filePtr,
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index fc4ddb6..2f3f48e 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -2061,8 +2061,7 @@ TclInitChanCmd(
* Can assume that reference counts are all incremented.
*/
- Tcl_DictObjPut(NULL, mapObj, Tcl_NewStringObj(extras[i], -1),
- Tcl_NewStringObj(extras[i+1], -1));
+ TclDictPutString(NULL, mapObj, extras[i], extras[i + 1]);
}
Tcl_SetEnsembleMappingDict(interp, ensemble, mapObj);
return ensemble;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 938090c..bb6c4d0 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3316,6 +3316,14 @@ MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
const char **elementPtr, const char **nextPtr,
Tcl_Size *sizePtr, int *literalPtr);
MODULE_SCOPE Tcl_Obj * TclDictObjSmartRef(Tcl_Interp *interp, Tcl_Obj *);
+MODULE_SCOPE int TclDictGet(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+ const char *key, Tcl_Obj **valuePtrPtr);
+MODULE_SCOPE int TclDictPut(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+ const char *key, Tcl_Obj *valuePtr);
+MODULE_SCOPE int TclDictPutString(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+ const char *key, const char *value);
+MODULE_SCOPE int TclDictRemove(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+ const char *key);
/* TIP #280 - Modified token based evaluation, with line information. */
MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script,
Tcl_Size numBytes, int flags, Tcl_Size line,
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index e38ec2b..70e1246 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -2842,18 +2842,6 @@ ChildEval(
Tcl_Preserve(childInterp);
Tcl_AllowExceptions(childInterp);
- /*
- * If we're transferring to another interpreter, check it's limits first.
- * It's much more reliable to do that now rather than waiting for the
- * intermittent checks done during running; the slight performance hit for
- * a cross-interp call is not a big problem. [Bug e3f4a8b78d]
- */
-
- if (interp != childInterp && Tcl_LimitCheck(childInterp) != TCL_OK) {
- result = TCL_ERROR;
- goto done;
- }
-
if (objc == 1) {
/*
* TIP #280: Make actual argument location available to eval'd script.
@@ -2872,7 +2860,6 @@ ChildEval(
result = Tcl_EvalObjEx(childInterp, objPtr, 0);
Tcl_DecrRefCount(objPtr);
}
- done:
Tcl_TransferResult(childInterp, result, interp);
Tcl_Release(childInterp);
@@ -4473,8 +4460,7 @@ ChildCommandLimitCmd(
if (hPtr != NULL) {
limitCBPtr = (ScriptLimitCallback *)Tcl_GetHashValue(hPtr);
if (limitCBPtr != NULL && limitCBPtr->scriptObj != NULL) {
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[0], -1),
- limitCBPtr->scriptObj);
+ TclDictPut(NULL, dictPtr, options[0], limitCBPtr->scriptObj);
} else {
goto putEmptyCommandInDict;
}
@@ -4483,22 +4469,19 @@ ChildCommandLimitCmd(
putEmptyCommandInDict:
TclNewObj(empty);
- Tcl_DictObjPut(NULL, dictPtr,
- Tcl_NewStringObj(options[0], -1), empty);
+ TclDictPut(NULL, dictPtr, options[0], empty);
}
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1),
- Tcl_NewWideIntObj(Tcl_LimitGetGranularity(childInterp,
- TCL_LIMIT_COMMANDS)));
+ TclDictPut(NULL, dictPtr, options[1], Tcl_NewWideIntObj(
+ Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_COMMANDS)));
if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_COMMANDS)) {
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1),
- Tcl_NewWideIntObj(Tcl_LimitGetCommands(childInterp)));
+ TclDictPut(NULL, dictPtr, options[2], Tcl_NewWideIntObj(
+ Tcl_LimitGetCommands(childInterp)));
} else {
Tcl_Obj *empty;
TclNewObj(empty);
- Tcl_DictObjPut(NULL, dictPtr,
- Tcl_NewStringObj(options[2], -1), empty);
+ TclDictPut(NULL, dictPtr, options[2], empty);
}
Tcl_SetObjResult(interp, dictPtr);
return TCL_OK;
@@ -4660,8 +4643,7 @@ ChildTimeLimitCmd(
if (hPtr != NULL) {
limitCBPtr = (ScriptLimitCallback *)Tcl_GetHashValue(hPtr);
if (limitCBPtr != NULL && limitCBPtr->scriptObj != NULL) {
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[0], -1),
- limitCBPtr->scriptObj);
+ TclDictPut(NULL, dictPtr, options[0], limitCBPtr->scriptObj);
} else {
goto putEmptyCommandInDict;
}
@@ -4669,29 +4651,25 @@ ChildTimeLimitCmd(
Tcl_Obj *empty;
putEmptyCommandInDict:
TclNewObj(empty);
- Tcl_DictObjPut(NULL, dictPtr,
- Tcl_NewStringObj(options[0], -1), empty);
+ TclDictPut(NULL, dictPtr, options[0], empty);
}
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[1], -1),
- Tcl_NewWideIntObj(Tcl_LimitGetGranularity(childInterp,
- TCL_LIMIT_TIME)));
+ TclDictPut(NULL, dictPtr, options[1], Tcl_NewWideIntObj(
+ Tcl_LimitGetGranularity(childInterp, TCL_LIMIT_TIME)));
if (Tcl_LimitTypeEnabled(childInterp, TCL_LIMIT_TIME)) {
Tcl_Time limitMoment;
Tcl_LimitGetTime(childInterp, &limitMoment);
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[2], -1),
- Tcl_NewWideIntObj(limitMoment.usec/1000));
- Tcl_DictObjPut(NULL, dictPtr, Tcl_NewStringObj(options[3], -1),
+ TclDictPut(NULL, dictPtr, options[2],
+ Tcl_NewWideIntObj(limitMoment.usec / 1000));
+ TclDictPut(NULL, dictPtr, options[3],
Tcl_NewWideIntObj(limitMoment.sec));
} else {
Tcl_Obj *empty;
TclNewObj(empty);
- Tcl_DictObjPut(NULL, dictPtr,
- Tcl_NewStringObj(options[2], -1), empty);
- Tcl_DictObjPut(NULL, dictPtr,
- Tcl_NewStringObj(options[3], -1), empty);
+ TclDictPut(NULL, dictPtr, options[2], empty);
+ TclDictPut(NULL, dictPtr, options[3], empty);
}
Tcl_SetObjResult(interp, dictPtr);
return TCL_OK;
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 1bb3587..20e85dd 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -471,7 +471,7 @@ MemoryAllocationError(
"list construction failed: unable to alloc %" TCL_Z_MODIFIER
"u bytes",
size));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
}
return TCL_ERROR;
}
@@ -498,7 +498,7 @@ ListLimitExceededError(Tcl_Interp *interp)
Tcl_SetObjResult(
interp,
Tcl_NewStringObj("max length of a Tcl list exceeded", -1));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2970,10 +2970,8 @@ TclLsetFlat(
/* ...the index points outside the sublist. */
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "index \"%s\" out of range",
- Tcl_GetString(indexArray[-1])));
- Tcl_SetErrorCode(interp,
- "TCL", "VALUE", "INDEX" "OUTOFRANGE", (void *)NULL);
+ "index \"%s\" out of range", TclGetString(indexArray[-1])));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
}
result = TCL_ERROR;
break;
@@ -3163,8 +3161,7 @@ TclListObjSetElement(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"index \"%" TCL_SIZE_MODIFIER "d\" out of range", index));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX",
- "OUTOFRANGE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tclMain.c b/generic/tclMain.c
index a7cb7fb..ad36b3f 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -406,13 +406,9 @@ Tcl_MainEx(
chan = Tcl_GetStdChannel(TCL_STDERR);
if (chan) {
Tcl_Obj *options = Tcl_GetReturnOptions(interp, code);
- Tcl_Obj *keyPtr, *valuePtr;
-
- TclNewLiteralStringObj(keyPtr, "-errorinfo");
- Tcl_IncrRefCount(keyPtr);
- Tcl_DictObjGet(NULL, options, keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
+ Tcl_Obj *valuePtr = NULL;
+ TclDictGet(NULL, options, "-errorinfo", &valuePtr);
if (valuePtr) {
if (Tcl_WriteObj(chan, valuePtr) < 0) {
Tcl_WriteChars(chan, ENCODING_ERROR, -1);
diff --git a/generic/tclOOInfo.c b/generic/tclOOInfo.c
index 7435fff..be329d7 100644
--- a/generic/tclOOInfo.c
+++ b/generic/tclOOInfo.c
@@ -125,10 +125,8 @@ TclOOInitInfo(
infoCmd = Tcl_FindCommand(interp, "info", NULL, TCL_GLOBAL_ONLY);
if (infoCmd) {
Tcl_GetEnsembleMappingDict(NULL, infoCmd, &mapDict);
- Tcl_DictObjPut(NULL, mapDict, Tcl_NewStringObj("object", -1),
- Tcl_NewStringObj("::oo::InfoObject", -1));
- Tcl_DictObjPut(NULL, mapDict, Tcl_NewStringObj("class", -1),
- Tcl_NewStringObj("::oo::InfoClass", -1));
+ TclDictPutString(NULL, mapDict, "object", "::oo::InfoObject");
+ TclDictPutString(NULL, mapDict, "class", "::oo::InfoClass");
Tcl_SetEnsembleMappingDict(interp, infoCmd, mapDict);
}
}
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 36856d4..8018fbc 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -949,7 +949,7 @@ Tcl_ConvertToType(
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't convert value to type %s", typePtr->name));
- Tcl_SetErrorCode(interp, "TCL", "API_ABUSE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "API_ABUSE", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2139,7 +2139,7 @@ TclSetBooleanFromAny(
Tcl_AppendLimitedToObj(msg, str, length, 50, "");
Tcl_AppendToObj(msg, "\"", -1);
Tcl_SetObjResult(interp, msg);
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "BOOLEAN", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "BOOLEAN", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2428,7 +2428,7 @@ Tcl_GetDoubleFromObj(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"floating point value is Not a Number", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DOUBLE", "NAN",
- (void *)NULL);
+ (char *)NULL);
}
return TCL_ERROR;
}
@@ -2559,7 +2559,7 @@ Tcl_GetIntFromObj(
const char *s =
"integer value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
- Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
@@ -2681,7 +2681,7 @@ Tcl_GetLongFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (char *)NULL);
}
return TCL_ERROR;
}
@@ -2725,7 +2725,7 @@ Tcl_GetLongFromObj(
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
- Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
@@ -2989,7 +2989,7 @@ Tcl_GetWideIntFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3027,7 +3027,7 @@ Tcl_GetWideIntFromObj(
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
- Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
@@ -3072,7 +3072,7 @@ Tcl_GetWideUIntFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected unsigned integer but got \"%s\"",
TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3111,7 +3111,7 @@ Tcl_GetWideUIntFromObj(
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
Tcl_SetObjResult(interp, msg);
- Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
@@ -3158,7 +3158,7 @@ TclGetWideBitsFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (char *)NULL);
}
return TCL_ERROR;
}
@@ -3482,7 +3482,7 @@ GetBignumFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer but got \"%s\"",
TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INTEGER", (char *)NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tclPipe.c b/generic/tclPipe.c
index 854ecd5..73f291a 100644
--- a/generic/tclPipe.c
+++ b/generic/tclPipe.c
@@ -111,7 +111,7 @@ FileForRedirect(
Tcl_GetChannelName(chan),
((writing) ? "writing" : "reading")));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "BADCHAN", (void *)NULL);
+ "BADCHAN", (char *)NULL);
}
return NULL;
}
@@ -155,7 +155,7 @@ FileForRedirect(
badLastArg:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't specify \"%s\" as last word in command", arg));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "SYNTAX", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "SYNTAX", (char *)NULL);
return NULL;
}
@@ -514,7 +514,7 @@ TclCreatePipeline(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal use of | or |& in command", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "PIPESYNTAX", (void *)NULL);
+ "PIPESYNTAX", (char *)NULL);
goto error;
}
}
@@ -543,7 +543,7 @@ TclCreatePipeline(
"can't specify \"%s\" as last word in command",
argv[i]));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "PIPESYNTAX", (void *)NULL);
+ "PIPESYNTAX", (char *)NULL);
goto error;
}
skip = 2;
@@ -660,7 +660,7 @@ TclCreatePipeline(
"must specify \"%s\" as last word in command",
argv[i]));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "PIPESYNTAX", (void *)NULL);
+ "PIPESYNTAX", (char *)NULL);
goto error;
}
errorFile = outputFile;
@@ -702,7 +702,7 @@ TclCreatePipeline(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"illegal use of | or |& in command", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "PIPESYNTAX",
- (void *)NULL);
+ (char *)NULL);
goto error;
}
@@ -1056,7 +1056,7 @@ Tcl_OpenCommandChannel(
"can't read output from command:"
" standard output was redirected", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "BADREDIRECT", (void *)NULL);
+ "BADREDIRECT", (char *)NULL);
goto error;
}
if ((flags & TCL_STDIN) && (inPipe == NULL)) {
@@ -1064,7 +1064,7 @@ Tcl_OpenCommandChannel(
"can't write input to command:"
" standard input was redirected", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
- "BADREDIRECT", (void *)NULL);
+ "BADREDIRECT", (char *)NULL);
goto error;
}
}
@@ -1075,7 +1075,7 @@ Tcl_OpenCommandChannel(
if (channel == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"pipe for command could not be created", -1));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "NOPIPE", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "NOPIPE", (char *)NULL);
goto error;
}
return channel;
diff --git a/generic/tclProcess.c b/generic/tclProcess.c
index a5607d9..bed3a60 100644
--- a/generic/tclProcess.c
+++ b/generic/tclProcess.c
@@ -538,7 +538,7 @@ ProcessStatusObjCmd(
* Add to result.
*/
- Tcl_DictObjPut(interp, dict, Tcl_NewWideIntObj(info->resolvedPid),
+ Tcl_DictObjPut(NULL, dict, Tcl_NewIntObj(info->resolvedPid),
BuildProcessStatusObj(info));
}
}
@@ -588,7 +588,7 @@ ProcessStatusObjCmd(
* Add to result.
*/
- Tcl_DictObjPut(interp, dict, Tcl_NewWideIntObj(info->resolvedPid),
+ Tcl_DictObjPut(NULL, dict, Tcl_NewIntObj(info->resolvedPid),
BuildProcessStatusObj(info));
}
}
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 1b78184..ee21cf8 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -1531,7 +1531,7 @@ TclParseNumber(
Tcl_AppendLimitedToObj(msg, bytes, numBytes, 50, "");
Tcl_AppendToObj(msg, "\"", -1);
Tcl_SetObjResult(interp, msg);
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (char *)NULL);
}
}
@@ -4793,7 +4793,7 @@ Tcl_InitBignumFromDouble(
const char *s = "integer value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
- Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (void *)NULL);
+ Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 9dc16a7..44ad263 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -432,7 +432,7 @@ TestbooleanobjCmd(
} else {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad option \"", Tcl_GetString(objv[1]),
- "\": must be set, get, or not", (void *)NULL);
+ "\": must be set, get, or not", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -549,7 +549,7 @@ TestdoubleobjCmd(
} else {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad option \"", Tcl_GetString(objv[1]),
- "\": must be set, get, mult10, or div10", (void *)NULL);
+ "\": must be set, get, mult10, or div10", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -838,7 +838,7 @@ TestintobjCmd(
} else {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad option \"", Tcl_GetString(objv[1]),
- "\": must be set, get, get2, mult10, or div10", (void *)NULL);
+ "\": must be set, get, get2, mult10, or div10", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -1247,7 +1247,7 @@ TestobjCmd(
}
if ((targetType = Tcl_GetObjType(Tcl_GetString(objv[3]))) == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "no type ", Tcl_GetString(objv[3]), " found", (void *)NULL);
+ "no type ", Tcl_GetString(objv[3]), " found", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_ConvertToType(interp, varPtr[varIndex], targetType)
@@ -1404,7 +1404,7 @@ TeststringobjCmd(
Tcl_AppendStringsToObj(varPtr[varIndex], strings[0], strings[1],
strings[2], strings[3], strings[4], strings[5],
strings[6], strings[7], strings[8], strings[9],
- strings[10], strings[11], (void *)NULL);
+ strings[10], strings[11], (char *)NULL);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 2: /* get */
diff --git a/generic/tclTestProcBodyObj.c b/generic/tclTestProcBodyObj.c
index 7342af7..8c32066 100644
--- a/generic/tclTestProcBodyObj.c
+++ b/generic/tclTestProcBodyObj.c
@@ -265,7 +265,7 @@ ProcBodyTestProcObjCmd(
if (cmdPtr->objClientData != TclIsProc(cmdPtr)) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "command \"", fullName, "\" is not a Tcl procedure", (void *)NULL);
+ "command \"", fullName, "\" is not a Tcl procedure", (char *)NULL);
return TCL_ERROR;
}
@@ -276,7 +276,7 @@ ProcBodyTestProcObjCmd(
procPtr = (Proc *) cmdPtr->objClientData;
if (procPtr == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "procedure \"",
- fullName, "\" does not have a Proc struct!", (void *)NULL);
+ fullName, "\" does not have a Proc struct!", (char *)NULL);
return TCL_ERROR;
}
@@ -288,7 +288,7 @@ ProcBodyTestProcObjCmd(
if (bodyObjPtr == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"failed to create a procbody object for procedure \"",
- fullName, "\"", (void *)NULL);
+ fullName, "\"", (char *)NULL);
return TCL_ERROR;
}
Tcl_IncrRefCount(bodyObjPtr);
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index b10465d..e4a9312 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -371,7 +371,7 @@ ThreadObjCmd(
char buf[TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "%" TCL_LL_MODIFIER "d", (long long)id);
- Tcl_AppendResult(interp, "cannot join thread ", buf, (void *)NULL);
+ Tcl_AppendResult(interp, "cannot join thread ", buf, (char *)NULL);
}
return result;
}
@@ -509,7 +509,7 @@ ThreadCreate(
if (Tcl_CreateThread(&id, NewTestThread, &ctrl,
TCL_THREAD_STACK_DEFAULT, joinable) != TCL_OK) {
Tcl_MutexUnlock(&threadMutex);
- Tcl_AppendResult(interp, "can't create a new thread", (void *)NULL);
+ Tcl_AppendResult(interp, "can't create a new thread", (char *)NULL);
return TCL_ERROR;
}
@@ -820,7 +820,7 @@ ThreadSend(
}
if (!found) {
Tcl_MutexUnlock(&threadMutex);
- Tcl_AppendResult(interp, "invalid thread id", (void *)NULL);
+ Tcl_AppendResult(interp, "invalid thread id", (char *)NULL);
return TCL_ERROR;
}
@@ -914,7 +914,7 @@ ThreadSend(
if (resultPtr->code != TCL_OK) {
if (resultPtr->errorCode) {
- Tcl_SetErrorCode(interp, resultPtr->errorCode, (void *)NULL);
+ Tcl_SetErrorCode(interp, resultPtr->errorCode, (char *)NULL);
Tcl_Free(resultPtr->errorCode);
}
if (resultPtr->errorInfo) {
@@ -922,7 +922,7 @@ ThreadSend(
Tcl_Free(resultPtr->errorInfo);
}
}
- Tcl_AppendResult(interp, resultPtr->result, (void *)NULL);
+ Tcl_AppendResult(interp, resultPtr->result, (char *)NULL);
Tcl_ConditionFinalize(&resultPtr->done);
code = resultPtr->code;
@@ -973,7 +973,7 @@ ThreadCancel(
}
if (!found) {
Tcl_MutexUnlock(&threadMutex);
- Tcl_AppendResult(interp, "invalid thread id", (void *)NULL);
+ Tcl_AppendResult(interp, "invalid thread id", (char *)NULL);
return TCL_ERROR;
}
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index e2c96a9..c2fa64f 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3921,10 +3921,8 @@ TclIndexEncode(
rangeerror:
if (interp) {
- Tcl_SetObjResult(
- interp,
- Tcl_ObjPrintf("index \"%s\" out of range", TclGetString(objPtr)));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (void *)NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("index \"%s\" out of range", TclGetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index b0bb383..f09030a 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -6262,8 +6262,7 @@ TclZipfs_Init(
*/
Tcl_GetEnsembleMappingDict(NULL, ensemble, &mapObj);
- Tcl_DictObjPut(NULL, mapObj, Tcl_NewStringObj("find", -1),
- Tcl_NewStringObj("::tcl::zipfs::find", -1));
+ TclDictPutString(NULL, mapObj, "find", "::tcl::zipfs::find");
Tcl_CreateObjCommand(interp, "::tcl::zipfs::tcl_library_init",
ZipFSTclLibraryObjCmd, NULL, NULL);
Tcl_PkgProvide(interp, "tcl::zipfs", "2.0");
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 595ddf4..ff360d6 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -228,6 +228,26 @@ static const Tcl_ChannelType zlibChannelType = {
/*
*----------------------------------------------------------------------
*
+ * Latin1 --
+ * Helper to definitely get the ISO 8859-1 encoding. It's internally
+ * defined by Tcl so this operation should always succeed.
+ *
+ *----------------------------------------------------------------------
+ */
+static inline Tcl_Encoding
+Latin1(void)
+{
+ Tcl_Encoding latin1enc = Tcl_GetEncoding(NULL, "iso8859-1");
+
+ if (latin1enc == NULL) {
+ Tcl_Panic("no latin-1 encoding");
+ }
+ return latin1enc;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* ConvertError --
*
* Utility function for converting a zlib error into a Tcl error.
@@ -388,7 +408,7 @@ ConvertErrorToList(
* GenerateHeader --
*
* Function for creating a gzip header from the contents of a dictionary
- * (as described in the documentation). GetValue is a helper function.
+ * (as described in the documentation).
*
* Results:
* A Tcl result code.
@@ -401,33 +421,6 @@ ConvertErrorToList(
*----------------------------------------------------------------------
*/
-static inline int
-GetValue(
- Tcl_Interp *interp,
- Tcl_Obj *dictObj,
- const char *nameStr,
- Tcl_Obj **valuePtrPtr)
-{
- Tcl_Obj *name = Tcl_NewStringObj(nameStr, TCL_AUTO_LENGTH);
- int result = Tcl_DictObjGet(interp, dictObj, name, valuePtrPtr);
-
- TclDecrRefCount(name);
- return result;
-}
-
-/*
- * RFC 1952 says that header strings are in ISO 8859-1 (LATIN-1).
- */
-static inline Tcl_Encoding
-Latin1(void)
-{
- Tcl_Encoding latin1enc = Tcl_GetEncoding(NULL, "iso8859-1");
- if (latin1enc == NULL) {
- Tcl_Panic("no latin-1 encoding");
- }
- return latin1enc;
-}
-
static int
GenerateHeader(
Tcl_Interp *interp, /* Where to put error messages. */
@@ -447,7 +440,7 @@ GenerateHeader(
"binary", "text"
};
- if (GetValue(interp, dictObj, "comment", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "comment", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
Tcl_EncodingState state;
@@ -476,14 +469,14 @@ GenerateHeader(
}
}
- if (GetValue(interp, dictObj, "crc", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "crc", &value) != TCL_OK) {
goto error;
} else if (value != NULL &&
Tcl_GetBooleanFromObj(interp, value, &headerPtr->header.hcrc)) {
goto error;
}
- if (GetValue(interp, dictObj, "filename", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "filename", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
Tcl_EncodingState state;
@@ -512,7 +505,7 @@ GenerateHeader(
}
}
- if (GetValue(interp, dictObj, "os", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "os", &value) != TCL_OK) {
goto error;
} else if (value != NULL && Tcl_GetIntFromObj(interp, value,
&headerPtr->header.os) != TCL_OK) {
@@ -524,7 +517,7 @@ GenerateHeader(
* input data.
*/
- if (GetValue(interp, dictObj, "time", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "time", &value) != TCL_OK) {
goto error;
} else if (value != NULL && TclGetWideIntFromObj(interp, value,
&wideValue) != TCL_OK) {
@@ -532,7 +525,7 @@ GenerateHeader(
}
headerPtr->header.time = wideValue;
- if (GetValue(interp, dictObj, "type", &value) != TCL_OK) {
+ if (TclDictGet(interp, dictObj, "type", &value) != TCL_OK) {
goto error;
} else if (value != NULL && Tcl_GetIndexFromObj(interp, value, types,
"type", TCL_EXACT, &headerPtr->header.text) != TCL_OK) {
@@ -551,7 +544,6 @@ GenerateHeader(
* ExtractHeader --
*
* Take the values out of a gzip header and store them in a dictionary.
- * SetValue is a helper macro.
*
* Results:
* None.
@@ -562,28 +554,24 @@ GenerateHeader(
*----------------------------------------------------------------------
*/
-#define SetValue(dictObj, key, value) \
- Tcl_DictObjPut(NULL, (dictObj), Tcl_NewStringObj( \
- (key), TCL_AUTO_LENGTH), (value))
-
static void
ExtractHeader(
gz_header *headerPtr, /* The gzip header to extract from. */
Tcl_Obj *dictObj) /* The dictionary to store in. */
{
Tcl_Encoding latin1enc = NULL;
+ /* RFC 1952 says that header strings are in
+ * ISO 8859-1 (LATIN-1). */
Tcl_DString tmp;
if (headerPtr->comment != Z_NULL) {
- if (latin1enc == NULL) {
- latin1enc = Latin1();
- }
+ latin1enc = Latin1();
(void) Tcl_ExternalToUtfDString(latin1enc, (char *) headerPtr->comment,
TCL_AUTO_LENGTH, &tmp);
- SetValue(dictObj, "comment", Tcl_DStringToObj(&tmp));
+ TclDictPut(NULL, dictObj, "comment", Tcl_DStringToObj(&tmp));
}
- SetValue(dictObj, "crc", Tcl_NewBooleanObj(headerPtr->hcrc));
+ TclDictPut(NULL, dictObj, "crc", Tcl_NewBooleanObj(headerPtr->hcrc));
if (headerPtr->name != Z_NULL) {
if (latin1enc == NULL) {
latin1enc = Latin1();
@@ -591,17 +579,17 @@ ExtractHeader(
(void) Tcl_ExternalToUtfDString(latin1enc, (char *) headerPtr->name,
TCL_AUTO_LENGTH, &tmp);
- SetValue(dictObj, "filename", Tcl_DStringToObj(&tmp));
+ TclDictPut(NULL, dictObj, "filename", Tcl_DStringToObj(&tmp));
}
if (headerPtr->os != 255) {
- SetValue(dictObj, "os", Tcl_NewWideIntObj(headerPtr->os));
+ TclDictPut(NULL, dictObj, "os", Tcl_NewWideIntObj(headerPtr->os));
}
if (headerPtr->time != 0 /* magic - no time */) {
- SetValue(dictObj, "time", Tcl_NewWideIntObj(headerPtr->time));
+ TclDictPut(NULL, dictObj, "time", Tcl_NewWideIntObj(headerPtr->time));
}
if (headerPtr->text != Z_UNKNOWN) {
- SetValue(dictObj, "type", Tcl_NewStringObj(
- headerPtr->text ? "text" : "binary", TCL_AUTO_LENGTH));
+ TclDictPutString(NULL, dictObj, "type",
+ headerPtr->text ? "text" : "binary");
}
if (latin1enc != NULL) {
@@ -1917,7 +1905,7 @@ Tcl_ZlibInflate(
Tcl_SetByteArrayLength(obj, stream.total_out);
if (headerPtr != NULL) {
ExtractHeader(&header, gzipHeaderDictObj);
- SetValue(gzipHeaderDictObj, "size",
+ TclDictPut(NULL, gzipHeaderDictObj, "size",
Tcl_NewWideIntObj(stream.total_out));
Tcl_Free(nameBuf);
Tcl_Free(commentBuf);
diff --git a/tests/interp.test b/tests/interp.test
index 2505052..c299fd2 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -22,6 +22,12 @@ 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:encoding:system 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:tempdir tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable tcl:info:cmdtype tcl:info:nameofexecutable tcl:process:autopurge tcl:process:list tcl:process:purge tcl:process:status tcl:zipfs:lmkimg tcl:zipfs:lmkzip tcl:zipfs:mkimg tcl:zipfs:mkkey tcl:zipfs:mkzip tcl:zipfs:mount tcl:zipfs:mount_data tcl:zipfs:unmount unload}
+proc _ms_limit_args {ms {t0 {}}} {
+ if {$t0 eq {}} { set t0 [clock milliseconds] }
+ incr t0 $ms
+ list -seconds [expr {$t0 / 1000}] -milliseconds [expr {$t0 % 1000}]
+}
+
foreach i [interp children] {
interp delete $i
}
@@ -3155,7 +3161,7 @@ test interp-34.3 {basic test of limits - pure bytecode loop} -body {
}
}
# We use a time limit here; command limits don't trap this case
- $i limit time -seconds [expr {[clock seconds]+2}]
+ $i limit time {*}[_ms_limit_args 50]
$i eval foobar
} -returnCodes error -result {time limit exceeded} -cleanup {
interp delete $i
@@ -3171,7 +3177,7 @@ test interp-34.3.1 {basic test of limits - pure inside-command loop} -body {
}
}
# We use a time limit here; command limits don't trap this case
- $i limit time -seconds [expr {[clock seconds] + 2}]
+ $i limit time {*}[_ms_limit_args 50]
$i eval foobar
} -returnCodes error -result {time limit exceeded} -cleanup {
interp delete $i
@@ -3304,7 +3310,7 @@ test interp-34.7 {limits with callbacks: deleting the handler interp} -setup {
# Bug 1085023
test interp-34.8 {time limits trigger in vwaits} -body {
set i [interp create]
- interp limit $i time -seconds [expr {[clock seconds] + 1}] -granularity 1
+ interp limit $i time {*}[_ms_limit_args 50] -granularity 1
$i eval {
set x {}
vwait x
@@ -3314,25 +3320,24 @@ test interp-34.8 {time limits trigger in vwaits} -body {
} -returnCodes error -result {limit exceeded}
test interp-34.9 {time limits trigger in blocking after} {
set i [interp create]
- set t0 [clock seconds]
- interp limit $i time -seconds [expr {$t0 + 1}] -granularity 1
+ set t0 [clock milliseconds]
+ interp limit $i time {*}[_ms_limit_args 50 $t0] -granularity 1
set code [catch {
$i eval {after 10000}
} msg]
- set t1 [clock seconds]
+ set t1 [clock milliseconds]
interp delete $i
- list $code $msg [expr {($t1-$t0) < 3 ? "OK" : $t1-$t0}]
+ list $code $msg [expr {($t1-$t0) < 1000 ? "OK" : $t1-$t0}]
} {1 {time limit exceeded} OK}
test interp-34.10 {time limits trigger in vwaits: Bug 1221395} -body {
set i [interp create]
- # Assume someone hasn't set the clock to early 1970!
- $i limit time -seconds [expr {[clock seconds] + 1}] -granularity 4
interp alias $i log {} lappend result
set result {}
+ $i limit time {*}[_ms_limit_args 50] -granularity 4
catch {
$i eval {
log 1
- after 1000
+ after 100
log 2
}
} msg
@@ -3340,10 +3345,10 @@ test interp-34.10 {time limits trigger in vwaits: Bug 1221395} -body {
lappend result $msg
} -result {1 {time limit exceeded}}
test interp-34.11 {time limit extension in callbacks} -constraints knownBug -setup {
- proc cb1 {i t} {
+ proc cb1 {i args} {
global result
lappend result cb1
- $i limit time -seconds $t -command cb2
+ $i limit time {*}[_ms_limit_args {*}$args] -command cb2
}
proc cb2 {} {
global result
@@ -3351,9 +3356,9 @@ test interp-34.11 {time limit extension in callbacks} -constraints knownBug -set
}
} -body {
set i [interp create]
- set t0 [clock seconds]
- $i limit time -seconds [expr {$t0 + 1}] -granularity 1 \
- -command "cb1 $i [expr {$t0 + 2}]"
+ set t0 [clock milliseconds]
+ $i limit time {*}[_ms_limit_args 50 $t0] \
+ -command "cb1 $i 100 $t0"
set ::result {}
lappend ::result [catch {
$i eval {
@@ -3362,8 +3367,8 @@ test interp-34.11 {time limit extension in callbacks} -constraints knownBug -set
}
}
} msg] $msg
- set t1 [clock seconds]
- lappend ::result [expr {$t1-$t0>=2 ? "ok" : "$t0,$t1"}]
+ set t1 [clock milliseconds]
+ lappend ::result [expr {$t1-$t0>=100 ? "ok" : "$t0,$t1"}]
interp delete $i
return $::result
} -result {cb1 cb2 1 {time limit exceeded} ok} -cleanup {
@@ -3371,27 +3376,27 @@ test interp-34.11 {time limit extension in callbacks} -constraints knownBug -set
rename cb2 {}
}
test interp-34.12 {time limit extension in callbacks} -setup {
- proc cb1 {i} {
+ proc cb1 {i t0} {
global result times
lappend result cb1
set times [lassign $times t]
- $i limit time -seconds $t
+ $i limit time {*}[_ms_limit_args $t $t0]
}
} -body {
set i [interp create]
- set t0 [clock seconds]
- set ::times "[expr {$t0 + 2}] [expr {$t0 + 100}]"
- $i limit time -seconds [expr {$t0 + 1}] -granularity 1 -command "cb1 $i"
+ set t0 [clock milliseconds]
+ set ::times {100 10000}
+ $i limit time {*}[_ms_limit_args 50] -granularity 1 -command "cb1 $i $t0"
set ::result {}
lappend ::result [catch {
$i eval {
- for {set i 0} {$i<30} {incr i} {
- after 100
+ for {set i 0} {$i<5} {incr i} {
+ after 50
}
}
} msg] $msg
- set t1 [clock seconds]
- lappend ::result [expr {$t1-$t0>=2 ? "ok" : "$t0,$t1"}]
+ set t1 [clock milliseconds]
+ lappend ::result [expr {$t1-$t0>=100 ? "ok" : "$t0,$t1"}]
interp delete $i
return $::result
} -result {cb1 cb1 0 {} ok} -cleanup {
@@ -3400,7 +3405,7 @@ test interp-34.12 {time limit extension in callbacks} -setup {
test interp-34.13 {time limit granularity and vwait: Bug 2891362} -setup {
set i [interp create -safe]
} -body {
- $i limit time -seconds [clock add [clock seconds] 1 second]
+ $i limit time {*}[_ms_limit_args 50]
$i eval {
after 2000 set x timeout
vwait x
@@ -3413,16 +3418,16 @@ test interp-34.14 {[Bug e3f4a8b78d]: interp limit and interp eval} -setup {
set i [interp create]
set result {}
} -body {
- $i limit command -value [$i eval {info cmdcount}]
- catch {$i eval [list expr 1+3]} msg
- lappend result $msg
- catch {$i eval [list expr 1+3]} msg
- lappend result $msg
- catch {interp eval $i [list expr 1+3]} msg
- lappend result $msg
+ $i limit command -value [$i eval {info cmdcount}] -granularity 1
+ lappend result [catch {$i eval [list expr 1+3]} msg] $msg
+ lappend result [catch {$i eval [list expr 1+3]} msg] $msg
+ lappend result [catch {$i eval {set cmd expr; $cmd 1+3}} msg] $msg
+ lappend result [catch {$i eval {expr 1+3}} msg] $msg
+ lappend result [catch {$i eval expr 1+3} msg] $msg
+ lappend result [catch {interp eval $i [list expr 1+3]} msg] $msg
} -cleanup {
interp delete $i
-} -result {{command count limit exceeded} {command count limit exceeded} {command count limit exceeded}}
+} -result [lrepeat 6 1 {command count limit exceeded}]
test interp-35.1 {interp limit syntax} -body {
interp limit
@@ -3684,6 +3689,7 @@ unset -nocomplain hidden_cmds
foreach i [interp children] {
interp delete $i
}
+rename _ms_limit_args {}
::tcltest::cleanupTests
return
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 3f972ae..edb1edb 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -567,21 +567,6 @@ FileGetHandleProc(
*----------------------------------------------------------------------
*/
-static inline void
-StoreElementInDict(
- Tcl_Obj *dictObj,
- const char *name,
- Tcl_Obj *valueObj)
-{
- /*
- * We assume that the dict is being built fresh and that there's never any
- * duplicate keys.
- */
-
- Tcl_Obj *nameObj = Tcl_NewStringObj(name, -1);
- Tcl_DictObjPut(NULL, dictObj, nameObj, valueObj);
-}
-
static inline const char *
GetTypeFromMode(
int mode)
@@ -631,7 +616,7 @@ StatOpenFile(
*/
TclNewObj(dictObj);
-#define STORE_ELEM(name, value) StoreElementInDict(dictObj, name, value)
+#define STORE_ELEM(name, value) TclDictPut(NULL, dictObj, name, value)
STORE_ELEM("dev", Tcl_NewWideIntObj((long) statBuf.st_dev));
STORE_ELEM("ino", Tcl_NewWideIntObj((Tcl_WideInt) statBuf.st_ino));
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index 4c08464..248ca5b 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -814,21 +814,6 @@ CombineDwords(
return converter.QuadPart;
}
-static inline void
-StoreElementInDict(
- Tcl_Obj *dictObj,
- const char *name,
- Tcl_Obj *valueObj)
-{
- /*
- * We assume that the dict is being built fresh and that there's never any
- * duplicate keys.
- */
-
- Tcl_Obj *nameObj = Tcl_NewStringObj(name, TCL_INDEX_NONE);
- Tcl_DictObjPut(NULL, dictObj, nameObj, valueObj);
-}
-
static inline time_t
ToCTime(
FILETIME fileTime) /* UTC time */
@@ -891,7 +876,7 @@ StatOpenFile(
*/
TclNewObj(dictObj);
-#define STORE_ELEM(name, value) StoreElementInDict(dictObj, name, value)
+#define STORE_ELEM(name, value) TclDictPut(NULL, dictObj, name, value)
STORE_ELEM("dev", Tcl_NewWideIntObj((long) dev));
STORE_ELEM("ino", Tcl_NewWideIntObj((long long) inode));