summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-06-26 16:06:44 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-06-26 16:06:44 (GMT)
commit33e20f17a6f8a5fddafb1a39563a04aed53705e1 (patch)
treeef6d95e2507af8bda6b80cb5f244f4745bf2fcbe /generic/tclCompile.c
parenta0860b63fb252ca05d70706533db45c410b95c0e (diff)
downloadtcl-33e20f17a6f8a5fddafb1a39563a04aed53705e1.zip
tcl-33e20f17a6f8a5fddafb1a39563a04aed53705e1.tar.gz
tcl-33e20f17a6f8a5fddafb1a39563a04aed53705e1.tar.bz2
Fix bytecode ranges in the cmdMapPtr. still leaky.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 626c5ae..62943b2 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -1742,7 +1742,8 @@ static void
CompileCommandTokens(
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
- CompileEnv *envPtr)
+ CompileEnv *envPtr,
+ int *lastPopPtr)
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *cmdObj = Tcl_NewObj();
@@ -2017,6 +2018,8 @@ finishCommand:
EnterCmdExtentData(envPtr, currCmdIndex,
parsePtr->term - parsePtr->commandStart,
(envPtr->codeNext-envPtr->codeStart) - startCodeOffset);
+ *lastPopPtr = currCmdIndex;
+
if (cmdKnown) {
Tcl_DecrRefCount(cmdObj);
@@ -2051,6 +2054,7 @@ TclCompileScript(
unsigned char *entryCodeNext = envPtr->codeNext;
const char *p;
int cmdLine, *clNext;
+ int lastPop = -1;
if (envPtr->iPtr == NULL) {
Tcl_Panic("TclCompileScript() called on uninitialized CompileEnv");
@@ -2081,6 +2085,7 @@ TclCompileScript(
parse.commandStart + parse.commandSize - 1)?
parse.commandSize - 1 : parse.commandSize);
TclCompileSyntaxError(interp, envPtr);
+ lastPop = -1;
break;
}
@@ -2109,7 +2114,7 @@ TclCompileScript(
envPtr->line = cmdLine;
envPtr->clNext = clNext;
- CompileCommandTokens(interp, &parse, envPtr);
+ CompileCommandTokens(interp, &parse, envPtr, &lastPop);
cmdLine = envPtr->line;
clNext = envPtr->clNext;
@@ -2145,8 +2150,8 @@ TclCompileScript(
if (envPtr->codeNext == entryCodeNext) {
PushStringLiteral(envPtr, "");
- } else if (envPtr->codeNext[-1] == INST_POP) {
- /* Remove the surplus INST_POP */
+ } else if (lastPop >= 0) {
+ envPtr->cmdMapPtr[lastPop].numCodeBytes--;
envPtr->codeNext--;
TclAdjustStackDepth(1, envPtr);
}