Subject: More elimination of error message litter to fix [Bug 20a81392ec].

From: dgp <[email-masked]>
Date: Fri, 28 Jun 2013 02:58:15 +0000

---
 generic/tclCompCmdsSZ.c |  3 +++
 generic/tclCompile.c    |  8 --------
 generic/tclExecute.c    | 18 +++++++-----------
 3 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 855dd8f..026b214 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -748,6 +748,9 @@ TclSubstCompile(
     Tcl_InterpState state = NULL;
 
     TclSubstParse(interp, bytes, numBytes, flags, &parse, &state);
+    if (state != NULL) {
+	Tcl_ResetResult(interp);
+    }
 
     /*
      * Tricky point! If the first token does not result in a *guaranteed* push
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 5a8524c..1f72aa7 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -2058,14 +2058,6 @@ TclCompileScript(
      * from the script.
      */
 
-    /* TODO: Figure out when/why we need this */
-#if 0
-if (Tcl_GetStringResult(interp)[0] != '\0') {
-    fprintf(stdout, "INIT: '%s'\n", Tcl_GetStringResult(interp));
-    fflush(stdout);
-}
-#endif
-    Tcl_ResetResult(interp);
     while (numBytes > 0) {
 	Tcl_Parse parse;
 	const char *next;
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index d3a0d32..37bf072 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1426,17 +1426,12 @@ Tcl_NRExprObj(
     Tcl_Obj *resultPtr)
 {
     ByteCode *codePtr;
+    Tcl_InterpState state = Tcl_SaveInterpState(interp, TCL_OK);
 
-    /* TODO: consider saving whole state? */
-    Tcl_Obj *saveObjPtr = Tcl_GetObjResult(interp);
-
-    Tcl_IncrRefCount(saveObjPtr);
-
+    Tcl_ResetResult(interp);
     codePtr = CompileExprObj(interp, objPtr);
 
-    /* TODO: Confirm reset not required? */
-    /*Tcl_ResetResult(interp);*/
-    Tcl_NRAddCallback(interp, ExprObjCallback, saveObjPtr, resultPtr,
+    Tcl_NRAddCallback(interp, ExprObjCallback, state, resultPtr,
 	    NULL, NULL);
     return TclNRExecuteByteCode(interp, codePtr);
 }
@@ -1447,14 +1442,15 @@ ExprObjCallback(
     Tcl_Interp *interp,
     int result)
 {
-    Tcl_Obj *saveObjPtr = data[0];
+    Tcl_InterpState state = data[0];
     Tcl_Obj *resultPtr = data[1];
 
     if (result == TCL_OK) {
 	TclSetDuplicateObj(resultPtr, Tcl_GetObjResult(interp));
-	Tcl_SetObjResult(interp, saveObjPtr);
+	(void) Tcl_RestoreInterpState(interp, state);
+    } else {
+	Tcl_DiscardInterpState(state);
     }
-    TclDecrRefCount(saveObjPtr);
     return result;
 }
 
-- 
cgit v0.12