summaryrefslogtreecommitdiffstats
path: root/generic/tclEvent.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-10-05 18:14:24 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-10-05 18:14:24 (GMT)
commiteab3283014b276dd97ea9817fb75bf47c6181959 (patch)
tree88717c7d63e6416c4f15a3f6e1c96edd873699dc /generic/tclEvent.c
parentafd7b17255862ddee543ced29fb8e728965cf992 (diff)
downloadtcl-eab3283014b276dd97ea9817fb75bf47c6181959.zip
tcl-eab3283014b276dd97ea9817fb75bf47c6181959.tar.gz
tcl-eab3283014b276dd97ea9817fb75bf47c6181959.tar.bz2
* generic/tclBasic.c (Tcl_CreateInterp,Tcl_DeleteInterp,
TclEvalObjvInternal,Tcl_LogCommandInfo): * generic/tclCmdAH.c (Tcl_CatchObjCmd): * generic/tclEvent.c (BgError,Tcl_BackgroundError,HandleBgErrors): * generic/tclInt.h (Interp, ERROR_CODE_SET): * generic/tclNamesp.c (Tcl_CreateNamespace,Tcl_DeleteNamespace,TclTeardownNamespace): * generic/tclResult.c (Tcl_ResetResult,Tcl_SetObjErrorCode,TclTransferResult): * generic/tclTrace.c (CallVarTraces): Reworked management of the "errorCode" data of an interp. That information is now primarily stored in a new private (Tcl_Obj *) field of the Interp struct, rather than using a global variable ::errorCode as the primary storage. The ERROR_CODE_SET flag bit value is no longer required to manage the value in its new location, and is removed. Variable traces are established to support compatibility for any code expecting the ::errorCode variable to hold the information.
Diffstat (limited to 'generic/tclEvent.c')
-rw-r--r--generic/tclEvent.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 292e09b..5a38ad7 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEvent.c,v 1.46 2004/09/27 16:24:24 dgp Exp $
+ * RCS: @(#) $Id: tclEvent.c,v 1.47 2004/10/05 18:14:27 dgp Exp $
*/
#include "tclInt.h"
@@ -33,7 +33,7 @@ typedef struct BgError {
* Malloc-ed. */
char *errorInfo; /* Value of the errorInfo variable
* (malloc-ed). */
- char *errorCode; /* Value of the errorCode variable
+ Tcl_Obj *errorCode; /* Value of the errorCode variable
* (malloc-ed). */
struct BgError *nextPtr; /* Next in list of all pending error
* reports for this interpreter, or NULL
@@ -163,6 +163,7 @@ Tcl_BackgroundError(interp)
CONST char *errResult, *varValue;
ErrAssocData *assocPtr;
int length;
+ Interp *iPtr = (Interp *) interp;
/*
* The Tcl_AddErrorInfo call below (with an empty string) ensures that
@@ -186,12 +187,15 @@ Tcl_BackgroundError(interp)
}
errPtr->errorInfo = (char *) ckalloc((unsigned) (strlen(varValue) + 1));
strcpy(errPtr->errorInfo, varValue);
- varValue = Tcl_GetVar(interp, "errorCode", TCL_GLOBAL_ONLY);
- if (varValue == NULL) {
- varValue = "";
+
+ if (iPtr->errorCode) {
+ errPtr->errorCode = iPtr->errorCode;
+ } else {
+ /* Does this ever happen ? */
+ errPtr->errorCode = Tcl_NewObj();
}
- errPtr->errorCode = (char *) ckalloc((unsigned) (strlen(varValue) + 1));
- strcpy(errPtr->errorCode, varValue);
+ Tcl_IncrRefCount(errPtr->errorCode);
+
errPtr->nextPtr = NULL;
assocPtr = (ErrAssocData *) Tcl_GetAssocData(interp, "tclBgError",
@@ -266,8 +270,8 @@ HandleBgErrors(clientData)
Tcl_SetVar(interp, "errorInfo", assocPtr->firstBgPtr->errorInfo,
TCL_GLOBAL_ONLY);
- Tcl_SetVar(interp, "errorCode", assocPtr->firstBgPtr->errorCode,
- TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "errorCode", NULL,
+ assocPtr->firstBgPtr->errorCode, TCL_GLOBAL_ONLY);
/*
* Create and invoke the bgerror command.
@@ -358,7 +362,7 @@ doneWithInterp:
if (assocPtr->firstBgPtr) {
ckfree(assocPtr->firstBgPtr->errorMsg);
ckfree(assocPtr->firstBgPtr->errorInfo);
- ckfree(assocPtr->firstBgPtr->errorCode);
+ Tcl_DecrRefCount(assocPtr->firstBgPtr->errorCode);
errPtr = assocPtr->firstBgPtr->nextPtr;
ckfree((char *) assocPtr->firstBgPtr);
assocPtr->firstBgPtr = errPtr;
@@ -407,7 +411,7 @@ BgErrorDeleteProc(clientData, interp)
assocPtr->firstBgPtr = errPtr->nextPtr;
ckfree(errPtr->errorMsg);
ckfree(errPtr->errorInfo);
- ckfree(errPtr->errorCode);
+ Tcl_DecrRefCount(errPtr->errorCode);
ckfree((char *) errPtr);
}
Tcl_CancelIdleCall(HandleBgErrors, (ClientData) assocPtr);