diff options
Diffstat (limited to 'generic/tclResult.c')
-rw-r--r-- | generic/tclResult.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/generic/tclResult.c b/generic/tclResult.c index 3d432df..6f92950 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclResult.c,v 1.42 2007/11/11 19:53:20 msofer Exp $ + * RCS: @(#) $Id: tclResult.c,v 1.43 2007/11/12 03:38:14 msofer Exp $ */ #include "tclInt.h" @@ -336,6 +336,7 @@ Tcl_RestoreResult( Tcl_DecrRefCount(iPtr->objResultPtr); iPtr->objResultPtr = statePtr->objResultPtr; + iPtr->flags |= INTERP_RESULT_UNCLEAN; } /* @@ -443,6 +444,7 @@ Tcl_SetResult( */ ResetObjResult(iPtr); + iPtr->flags |= INTERP_RESULT_UNCLEAN; } /* @@ -475,6 +477,7 @@ Tcl_GetStringResult( Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)), TCL_VOLATILE); } + ((Interp *)interp)->flags |= INTERP_RESULT_UNCLEAN; return interp->result; } @@ -584,6 +587,7 @@ Tcl_GetObjResult( } iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; + iPtr->flags &= ~INTERP_RESULT_UNCLEAN; } return iPtr->objResultPtr; } @@ -826,6 +830,7 @@ SetupAppendBuffer( Tcl_FreeResult((Tcl_Interp *) iPtr); iPtr->result = iPtr->appendResult; + iPtr->flags |= INTERP_RESULT_UNCLEAN; } /* @@ -866,6 +871,7 @@ Tcl_FreeResult( } ResetObjResult(iPtr); + iPtr->flags &= ~INTERP_RESULT_UNCLEAN; } /* @@ -891,9 +897,17 @@ void Tcl_ResetResult( register Tcl_Interp *interp)/* Interpreter for which to clear result. */ { - register Interp *iPtr = (Interp *) interp; + /* + * This function is defined in a macro in tclInt.h + */ - ResetObjResult(iPtr); + TclResetResult((Interp *) interp); +} + +void +TclCleanResult( + Interp *iPtr) +{ if (iPtr->freeProc != NULL) { if (iPtr->freeProc == TCL_DYNAMIC) { ckfree(iPtr->result); @@ -907,8 +921,8 @@ Tcl_ResetResult( if (iPtr->errorCode) { /* Legacy support */ if (iPtr->flags & ERR_LEGACY_COPY) { - Tcl_ObjSetVar2(interp, iPtr->ecVar, NULL, - iPtr->errorCode, TCL_GLOBAL_ONLY); + Tcl_ObjSetVar2((Tcl_Interp *)iPtr, iPtr->ecVar, + NULL, iPtr->errorCode, TCL_GLOBAL_ONLY); } Tcl_DecrRefCount(iPtr->errorCode); iPtr->errorCode = NULL; @@ -916,8 +930,8 @@ Tcl_ResetResult( if (iPtr->errorInfo) { /* Legacy support */ if (iPtr->flags & ERR_LEGACY_COPY) { - Tcl_ObjSetVar2(interp, iPtr->eiVar, NULL, - iPtr->errorInfo, TCL_GLOBAL_ONLY); + Tcl_ObjSetVar2((Tcl_Interp *) iPtr, iPtr->eiVar, + NULL, iPtr->errorInfo, TCL_GLOBAL_ONLY); } Tcl_DecrRefCount(iPtr->errorInfo); iPtr->errorInfo = NULL; @@ -928,7 +942,7 @@ Tcl_ResetResult( Tcl_DecrRefCount(iPtr->returnOpts); iPtr->returnOpts = NULL; } - iPtr->flags &= ~(ERR_ALREADY_LOGGED | ERR_LEGACY_COPY); + iPtr->flags &= ~(ERR_ALREADY_LOGGED | ERR_LEGACY_COPY | INTERP_RESULT_UNCLEAN); } /* @@ -954,22 +968,11 @@ ResetObjResult( register Interp *iPtr) /* Points to the interpreter whose result * object should be reset. */ { - register Tcl_Obj *objResultPtr = iPtr->objResultPtr; - - if (Tcl_IsShared(objResultPtr)) { - TclDecrRefCount(objResultPtr); - TclNewObj(objResultPtr); - Tcl_IncrRefCount(objResultPtr); - iPtr->objResultPtr = objResultPtr; - } else if (objResultPtr->bytes != tclEmptyStringRep) { - if (objResultPtr->bytes != NULL) { - ckfree((char *) objResultPtr->bytes); - } - objResultPtr->bytes = tclEmptyStringRep; - objResultPtr->length = 0; - TclFreeIntRep(objResultPtr); - objResultPtr->typePtr = NULL; - } + /* + * This function is defined in a macro in tclInt.h + */ + + ResetObjResultM(iPtr); } /* @@ -1078,6 +1081,7 @@ Tcl_SetObjErrorCode( } iPtr->errorCode = errorObjPtr; Tcl_IncrRefCount(iPtr->errorCode); + iPtr->flags |= INTERP_RESULT_UNCLEAN; } /* @@ -1205,6 +1209,7 @@ TclProcessReturn( } iPtr->returnOpts = returnOpts; Tcl_IncrRefCount(iPtr->returnOpts); + iPtr->flags |= INTERP_RESULT_UNCLEAN; } if (code == TCL_ERROR) { @@ -1234,14 +1239,16 @@ TclProcessReturn( if (valuePtr != NULL) { TclGetIntFromObj(NULL, valuePtr, &iPtr->errorLine); } + iPtr->flags |= INTERP_RESULT_UNCLEAN; } if (level != 0) { iPtr->returnLevel = level; iPtr->returnCode = code; + iPtr->flags |= INTERP_RESULT_UNCLEAN; return TCL_RETURN; } if (code == TCL_ERROR) { - iPtr->flags |= ERR_LEGACY_COPY; + iPtr->flags |= (ERR_LEGACY_COPY | INTERP_RESULT_UNCLEAN); } return code; } @@ -1402,6 +1409,7 @@ TclMergeReturnOptions( } else { *optionsPtrPtr = returnOpts; } + ((Interp *)interp)->flags |= INTERP_RESULT_UNCLEAN; return TCL_OK; error: @@ -1508,6 +1516,7 @@ Tcl_SetReturnOptions( } Tcl_DecrRefCount(options); + ((Interp *)interp)->flags |= INTERP_RESULT_UNCLEAN; return code; } |