summaryrefslogtreecommitdiffstats
path: root/generic/tclResult.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-09-17 22:59:12 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-09-17 22:59:12 (GMT)
commit943be4691a0b7e656418187abe765d4c43190d17 (patch)
tree5d34faf294f095a400e608bc71536e1ee5249533 /generic/tclResult.c
parent4ce4e4d5af827805c97d9f0c2a3d2953922f15d0 (diff)
downloadtcl-943be4691a0b7e656418187abe765d4c43190d17.zip
tcl-943be4691a0b7e656418187abe765d4c43190d17.tar.gz
tcl-943be4691a0b7e656418187abe765d4c43190d17.tar.bz2
* generic/tclBasic.c (Tcl_AddObjErrorInfo, Tcl_LogCommandInfo):
* generic/tclCmdAH.c ([catch], [error]): * generic/tclCmdMZ.c ([return]): * generic/tclProc.c (TclUpdateReturnInfo): * generic/tclResult.c (Tcl_SetErrorCodeVA, Tcl_SetObjErrorCode TclTransferResult): Refactored so that all errorCode setting flows through Tcl_SetObjErrorCode(). This greatly reduces the number of different places in the code that need to know details about an internal bitflag field of the Interp struct. Also places errorCode setting in one place for easier future mods.
Diffstat (limited to 'generic/tclResult.c')
-rw-r--r--generic/tclResult.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 7c4d696..c41b41b 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.8 2003/09/04 16:44:12 dgp Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.9 2004/09/17 22:59:15 dgp Exp $
*/
#include "tclInt.h"
@@ -876,26 +876,21 @@ Tcl_SetErrorCodeVA (interp, argList)
* variable. */
va_list argList; /* Variable argument list. */
{
- char *string;
- int flags;
- Interp *iPtr = (Interp *) interp;
+ Tcl_Obj *errorObj = Tcl_NewObj();
/*
* Scan through the arguments one at a time, appending them to
* $errorCode as list elements.
*/
- flags = TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT;
while (1) {
- string = va_arg(argList, char *);
- if (string == NULL) {
+ char *elem = va_arg(argList, char *);
+ if (elem == NULL) {
break;
}
- (void) Tcl_SetVar2((Tcl_Interp *) iPtr, "errorCode",
- (char *) NULL, string, flags);
- flags |= TCL_APPEND_VALUE;
+ Tcl_ListObjAppendElement(NULL, errorObj, Tcl_NewStringObj(elem, -1));
}
- iPtr->flags |= ERROR_CODE_SET;
+ Tcl_SetObjErrorCode(interp, errorObj);
}
/*
@@ -961,10 +956,10 @@ Tcl_SetObjErrorCode(interp, errorObjPtr)
Tcl_Interp *interp;
Tcl_Obj *errorObjPtr;
{
- Interp *iPtr;
+ Interp *iPtr = (Interp *) interp;
- iPtr = (Interp *) interp;
- Tcl_SetVar2Ex(interp, "errorCode", NULL, errorObjPtr, TCL_GLOBAL_ONLY);
+ Tcl_ObjSetVar2(interp, iPtr->execEnvPtr->errorCode, NULL,
+ errorObjPtr, TCL_GLOBAL_ONLY);
iPtr->flags |= ERROR_CODE_SET;
}
@@ -1037,13 +1032,11 @@ TclTransferResult(sourceInterp, result, targetInterp)
TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(targetInterp, "errorInfo", NULL, objPtr,
TCL_GLOBAL_ONLY);
+ ((Interp *) targetInterp)->flags |= ERR_IN_PROGRESS;
objPtr = Tcl_GetVar2Ex(sourceInterp, "errorCode", NULL,
TCL_GLOBAL_ONLY);
- Tcl_SetVar2Ex(targetInterp, "errorCode", NULL, objPtr,
- TCL_GLOBAL_ONLY);
-
- ((Interp *) targetInterp)->flags |= (ERR_IN_PROGRESS | ERROR_CODE_SET);
+ Tcl_SetObjErrorCode(targetInterp, objPtr);
}
/* This may need examination for safety */