summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorstanton <stanton>1999-02-10 23:31:10 (GMT)
committerstanton <stanton>1999-02-10 23:31:10 (GMT)
commitbcc73119d3301482376ec5d7876b49b28e615e75 (patch)
treed13f4f917b1cc9bcb348bfb160c43812ede3fcc1 /generic
parent346e62b0d3e9ae361bfab66add2936891f6f299e (diff)
downloadtcl-bcc73119d3301482376ec5d7876b49b28e615e75.zip
tcl-bcc73119d3301482376ec5d7876b49b28e615e75.tar.gz
tcl-bcc73119d3301482376ec5d7876b49b28e615e75.tar.bz2
* unix/mkLinks:
* doc/SetVar.3: * generic/tcl.h: * generic/tclVar.c: Restored Tcl_ObjGetVar2 and Tcl_ObjSetVar2 from 8.0. Renamed Tcl_Get/SetObjVar2 to Tcl_GetVar2Ex and Tcl_SetVar2Ex. * Merged 8.0.5b2 patches
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h45
-rw-r--r--generic/tclBasic.c35
-rw-r--r--generic/tclBinary.c26
-rw-r--r--generic/tclCmdAH.c10
-rw-r--r--generic/tclCmdIL.c35
-rw-r--r--generic/tclCompCmds.c12
-rw-r--r--generic/tclCompile.c15
-rw-r--r--generic/tclCompile.h18
-rw-r--r--generic/tclExecute.c42
-rw-r--r--generic/tclFileName.c13
-rw-r--r--generic/tclIOCmd.c6
-rw-r--r--generic/tclInt.h280
-rw-r--r--generic/tclMain.c8
-rw-r--r--generic/tclNamesp.c112
-rw-r--r--generic/tclParse.c4
-rw-r--r--generic/tclProc.c12
-rw-r--r--generic/tclResult.c12
-rw-r--r--generic/tclScan.c5
-rw-r--r--generic/tclTest.c67
-rw-r--r--generic/tclVar.c424
20 files changed, 624 insertions, 557 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 4b6864b..d8dad65 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -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: tcl.h,v 1.1.2.11 1999/02/01 21:29:48 stanton Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.1.2.12 1999/02/10 23:31:12 stanton Exp $
*/
#ifndef _TCL
@@ -515,6 +515,7 @@ typedef struct Tcl_Obj {
EXTERN void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
EXTERN void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
EXTERN int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
+EXTERN void TclFreeObj _ANSI_ARGS_((Tcl_Obj *objPtr));
#ifdef TCL_MEM_DEBUG
# define Tcl_IncrRefCount(objPtr) \
@@ -1289,7 +1290,6 @@ EXTERN void Tcl_AppendToObj _ANSI_ARGS_((Tcl_Obj *objPtr,
char *bytes, int length));
EXTERN void Tcl_AppendStringsToObj _ANSI_ARGS_(
TCL_VARARGS(Tcl_Obj *,interp));
-EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN void Tcl_AlertNotifier _ANSI_ARGS_((ClientData clientData));
EXTERN Tcl_AsyncHandler Tcl_AsyncCreate _ANSI_ARGS_((Tcl_AsyncProc *proc,
ClientData clientData));
@@ -1364,9 +1364,8 @@ EXTERN Tcl_Command Tcl_CreateObjCommand _ANSI_ARGS_((
Tcl_CmdDeleteProc *deleteProc));
EXTERN Tcl_Interp * Tcl_CreateSlave _ANSI_ARGS_((Tcl_Interp *interp,
char *slaveName, int isSafe));
-EXTERN void Tcl_CreateThreadExitHandler
- _ANSI_ARGS_((Tcl_ExitProc *proc,
- ClientData clientData));
+EXTERN void Tcl_CreateThreadExitHandler _ANSI_ARGS_((
+ Tcl_ExitProc *proc, ClientData clientData));
EXTERN Tcl_TimerToken Tcl_CreateTimerHandler _ANSI_ARGS_((int milliseconds,
Tcl_TimerProc *proc, ClientData clientData));
EXTERN Tcl_Trace Tcl_CreateTrace _ANSI_ARGS_((Tcl_Interp *interp,
@@ -1422,14 +1421,14 @@ EXTERN void Tcl_DeleteHashEntry _ANSI_ARGS_((
EXTERN void Tcl_DeleteHashTable _ANSI_ARGS_((
Tcl_HashTable *tablePtr));
EXTERN void Tcl_DeleteInterp _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN void Tcl_DeleteThreadExitHandler
- _ANSI_ARGS_((Tcl_ExitProc *proc,
- ClientData clientData));
+EXTERN void Tcl_DeleteThreadExitHandler _ANSI_ARGS_((
+ Tcl_ExitProc *proc, ClientData clientData));
EXTERN void Tcl_DeleteTimerHandler _ANSI_ARGS_((
Tcl_TimerToken token));
EXTERN void Tcl_DeleteTrace _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Trace trace));
-EXTERN void Tcl_DetachPids _ANSI_ARGS_((int numPids, Tcl_Pid *pidPtr));
+EXTERN void Tcl_DetachPids _ANSI_ARGS_((int numPids,
+ Tcl_Pid *pidPtr));
EXTERN void Tcl_DiscardResult _ANSI_ARGS_((
Tcl_SavedResult *statePtr));
EXTERN void Tcl_DontCallWhenDeleted _ANSI_ARGS_((
@@ -1507,7 +1506,6 @@ EXTERN Tcl_HashEntry * Tcl_FirstHashEntry _ANSI_ARGS_((
Tcl_HashSearch *searchPtr));
EXTERN int Tcl_Flush _ANSI_ARGS_((Tcl_Channel chan));
EXTERN void Tcl_FreeEncoding _ANSI_ARGS_((Tcl_Encoding encoding));
-EXTERN void TclFreeObj _ANSI_ARGS_((Tcl_Obj *objPtr));
EXTERN void Tcl_FreeResult _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Tcl_GetAlias _ANSI_ARGS_((Tcl_Interp *interp,
char *slaveCmd, Tcl_Interp **targetInterpPtr,
@@ -1575,8 +1573,6 @@ EXTERN int Tcl_GetLongFromObj _ANSI_ARGS_((Tcl_Interp *interp,
EXTERN Tcl_Interp * Tcl_GetMaster _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN CONST char * Tcl_GetNameOfExecutable _ANSI_ARGS_((void));
EXTERN Tcl_Obj * Tcl_GetObjResult _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN Tcl_Obj * Tcl_GetObjVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- char *part1, char *part2, int flags));
EXTERN Tcl_ObjType * Tcl_GetObjType _ANSI_ARGS_((char *typeName));
EXTERN int Tcl_GetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
char *string, int write, int checkUsage,
@@ -1600,6 +1596,8 @@ EXTERN char * Tcl_GetVar _ANSI_ARGS_((Tcl_Interp *interp,
char *varName, int flags));
EXTERN char * Tcl_GetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
char *part1, char *part2, int flags));
+EXTERN Tcl_Obj * Tcl_GetVar2Ex _ANSI_ARGS_((Tcl_Interp *interp,
+ char *part1, char *part2, int flags));
EXTERN int Tcl_GlobalEval _ANSI_ARGS_((Tcl_Interp *interp,
char *command));
EXTERN char * Tcl_HashStats _ANSI_ARGS_((Tcl_HashTable *tablePtr));
@@ -1663,6 +1661,12 @@ EXTERN void Tcl_NotifyChannel _ANSI_ARGS_((Tcl_Channel channel,
int mask));
EXTERN int Tcl_NumUtfChars _ANSI_ARGS_((CONST char *src,
int len));
+EXTERN Tcl_Obj * Tcl_ObjGetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
+ Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
+ int flags));
+EXTERN Tcl_Obj * Tcl_ObjSetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
+ Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
+ Tcl_Obj *newValuePtr, int flags));
EXTERN Tcl_Channel Tcl_OpenCommandChannel _ANSI_ARGS_((
Tcl_Interp *interp, int argc, char **argv,
int flags));
@@ -1760,9 +1764,6 @@ EXTERN void Tcl_SetObjLength _ANSI_ARGS_((Tcl_Obj *objPtr,
int length));
EXTERN void Tcl_SetObjResult _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *resultObjPtr));
-EXTERN Tcl_Obj * Tcl_SetObjVar2 _ANSI_ARGS_((Tcl_Interp *interp,
- char *part1, char *part2, Tcl_Obj *newValuePtr,
- int flags));
EXTERN void Tcl_SetPanicProc _ANSI_ARGS_((void (*proc)
_ANSI_ARGS_(TCL_VARARGS(char *, format))));
EXTERN int Tcl_SetRecursionLimit _ANSI_ARGS_((Tcl_Interp *interp,
@@ -1782,6 +1783,9 @@ EXTERN char * Tcl_SetVar _ANSI_ARGS_((Tcl_Interp *interp,
EXTERN char * Tcl_SetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
char *part1, char *part2, char *newValue,
int flags));
+EXTERN Tcl_Obj * Tcl_SetVar2Ex _ANSI_ARGS_((Tcl_Interp *interp,
+ char *part1, char *part2, Tcl_Obj *newValuePtr,
+ int flags));
EXTERN char * Tcl_SignalId _ANSI_ARGS_((int sig));
EXTERN char * Tcl_SignalMsg _ANSI_ARGS_((int sig));
EXTERN void Tcl_Sleep _ANSI_ARGS_((int ms));
@@ -1890,6 +1894,17 @@ EXTERN int Tcl_WriteObj _ANSI_ARGS_((Tcl_Channel chan,
EXTERN void Tcl_WrongNumArgs _ANSI_ARGS_((Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[], char *message));
+#undef TCL_STORAGE_CLASS
+#define TCL_STORAGE_CLASS
+
+/*
+ * Convenience declaration of Tcl_AppInit for backwards compatibility.
+ * This function is not *implemented* by the tcl library, so the storage
+ * class is neither DLLEXPORT nor DLLIMPORT
+ */
+
+EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
+
#endif /* RESOURCE_INCLUDED */
#undef TCL_STORAGE_CLASS
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 92902da8..3ea4d08 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -7,12 +7,12 @@
*
* Copyright (c) 1987-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.1.2.7 1999/02/01 21:29:49 stanton Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.1.2.8 1999/02/10 23:31:12 stanton Exp $
*/
#include "tclInt.h"
@@ -1417,7 +1417,7 @@ Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc)
Command *cmdPtr, *refCmdPtr;
Tcl_HashEntry *hPtr;
char *tail;
- int new, result;
+ int new;
ImportedCmdData *dataPtr;
if (iPtr->flags & DELETED) {
@@ -1436,10 +1436,9 @@ Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc)
*/
if (strstr(cmdName, "::") != NULL) {
- result = TclGetNamespaceForQualName(interp, cmdName,
- (Namespace *) NULL, CREATE_NS_IF_UNKNOWN, &nsPtr,
- &dummy1, &dummy2, &tail);
- if ((result != TCL_OK) || (nsPtr == NULL) || (tail == NULL)) {
+ TclGetNamespaceForQualName(interp, cmdName, (Namespace *) NULL,
+ CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
+ if ((nsPtr == NULL) || (tail == NULL)) {
return (Tcl_Command) NULL;
}
} else {
@@ -1564,7 +1563,7 @@ Tcl_CreateObjCommand(interp, cmdName, proc, clientData, deleteProc)
Command *cmdPtr, *refCmdPtr;
Tcl_HashEntry *hPtr;
char *tail;
- int new, result;
+ int new;
ImportedCmdData *dataPtr;
if (iPtr->flags & DELETED) {
@@ -1583,10 +1582,9 @@ Tcl_CreateObjCommand(interp, cmdName, proc, clientData, deleteProc)
*/
if (strstr(cmdName, "::") != NULL) {
- result = TclGetNamespaceForQualName(interp, cmdName,
- (Namespace *) NULL, CREATE_NS_IF_UNKNOWN, &nsPtr,
- &dummy1, &dummy2, &tail);
- if ((result != TCL_OK) || (nsPtr == NULL) || (tail == NULL)) {
+ TclGetNamespaceForQualName(interp, cmdName, (Namespace *) NULL,
+ CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
+ if ((nsPtr == NULL) || (tail == NULL)) {
return (Tcl_Command) NULL;
}
} else {
@@ -1914,12 +1912,9 @@ TclRenameCommand(interp, oldName, newName)
* Tcl_CreateCommand would.
*/
- result = TclGetNamespaceForQualName(interp, newName, (Namespace *) NULL,
- (CREATE_NS_IF_UNKNOWN | TCL_LEAVE_ERR_MSG),
- &newNsPtr, &dummy1, &dummy2, &newTail);
- if (result != TCL_OK) {
- return result;
- }
+ TclGetNamespaceForQualName(interp, newName, (Namespace *) NULL,
+ CREATE_NS_IF_UNKNOWN, &newNsPtr, &dummy1, &dummy2, &newTail);
+
if ((newNsPtr == NULL) || (newTail == NULL)) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"can't rename to \"", newName, "\": bad command name",
@@ -3960,7 +3955,7 @@ Tcl_AddObjErrorInfo(interp, message, length)
iPtr->flags |= ERR_IN_PROGRESS;
if (iPtr->result[0] == 0) {
- (void) Tcl_SetObjVar2(interp, "errorInfo", NULL, iPtr->objResultPtr,
+ (void) Tcl_SetVar2Ex(interp, "errorInfo", NULL, iPtr->objResultPtr,
TCL_GLOBAL_ONLY);
} else { /* use the string result */
Tcl_SetVar2(interp, "errorInfo", (char *) NULL, interp->result,
@@ -3985,7 +3980,7 @@ Tcl_AddObjErrorInfo(interp, message, length)
if (length != 0) {
messagePtr = Tcl_NewStringObj(message, length);
Tcl_IncrRefCount(messagePtr);
- Tcl_SetObjVar2(interp, "errorInfo", NULL, messagePtr,
+ Tcl_SetVar2Ex(interp, "errorInfo", NULL, messagePtr,
(TCL_GLOBAL_ONLY | TCL_APPEND_VALUE));
Tcl_DecrRefCount(messagePtr); /* free msg object appended above */
}
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index e8cd6a6..fc14b92 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBinary.c,v 1.1.2.2 1998/09/24 23:58:41 stanton Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.1.2.3 1999/02/10 23:31:13 stanton Exp $
*/
#include <math.h>
@@ -964,10 +964,8 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv)
}
}
valuePtr = Tcl_NewByteArrayObj(src, size);
- resultPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[arg]),
- NULL, valuePtr,
- TCL_LEAVE_ERR_MSG);
+ resultPtr = Tcl_ObjSetVar2(interp, objv[arg],
+ NULL, valuePtr, TCL_LEAVE_ERR_MSG);
arg++;
if (resultPtr == NULL) {
Tcl_DecrRefCount(valuePtr); /* unneeded */
@@ -1019,10 +1017,8 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv)
}
}
- resultPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[arg]),
- NULL, valuePtr,
- TCL_LEAVE_ERR_MSG);
+ resultPtr = Tcl_ObjSetVar2(interp, objv[arg],
+ NULL, valuePtr, TCL_LEAVE_ERR_MSG);
arg++;
if (resultPtr == NULL) {
Tcl_DecrRefCount(valuePtr); /* unneeded */
@@ -1076,10 +1072,8 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv)
}
}
- resultPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[arg]),
- NULL, valuePtr,
- TCL_LEAVE_ERR_MSG);
+ resultPtr = Tcl_ObjSetVar2(interp, objv[arg],
+ NULL, valuePtr, TCL_LEAVE_ERR_MSG);
arg++;
if (resultPtr == NULL) {
Tcl_DecrRefCount(valuePtr); /* unneeded */
@@ -1140,10 +1134,8 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv)
offset += count*size;
}
- resultPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[arg]),
- NULL, valuePtr,
- TCL_LEAVE_ERR_MSG);
+ resultPtr = Tcl_ObjSetVar2(interp, objv[arg],
+ NULL, valuePtr, TCL_LEAVE_ERR_MSG);
arg++;
if (resultPtr == NULL) {
Tcl_DecrRefCount(valuePtr); /* unneeded */
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 982b5d7..447c01d 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.1.2.8 1999/02/01 21:29:49 stanton Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.1.2.9 1999/02/10 23:31:13 stanton Exp $
*/
#include "tclInt.h"
@@ -261,8 +261,7 @@ Tcl_CatchObjCmd(dummy, interp, objc, objv)
result = Tcl_EvalObjEx(interp, objv[1], 0);
if (objc == 3) {
- if (Tcl_SetObjVar2(interp,
- Tcl_GetString(varNamePtr), NULL,
+ if (Tcl_ObjSetVar2(interp, varNamePtr, NULL,
Tcl_GetObjResult(interp), 0) == NULL) {
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp),
@@ -572,7 +571,7 @@ Tcl_ErrorObjCmd(dummy, interp, objc, objv)
}
if (objc == 4) {
- Tcl_SetObjVar2(interp, "errorCode", NULL, objv[3], TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "errorCode", NULL, objv[3], TCL_GLOBAL_ONLY);
iPtr->flags |= ERROR_CODE_SET;
}
@@ -1767,8 +1766,7 @@ Tcl_ForeachObjCmd(dummy, interp, objc, objv)
valuePtr = Tcl_NewObj(); /* empty string */
isEmptyObj = 1;
}
- varValuePtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(varvList[i][v]),
+ varValuePtr = Tcl_ObjSetVar2(interp, varvList[i][v],
NULL, valuePtr, 0);
if (varValuePtr == NULL) {
if (isEmptyObj) {
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index abf261f..56d48cb 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -9,12 +9,12 @@
* Copyright (c) 1987-1993 The Regents of the University of California.
* Copyright (c) 1993-1997 Lucent Technologies.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.1.2.6 1999/02/01 21:29:50 stanton Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.1.2.7 1999/02/10 23:31:14 stanton Exp $
*/
#include "tclInt.h"
@@ -663,7 +663,6 @@ InfoCommandsCmd(dummy, interp, objc, objv)
Tcl_Obj *listPtr, *elemObjPtr;
int specificNsInPattern = 0; /* Init. to avoid compiler warning. */
Tcl_Command cmd;
- int result;
/*
* Get the pattern and find the "effective namespace" in which to
@@ -685,13 +684,11 @@ InfoCommandsCmd(dummy, interp, objc, objv)
Namespace *dummy1NsPtr, *dummy2NsPtr;
- pattern = Tcl_GetString(objv[2]);
- result = TclGetNamespaceForQualName(interp, pattern,
- (Namespace *) NULL, /*flags*/ TCL_LEAVE_ERR_MSG,
- &nsPtr, &dummy1NsPtr, &dummy2NsPtr, &simplePattern);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
+
+ pattern = Tcl_GetString(objv[2]);
+ TclGetNamespaceForQualName(interp, pattern, (Namespace *) NULL,
+ /*flags*/ 0, &nsPtr, &dummy1NsPtr, &dummy2NsPtr, &simplePattern);
+
if (nsPtr != NULL) { /* we successfully found the pattern's ns */
specificNsInPattern = (strcmp(simplePattern, pattern) != 0);
}
@@ -851,8 +848,7 @@ InfoDefaultCmd(dummy, interp, objc, objv)
if (TclIsVarArgument(localPtr)
&& (strcmp(argName, localPtr->name) == 0)) {
if (localPtr->defValuePtr != NULL) {
- valueObjPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[4]), NULL,
+ valueObjPtr = Tcl_ObjSetVar2(interp, objv[4], NULL,
localPtr->defValuePtr, 0);
if (valueObjPtr == NULL) {
defStoreError:
@@ -865,8 +861,8 @@ InfoDefaultCmd(dummy, interp, objc, objv)
Tcl_SetIntObj(Tcl_GetObjResult(interp), 1);
} else {
Tcl_Obj *nullObjPtr = Tcl_NewObj();
- valueObjPtr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objv[4]), NULL, nullObjPtr, 0);
+ valueObjPtr = Tcl_ObjSetVar2(interp, objv[4], NULL,
+ nullObjPtr, 0);
if (valueObjPtr == NULL) {
Tcl_DecrRefCount(nullObjPtr); /* free unneeded obj */
goto defStoreError;
@@ -1659,7 +1655,6 @@ InfoVarsCmd(dummy, interp, objc, objv)
Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
Tcl_Obj *listPtr, *elemObjPtr;
int specificNsInPattern = 0; /* Init. to avoid compiler warning. */
- int result;
/*
* Get the pattern and find the "effective namespace" in which to
@@ -1683,12 +1678,10 @@ InfoVarsCmd(dummy, interp, objc, objv)
Namespace *dummy1NsPtr, *dummy2NsPtr;
pattern = Tcl_GetString(objv[2]);
- result = TclGetNamespaceForQualName(interp, pattern,
- (Namespace *) NULL, /*flags*/ TCL_LEAVE_ERR_MSG,
- &nsPtr, &dummy1NsPtr, &dummy2NsPtr, &simplePattern);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
+ TclGetNamespaceForQualName(interp, pattern, (Namespace *) NULL,
+ /*flags*/ 0, &nsPtr, &dummy1NsPtr, &dummy2NsPtr,
+ &simplePattern);
+
if (nsPtr != NULL) { /* we successfully found the pattern's ns */
specificNsInPattern = (strcmp(simplePattern, pattern) != 0);
}
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 4e76c3f..337f697 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.1.2.7 1998/12/01 23:33:39 stanton Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.1.2.8 1999/02/10 23:31:14 stanton Exp $
*/
#include "tclInt.h"
@@ -171,7 +171,7 @@ TclCompileCatchCmd(interp, parsePtr, envPtr)
envPtr->exceptDepth++;
envPtr->maxExceptDepth =
TclMax(envPtr->exceptDepth, envPtr->maxExceptDepth);
- range = TclCreateExceptRange(CATCH_EXCEPTION, envPtr);
+ range = TclCreateExceptRange(CATCH_EXCEPTION_RANGE, envPtr);
TclEmitInstInt4(INST_BEGIN_CATCH4, range, envPtr);
startOffset = (envPtr->codeNext - envPtr->codeStart);
@@ -409,8 +409,8 @@ TclCompileForCmd(interp, parsePtr, envPtr)
envPtr->exceptDepth++;
envPtr->maxExceptDepth =
TclMax(envPtr->exceptDepth, envPtr->maxExceptDepth);
- bodyRange = TclCreateExceptRange(LOOP_EXCEPTION, envPtr);
- nextRange = TclCreateExceptRange(LOOP_EXCEPTION, envPtr);
+ bodyRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
+ nextRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
/*
* Inline compile the initial command.
@@ -762,7 +762,7 @@ TclCompileForeachCmd(interp, parsePtr, envPtr)
* Evaluate then store each value list in the associated temporary.
*/
- range = TclCreateExceptRange(LOOP_EXCEPTION, envPtr);
+ range = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
loopIndex = 0;
for (i = 0, tokenPtr = parsePtr->tokenPtr;
@@ -1863,7 +1863,7 @@ TclCompileWhileCmd(interp, parsePtr, envPtr)
envPtr->exceptDepth++;
envPtr->maxExceptDepth =
TclMax(envPtr->exceptDepth, envPtr->maxExceptDepth);
- range = TclCreateExceptRange(LOOP_EXCEPTION, envPtr);
+ range = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
envPtr->exceptArrayPtr[range].continueOffset =
(envPtr->codeNext - envPtr->codeStart);
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index cdf6e9e..e18faa7 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompile.c,v 1.1.2.8 1998/12/12 01:36:54 lfb Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.1.2.9 1999/02/10 23:31:14 stanton Exp $
*/
#include "tclInt.h"
@@ -1367,7 +1367,7 @@ TclCompileExprWords(interp, tokenPtr, numWords, envPtr)
envPtr->exceptDepth++;
envPtr->maxExceptDepth =
TclMax(envPtr->exceptDepth, envPtr->maxExceptDepth);
- range = TclCreateExceptRange(CATCH_EXCEPTION, envPtr);
+ range = TclCreateExceptRange(CATCH_EXCEPTION_RANGE, envPtr);
TclEmitInstInt4(INST_BEGIN_CATCH4, range, envPtr);
Tcl_DStringInit(&exprBuffer);
@@ -2516,13 +2516,13 @@ TclFixupForwardJump(envPtr, jumpFixupPtr, jumpDist, distThreshold)
rangePtr->codeOffset += 3;
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
rangePtr->breakOffset += 3;
if (rangePtr->continueOffset != -1) {
rangePtr->continueOffset += 3;
}
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
rangePtr->catchOffset += 3;
break;
default:
@@ -3028,15 +3028,16 @@ TclPrintByteCodeObj(interp, objPtr)
ExceptionRange *rangePtr = &(codePtr->exceptArrayPtr[i]);
fprintf(stdout, " %d: level %d, %s, pc %d-%d, ",
i, rangePtr->nestingLevel,
- ((rangePtr->type == LOOP_EXCEPTION)? "loop" : "catch"),
+ ((rangePtr->type == LOOP_EXCEPTION_RANGE)
+ ? "loop" : "catch"),
rangePtr->codeOffset,
(rangePtr->codeOffset + rangePtr->numCodeBytes - 1));
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
fprintf(stdout, "continue %d, break %d\n",
rangePtr->continueOffset, rangePtr->breakOffset);
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
fprintf(stdout, "catch %d\n", rangePtr->catchOffset);
break;
default:
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index b7da7c4..6f5d099 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -6,7 +6,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompile.h,v 1.1.2.3 1998/09/30 20:46:24 stanton Exp $
+ * RCS: @(#) $Id: tclCompile.h,v 1.1.2.4 1999/02/10 23:31:15 stanton Exp $
*/
#ifndef _TCLCOMPILATION
@@ -82,10 +82,10 @@ extern int tclTraceExec;
*/
typedef enum {
- LOOP_EXCEPTION, /* Exception's range is part of a loop.
+ LOOP_EXCEPTION_RANGE, /* Exception's range is part of a loop.
* Break and continue "exceptions" cause
* jumps to appropriate PC offsets. */
- CATCH_EXCEPTION /* Exception's range is controlled by a
+ CATCH_EXCEPTION_RANGE /* Exception's range is controlled by a
* catch command. Errors in the range cause
* a jump to a catch PC offset. */
} ExceptionRangeType;
@@ -98,13 +98,13 @@ typedef struct ExceptionRange {
int codeOffset; /* Offset of the first instruction byte of
* the code range. */
int numCodeBytes; /* Number of bytes in the code range. */
- int breakOffset; /* If LOOP_EXCEPTION, the target PC offset
- * for a break command in the range. */
- int continueOffset; /* If LOOP_EXCEPTION and not -1, the target
- * PC offset for a continue command in the
- * code range. Otherwise, ignore this range
+ int breakOffset; /* If LOOP_EXCEPTION_RANGE, the target PC
+ * offset for a break command in the range. */
+ int continueOffset; /* If LOOP_EXCEPTION_RANGE and not -1, the
+ * target PC offset for a continue command in
+ * the code range. Otherwise, ignore this range
* when processing a continue command. */
- int catchOffset; /* If a CATCH_EXCEPTION, the target PC
+ int catchOffset; /* If a CATCH_EXCEPTION_RANGE, the target PC
* offset for any "exception" in range. */
} ExceptionRange;
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 2ee7669..b0f3ea4 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.1.2.8 1999/02/01 21:29:51 stanton Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.1.2.9 1999/02/10 23:31:16 stanton Exp $
*/
#include "tclInt.h"
@@ -906,7 +906,7 @@ TclExecuteByteCode(interp, codePtr)
}
newPcOffset = 0;
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
if (result == TCL_BREAK) {
newPcOffset = rangePtr->breakOffset;
} else if (rangePtr->continueOffset == -1) {
@@ -922,7 +922,7 @@ TclExecuteByteCode(interp, codePtr)
StringForResultCode(result),
rangePtr->codeOffset, newPcOffset));
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
TRACE(("%u => ... after \"%.20s\", %s...\n",
objc, cmdNameBuf,
StringForResultCode(result)));
@@ -998,7 +998,7 @@ TclExecuteByteCode(interp, codePtr)
goto abnormalReturn; /* no catch exists to check */
}
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
if (result == TCL_BREAK) {
newPcOffset = rangePtr->breakOffset;
} else if (rangePtr->continueOffset == -1) {
@@ -1014,7 +1014,7 @@ TclExecuteByteCode(interp, codePtr)
O2S(objPtr), StringForResultCode(result),
rangePtr->codeOffset, newPcOffset), valuePtr);
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
TRACE_WITH_OBJ(("\"%.30s\" => %s ",
O2S(objPtr), StringForResultCode(result)),
valuePtr);
@@ -1097,8 +1097,7 @@ TclExecuteByteCode(interp, codePtr)
case INST_LOAD_SCALAR_STK:
objPtr = POP_OBJECT(); /* scalar name */
DECACHE_STACK_INFO();
- valuePtr = Tcl_GetObjVar2(interp,
- Tcl_GetString(objPtr), NULL, TCL_LEAVE_ERR_MSG);
+ valuePtr = Tcl_ObjGetVar2(interp, objPtr, NULL, TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (valuePtr == NULL) {
TRACE_WITH_OBJ(("\"%.30s\" => ERROR: ", O2S(objPtr)),
@@ -1149,8 +1148,7 @@ TclExecuteByteCode(interp, codePtr)
objPtr = POP_OBJECT(); /* array name */
DECACHE_STACK_INFO();
- valuePtr = Tcl_GetObjVar2(interp,
- Tcl_GetString(objPtr), Tcl_GetString(elemPtr),
+ valuePtr = Tcl_ObjGetVar2(interp, objPtr, elemPtr,
TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (valuePtr == NULL) {
@@ -1173,8 +1171,7 @@ TclExecuteByteCode(interp, codePtr)
case INST_LOAD_STK:
objPtr = POP_OBJECT(); /* variable name */
DECACHE_STACK_INFO();
- valuePtr = Tcl_GetObjVar2(interp, Tcl_GetString(objPtr), NULL,
- TCL_LEAVE_ERR_MSG);
+ valuePtr = Tcl_ObjGetVar2(interp, objPtr, NULL, TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (valuePtr == NULL) {
TRACE_WITH_OBJ(("\"%.30s\" => ERROR: ",
@@ -1220,8 +1217,8 @@ TclExecuteByteCode(interp, codePtr)
valuePtr = POP_OBJECT();
objPtr = POP_OBJECT(); /* scalar name */
DECACHE_STACK_INFO();
- value2Ptr = Tcl_SetObjVar2(interp, Tcl_GetString(objPtr), NULL,
- valuePtr, TCL_LEAVE_ERR_MSG);
+ value2Ptr = Tcl_ObjSetVar2(interp, objPtr, NULL, valuePtr,
+ TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (value2Ptr == NULL) {
TRACE_WITH_OBJ(("\"%.30s\" <- \"%.30s\" => ERROR: ",
@@ -1283,9 +1280,8 @@ TclExecuteByteCode(interp, codePtr)
elemPtr = POP_OBJECT();
objPtr = POP_OBJECT(); /* array name */
DECACHE_STACK_INFO();
- value2Ptr = Tcl_SetObjVar2(interp,
- Tcl_GetString(objPtr), Tcl_GetString(elemPtr),
- valuePtr, TCL_LEAVE_ERR_MSG);
+ value2Ptr = Tcl_ObjSetVar2(interp, objPtr, elemPtr, valuePtr,
+ TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (value2Ptr == NULL) {
TRACE_WITH_OBJ(("\"%.30s(%.30s)\" <- \"%.30s\" => ERROR: ",
@@ -1311,8 +1307,8 @@ TclExecuteByteCode(interp, codePtr)
valuePtr = POP_OBJECT();
objPtr = POP_OBJECT(); /* variable name */
DECACHE_STACK_INFO();
- value2Ptr = Tcl_SetObjVar2(interp, Tcl_GetString(objPtr), NULL,
- valuePtr, TCL_LEAVE_ERR_MSG);
+ value2Ptr = Tcl_ObjSetVar2(interp, objPtr, NULL, valuePtr,
+ TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (value2Ptr == NULL) {
TRACE_WITH_OBJ(("\"%.30s\" <- \"%.30s\" => ERROR: ",
@@ -2564,12 +2560,12 @@ TclExecuteByteCode(interp, codePtr)
goto abnormalReturn; /* no catch exists to check */
}
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
result = TCL_OK;
TRACE(("=> range at %d, new pc %d\n",
rangePtr->codeOffset, rangePtr->breakOffset));
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
result = TCL_BREAK;
TRACE(("=> ...\n"));
goto processCatch; /* it will use rangePtr */
@@ -2596,7 +2592,7 @@ TclExecuteByteCode(interp, codePtr)
goto abnormalReturn;
}
switch (rangePtr->type) {
- case LOOP_EXCEPTION:
+ case LOOP_EXCEPTION_RANGE:
if (rangePtr->continueOffset == -1) {
TRACE(("=> loop w/o continue, checking for catch\n"));
goto checkForCatch;
@@ -2606,7 +2602,7 @@ TclExecuteByteCode(interp, codePtr)
rangePtr->codeOffset, rangePtr->continueOffset));
}
break;
- case CATCH_EXCEPTION:
+ case CATCH_EXCEPTION_RANGE:
result = TCL_CONTINUE;
TRACE(("=> ...\n"));
goto processCatch; /* it will use rangePtr */
@@ -3317,7 +3313,7 @@ GetExceptRangeForPc(pc, catchOnly, codePtr)
int end = (start + rangePtr->numCodeBytes);
if ((start <= pcOffset) && (pcOffset < end)) {
if ((!catchOnly)
- || (rangePtr->type == CATCH_EXCEPTION)) {
+ || (rangePtr->type == CATCH_EXCEPTION_RANGE)) {
return rangePtr;
}
}
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index b14577a..7da53a9 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFileName.c,v 1.1.2.7 1998/12/12 01:36:58 lfb Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.1.2.8 1999/02/10 23:31:16 stanton Exp $
*/
#include "tclInt.h"
@@ -1088,15 +1088,12 @@ TclGetExtension(name)
}
/*
- * Back up to the first period in a series of contiguous dots.
- * This is needed so foo..o will be split on the first dot.
+ * In earlier versions, we used to back up to the first period in a series
+ * so that "foo..o" would be split into "foo" and "..o". This is a
+ * confusing and usually incorrect behavior, so now we split at the last
+ * period in the name.
*/
- if (p != NULL) {
- while ((p > name) && *(p-1) == '.') {
- p--;
- }
- }
return p;
}
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 92ca4cf..334b129 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.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: tclIOCmd.c,v 1.1.2.2 1998/09/24 23:58:52 stanton Exp $
+ * RCS: @(#) $Id: tclIOCmd.c,v 1.1.2.3 1999/02/10 23:31:17 stanton Exp $
*/
#include "tclInt.h"
@@ -252,8 +252,8 @@ Tcl_GetsObjCmd(dummy, interp, objc, objv)
lineLen = -1;
}
if (objc == 3) {
- if (Tcl_SetObjVar2(interp, Tcl_GetString(objv[2]),
- NULL, linePtr, TCL_LEAVE_ERR_MSG ) == NULL) {
+ if (Tcl_ObjSetVar2(interp, objv[2], NULL, linePtr,
+ TCL_LEAVE_ERR_MSG) == NULL) {
Tcl_DecrRefCount(linePtr);
return TCL_ERROR;
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index c8c41b6..de3f6cb 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -6,12 +6,12 @@
* Copyright (c) 1987-1993 The Regents of the University of California.
* Copyright (c) 1993-1997 Lucent Technologies.
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.1.2.10 1998/12/24 00:13:59 rjohnson Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.1.2.11 1999/02/10 23:31:17 stanton Exp $
*/
#ifndef _TCLINT
@@ -22,7 +22,7 @@
* included here, so that system-dependent personalizations for the
* include files only have to be made in once place. This results
* in a few extra includes, but greater modularity. The order of
- * the three groups of #includes is important. For example, stdio.h
+ * the three groups of #includes is important. For example, stdio.h
* is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
* needed by stdlib.h in some configurations.
*/
@@ -97,18 +97,18 @@ typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
int flags, Tcl_Var *rPtr));
typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
- char* name, Tcl_Namespace *context, int flags,
- Tcl_Command *rPtr));
+ char* name, Tcl_Namespace *context, int flags,
+ Tcl_Command *rPtr));
typedef struct Tcl_ResolverInfo {
Tcl_ResolveCmdProc *cmdResProc; /* Procedure handling command name
- * resolution. */
+ * resolution. */
Tcl_ResolveVarProc *varResProc; /* Procedure handling variable name
- * resolution for variables that
- * can only be handled at runtime. */
+ * resolution for variables that
+ * can only be handled at runtime. */
Tcl_ResolveCompiledVarProc *compiledVarResProc;
- /* Procedure handling variable name
- * resolution at compile time. */
+ /* Procedure handling variable name
+ * resolution at compile time. */
} Tcl_ResolverInfo;
/*
@@ -140,7 +140,7 @@ typedef struct Namespace {
* this one. NULL if this is the global
* namespace. */
Tcl_HashTable childTable; /* Contains any child namespaces. Indexed
- * by strings; values have type
+ * by strings; values have type
* (Namespace *). */
long nsId; /* Unique id for the namespace. */
Tcl_Interp *interp; /* The interpreter containing this
@@ -157,8 +157,8 @@ typedef struct Namespace {
* objects. The namespace can't be freed
* until refCount becomes zero. */
Tcl_HashTable cmdTable; /* Contains all the commands currently
- * registered in the namespace. Indexed by
- * strings; values have type (Command *).
+ * registered in the namespace. Indexed by
+ * strings; values have type (Command *).
* Commands imported by Tcl_Import have
* Command structures that point (via an
* ImportedCmdRef structure) to the
@@ -166,7 +166,7 @@ typedef struct Namespace {
* namespace's command table. */
Tcl_HashTable varTable; /* Contains all the (global) variables
* currently in this namespace. Indexed
- * by strings; values have type (Var *). */
+ * by strings; values have type (Var *). */
char **exportArrayPtr; /* Points to an array of string patterns
* specifying which commands are exported.
* A pattern may include "string match"
@@ -229,8 +229,8 @@ typedef struct Namespace {
* namespace's storage will be freed.
*/
-#define NS_DYING 0x01
-#define NS_DEAD 0x02
+#define NS_DYING 0x01
+#define NS_DEAD 0x02
/*
* Flag passed to TclGetNamespaceForQualName to have it create all namespace
@@ -271,7 +271,7 @@ typedef struct VarTrace {
/*
* When a variable trace is active (i.e. its associated procedure is
* executing), one of the following structures is linked into a list
- * associated with the variable's interpreter. The information in
+ * associated with the variable's interpreter. The information in
* the structure is needed in order for Tcl to behave reasonably
* if traces are deleted while traces are active.
*/
@@ -303,9 +303,9 @@ typedef struct ArraySearch {
Tcl_HashSearch search; /* Info kept by the hash module about
* progress through the array. */
Tcl_HashEntry *nextEntry; /* Non-null means this is the next element
- * to be enumerated (it's leftover from
+ * to be enumerated (it's leftover from
* the Tcl_FirstHashEntry call or from
- * an "array anymore" command). NULL
+ * an "array anymore" command). NULL
* means must call Tcl_NextHashEntry
* to get value to return. */
struct ArraySearch *nextPtr;/* Next in list of all active searches
@@ -383,7 +383,7 @@ typedef struct Var {
* than a scalar variable or link. The
* "tablePtr" field points to the array's
* hashtable for its elements.
- * VAR_LINK - 1 means this Var structure contains a
+ * VAR_LINK - 1 means this Var structure contains a
* pointer to another Var structure that
* either has the real value or is itself
* another VAR_LINK pointer. Variables like
@@ -434,7 +434,7 @@ typedef struct Var {
#define VAR_SCALAR 0x1
#define VAR_ARRAY 0x2
#define VAR_LINK 0x4
-#define VAR_UNDEFINED 0x8
+#define VAR_UNDEFINED 0x8
#define VAR_IN_HASHTABLE 0x10
#define VAR_TRACE_ACTIVE 0x20
#define VAR_ARRAY_ELEMENT 0x40
@@ -606,7 +606,7 @@ typedef struct Proc {
} Proc;
/*
- * The structure below defines a command trace. This is used to allow Tcl
+ * The structure below defines a command trace. This is used to allow Tcl
* clients to find out whenever a command is about to be executed.
*/
@@ -628,7 +628,7 @@ typedef struct Trace {
typedef struct AssocData {
Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
ClientData clientData; /* Value to pass to proc. */
-} AssocData;
+} AssocData;
/*
* The structure below defines a call frame. A call frame defines a naming
@@ -707,7 +707,7 @@ void TclHandleRelease _ANSI_ARGS_((TclHandle handle));
/*
*----------------------------------------------------------------
- * Data structures related to history. These are used primarily
+ * Data structures related to history. These are used primarily
* in tclHistory.c
*----------------------------------------------------------------
*/
@@ -879,7 +879,7 @@ typedef struct ExecEnv {
*/
typedef struct LiteralEntry {
- struct LiteralEntry *nextPtr; /* Points to next entry in this
+ struct LiteralEntry *nextPtr; /* Points to next entry in this
* hash bucket or NULL if end of
* chain. */
Tcl_Obj *objPtr; /* Points to Tcl object that
@@ -940,7 +940,7 @@ typedef struct ByteCodeStats {
double currentLitBytes; /* Current literal bytes. */
double currentExceptBytes; /* Current exception table bytes. */
double currentAuxBytes; /* Current auxiliary information bytes. */
- double currentCmdMapBytes; /* Current src<->code map bytes. */
+ double currentCmdMapBytes; /* Current src<->code map bytes. */
long numLiteralsCreated; /* Total literal objects ever compiled. */
double totalLitStringBytes; /* Total string bytes in all literals. */
@@ -965,7 +965,7 @@ typedef struct ByteCodeStats {
typedef struct ImportRef {
struct Command *importedCmdPtr;
- /* Points to the imported command created in
+ /* Points to the imported command created in
* an importing namespace; this command
* redirects its invocations to the "real"
* command. */
@@ -984,7 +984,7 @@ typedef struct ImportRef {
typedef struct ImportedCmdData {
struct Command *realCmdPtr; /* "Real" command that this imported command
- * refers to. */
+ * refers to. */
struct Command *selfPtr; /* Pointer to this imported command. Needed
* only when deleting it in order to remove
* it from the real command's linked list of
@@ -1016,9 +1016,9 @@ typedef struct Command {
* structure can be freed when refCount
* becomes zero. */
int cmdEpoch; /* Incremented to invalidate any references
- * that point to this command when it is
+ * that point to this command when it is
* renamed, deleted, hidden, or exposed. */
- CompileProc *compileProc; /* Procedure called to compile command. NULL
+ CompileProc *compileProc; /* Procedure called to compile command. NULL
* if no compile proc exists for command. */
Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */
ClientData objClientData; /* Arbitrary value passed to object proc. */
@@ -1087,7 +1087,7 @@ typedef struct Interp {
/*
* Note: the first three fields must match exactly the fields in
- * a Tcl_Interp struct (see tcl.h). If you change one, be sure to
+ * a Tcl_Interp struct (see tcl.h). If you change one, be sure to
* change the other.
*
* The interpreter's result is held in both the string and the
@@ -1101,16 +1101,16 @@ typedef struct Interp {
* and Tcl_GetStringResult. See the SetResult man page for details.
*/
- char *result; /* If the last command returned a string
+ char *result; /* If the last command returned a string
* result, this points to it. Should not be
* accessed directly; see comment above. */
- Tcl_FreeProc *freeProc; /* Zero means a string result is statically
- * allocated. TCL_DYNAMIC means string
- * result was allocated with ckalloc and
- * should be freed with ckfree. Other values
- * give address of procedure to invoke to
- * free the string result. Tcl_Eval must
- * free it before executing next command. */
+ Tcl_FreeProc *freeProc; /* Zero means a string result is statically
+ * allocated. TCL_DYNAMIC means string
+ * result was allocated with ckalloc and
+ * should be freed with ckfree. Other values
+ * give address of procedure to invoke to
+ * free the string result. Tcl_Eval must
+ * free it before executing next command. */
int errorLine; /* When TCL_ERROR is returned, this gives
* the line number in the command where the
* error occurred (1 means first line). */
@@ -1121,7 +1121,7 @@ typedef struct Interp {
TclHandle handle; /* Handle used to keep track of when this
* interp is deleted. */
- Namespace *globalNsPtr; /* The interpreter's global namespace. */
+ Namespace *globalNsPtr; /* The interpreter's global namespace. */
Tcl_HashTable *hiddenCmdTablePtr;
/* Hash table used by tclBasic.c to keep
* track of hidden commands on a per-interp
@@ -1130,7 +1130,7 @@ typedef struct Interp {
* track of master/slave interps on
* a per-interp basis. */
Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
- * defined for the interpreter. Indexed by
+ * defined for the interpreter. Indexed by
* strings (function names); values have
* type (MathFunc *). */
@@ -1143,7 +1143,7 @@ typedef struct Interp {
int numLevels; /* Keeps track of how many nested calls to
* Tcl_Eval are in progress for this
- * interpreter. It's used to delay deletion
+ * interpreter. It's used to delay deletion
* of the table until all Tcl_Eval
* invocations are completed. */
int maxNestingDepth; /* If numLevels exceeds this value then Tcl
@@ -1169,11 +1169,11 @@ typedef struct Interp {
/*
* Information used by Tcl_AppendResult to keep track of partial
- * results. See Tcl_AppendResult code for details.
+ * results. See Tcl_AppendResult code for details.
*/
char *appendResult; /* Storage space for results generated
- * by Tcl_AppendResult. Malloc-ed. NULL
+ * by Tcl_AppendResult. Malloc-ed. NULL
* means not yet allocated. */
int appendAvl; /* Total amount of space available at
* partialResult. */
@@ -1181,7 +1181,7 @@ typedef struct Interp {
* stored at partialResult. */
/*
- * A cache of compiled regular expressions. See Tcl_RegExpCompile
+ * A cache of compiled regular expressions. See Tcl_RegExpCompile
* in tclUtil.c for details. THIS CACHE IS OBSOLETE and is only
* retained for backward compatibility with Tcl_RegExpCompile.
* New code should use the object interface so the Tcl_Obj caches
@@ -1190,7 +1190,7 @@ typedef struct Interp {
#define NUM_REGEXPS 5
char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
- * regular expression patterns. NULL
+ * regular expression patterns. NULL
* means that this slot isn't used.
* Malloc-ed. */
int patLengths[NUM_REGEXPS];/* Number of non-null characters in
@@ -1225,7 +1225,7 @@ typedef struct Interp {
* values. */
int termOffset; /* Offset of character just after last one
* compiled or executed by Tcl_EvalObj. */
- LiteralTable literalTable; /* Contains LiteralEntry's describing all
+ LiteralTable literalTable; /* Contains LiteralEntry's describing all
* Tcl objects holding literals of scripts
* compiled by the interpreter. Indexed by
* the string representations of literals.
@@ -1256,10 +1256,10 @@ typedef struct Interp {
long randSeed; /* Seed used for rand() function. */
Trace *tracePtr; /* List of traces for this interpreter. */
Tcl_HashTable *assocData; /* Hash table for associating data with
- * this interpreter. Cleaned up when
- * this interpreter is deleted. */
+ * this interpreter. Cleaned up when
+ * this interpreter is deleted. */
struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode
- * execution. Contains a pointer to the
+ * execution. Contains a pointer to the
* Tcl evaluation stack. */
Tcl_Obj *emptyObjPtr; /* Points to an object holding an empty
* string. Returned by Tcl_ObjSetVar2 when
@@ -1277,7 +1277,7 @@ typedef struct Interp {
#ifdef TCL_COMPILE_STATS
ByteCodeStats stats; /* Holds compilation and execution
* statistics for this interpreter. */
-#endif /* TCL_COMPILE_STATS */
+#endif /* TCL_COMPILE_STATS */
} Interp;
/*
@@ -1286,7 +1286,7 @@ typedef struct Interp {
* TCL_BRACKET_TERM 1 means that the current script is terminated by
* a close bracket rather than the end of the string.
* TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with
- * a code other than TCL_OK or TCL_ERROR; 0 means
+ * a code other than TCL_OK or TCL_ERROR; 0 means
* codes other than these should be turned into errors.
*/
@@ -1309,7 +1309,7 @@ typedef struct Interp {
* "error message log" command).
* ERROR_CODE_SET: Non-zero means that Tcl_SetErrorCode has been
* called to record information for the current
- * error. Zero means Tcl_Eval must clear the
+ * error. Zero means Tcl_Eval must clear the
* errorCode variable if an error is returned.
* EXPR_INITIALIZED: Non-zero means initialization specific to
* expressions has been carried out.
@@ -1318,14 +1318,14 @@ typedef struct Interp {
* sequence of instructions. This is set 1, for
* example, when command traces are requested.
* RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
- * interp has not be initialized. This is set 1
+ * interp has not be initialized. This is set 1
* when we first use the rand() or srand() functions.
- * SAFE_INTERP: Non zero means that the current interp is a
- * safe interp (ie it has only the safe commands
- * installed, less priviledge than a regular interp).
+ * SAFE_INTERP: Non zero means that the current interp is a
+ * safe interp (ie it has only the safe commands
+ * installed, less priviledge than a regular interp).
* USE_EVAL_DIRECT: Non-zero means don't use the compiler or byte-code
* interpreter; instead, have Tcl_EvalObj call
- * Tcl_EvalDirect. Used primarily for testing the
+ * Tcl_EvalDirect. Used primarily for testing the
* new parser.
*/
@@ -1336,7 +1336,7 @@ typedef struct Interp {
#define EXPR_INITIALIZED 0x10
#define DONT_COMPILE_CMDS_INLINE 0x20
#define RAND_SEED_INITIALIZED 0x40
-#define SAFE_INTERP 0x80
+#define SAFE_INTERP 0x80
#define USE_EVAL_DIRECT 0x100
/*
@@ -1372,7 +1372,7 @@ typedef struct ParseValue {
/*
*----------------------------------------------------------------
* The following data structures and declarations are for the new
- * Tcl parser. This stuff should all move to tcl.h eventually.
+ * Tcl parser. This stuff should all move to tcl.h eventually.
*----------------------------------------------------------------
*/
@@ -1416,7 +1416,7 @@ typedef struct Tcl_Token {
* text that is part of a word.
* NumComponents is always 0.
* TCL_TOKEN_BS - The token describes a backslash sequence
- * that must be collapsed. NumComponents
+ * that must be collapsed. NumComponents
* is always 0.
* TCL_TOKEN_COMMAND - The token describes a command whose result
* must be substituted into the word. The
@@ -1453,7 +1453,7 @@ typedef struct Tcl_Token {
* primitive operand is described by a
* TCL_TOKEN_SUB_EXPR token followed by a
* TCL_TOKEN_TEXT token. A binary subexpression
- * is described by a TCL_TOKEN_SUB_EXPR token
+ * is described by a TCL_TOKEN_SUB_EXPR token
* followed by the TCL_TOKEN_OPERATOR token
* for the operator, then TCL_TOKEN_SUB_EXPR
* tokens for the left then the right operands.
@@ -1510,7 +1510,7 @@ typedef struct Tcl_Parse {
/*
* The fields below are intended only for the private use of the
- * parser. They should not be used by procedures that invoke
+ * parser. They should not be used by procedures that invoke
* Tcl_ParseCommand.
*/
@@ -1650,7 +1650,7 @@ typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
int objIndex, CONST char *fileName, Tcl_Obj *attrObjPtr));
typedef struct TclFileAttrProcs {
- TclGetFileAttrProc *getProc; /* The procedure for getting attrs. */
+ TclGetFileAttrProc *getProc; /* The procedure for getting attrs. */
TclSetFileAttrProc *setProc; /* The procedure for setting attrs. */
} TclFileAttrProcs;
@@ -1689,11 +1689,11 @@ typedef int (*TclObjCmdProcType) _ANSI_ARGS_((ClientData clientData,
extern Tcl_Time tclBlockTime;
extern int tclBlockTimeSet;
extern char * tclExecutableName;
-extern Tcl_ChannelType tclFileChannelType;
+extern Tcl_ChannelType tclFileChannelType;
extern char * tclMemDumpFileName;
extern TclPlatformType tclPlatform;
extern char * tclpFileAttrStrings[];
-extern CONST TclFileAttrProcs tclpFileAttrProcs[];
+extern CONST TclFileAttrProcs tclpFileAttrProcs[];
/*
* Variables denoting the Tcl object types defined in the core.
@@ -1715,8 +1715,8 @@ extern Tcl_ObjType tclStringType;
extern Tcl_Obj * tclFreeObjList;
#ifdef TCL_COMPILE_STATS
-extern long tclObjsAlloced;
-extern long tclObjsFreed;
+extern long tclObjsAlloced;
+extern long tclObjsFreed;
#endif /* TCL_COMPILE_STATS */
/*
@@ -1741,7 +1741,7 @@ EXTERN int TclAccessDeleteProc _ANSI_ARGS_((TclAccessProc_ *proc));
EXTERN int TclAccessInsertProc _ANSI_ARGS_((TclAccessProc_ *proc));
EXTERN void TclAllocateFreeObjects _ANSI_ARGS_((void));
EXTERN int TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp,
- int numPids, Tcl_Pid *pidPtr,
+ int numPids, Tcl_Pid *pidPtr,
Tcl_Channel errorChan));
EXTERN void TclCleanupCommand _ANSI_ARGS_((Command *cmdPtr));
EXTERN int TclCopyAndCollapse _ANSI_ARGS_((int count,
@@ -1761,7 +1761,7 @@ EXTERN int TclCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *argsPtr, Tcl_Obj *bodyPtr,
Proc **procPtrPtr));
EXTERN void TclDeleteCompiledLocalVars _ANSI_ARGS_((
- Interp *iPtr, CallFrame *framePtr));
+ Interp *iPtr, CallFrame *framePtr));
EXTERN void TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
Tcl_HashTable *tablePtr));
EXTERN int TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp,
@@ -1776,7 +1776,7 @@ EXTERN int TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[]));
EXTERN int TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp,
int argc, char **argv)) ;
-EXTERN int TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
+EXTERN int TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
int argc, char **argv));
EXTERN int TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
int argc, char **argv)) ;
@@ -1804,12 +1804,12 @@ EXTERN Proc * TclFindProc _ANSI_ARGS_((Interp *iPtr,
EXTERN int TclFormatInt _ANSI_ARGS_((char *buffer, long n));
EXTERN void TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr));
EXTERN void TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Channel chan));
+ Tcl_Channel chan));
EXTERN int TclGetDate _ANSI_ARGS_((char *p,
unsigned long now, long zone,
unsigned long *timePtr));
EXTERN Tcl_Obj * TclGetElementOfIndexedArray _ANSI_ARGS_((
- Tcl_Interp *interp, int localIndex,
+ Tcl_Interp *interp, int localIndex,
Tcl_Obj *elemPtr, int leaveErrorMsg));
EXTERN char * TclGetEnv _ANSI_ARGS_((CONST char *name,
Tcl_DString *valuePtr));
@@ -1834,23 +1834,23 @@ EXTERN int TclGetNamespaceForQualName _ANSI_ARGS_((
char **simpleNamePtr));
EXTERN TclObjCmdProcType TclGetObjInterpProc _ANSI_ARGS_((void));
EXTERN int TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, int *seekFlagPtr));
+ char *string, int *seekFlagPtr));
EXTERN Tcl_Command TclGetOriginalCommand _ANSI_ARGS_((
Tcl_Command command));
EXTERN int TclGlob _ANSI_ARGS_((Tcl_Interp *interp,
char *pattern, int noComplain));
EXTERN int TclGlobalInvoke _ANSI_ARGS_((Tcl_Interp *interp,
- int argc, char **argv, int flags));
+ int argc, char **argv, int flags));
EXTERN int TclGuessPackageName _ANSI_ARGS_((char *fileName,
Tcl_DString *bufPtr));
EXTERN int TclHideUnsafeCommands _ANSI_ARGS_((
- Tcl_Interp *interp));
+ Tcl_Interp *interp));
EXTERN int TclInExit _ANSI_ARGS_((void));
EXTERN Tcl_Obj * TclIncrElementOfIndexedArray _ANSI_ARGS_((
- Tcl_Interp *interp, int localIndex,
+ Tcl_Interp *interp, int localIndex,
Tcl_Obj *elemPtr, long incrAmount));
EXTERN Tcl_Obj * TclIncrIndexedScalar _ANSI_ARGS_((
- Tcl_Interp *interp, int localIndex,
+ Tcl_Interp *interp, int localIndex,
long incrAmount));
EXTERN Tcl_Obj * TclIncrVar2 _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
@@ -1868,13 +1868,13 @@ EXTERN void TclInitObjSubsystem _ANSI_ARGS_((void));
EXTERN void TclInitSubsystems _ANSI_ARGS_((CONST char *argv0));
EXTERN void TclInterpInit _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int TclInvoke _ANSI_ARGS_((Tcl_Interp *interp,
- int argc, char **argv, int flags));
+ int argc, char **argv, int flags));
EXTERN int TclInvokeObjectCommand _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv));
+ ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv));
EXTERN int TclInvokeStringCommand _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[]));
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]));
EXTERN int TclIsLocalScalar _ANSI_ARGS_((CONST char *src,
int len));
EXTERN Proc * TclIsProc _ANSI_ARGS_((Command *cmdPtr));
@@ -1889,17 +1889,17 @@ EXTERN int TclNeedSpace _ANSI_ARGS_((char *start, char *end));
EXTERN Tcl_Obj * TclNewProcBodyObj _ANSI_ARGS_((Proc *procPtr));
EXTERN int TclObjCommandComplete _ANSI_ARGS_((Tcl_Obj *cmdPtr));
EXTERN int TclObjInterpProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
EXTERN int TclObjInvoke _ANSI_ARGS_((Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[], int flags));
+ int objc, Tcl_Obj *CONST objv[], int flags));
EXTERN int TclObjInvokeGlobal _ANSI_ARGS_((Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[], int flags));
+ int objc, Tcl_Obj *CONST objv[], int flags));
EXTERN int TclOpenFileChannelDeleteProc _ANSI_ARGS_((
TclOpenFileChannelProc_ *proc));
EXTERN int TclOpenFileChannelInsertProc _ANSI_ARGS_((
TclOpenFileChannelProc_ *proc));
-EXTERN int TclpAccess _ANSI_ARGS_((CONST char *filename,
+EXTERN int TclpAccess _ANSI_ARGS_((CONST char *filename,
int mode));
EXTERN char * TclpAlloc _ANSI_ARGS_((unsigned int size));
EXTERN int TclpChdir _ANSI_ARGS_((CONST char *dirName));
@@ -1907,20 +1907,20 @@ EXTERN int TclpCheckStackSpace _ANSI_ARGS_((void));
EXTERN int TclpCloseFile _ANSI_ARGS_((TclFile file));
EXTERN int TclpCopyFile _ANSI_ARGS_((CONST char *source,
CONST char *dest));
-EXTERN int TclpCopyDirectory _ANSI_ARGS_((CONST char *source,
+EXTERN int TclpCopyDirectory _ANSI_ARGS_((CONST char *source,
CONST char *dest, Tcl_DString *errorPtr));
EXTERN Tcl_Channel TclpCreateCommandChannel _ANSI_ARGS_((
- TclFile readFile, TclFile writeFile,
+ TclFile readFile, TclFile writeFile,
TclFile errorFile, int numPids, Tcl_Pid *pidPtr));
-EXTERN int TclpCreateDirectory _ANSI_ARGS_((CONST char *path));
-EXTERN int TclpCreatePipe _ANSI_ARGS_((TclFile *readPipe,
+EXTERN int TclpCreateDirectory _ANSI_ARGS_((CONST char *path));
+EXTERN int TclpCreatePipe _ANSI_ARGS_((TclFile *readPipe,
TclFile *writePipe));
EXTERN int TclpCreateProcess _ANSI_ARGS_((Tcl_Interp *interp,
int argc, char **argv, TclFile inputFile,
TclFile outputFile, TclFile errorFile,
Tcl_Pid *pidPtr));
EXTERN TclFile TclpCreateTempFile _ANSI_ARGS_((CONST char *contents));
-EXTERN int TclpDeleteFile _ANSI_ARGS_((CONST char *path));
+EXTERN int TclpDeleteFile _ANSI_ARGS_((CONST char *path));
EXTERN void TclpExit _ANSI_ARGS_((int status));
EXTERN void TclpFinalizeCondition _ANSI_ARGS_((
Tcl_Condition *condPtr));
@@ -1964,34 +1964,34 @@ EXTERN TclFile TclpOpenFile _ANSI_ARGS_((CONST char *fname,
EXTERN Tcl_Channel TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
char *fileName, char *modeString,
int permissions));
-EXTERN char * TclpReadlink _ANSI_ARGS_((CONST char *fileName,
+EXTERN char * TclpReadlink _ANSI_ARGS_((CONST char *fileName,
Tcl_DString *linkPtr));
EXTERN char * TclpRealloc _ANSI_ARGS_((char *ptr,
unsigned int size));
EXTERN void TclpReleaseFile _ANSI_ARGS_((TclFile file));
-EXTERN int TclpRemoveDirectory _ANSI_ARGS_((CONST char *path,
+EXTERN int TclpRemoveDirectory _ANSI_ARGS_((CONST char *path,
int recursive, Tcl_DString *errorPtr));
-EXTERN int TclpRenameFile _ANSI_ARGS_((CONST char *source,
+EXTERN int TclpRenameFile _ANSI_ARGS_((CONST char *source,
CONST char *dest));
EXTERN void TclpSetInitialEncodings _ANSI_ARGS_((void));
EXTERN void TclpSetVariables _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN VOID * TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
-EXTERN void TclpSysFree _ANSI_ARGS_((VOID *ptr));
-EXTERN VOID * TclpSysRealloc _ANSI_ARGS_((VOID *cp,
+EXTERN VOID * TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
+EXTERN void TclpSysFree _ANSI_ARGS_((VOID *ptr));
+EXTERN VOID * TclpSysRealloc _ANSI_ARGS_((VOID *cp,
unsigned int size));
EXTERN void TclpUnloadFile _ANSI_ARGS_((ClientData clientData));
EXTERN char * TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, char *name1, char *name2,
int flags));
EXTERN int TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Interp *cmdInterp, Tcl_Command cmd));
+ Tcl_Interp *cmdInterp, Tcl_Command cmd));
EXTERN void TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
EXTERN int TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
- Proc *procPtr, Tcl_Obj *bodyPtr, Namespace *nsPtr,
- CONST char *description, CONST char *procName));
+ Proc *procPtr, Tcl_Obj *bodyPtr, Namespace *nsPtr,
+ CONST char *description, CONST char *procName));
EXTERN void TclProcDeleteProc _ANSI_ARGS_((ClientData clientData));
EXTERN int TclProcInterpProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+ Tcl_Interp *interp, int argc, char **argv));
EXTERN int TclpThreadCreate _ANSI_ARGS_((Tcl_ThreadId *idPtr,
Tcl_ThreadCreateProc proc, ClientData clientData));
EXTERN VOID * TclpThreadDataKeyGet _ANSI_ARGS_((
@@ -2010,7 +2010,7 @@ EXTERN void TclResetShadowedCmdRefs _ANSI_ARGS_((
Tcl_Interp *interp, Command *newCmdPtr));
EXTERN int TclServiceIdle _ANSI_ARGS_((void));
EXTERN Tcl_Obj * TclSetElementOfIndexedArray _ANSI_ARGS_((
- Tcl_Interp *interp, int localIndex,
+ Tcl_Interp *interp, int localIndex,
Tcl_Obj *elemPtr, Tcl_Obj *objPtr,
int leaveErrorMsg));
EXTERN void TclSetLibraryPath _ANSI_ARGS_((Tcl_Obj *pathPtr));
@@ -2020,9 +2020,9 @@ EXTERN Tcl_Obj * TclSetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
EXTERN char * TclSetPreInitScript _ANSI_ARGS_((char *string));
EXTERN void TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, char *proto, int *portPtr));
+ char *string, char *proto, int *portPtr));
EXTERN int TclSockMinimumBuffers _ANSI_ARGS_((int sock,
- int size));
+ int size));
EXTERN int TclStat _ANSI_ARGS_((CONST char *path,
TclStat_ *buf));
EXTERN int TclStatDeleteProc _ANSI_ARGS_((TclStatProc_ *proc));
@@ -2031,8 +2031,8 @@ EXTERN void TclTeardownNamespace _ANSI_ARGS_((Namespace *nsPtr));
EXTERN int TclTestChannelCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char **argv));
EXTERN int TclTestChannelEventCmd _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv));
+ ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv));
EXTERN void TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp,
int result, Tcl_Interp *targetInterp));
EXTERN int TclUniCharIsAlnum _ANSI_ARGS_((int ch));
@@ -2234,13 +2234,13 @@ EXTERN int Tcl_WhileObjCmd _ANSI_ARGS_((ClientData clientData,
*/
#ifdef MAC_TCL
-EXTERN int Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
+EXTERN int Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData,
+EXTERN int Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
-EXTERN int Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
+EXTERN int Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
-EXTERN int Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
+EXTERN int Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
EXTERN int Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
@@ -2304,7 +2304,7 @@ EXTERN int TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
#ifdef TCL_MEM_DEBUG
# define TclNewObj(objPtr) \
(objPtr) = (Tcl_Obj *) \
- Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
+ Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
(objPtr)->refCount = 0; \
(objPtr)->bytes = tclEmptyStringRep; \
(objPtr)->length = 0; \
@@ -2321,19 +2321,19 @@ EXTERN int TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
# define TclDecrRefCount(objPtr) \
if (--(objPtr)->refCount <= 0) { \
- if ((objPtr)->refCount < -1) \
- panic("Reference count for %lx was negative: %s line %d", \
+ if ((objPtr)->refCount < -1) \
+ panic("Reference count for %lx was negative: %s line %d", \
(objPtr), __FILE__, __LINE__); \
- if (((objPtr)->bytes != NULL) \
- && ((objPtr)->bytes != tclEmptyStringRep)) { \
+ if (((objPtr)->bytes != NULL) \
+ && ((objPtr)->bytes != tclEmptyStringRep)) { \
ckfree((char *) (objPtr)->bytes); \
- } \
- if (((objPtr)->typePtr != NULL) \
- && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
+ } \
+ if (((objPtr)->typePtr != NULL) \
+ && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
(objPtr)->typePtr->freeIntRepProc(objPtr); \
- } \
- ckfree((char *) (objPtr)); \
- TclIncrObjsFreed(); \
+ } \
+ ckfree((char *) (objPtr)); \
+ TclIncrObjsFreed(); \
}
#else /* not TCL_MEM_DEBUG */
@@ -2359,18 +2359,18 @@ extern Tcl_Mutex tclObjMutex;
# define TclDecrRefCount(objPtr) \
if (--(objPtr)->refCount <= 0) { \
- if (((objPtr)->bytes != NULL) \
- && ((objPtr)->bytes != tclEmptyStringRep)) { \
+ if (((objPtr)->bytes != NULL) \
+ && ((objPtr)->bytes != tclEmptyStringRep)) { \
ckfree((char *) (objPtr)->bytes); \
- } \
- if (((objPtr)->typePtr != NULL) \
- && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
+ } \
+ if (((objPtr)->typePtr != NULL) \
+ && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
(objPtr)->typePtr->freeIntRepProc(objPtr); \
- } \
+ } \
Tcl_MutexLock(&tclObjMutex); \
- (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
- tclFreeObjList = (objPtr); \
- TclIncrObjsFreed(); \
+ (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
+ tclFreeObjList = (objPtr); \
+ TclIncrObjsFreed(); \
Tcl_MutexUnlock(&tclObjMutex); \
}
#endif /* TCL_MEM_DEBUG */
@@ -2391,12 +2391,12 @@ extern Tcl_Mutex tclObjMutex;
#define TclInitStringRep(objPtr, bytePtr, len) \
if ((len) == 0) { \
- (objPtr)->bytes = tclEmptyStringRep; \
+ (objPtr)->bytes = tclEmptyStringRep; \
(objPtr)->length = 0; \
} else { \
(objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
- (unsigned) (len)); \
+ (unsigned) (len)); \
(objPtr)->bytes[len] = '\0'; \
(objPtr)->length = (len); \
}
@@ -2425,9 +2425,9 @@ extern Tcl_Mutex tclObjMutex;
*/
EXTERN void Tcl_AddInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, Tcl_ResolveCmdProc *cmdProc,
- Tcl_ResolveVarProc *varProc,
- Tcl_ResolveCompiledVarProc *compiledVarProc));
+ char *name, Tcl_ResolveCmdProc *cmdProc,
+ Tcl_ResolveVarProc *varProc,
+ Tcl_ResolveCompiledVarProc *compiledVarProc));
EXTERN int Tcl_AppendExportList _ANSI_ARGS_((
Tcl_Interp *interp, Tcl_Namespace *nsPtr,
Tcl_Obj *objPtr));
@@ -2445,14 +2445,14 @@ EXTERN Tcl_Command Tcl_FindCommand _ANSI_ARGS_((Tcl_Interp *interp,
EXTERN Tcl_Namespace * Tcl_FindNamespace _ANSI_ARGS_((Tcl_Interp *interp,
char *name, Tcl_Namespace *contextNsPtr,
int flags));
-EXTERN int Tcl_GetInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, Tcl_ResolverInfo *resInfo));
-EXTERN int Tcl_GetNamespaceResolvers _ANSI_ARGS_((
+EXTERN int Tcl_GetInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
+ char *name, Tcl_ResolverInfo *resInfo));
+EXTERN int Tcl_GetNamespaceResolvers _ANSI_ARGS_((
Tcl_Namespace *namespacePtr,
Tcl_ResolverInfo *resInfo));
EXTERN void Tcl_GetVariableFullName _ANSI_ARGS_((
Tcl_Interp *interp, Tcl_Var variable,
- Tcl_Obj *objPtr));
+ Tcl_Obj *objPtr));
EXTERN Tcl_Var Tcl_FindNamespaceVar _ANSI_ARGS_((
Tcl_Interp *interp, char *name,
Tcl_Namespace *contextNsPtr, int flags));
diff --git a/generic/tclMain.c b/generic/tclMain.c
index e8f7f6a..5c6ba10 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMain.c,v 1.1.2.3 1999/02/01 21:29:54 stanton Exp $
+ * RCS: @(#) $Id: tclMain.c,v 1.1.2.4 1999/02/10 23:31:17 stanton Exp $
*/
#include "tcl.h"
@@ -151,8 +151,8 @@ Tcl_Main(argc, argv, appInitProc)
*/
Tcl_AddErrorInfo(interp, "");
- Tcl_WriteObj(errChannel,
- Tcl_GetObjVar2(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY));
+ Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp, "errorInfo",
+ NULL, TCL_GLOBAL_ONLY));
Tcl_WriteChars(errChannel, "\n", 1);
}
exitCode = 1;
@@ -184,7 +184,7 @@ Tcl_Main(argc, argv, appInitProc)
if (tty) {
Tcl_Obj *promptCmdPtr;
- promptCmdPtr = Tcl_GetObjVar2(interp,
+ promptCmdPtr = Tcl_GetVar2Ex(interp,
(gotPartial ? "tcl_prompt2" : "tcl_prompt1"),
NULL, TCL_GLOBAL_ONLY);
if (promptCmdPtr == NULL) {
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 2e8040b..5fbd4a6 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -9,7 +9,7 @@
*
* Copyright (c) 1993-1997 Lucent Technologies.
* Copyright (c) 1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* Originally implemented by
* Michael J. McLennan
@@ -19,7 +19,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.1.2.6 1999/02/01 21:29:54 stanton Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.1.2.7 1999/02/10 23:31:17 stanton Exp $
*/
#include "tclInt.h"
@@ -288,11 +288,8 @@ Tcl_PushCallFrame(interp, callFramePtr, namespacePtr, isProcCallFrame)
} else {
nsPtr = (Namespace *) namespacePtr;
if (nsPtr->flags & NS_DEAD) {
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "namespace \"",
- nsPtr->fullName, "\" not found in context \"",
- Tcl_GetCurrentNamespace(interp)->fullName, "\"",
- (char *) NULL);
- return TCL_ERROR;
+ panic("Trying to push call frame for dead namespace");
+ /*NOTREACHED*/
}
}
@@ -448,7 +445,7 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
char *simpleName;
Tcl_HashEntry *entryPtr;
Tcl_DString buffer1, buffer2;
- int newEntry, result;
+ int newEntry;
/*
* If there is no active namespace, the interpreter is being
@@ -472,13 +469,9 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
* Find the parent for the new namespace.
*/
- result = TclGetNamespaceForQualName(interp, name,
- (Namespace *) NULL,
+ TclGetNamespaceForQualName(interp, name, (Namespace *) NULL,
/*flags*/ (CREATE_NS_IF_UNKNOWN | TCL_LEAVE_ERR_MSG),
&parentPtr, &dummy1Ptr, &dummy2Ptr, &simpleName);
- if (result != TCL_OK) {
- return NULL;
- }
/*
* If the unqualified name at the end is empty, there were trailing
@@ -918,7 +911,7 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
Namespace *nsPtr, *exportNsPtr, *dummyPtr;
Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
char *simplePattern, *patternCpy;
- int neededElems, len, i, result;
+ int neededElems, len, i;
/*
* If the specified namespace is NULL, use the current namespace.
@@ -951,12 +944,10 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
* Check that the pattern doesn't have namespace qualifiers.
*/
- result = TclGetNamespaceForQualName(interp, pattern, nsPtr,
+ TclGetNamespaceForQualName(interp, pattern, nsPtr,
/*flags*/ TCL_LEAVE_ERR_MSG, &exportNsPtr, &dummyPtr,
&dummyPtr, &simplePattern);
- if (result != TCL_OK) {
- return result;
- }
+
if ((exportNsPtr != nsPtr) || (strcmp(pattern, simplePattern) != 0)) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"invalid export pattern \"", pattern,
@@ -1166,12 +1157,10 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite)
"empty import pattern", -1);
return TCL_ERROR;
}
- result = TclGetNamespaceForQualName(interp, pattern, nsPtr,
+ TclGetNamespaceForQualName(interp, pattern, nsPtr,
/*flags*/ TCL_LEAVE_ERR_MSG, &importNsPtr, &dummyPtr,
&dummyPtr, &simplePattern);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
+
if (importNsPtr == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"unknown namespace in import pattern \"",
@@ -1336,7 +1325,6 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
register Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
Command *cmdPtr;
- int result;
/*
* If the specified namespace is NULL, use the current namespace.
@@ -1354,12 +1342,10 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
* the end.
*/
- result = TclGetNamespaceForQualName(interp, pattern, nsPtr,
+ TclGetNamespaceForQualName(interp, pattern, nsPtr,
/*flags*/ TCL_LEAVE_ERR_MSG, &importNsPtr, &dummyPtr,
&actualCtxPtr, &simplePattern);
- if (result != TCL_OK) {
- return result;
- }
+
if (importNsPtr == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"unknown namespace in namespace forget pattern \"",
@@ -1571,15 +1557,14 @@ DeleteImportedCmd(clientData)
* final component is stored in *simpleNamePtr.
*
* Results:
- * Ordinarily this procedure returns TCL_OK. It sets *nsPtrPtr and
- * *altNsPtrPtr to point to the two possible namespaces which represent
- * the last (containing) namespace in the qualified name. If the
- * procedure sets either *nsPtrPtr or *altNsPtrPtr to NULL, then the
- * search along that path failed. The procedure also stores a pointer
- * to the simple name of the final component in *simpleNamePtr. If the
- * qualified name is "::" or was treated as a namespace reference
- * (FIND_ONLY_NS), the procedure stores a pointer to the
- * namespace in *nsPtrPtr, NULL in *altNsPtrPtr, and sets
+ * It sets *nsPtrPtr and *altNsPtrPtr to point to the two possible
+ * namespaces which represent the last (containing) namespace in the
+ * qualified name. If the procedure sets either *nsPtrPtr or *altNsPtrPtr
+ * to NULL, then the search along that path failed. The procedure also
+ * stores a pointer to the simple name of the final component in
+ * *simpleNamePtr. If the qualified name is "::" or was treated as a
+ * namespace reference (FIND_ONLY_NS), the procedure stores a pointer
+ * to the namespace in *nsPtrPtr, NULL in *altNsPtrPtr, and sets
* *simpleNamePtr to point to an empty string.
*
* If there is an error, this procedure returns TCL_ERROR. If "flags"
@@ -1591,9 +1576,12 @@ DeleteImportedCmd(clientData)
* set to the input context namespace pointer in cxtNsPtr. If cxtNsPtr
* is NULL, it is set to the current namespace context.
*
+ * For backwards compatibility with the TclPro byte code loader,
+ * this function always returns TCL_OK.
+ *
* Side effects:
- * If flags contains TCL_LEAVE_ERR_MSG and an error is encountered,
- * the interpreter's result object will contain an error message.
+ * If "flags" contains CREATE_NS_IF_UNKNOWN, new namespaces may be
+ * created.
*
*----------------------------------------------------------------------
*/
@@ -1648,7 +1636,7 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
char *nsName;
Tcl_HashEntry *entryPtr;
Tcl_DString buffer;
- int len, result;
+ int len;
/*
* Determine the context namespace nsPtr in which to start the primary
@@ -1773,18 +1761,15 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
} else if (flags & CREATE_NS_IF_UNKNOWN) {
Tcl_CallFrame frame;
- result = Tcl_PushCallFrame(interp, &frame,
+ (void) Tcl_PushCallFrame(interp, &frame,
(Tcl_Namespace *) nsPtr, /*isProcCallFrame*/ 0);
- if (result != TCL_OK) {
- Tcl_DStringFree(&buffer);
- return result;
- }
+
nsPtr = (Namespace *) Tcl_CreateNamespace(interp, nsName,
(ClientData) NULL, (Tcl_NamespaceDeleteProc *) NULL);
Tcl_PopCallFrame(interp);
+
if (nsPtr == NULL) {
- Tcl_DStringFree(&buffer);
- return TCL_ERROR;
+ panic("Could not create namespace '%s'", nsName);
}
} else { /* namespace not found and wasn't created */
nsPtr = NULL;
@@ -1887,7 +1872,6 @@ Tcl_FindNamespace(interp, name, contextNsPtr, flags)
{
Namespace *nsPtr, *dummy1Ptr, *dummy2Ptr;
char *dummy;
- int result;
/*
* Find the namespace(s) that contain the specified namespace name.
@@ -1895,12 +1879,9 @@ Tcl_FindNamespace(interp, name, contextNsPtr, flags)
* to its last component, a namespace.
*/
- result = TclGetNamespaceForQualName(interp, name,
- (Namespace *) contextNsPtr, /*flags*/ (flags | FIND_ONLY_NS),
- &nsPtr, &dummy1Ptr, &dummy2Ptr, &dummy);
- if (result != TCL_OK) {
- return NULL;
- }
+ TclGetNamespaceForQualName(interp, name, (Namespace *) contextNsPtr,
+ (flags | FIND_ONLY_NS), &nsPtr, &dummy1Ptr, &dummy2Ptr, &dummy);
+
if (nsPtr != NULL) {
return (Tcl_Namespace *) nsPtr;
} else if (flags & TCL_LEAVE_ERR_MSG) {
@@ -2011,12 +1992,8 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
* Find the namespace(s) that contain the command.
*/
- result = TclGetNamespaceForQualName(interp, name,
- (Namespace *) contextNsPtr, flags, &nsPtr[0], &nsPtr[1],
- &cxtNsPtr, &simpleName);
- if (result != TCL_OK) {
- return (Tcl_Command) NULL;
- }
+ TclGetNamespaceForQualName(interp, name, (Namespace *) contextNsPtr,
+ flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName);
/*
* Look for the command in the command table of its namespace.
@@ -2145,12 +2122,8 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
* Find the namespace(s) that contain the variable.
*/
- result = TclGetNamespaceForQualName(interp, name,
- (Namespace *) contextNsPtr, flags, &nsPtr[0], &nsPtr[1],
- &cxtNsPtr, &simpleName);
- if (result != TCL_OK) {
- return (Tcl_Var) NULL;
- }
+ TclGetNamespaceForQualName(interp, name, (Namespace *) contextNsPtr,
+ flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName);
/*
* Look for the variable in the variable table of its namespace.
@@ -3785,7 +3758,6 @@ SetNsNameFromAny(interp, objPtr)
char *name, *dummy;
Namespace *nsPtr, *dummy1Ptr, *dummy2Ptr;
register ResolvedNsName *resNamePtr;
- int flags, result;
/*
* Get the string representation. Make it up-to-date if necessary.
@@ -3803,12 +3775,8 @@ SetNsNameFromAny(interp, objPtr)
* object with a NULL ResolvedNsName* internal rep.
*/
- flags = ((interp != NULL)? TCL_LEAVE_ERR_MSG : 0) | FIND_ONLY_NS;
- result = TclGetNamespaceForQualName(interp, name, (Namespace *) NULL,
- flags, &nsPtr, &dummy1Ptr, &dummy2Ptr, &dummy);
- if (result != TCL_OK) {
- return result;
- }
+ TclGetNamespaceForQualName(interp, name, (Namespace *) NULL,
+ FIND_ONLY_NS, &nsPtr, &dummy1Ptr, &dummy2Ptr, &dummy);
/*
* If we found a namespace, then create a new ResolvedNsName structure
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 823e5f9..ec35cdf 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParse.c,v 1.1.2.8 1999/02/01 21:29:54 stanton Exp $
+ * RCS: @(#) $Id: tclParse.c,v 1.1.2.9 1999/02/10 23:31:18 stanton Exp $
*/
#include "tclInt.h"
@@ -1213,7 +1213,7 @@ Tcl_EvalTokens(interp, tokenPtr, count)
} else {
index = NULL;
}
- valuePtr = Tcl_GetObjVar2(interp, varName, index,
+ valuePtr = Tcl_GetVar2Ex(interp, varName, index,
TCL_LEAVE_ERR_MSG);
if (varName != nameBuffer) {
ckfree(varName);
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 4a88fde..0040a45 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclProc.c,v 1.1.2.6 1999/02/01 21:29:55 stanton Exp $
+ * RCS: @(#) $Id: tclProc.c,v 1.1.2.7 1999/02/10 23:31:18 stanton Exp $
*/
#include "tclInt.h"
@@ -71,7 +71,6 @@ Tcl_ProcObjCmd(dummy, interp, objc, objv)
Namespace *nsPtr, *altNsPtr, *cxtNsPtr;
Tcl_Command cmd;
Tcl_DString ds;
- int result;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 1, objv, "name args body");
@@ -85,12 +84,9 @@ Tcl_ProcObjCmd(dummy, interp, objc, objv)
*/
fullName = TclGetString(objv[1]);
- result = TclGetNamespaceForQualName(interp, fullName,
- (Namespace *) NULL, TCL_LEAVE_ERR_MSG,
- &nsPtr, &altNsPtr, &cxtNsPtr, &procName);
- if (result != TCL_OK) {
- return result;
- }
+ TclGetNamespaceForQualName(interp, fullName, (Namespace *) NULL,
+ 0, &nsPtr, &altNsPtr, &cxtNsPtr, &procName);
+
if (nsPtr == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"can't create procedure \"", fullName,
diff --git a/generic/tclResult.c b/generic/tclResult.c
index f47b06f..3f09149 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.1.2.2 1998/10/03 01:56:42 stanton Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.1.2.3 1999/02/10 23:31:19 stanton Exp $
*/
#include "tclInt.h"
@@ -867,7 +867,7 @@ Tcl_SetObjErrorCode(interp, errorObjPtr)
Interp *iPtr;
iPtr = (Interp *) interp;
- Tcl_SetObjVar2(interp, "errorCode", NULL, errorObjPtr, TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "errorCode", NULL, errorObjPtr, TCL_GLOBAL_ONLY);
iPtr->flags |= ERROR_CODE_SET;
}
@@ -936,14 +936,14 @@ TclTransferResult(sourceInterp, result, targetInterp)
Tcl_ResetResult(targetInterp);
- objPtr = Tcl_GetObjVar2(sourceInterp, "errorInfo", NULL,
+ objPtr = Tcl_GetVar2Ex(sourceInterp, "errorInfo", NULL,
TCL_GLOBAL_ONLY);
- Tcl_SetObjVar2(targetInterp, "errorInfo", NULL, objPtr,
+ Tcl_SetVar2Ex(targetInterp, "errorInfo", NULL, objPtr,
TCL_GLOBAL_ONLY);
- objPtr = Tcl_GetObjVar2(sourceInterp, "errorCode", NULL,
+ objPtr = Tcl_GetVar2Ex(sourceInterp, "errorCode", NULL,
TCL_GLOBAL_ONLY);
- Tcl_SetObjVar2(targetInterp, "errorCode", NULL, objPtr,
+ Tcl_SetVar2Ex(targetInterp, "errorCode", NULL, objPtr,
TCL_GLOBAL_ONLY);
((Interp *) targetInterp)->flags |= (ERR_IN_PROGRESS | ERROR_CODE_SET);
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 4b00b06..2ec6d4c 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.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: tclScan.c,v 1.1.2.2 1998/11/18 04:15:46 stanton Exp $
+ * RCS: @(#) $Id: tclScan.c,v 1.1.2.3 1999/02/10 23:31:19 stanton Exp $
*/
#include "tclInt.h"
@@ -1012,8 +1012,7 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
for (i = 0; i < numVars; i++) {
if (objs[i] != NULL) {
result++;
- if (Tcl_SetObjVar2(interp, Tcl_GetString(objv[i+3]),
- NULL, objs[i], 0) == NULL) {
+ if (Tcl_ObjSetVar2(interp, objv[i+3], NULL, objs[i], 0) == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"couldn't set variable \"",
Tcl_GetString(objv[i+3]), "\"", (char *) NULL);
diff --git a/generic/tclTest.c b/generic/tclTest.c
index c7eba49..578a8fe 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.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: tclTest.c,v 1.1.2.11 1999/02/01 21:29:55 stanton Exp $
+ * RCS: @(#) $Id: tclTest.c,v 1.1.2.12 1999/02/10 23:31:19 stanton Exp $
*/
#define TCL_TEST
@@ -254,8 +254,8 @@ static int TestsaveresultCmd _ANSI_ARGS_((ClientData dummy,
static void TestsaveresultFree _ANSI_ARGS_((char *blockPtr));
static int TestsetassocdataCmd _ANSI_ARGS_((ClientData dummy,
Tcl_Interp *interp, int argc, char **argv));
-static int TestsetnoerrCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, char **argv));
+static int TestsetCmd _ANSI_ARGS_((ClientData dummy,
+ Tcl_Interp *interp, int argc, char **argv));
static int TestsetobjerrorcodeCmd _ANSI_ARGS_((
ClientData dummy, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[]));
@@ -282,13 +282,13 @@ static int TestupvarCmd _ANSI_ARGS_((ClientData dummy,
Tcl_Interp *interp, int argc, char **argv));
/*
- * External initialization routines:
+ * External (platform specific) initialization routine, these declarations
+ * explicitly don't use EXTERN since this code does not get compiled
+ * into the library:
*/
-EXTERN int TclplatformtestInit _ANSI_ARGS_((
- Tcl_Interp *interp));
-EXTERN int TclThread_Init _ANSI_ARGS_((
- Tcl_Interp *interp));
+extern int TclplatformtestInit _ANSI_ARGS_((Tcl_Interp *interp));
+extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
*----------------------------------------------------------------------
@@ -404,8 +404,10 @@ Tcltest_Init(interp)
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testsetassocdata", TestsetassocdataCmd,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
- Tcl_CreateCommand(interp, "testsetnoerr", TestsetnoerrCmd,
+ Tcl_CreateCommand(interp, "testsetnoerr", TestsetCmd,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ Tcl_CreateCommand(interp, "testseterr", TestsetCmd,
+ (ClientData) TCL_LEAVE_ERR_MSG, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "testsetobjerrorcode",
TestsetobjerrorcodeCmd, (ClientData) 0,
(Tcl_CmdDeleteProc *) NULL);
@@ -3697,50 +3699,45 @@ NoopObjCmd(unused, interp, objc, objv)
/*
*----------------------------------------------------------------------
*
- * TestsetnoerrCmd --
+ * TestsetCmd --
*
- * Implements the "testsetnoerr" cmd that is used when testing
- * the Tcl_Set/GetVar C Api without TCL_LEAVE_ERR_MSG flag
+ * Implements the "testset{err,noerr}" cmds that are used when testing
+ * Tcl_Set/GetVar C Api with/without TCL_LEAVE_ERR_MSG flag
*
* Results:
* A standard Tcl result.
*
* Side effects:
- * None.
+ * Variables may be set.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
-static int
-TestsetnoerrCmd(dummy, interp, argc, argv)
- ClientData dummy; /* Not used. */
+TestsetCmd(data, interp, argc, argv)
+ ClientData data; /* Additional flags for Get/SetVar2. */
register Tcl_Interp *interp; /* Current interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
+ int flags = (int) data;
char *value;
+
if (argc == 2) {
- Tcl_SetResult(interp, "before get", TCL_STATIC);
- value = Tcl_GetVar2(interp, argv[1], (char *) NULL, 0);
- if (value == NULL) {
- return TCL_ERROR;
- }
- Tcl_SetResult(interp, value, TCL_VOLATILE);
- return TCL_OK;
+ Tcl_SetResult(interp, "before get", TCL_STATIC);
+ value = Tcl_GetVar2(interp, argv[1], (char *) NULL, flags);
+ if (value == NULL) {
+ return TCL_ERROR;
+ }
+ Tcl_AppendElement(interp, value);
+ return TCL_OK;
} else if (argc == 3) {
- char *m1 = "before set";
- char *message=Tcl_Alloc(strlen(m1)+1);
-
- strcpy(message,m1);
-
- Tcl_SetResult(interp, message, TCL_DYNAMIC);
-
- value = Tcl_SetVar2(interp, argv[1], (char *) NULL, argv[2], 0);
- if (value == NULL) {
- return TCL_ERROR;
- }
- Tcl_SetResult(interp, value, TCL_VOLATILE);
+ Tcl_SetResult(interp, "before set", TCL_STATIC);
+ value = Tcl_SetVar2(interp, argv[1], (char *) NULL, argv[2], flags);
+ if (value == NULL) {
+ return TCL_ERROR;
+ }
+ Tcl_AppendElement(interp, value);
return TCL_OK;
} else {
Tcl_AppendResult(interp, "wrong # args: should be \"",
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 12adf5e..ebf45f1 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -9,11 +9,12 @@
*
* Copyright (c) 1987-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.1.2.3 1998/11/06 21:51:57 stanton Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.1.2.4 1999/02/10 23:31:20 stanton Exp $
*/
#include "tclInt.h"
@@ -28,7 +29,8 @@ static char *noSuchVar = "no such variable";
static char *isArray = "variable is array";
static char *needArray = "variable isn't array";
static char *noSuchElement = "no such element in array";
-static char *danglingUpvar = "upvar refers to element in deleted array";
+static char *danglingElement = "upvar refers to element in deleted array";
+static char *danglingVar = "upvar refers to variable in deleted namespace";
static char *badNamespace = "parent namespace doesn't exist";
static char *missingName = "missing variable name";
@@ -199,7 +201,7 @@ TclLookupVar(interp, part1, part2, flags, msg, createPart1, createPart2,
if (cxtNsPtr->varResProc) {
result = (*cxtNsPtr->varResProc)(interp, part1,
- (Tcl_Namespace *) cxtNsPtr, flags, &var);
+ (Tcl_Namespace *) cxtNsPtr, flags, &var);
} else {
result = TCL_CONTINUE;
}
@@ -207,7 +209,7 @@ TclLookupVar(interp, part1, part2, flags, msg, createPart1, createPart2,
while (result == TCL_CONTINUE && resPtr) {
if (resPtr->varResProc) {
result = (*resPtr->varResProc)(interp, part1,
- (Tcl_Namespace *) cxtNsPtr, flags, &var);
+ (Tcl_Namespace *) cxtNsPtr, flags, &var);
}
resPtr = resPtr->nextPtr;
}
@@ -238,27 +240,25 @@ TclLookupVar(interp, part1, part2, flags, msg, createPart1, createPart2,
*/
if (((flags & (TCL_GLOBAL_ONLY | TCL_NAMESPACE_ONLY)) != 0)
- || (varFramePtr == NULL)
- || !varFramePtr->isProcCallFrame
- || (strstr(part1, "::") != NULL)) {
+ || (varFramePtr == NULL)
+ || !varFramePtr->isProcCallFrame
+ || (strstr(part1, "::") != NULL)) {
char *tail;
+ /*
+ * Don't pass TCL_LEAVE_ERR_MSG, we may yet create the variable,
+ * or otherwise generate our own error!
+ */
var = Tcl_FindNamespaceVar(interp, part1, (Tcl_Namespace *) NULL,
- flags);
+ flags & ~TCL_LEAVE_ERR_MSG);
if (var != (Tcl_Var) NULL) {
varPtr = (Var *) var;
}
if (varPtr == NULL) {
- if (flags & TCL_LEAVE_ERR_MSG) {
- Tcl_ResetResult(interp);
- }
if (createPart1) { /* var wasn't found so create it */
- result = TclGetNamespaceForQualName(interp, part1,
- (Namespace *) NULL, flags, &varNsPtr, &dummy1Ptr,
- &dummy2Ptr, &tail);
- if (result != TCL_OK) {
- goto done;
- }
+ TclGetNamespaceForQualName(interp, part1, (Namespace *) NULL,
+ flags, &varNsPtr, &dummy1Ptr, &dummy2Ptr, &tail);
+
if (varNsPtr == NULL) {
if (flags & TCL_LEAVE_ERR_MSG) {
VarErrMsg(interp, part1, part2, msg, badNamespace);
@@ -308,7 +308,7 @@ TclLookupVar(interp, part1, part2, flags, msg, createPart1, createPart2,
if (createPart1) {
if (tablePtr == NULL) {
tablePtr = (Tcl_HashTable *)
- ckalloc(sizeof(Tcl_HashTable));
+ ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS);
varFramePtr->varTablePtr = tablePtr;
}
@@ -337,7 +337,7 @@ TclLookupVar(interp, part1, part2, flags, msg, createPart1, createPart2,
}
}
-lookupVarPart2:
+ lookupVarPart2:
if (openParen != NULL) {
*openParen = '(';
openParen = NULL;
@@ -374,10 +374,23 @@ lookupVarPart2:
varPtr = NULL;
goto done;
}
+
+ /*
+ * Make sure we are not resurrecting a namespace variable from a
+ * deleted namespace!
+ */
+ if ((varPtr->flags & VAR_IN_HASHTABLE) && (varPtr->hPtr == NULL)) {
+ if (flags & TCL_LEAVE_ERR_MSG) {
+ VarErrMsg(interp, part1, part2, msg, danglingVar);
+ }
+ varPtr = NULL;
+ goto done;
+ }
+
TclSetVarArray(varPtr);
TclClearVarUndefined(varPtr);
varPtr->value.tablePtr =
- (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
+ (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(varPtr->value.tablePtr, TCL_STRING_KEYS);
} else if (!TclIsVarArray(varPtr)) {
if (flags & TCL_LEAVE_ERR_MSG) {
@@ -498,17 +511,65 @@ Tcl_GetVar2(interp, part1, part2, flags)
{
Tcl_Obj *objPtr;
- objPtr = Tcl_GetObjVar2(interp, part1, part2, flags);
+ objPtr = Tcl_GetVar2Ex(interp, part1, part2, flags);
if (objPtr == NULL) {
return NULL;
}
return TclGetString(objPtr);
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_ObjGetVar2 --
+ *
+ * Return the value of a Tcl variable as a Tcl object, given a
+ * two-part name consisting of array name and element within array.
+ *
+ * Results:
+ * The return value points to the current object value of the variable
+ * given by part1Ptr and part2Ptr. If the specified variable doesn't
+ * exist, or if there is a clash in array usage, then NULL is returned
+ * and a message will be left in the interpreter's result if the
+ * TCL_LEAVE_ERR_MSG flag is set.
+ *
+ * Side effects:
+ * The ref count for the returned object is _not_ incremented to
+ * reflect the returned reference; if you want to keep a reference to
+ * the object you must increment its ref count yourself.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, flags)
+ Tcl_Interp *interp; /* Command interpreter in which variable is
+ * to be looked up. */
+ register Tcl_Obj *part1Ptr; /* Points to an object holding the name of
+ * an array (if part2 is non-NULL) or the
+ * name of a variable. */
+ register Tcl_Obj *part2Ptr; /* If non-null, points to an object holding
+ * the name of an element in the array
+ * part1Ptr. */
+ int flags; /* OR-ed combination of TCL_GLOBAL_ONLY,
+ * TCL_LEAVE_ERR_MSG, and
+ * TCL_PARSE_PART1 bits. */
+{
+ char *part1, *part2;
+
+ part1 = Tcl_GetString(part1Ptr);
+ if (part2Ptr != NULL) {
+ part2 = Tcl_GetString(part2Ptr);
+ } else {
+ part2 = NULL;
+ }
+
+ return Tcl_GetVar2Ex(interp, part1, part2, flags);
+}
/*
*----------------------------------------------------------------------
*
- * Tcl_GetObjVar2 --
+ * Tcl_GetVar2Ex --
*
* Return the value of a Tcl variable as a Tcl object, given a
* two-part name consisting of array name and element within array.
@@ -529,7 +590,7 @@ Tcl_GetVar2(interp, part1, part2, flags)
*/
Tcl_Obj *
-Tcl_GetObjVar2(interp, part1, part2, flags)
+Tcl_GetVar2Ex(interp, part1, part2, flags)
Tcl_Interp *interp; /* Command interpreter in which variable is
* to be looked up. */
char *part1; /* Name of an array (if part2 is non-NULL)
@@ -648,15 +709,16 @@ TclGetIndexedScalar(interp, localIndex, leaveErrorMsg)
int localCt = varFramePtr->procPtr->numCompiledLocals;
if (compiledLocals == NULL) {
- fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame with no compiled locals\n",
- localIndex);
- panic("TclGetIndexedScalar: no compiled locals in frame");
+ fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame 0x%x, no compiled locals\n",
+ localIndex, (unsigned int) varFramePtr);
+ panic("TclGetIndexedScalar: no compiled locals in frame 0x%x",
+ (unsigned int) varFramePtr);
}
if ((localIndex < 0) || (localIndex >= localCt)) {
- fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame with %i locals\n",
- localIndex, localCt);
- panic("TclGetIndexedScalar: can't get local %i in frame with %i locals",
- localIndex, localCt);
+ fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame 0x%x with %i locals\n",
+ localIndex, (unsigned int) varFramePtr, localCt);
+ panic("TclGetIndexedScalar: bad local index %i in frame 0x%x",
+ localIndex, (unsigned int) varFramePtr);
}
#endif /* TCL_COMPILE_DEBUG */
@@ -769,15 +831,15 @@ TclGetElementOfIndexedArray(interp, localIndex, elemPtr, leaveErrorMsg)
if (compiledLocals == NULL) {
fprintf(stderr, "\nTclGetElementOfIndexedArray: can't get element of local %i in frame 0x%x, no compiled locals\n",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
panic("TclGetIndexedScalar: no compiled locals in frame 0x%x",
- (unsigned int) varFramePtr);
+ (unsigned int) varFramePtr);
}
if ((localIndex < 0) || (localIndex >= localCt)) {
fprintf(stderr, "\nTclGetIndexedScalar: can't get element of local %i in frame 0x%x with %i locals\n",
- localIndex, (unsigned int) varFramePtr, localCt);
+ localIndex, (unsigned int) varFramePtr, localCt);
panic("TclGetElementOfIndexedArray: bad local index %i in frame 0x%x",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
}
#endif /* TCL_COMPILE_DEBUG */
@@ -904,8 +966,7 @@ Tcl_SetObjCmd(dummy, interp, objc, objv)
Tcl_Obj *varValueObj;
if (objc == 2) {
- varValueObj = Tcl_GetObjVar2(interp, TclGetString(objv[1]), NULL,
- TCL_LEAVE_ERR_MSG);
+ varValueObj = Tcl_ObjGetVar2(interp, objv[1], NULL, TCL_LEAVE_ERR_MSG);
if (varValueObj == NULL) {
return TCL_ERROR;
}
@@ -913,8 +974,8 @@ Tcl_SetObjCmd(dummy, interp, objc, objv)
return TCL_OK;
} else if (objc == 3) {
- varValueObj = Tcl_SetObjVar2(interp, TclGetString(objv[1]), NULL,
- objv[2], TCL_LEAVE_ERR_MSG);
+ varValueObj = Tcl_ObjSetVar2(interp, objv[1], NULL, objv[2],
+ TCL_LEAVE_ERR_MSG);
if (varValueObj == NULL) {
return TCL_ERROR;
}
@@ -1008,20 +1069,16 @@ Tcl_SetVar2(interp, part1, part2, newValue, flags)
{
register Tcl_Obj *valuePtr;
Tcl_Obj *varValuePtr;
- int length;
/*
* Create an object holding the variable's new value and use
- * Tcl_SetObjVar2 to actually set the variable.
+ * Tcl_SetVar2Ex to actually set the variable.
*/
- length = newValue ? strlen(newValue) : 0;
- TclNewObj(valuePtr);
- TclInitStringRep(valuePtr, newValue, length);
+ valuePtr = Tcl_NewStringObj(newValue, -1);
Tcl_IncrRefCount(valuePtr);
- varValuePtr = Tcl_SetObjVar2(interp, part1, part2, valuePtr,
- flags);
+ varValuePtr = Tcl_SetVar2Ex(interp, part1, part2, valuePtr, flags);
Tcl_DecrRefCount(valuePtr); /* done with the object */
if (varValuePtr == NULL) {
@@ -1033,7 +1090,61 @@ Tcl_SetVar2(interp, part1, part2, newValue, flags)
/*
*----------------------------------------------------------------------
*
- * Tcl_SetObjVar2 --
+ * Tcl_ObjSetVar2 --
+ *
+ * This function is the same as Tcl_SetVar2Ex below, except the
+ * variable names are passed in Tcl object instead of strings.
+ *
+ * Results:
+ * Returns a pointer to the Tcl_Obj holding the new value of the
+ * variable. If the write operation was disallowed because an array was
+ * expected but not found (or vice versa), then NULL is returned; if
+ * the TCL_LEAVE_ERR_MSG flag is set, then an explanatory message will
+ * be left in the interpreter's result. Note that the returned object
+ * may not be the same one referenced by newValuePtr; this is because
+ * variable traces may modify the variable's value.
+ *
+ * Side effects:
+ * The value of the given variable is set. If either the array or the
+ * entry didn't exist then a new variable is created.
+
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+Tcl_ObjSetVar2(interp, part1Ptr, part2Ptr, newValuePtr, flags)
+ Tcl_Interp *interp; /* Command interpreter in which variable is
+ * to be found. */
+ register Tcl_Obj *part1Ptr; /* Points to an object holding the name of
+ * an array (if part2 is non-NULL) or the
+ * name of a variable. */
+ register Tcl_Obj *part2Ptr; /* If non-null, points to an object holding
+ * the name of an element in the array
+ * part1Ptr. */
+ Tcl_Obj *newValuePtr; /* New value for variable. */
+ int flags; /* Various flags that tell how to set value:
+ * any of TCL_GLOBAL_ONLY,
+ * TCL_NAMESPACE_ONLY, TCL_APPEND_VALUE,
+ * TCL_LIST_ELEMENT, TCL_LEAVE_ERR_MSG, or
+ * TCL_PARSE_PART1. */
+{
+ char *part1, *part2;
+
+ part1 = Tcl_GetString(part1Ptr);
+ if (part2Ptr != NULL) {
+ part2 = Tcl_GetString(part2Ptr);
+ } else {
+ part2 = NULL;
+ }
+
+ return Tcl_SetVar2Ex(interp, part1, part2, newValuePtr, flags);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_SetVar2Ex --
*
* Given a two-part variable name, which may refer either to a scalar
* variable or an element of an array, change the value of the variable
@@ -1057,7 +1168,7 @@ Tcl_SetVar2(interp, part1, part2, newValue, flags)
* and incremented for its new value. If the new value for the variable
* is not the same one referenced by newValuePtr (perhaps as a result
* of a variable trace), then newValuePtr's ref count is left unchanged
- * by Tcl_SetObjVar2. newValuePtr's ref count is also left unchanged if
+ * by Tcl_SetVar2Ex. newValuePtr's ref count is also left unchanged if
* we are appending it as a string value: that is, if "flags" includes
* TCL_APPEND_VALUE but not TCL_LIST_ELEMENT.
*
@@ -1069,7 +1180,7 @@ Tcl_SetVar2(interp, part1, part2, newValue, flags)
*/
Tcl_Obj *
-Tcl_SetObjVar2(interp, part1, part2, newValuePtr, flags)
+Tcl_SetVar2Ex(interp, part1, part2, newValuePtr, flags)
Tcl_Interp *interp; /* Command interpreter in which variable is
* to be found. */
char *part1; /* Name of an array (if part2 is non-NULL)
@@ -1098,15 +1209,19 @@ Tcl_SetObjVar2(interp, part1, part2, newValuePtr, flags)
/*
* If the variable is in a hashtable and its hPtr field is NULL, then we
- * have an upvar to an array element where the array was deleted,
- * leaving the element dangling at the end of the upvar. Generate an
- * error (allowing the variable to be reset would screw up our storage
- * allocation and is meaningless anyway).
+ * may have an upvar to an array element where the array was deleted
+ * or an upvar to a namespace variable whose namespace was deleted.
+ * Generate an error (allowing the variable to be reset would screw up
+ * our storage allocation and is meaningless anyway).
*/
if ((varPtr->flags & VAR_IN_HASHTABLE) && (varPtr->hPtr == NULL)) {
if (flags & TCL_LEAVE_ERR_MSG) {
- VarErrMsg(interp, part1, part2, "set", danglingUpvar);
+ if (TclIsVarArrayElement(varPtr)) {
+ VarErrMsg(interp, part1, part2, "set", danglingElement);
+ } else {
+ VarErrMsg(interp, part1, part2, "set", danglingVar);
+ }
}
return NULL;
}
@@ -1196,7 +1311,7 @@ Tcl_SetObjVar2(interp, part1, part2, newValuePtr, flags)
neededBytes = Tcl_ScanElement(bytes, &listFlags);
oldValuePtr = Tcl_NewObj();
oldValuePtr->bytes = (char *)
- ckalloc((unsigned) (neededBytes + 1));
+ ckalloc((unsigned) (neededBytes + 1));
oldValuePtr->length = Tcl_ConvertElement(bytes,
oldValuePtr->bytes, listFlags);
varPtr->value.objPtr = oldValuePtr;
@@ -1323,15 +1438,15 @@ TclSetIndexedScalar(interp, localIndex, newValuePtr, leaveErrorMsg)
if (compiledLocals == NULL) {
fprintf(stderr, "\nTclSetIndexedScalar: can't set local %i in frame 0x%x, no compiled locals\n",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
panic("TclSetIndexedScalar: no compiled locals in frame 0x%x",
- (unsigned int) varFramePtr);
+ (unsigned int) varFramePtr);
}
if ((localIndex < 0) || (localIndex >= localCt)) {
fprintf(stderr, "\nTclSetIndexedScalar: can't set local %i in frame 0x%x with %i locals\n",
- localIndex, (unsigned int) varFramePtr, localCt);
+ localIndex, (unsigned int) varFramePtr, localCt);
panic("TclSetIndexedScalar: bad local index %i in frame 0x%x",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
}
#endif /* TCL_COMPILE_DEBUG */
@@ -1351,15 +1466,19 @@ TclSetIndexedScalar(interp, localIndex, newValuePtr, leaveErrorMsg)
/*
* If the variable is in a hashtable and its hPtr field is NULL, then we
- * have an upvar to an array element where the array was deleted,
- * leaving the element dangling at the end of the upvar. Generate an
- * error (allowing the variable to be reset would screw up our storage
- * allocation and is meaningless anyway).
+ * may have an upvar to an array element where the array was deleted
+ * or an upvar to a namespace variable whose namespace was deleted.
+ * Generate an error (allowing the variable to be reset would screw up
+ * our storage allocation and is meaningless anyway).
*/
if ((varPtr->flags & VAR_IN_HASHTABLE) && (varPtr->hPtr == NULL)) {
if (leaveErrorMsg) {
- VarErrMsg(interp, varName, NULL, "set", danglingUpvar);
+ if (TclIsVarArrayElement(varPtr)) {
+ VarErrMsg(interp, varName, NULL, "set", danglingElement);
+ } else {
+ VarErrMsg(interp, varName, NULL, "set", danglingVar);
+ }
}
return NULL;
}
@@ -1504,15 +1623,15 @@ TclSetElementOfIndexedArray(interp, localIndex, elemPtr, newValuePtr,
if (compiledLocals == NULL) {
fprintf(stderr, "\nTclSetElementOfIndexedArray: can't set element of local %i in frame 0x%x, no compiled locals\n",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
panic("TclSetIndexedScalar: no compiled locals in frame 0x%x",
- (unsigned int) varFramePtr);
+ (unsigned int) varFramePtr);
}
if ((localIndex < 0) || (localIndex >= localCt)) {
fprintf(stderr, "\nTclSetIndexedScalar: can't set elememt of local %i in frame 0x%x with %i locals\n",
- localIndex, (unsigned int) varFramePtr, localCt);
+ localIndex, (unsigned int) varFramePtr, localCt);
panic("TclSetElementOfIndexedArray: bad local index %i in frame 0x%x",
- localIndex, (unsigned int) varFramePtr);
+ localIndex, (unsigned int) varFramePtr);
}
#endif /* TCL_COMPILE_DEBUG */
@@ -1532,13 +1651,32 @@ TclSetElementOfIndexedArray(interp, localIndex, elemPtr, newValuePtr,
}
/*
+ * If the variable is in a hashtable and its hPtr field is NULL, then we
+ * may have an upvar to an array element where the array was deleted
+ * or an upvar to a namespace variable whose namespace was deleted.
+ * Generate an error (allowing the variable to be reset would screw up
+ * our storage allocation and is meaningless anyway).
+ */
+
+ if ((arrayPtr->flags & VAR_IN_HASHTABLE) && (arrayPtr->hPtr == NULL)) {
+ if (leaveErrorMsg) {
+ if (TclIsVarArrayElement(arrayPtr)) {
+ VarErrMsg(interp, arrayName, elem, "set", danglingElement);
+ } else {
+ VarErrMsg(interp, arrayName, elem, "set", danglingVar);
+ }
+ }
+ goto errorReturn;
+ }
+
+ /*
* Make sure we're dealing with an array.
*/
if (TclIsVarUndefined(arrayPtr) && !TclIsVarArrayElement(arrayPtr)) {
TclSetVarArray(arrayPtr);
arrayPtr->value.tablePtr =
- (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
+ (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(arrayPtr->value.tablePtr, TCL_STRING_KEYS);
TclClearVarUndefined(arrayPtr);
} else if (!TclIsVarArray(arrayPtr)) {
@@ -1681,17 +1819,10 @@ TclIncrVar2(interp, part1Ptr, part2Ptr, incrAmount, flags)
int createdNewObj; /* Set 1 if var's value object is shared
* so we must increment a copy (i.e. copy
* on write). */
- char *part1 = TclGetString(part1Ptr);
long i;
int result;
- char *index;
- if (part2Ptr != NULL) {
- index = TclGetString(part2Ptr);
- } else {
- index = NULL;
- }
- varValuePtr = Tcl_GetObjVar2(interp, part1, index, flags);
+ varValuePtr = Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, flags);
if (varValuePtr == NULL) {
Tcl_AddObjErrorInfo(interp,
"\n (reading value of variable to increment)", -1);
@@ -1723,7 +1854,7 @@ TclIncrVar2(interp, part1Ptr, part2Ptr, incrAmount, flags)
* Store the variable's new value and run any write traces.
*/
- resultPtr = Tcl_SetObjVar2(interp, part1, index, varValuePtr, flags);
+ resultPtr = Tcl_ObjSetVar2(interp, part1Ptr, part2Ptr, varValuePtr, flags);
if (resultPtr == NULL) {
return NULL;
}
@@ -1772,7 +1903,7 @@ TclIncrIndexedScalar(interp, localIndex, incrAmount)
int result;
varValuePtr = TclGetIndexedScalar(interp, localIndex,
- /*leaveErrorMsg*/ 1);
+ /*leaveErrorMsg*/ 1);
if (varValuePtr == NULL) {
Tcl_AddObjErrorInfo(interp,
"\n (reading value of variable to increment)", -1);
@@ -1806,7 +1937,7 @@ TclIncrIndexedScalar(interp, localIndex, incrAmount)
*/
resultPtr = TclSetIndexedScalar(interp, localIndex, varValuePtr,
- /*leaveErrorMsg*/ 1);
+ /*leaveErrorMsg*/ 1);
if (resultPtr == NULL) {
return NULL;
}
@@ -1859,7 +1990,7 @@ TclIncrElementOfIndexedArray(interp, localIndex, elemPtr, incrAmount)
int result;
varValuePtr = TclGetElementOfIndexedArray(interp, localIndex, elemPtr,
- /*leaveErrorMsg*/ 1);
+ /*leaveErrorMsg*/ 1);
if (varValuePtr == NULL) {
Tcl_AddObjErrorInfo(interp,
"\n (reading value of variable to increment)", -1);
@@ -1893,8 +2024,8 @@ TclIncrElementOfIndexedArray(interp, localIndex, elemPtr, incrAmount)
*/
resultPtr = TclSetElementOfIndexedArray(interp, localIndex, elemPtr,
- varValuePtr,
- /*leaveErrorMsg*/ 1);
+ varValuePtr,
+ /*leaveErrorMsg*/ 1);
if (resultPtr == NULL) {
return NULL;
}
@@ -2027,7 +2158,7 @@ Tcl_UnsetVar2(interp, part1, part2, flags)
ckfree((char *) tracePtr);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
+ activePtr = activePtr->nextPtr) {
if (activePtr->varPtr == varPtr) {
activePtr->nextTracePtr = NULL;
}
@@ -2045,7 +2176,7 @@ Tcl_UnsetVar2(interp, part1, part2, flags)
dummyVarPtr = &dummyVar;
if (TclIsVarArray(dummyVarPtr) && !TclIsVarUndefined(dummyVarPtr)) {
DeleteArray(iPtr, part1, dummyVarPtr,
- (flags & (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY)) | TCL_TRACE_UNSETS);
+ (flags & (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY)) | TCL_TRACE_UNSETS);
}
if (TclIsVarScalar(dummyVarPtr)
&& (dummyVarPtr->value.objPtr != NULL)) {
@@ -2055,9 +2186,7 @@ Tcl_UnsetVar2(interp, part1, part2, flags)
}
/*
- * If the variable was a namespace variable, decrement its reference
- * count. We are in the process of destroying its namespace so that
- * namespace will no longer "refer" to the variable.
+ * If the variable was a namespace variable, decrement its reference count.
*/
if (varPtr->flags & VAR_NAMESPACE_VAR) {
@@ -2179,8 +2308,8 @@ Tcl_TraceVar2(interp, part1, part2, flags, proc, clientData)
tracePtr->traceProc = proc;
tracePtr->clientData = clientData;
tracePtr->flags =
- flags & (TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS |
- TCL_TRACE_ARRAY);
+ flags & (TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS |
+ TCL_TRACE_ARRAY);
tracePtr->nextPtr = varPtr->tracePtr;
varPtr->tracePtr = tracePtr;
return TCL_OK;
@@ -2270,7 +2399,7 @@ Tcl_UntraceVar2(interp, part1, part2, flags, proc, clientData)
flags &= (TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS |
TCL_TRACE_ARRAY);
for (tracePtr = varPtr->tracePtr, prevPtr = NULL; ;
- prevPtr = tracePtr, tracePtr = tracePtr->nextPtr) {
+ prevPtr = tracePtr, tracePtr = tracePtr->nextPtr) {
if (tracePtr == NULL) {
return;
}
@@ -2287,7 +2416,7 @@ Tcl_UntraceVar2(interp, part1, part2, flags, proc, clientData)
*/
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
+ activePtr = activePtr->nextPtr) {
if (activePtr->nextTracePtr == tracePtr) {
activePtr->nextTracePtr = tracePtr->nextPtr;
}
@@ -2490,23 +2619,21 @@ Tcl_AppendObjCmd(dummy, interp, objc, objv)
register Tcl_Obj *varValuePtr = NULL;
/* Initialized to avoid compiler
* warning. */
- char *varName;
int i;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "varName ?value value ...?");
return TCL_ERROR;
}
- varName = TclGetString(objv[1]);
if (objc == 2) {
- varValuePtr = Tcl_GetObjVar2(interp, varName, NULL, TCL_LEAVE_ERR_MSG);
+ varValuePtr = Tcl_ObjGetVar2(interp, objv[1], NULL, TCL_LEAVE_ERR_MSG);
if (varValuePtr == NULL) {
return TCL_ERROR;
}
} else {
for (i = 2; i < objc; i++) {
- varValuePtr = Tcl_SetObjVar2(interp, varName, NULL, objv[i],
- (TCL_APPEND_VALUE | TCL_LEAVE_ERR_MSG));
+ varValuePtr = Tcl_ObjSetVar2(interp, objv[1], (Tcl_Obj *) NULL,
+ objv[i], (TCL_APPEND_VALUE | TCL_LEAVE_ERR_MSG));
if (varValuePtr == NULL) {
return TCL_ERROR;
}
@@ -2544,16 +2671,15 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
Tcl_Obj *varValuePtr, *newValuePtr;
register List *listRepPtr;
register Tcl_Obj **elemPtrs;
- char *varName;
int numElems, numRequired, createdNewObj, createVar, i, j;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "varName ?value value ...?");
return TCL_ERROR;
}
- varName = TclGetString(objv[1]);
if (objc == 2) {
- newValuePtr = Tcl_GetObjVar2(interp, varName, NULL, TCL_LEAVE_ERR_MSG);
+ newValuePtr = Tcl_ObjGetVar2(interp, objv[1], (Tcl_Obj *) NULL,
+ (TCL_LEAVE_ERR_MSG));
if (newValuePtr == NULL) {
/*
* The variable doesn't exist yet. Just create it with an empty
@@ -2561,7 +2687,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
*/
Tcl_Obj *nullObjPtr = Tcl_NewObj();
- newValuePtr = Tcl_SetObjVar2(interp, varName, NULL,
+ newValuePtr = Tcl_ObjSetVar2(interp, objv[1], NULL,
nullObjPtr, TCL_LEAVE_ERR_MSG);
if (newValuePtr == NULL) {
Tcl_DecrRefCount(nullObjPtr); /* free unneeded object */
@@ -2570,7 +2696,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
}
} else {
/*
- * We have arguments to append. We used to call Tcl_SetObjVar2 to
+ * We have arguments to append. We used to call Tcl_SetVar2 to
* append each argument one at a time to ensure that traces were run
* for each append step. We now append the arguments all at once
* because it's faster. Note that a read trace and a write trace for
@@ -2581,7 +2707,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
createdNewObj = 0;
createVar = 1;
- varValuePtr = Tcl_GetObjVar2(interp, varName, NULL, 0);
+ varValuePtr = Tcl_ObjGetVar2(interp, objv[1], NULL, 0);
if (varValuePtr == NULL) {
/*
* We couldn't read the old value: either the var doesn't yet
@@ -2589,7 +2715,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
* create it with Tcl_ObjSetVar2 below.
*/
- char *p;
+ char *p, *varName;
int nameBytes, i;
varName = Tcl_GetStringFromObj(objv[1], &nameBytes);
@@ -2635,7 +2761,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
if (numRequired > listRepPtr->maxElemCount) {
int newMax = (2 * numRequired);
Tcl_Obj **newElemPtrs = (Tcl_Obj **)
- ckalloc((unsigned) (newMax * sizeof(Tcl_Obj *)));
+ ckalloc((unsigned) (newMax * sizeof(Tcl_Obj *)));
memcpy((VOID *) newElemPtrs, (VOID *) elemPtrs,
(size_t) (numElems * sizeof(Tcl_Obj *)));
@@ -2668,7 +2794,7 @@ Tcl_LappendObjCmd(dummy, interp, objc, objv)
* was new and we didn't create the variable.
*/
- newValuePtr = Tcl_SetObjVar2(interp, varName, NULL, varValuePtr,
+ newValuePtr = Tcl_ObjSetVar2(interp, objv[1], NULL, varValuePtr,
TCL_LEAVE_ERR_MSG);
if (newValuePtr == NULL) {
if (createdNewObj && !createVar) {
@@ -2721,8 +2847,8 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
ARRAY_NAMES, ARRAY_NEXTELEMENT, ARRAY_SET, ARRAY_SIZE,
ARRAY_STARTSEARCH};
static char *arrayOptions[] = {"anymore", "donesearch", "exists",
- "get", "names", "nextelement", "set", "size", "startsearch",
- (char *) NULL};
+ "get", "names", "nextelement", "set", "size", "startsearch",
+ (char *) NULL};
Interp *iPtr = (Interp *) interp;
Var *varPtr, *arrayPtr;
@@ -2829,7 +2955,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
varPtr->searchPtr = searchPtr->nextPtr;
} else {
for (prevPtr = varPtr->searchPtr; ;
- prevPtr = prevPtr->nextPtr) {
+ prevPtr = prevPtr->nextPtr) {
if (prevPtr->nextPtr == searchPtr) {
prevPtr->nextPtr = searchPtr->nextPtr;
break;
@@ -2865,7 +2991,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
pattern = TclGetString(objv[3]);
}
for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
varPtr2 = (Var *) Tcl_GetHashValue(hPtr);
if (TclIsVarUndefined(varPtr2)) {
continue;
@@ -2883,8 +3009,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
return result;
}
- valuePtr = Tcl_GetObjVar2(interp,
- TclGetString(objv[2]), TclGetString(namePtr),
+ valuePtr = Tcl_ObjGetVar2(interp, objv[2], namePtr,
TCL_LEAVE_ERR_MSG);
if (valuePtr == NULL) {
Tcl_DecrRefCount(namePtr); /* free unneeded name obj */
@@ -2917,7 +3042,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
pattern = Tcl_GetString(objv[3]);
}
for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
varPtr2 = (Var *) Tcl_GetHashValue(hPtr);
if (TclIsVarUndefined(varPtr2)) {
continue;
@@ -2996,9 +3121,8 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
}
if (listLen > 0) {
for (i = 0; i < listLen; i += 2) {
- if (Tcl_SetObjVar2(interp, TclGetString(objv[2]),
- TclGetString(elemPtrs[i]), elemPtrs[i+1],
- TCL_LEAVE_ERR_MSG) == NULL) {
+ if (Tcl_ObjSetVar2(interp, objv[2], elemPtrs[i],
+ elemPtrs[i+1], TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
break;
}
@@ -3058,7 +3182,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
if (!notArray) {
for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr,
&search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
varPtr2 = (Var *) Tcl_GetHashValue(hPtr);
if (TclIsVarUndefined(varPtr2)) {
continue;
@@ -3090,7 +3214,7 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
searchPtr->id = varPtr->searchPtr->id + 1;
TclFormatInt(string, searchPtr->id);
Tcl_AppendStringsToObj(resultPtr, "s-", string, "-", varName,
- (char *) NULL);
+ (char *) NULL);
}
searchPtr->varPtr = varPtr;
searchPtr->nextEntry = Tcl_FirstHashEntry(varPtr->value.tablePtr,
@@ -3149,7 +3273,7 @@ MakeUpvar(iPtr, framePtr, otherP1, otherP2, otherFlags, myName, myFlags)
Tcl_HashTable *tablePtr;
Namespace *nsPtr, *altNsPtr, *dummyNsPtr;
char *tail;
- int new, result;
+ int new;
/*
* Find "other" in "framePtr". If not looking up other in just the
@@ -3188,21 +3312,18 @@ MakeUpvar(iPtr, framePtr, otherP1, otherP2, otherFlags, myName, myFlags)
varFramePtr = iPtr->varFramePtr;
if ((myFlags & (TCL_GLOBAL_ONLY | TCL_NAMESPACE_ONLY))
- || (varFramePtr == NULL)
- || !varFramePtr->isProcCallFrame
- || (strstr(myName, "::") != NULL)) {
- result = TclGetNamespaceForQualName((Tcl_Interp *) iPtr, myName,
- (Namespace *) NULL, (myFlags | TCL_LEAVE_ERR_MSG),
- &nsPtr, &altNsPtr, &dummyNsPtr, &tail);
- if (result != TCL_OK) {
- return result;
- }
+ || (varFramePtr == NULL)
+ || !varFramePtr->isProcCallFrame
+ || (strstr(myName, "::") != NULL)) {
+ TclGetNamespaceForQualName((Tcl_Interp *) iPtr, myName,
+ (Namespace *) NULL, myFlags, &nsPtr, &altNsPtr, &dummyNsPtr, &tail);
+
if (nsPtr == NULL) {
nsPtr = altNsPtr;
}
if (nsPtr == NULL) {
Tcl_AppendResult((Tcl_Interp *) iPtr, "bad variable name \"",
- myName, "\": unknown namespace", (char *) NULL);
+ myName, "\": unknown namespace", (char *) NULL);
return TCL_ERROR;
}
@@ -3295,11 +3416,11 @@ MakeUpvar(iPtr, framePtr, otherP1, otherP2, otherFlags, myName, myFlags)
}
} else if (!TclIsVarUndefined(varPtr)) {
Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", myName,
- "\" already exists", (char *) NULL);
+ "\" already exists", (char *) NULL);
return TCL_ERROR;
} else if (varPtr->tracePtr != NULL) {
Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", myName,
- "\" has traces: can't use for upvar", (char *) NULL);
+ "\" has traces: can't use for upvar", (char *) NULL);
return TCL_ERROR;
}
}
@@ -3606,7 +3727,7 @@ Tcl_VariableObjCmd(dummy, interp, objc, objv)
Tcl_Obj *CONST objv[]; /* Argument objects. */
{
Interp *iPtr = (Interp *) interp;
- char *varName, *tail;
+ char *varName, *tail, *cp;
Var *varPtr, *arrayPtr;
Tcl_Obj *varValuePtr;
int i, result;
@@ -3645,8 +3766,7 @@ Tcl_VariableObjCmd(dummy, interp, objc, objv)
*/
if (i+1 < objc) { /* a value was specified */
- varValuePtr = Tcl_SetObjVar2(interp, TclGetString(objv[i]),
- NULL, objv[i+1],
+ varValuePtr = Tcl_ObjSetVar2(interp, objv[i], NULL, objv[i+1],
(TCL_NAMESPACE_ONLY | TCL_LEAVE_ERR_MSG));
if (varValuePtr == NULL) {
return TCL_ERROR;
@@ -3663,17 +3783,17 @@ Tcl_VariableObjCmd(dummy, interp, objc, objv)
/*
* varName might have a scope qualifier, but the name for the
* local "link" variable must be the simple name at the tail.
+ *
+ * Locate tail in one pass: drop any prefix after two *or more*
+ * consecutive ":" characters).
*/
- for (tail = varName; *tail != '\0'; tail++) {
- /* empty body */
- }
- while ((tail > varName)
- && ((*tail != ':') || (*(tail-1) != ':'))) {
- tail--;
- }
- if (*tail == ':') {
- tail++;
+ for (tail = cp = varName; *cp != '\0'; ) {
+ if (*cp++ == ':') {
+ while (*cp++ == ':') {
+ tail = cp;
+ }
+ }
}
/*
@@ -3868,7 +3988,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags)
Tcl_DStringInit(&nameCopy);
Tcl_DStringAppend(&nameCopy, part1, (p-part1));
part2 = Tcl_DStringValue(&nameCopy)
- + (openParen + 1 - part1);
+ + (openParen + 1 - part1);
part2[-1] = 0;
part1 = Tcl_DStringValue(&nameCopy);
copiedName = 1;
@@ -3889,7 +4009,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags)
arrayPtr->refCount++;
active.varPtr = arrayPtr;
for (tracePtr = arrayPtr->tracePtr; tracePtr != NULL;
- tracePtr = active.nextTracePtr) {
+ tracePtr = active.nextTracePtr) {
active.nextTracePtr = tracePtr->nextPtr;
if (!(tracePtr->flags & flags)) {
continue;
@@ -3915,7 +4035,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags)
}
active.varPtr = varPtr;
for (tracePtr = varPtr->tracePtr; tracePtr != NULL;
- tracePtr = active.nextTracePtr) {
+ tracePtr = active.nextTracePtr) {
active.nextTracePtr = tracePtr->nextPtr;
if (!(tracePtr->flags & flags)) {
continue;
@@ -4047,7 +4167,7 @@ ParseSearchId(interp, varPtr, varName, string)
*/
for (searchPtr = varPtr->searchPtr; searchPtr != NULL;
- searchPtr = searchPtr->nextPtr) {
+ searchPtr = searchPtr->nextPtr) {
if (searchPtr->id == id) {
return searchPtr;
}
@@ -4137,7 +4257,7 @@ TclDeleteVars(iPtr, tablePtr)
}
for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL;
- hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr = Tcl_NextHashEntry(&search)) {
varPtr = (Var *) Tcl_GetHashValue(hPtr);
/*
@@ -4187,7 +4307,7 @@ TclDeleteVars(iPtr, tablePtr)
ckfree((char *) tracePtr);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
+ activePtr = activePtr->nextPtr) {
if (activePtr->varPtr == varPtr) {
activePtr->nextTracePtr = NULL;
}
@@ -4311,7 +4431,7 @@ TclDeleteCompiledLocalVars(iPtr, framePtr)
ckfree((char *) tracePtr);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
+ activePtr = activePtr->nextPtr) {
if (activePtr->varPtr == varPtr) {
activePtr->nextTracePtr = NULL;
}
@@ -4381,7 +4501,7 @@ DeleteArray(iPtr, arrayName, varPtr, flags)
DeleteSearches(varPtr);
for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
elPtr = (Var *) Tcl_GetHashValue(hPtr);
if (TclIsVarScalar(elPtr) && (elPtr->value.objPtr != NULL)) {
objPtr = elPtr->value.objPtr;
@@ -4399,7 +4519,7 @@ DeleteArray(iPtr, arrayName, varPtr, flags)
ckfree((char *) tracePtr);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
+ activePtr = activePtr->nextPtr) {
if (activePtr->varPtr == elPtr) {
activePtr->nextTracePtr = NULL;
}
@@ -4493,7 +4613,7 @@ VarErrMsg(interp, part1, part2, operation, reason)
{
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "can't ", operation, " \"", part1,
- (char *) NULL);
+ (char *) NULL);
if (part2 != NULL) {
Tcl_AppendResult(interp, "(", part2, ")", (char *) NULL);
}