summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-07-15 15:53:52 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-07-15 15:53:52 (GMT)
commitd70bdad3a4f08813f469ec8657f35f9096d3f454 (patch)
tree67cbc963e74dcc4f64b4826d78edb41c4da11566 /generic/tclNamesp.c
parent3b6daa4ddbfd2ba80a0c6b58b5736ede11562262 (diff)
downloadtcl-d70bdad3a4f08813f469ec8657f35f9096d3f454.zip
tcl-d70bdad3a4f08813f469ec8657f35f9096d3f454.tar.gz
tcl-d70bdad3a4f08813f469ec8657f35f9096d3f454.tar.bz2
Whitespace/comment tidying
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c1845
1 files changed, 914 insertions, 931 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index f1a86d6..e9a9494 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -21,7 +21,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.78 2005/07/05 17:33:06 dgp Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.79 2005/07/15 15:53:52 dkf Exp $
*/
#include "tclInt.h"
@@ -34,8 +34,8 @@
#define NUM_TRAIL_ELEMS 5
/*
- * Thread-local storage used to avoid having a global lock on data
- * that is not limited to a single interpreter.
+ * Thread-local storage used to avoid having a global lock on data that is not
+ * limited to a single interpreter.
*/
typedef struct ThreadSpecificData {
@@ -53,46 +53,43 @@ typedef struct ThreadSpecificData {
static Tcl_ThreadDataKey dataKey;
/*
- * This structure contains a cached pointer to a namespace that is the
- * result of resolving the namespace's name in some other namespace. It is
- * the internal representation for a nsName object. It contains the
- * pointer along with some information that is used to check the cached
- * pointer's validity.
+ * This structure contains a cached pointer to a namespace that is the result
+ * of resolving the namespace's name in some other namespace. It is the
+ * internal representation for a nsName object. It contains the pointer along
+ * with some information that is used to check the cached pointer's validity.
*/
typedef struct ResolvedNsName {
Namespace *nsPtr; /* A cached namespace pointer. */
- long nsId; /* nsPtr's unique namespace id. Used to
- * verify that nsPtr is still valid
- * (e.g., it's possible that the namespace
- * was deleted and a new one created at
- * the same address). */
+ long nsId; /* nsPtr's unique namespace id. Used to verify
+ * that nsPtr is still valid (e.g., it's
+ * possible that the namespace was deleted and
+ * a new one created at the same address). */
Namespace *refNsPtr; /* Points to the namespace containing the
- * reference (not the namespace that
- * contains the referenced namespace). */
- int refCount; /* Reference count: 1 for each nsName
- * object that has a pointer to this
- * ResolvedNsName structure as its internal
- * rep. This structure can be freed when
- * refCount becomes zero. */
+ * reference (not the namespace that contains
+ * the referenced namespace). */
+ int refCount; /* Reference count: 1 for each nsName object
+ * that has a pointer to this ResolvedNsName
+ * structure as its internal rep. This
+ * structure can be freed when refCount
+ * becomes zero. */
} ResolvedNsName;
/*
- * The client data for an ensemble command. This consists of the
- * table of commands that are actually exported by the namespace, and
- * an epoch counter that, combined with the exportLookupEpoch field of
- * the namespace structure, defines whether the table contains valid
- * data or will need to be recomputed next time the ensemble command
- * is called.
+ * The client data for an ensemble command. This consists of the table of
+ * commands that are actually exported by the namespace, and an epoch counter
+ * that, combined with the exportLookupEpoch field of the namespace structure,
+ * defines whether the table contains valid data or will need to be recomputed
+ * next time the ensemble command is called.
*/
typedef struct EnsembleConfig {
Namespace *nsPtr; /* The namspace backing this ensemble up. */
Tcl_Command token; /* The token for the command that provides
- * ensemble support for the namespace, or
- * NULL if the command has been deleted (or
- * never existed; the global namespace never
- * has an ensemble command.) */
+ * ensemble support for the namespace, or NULL
+ * if the command has been deleted (or never
+ * existed; the global namespace never has an
+ * ensemble command.) */
int epoch; /* The epoch at which this ensemble's table of
* exported commands is valid. */
char **subcommandArrayPtr; /* Array of ensemble subcommand names. At all
@@ -103,14 +100,14 @@ typedef struct EnsembleConfig {
/* Hash table of ensemble subcommand names,
* which are its keys so this also provides
* the storage management for those subcommand
- * names. The contents of the entry values are
- * object version the prefix lists to use when
- * substituting for the command/subcommand to
- * build the ensemble implementation command.
- * Has to be stored here as well as in
- * subcommandDict because that field is NULL
- * when we are deriving the ensemble from the
- * namespace exports list.
+ * names. The contents of the entry values
+ * are object version the prefix lists to use
+ * when substituting for the
+ * command/subcommand to build the ensemble
+ * implementation command. Has to be stored
+ * here as well as in subcommandDict because
+ * that field is NULL when we are deriving the
+ * ensemble from the namespace exports list.
* FUTURE WORK: use object hash table here. */
struct EnsembleConfig *next;/* The next ensemble in the linked list of
* ensembles associated with a namespace. If
@@ -145,19 +142,19 @@ typedef struct EnsembleConfig {
* (including objv[0]) and will have the
* results passed directly back to the caller
* (including the error code) unless the code
- * is TCL_CONTINUE in which case the subcommand
- * will be reparsed by the ensemble core,
- * presumably because the ensemble itself has
- * been updated. */
+ * is TCL_CONTINUE in which case the
+ * subcommand will be reparsed by the ensemble
+ * core, presumably because the ensemble
+ * itself has been updated. */
} EnsembleConfig;
#define ENS_DEAD 0x1 /* Flag value to say that the ensemble is dead
* and on its way out. */
/*
- * The data cached in a subcommand's Tcl_Obj rep. This structure is
- * not shared between Tcl_Objs referring to the same subcommand, even
- * where one is a duplicate of another.
+ * The data cached in a subcommand's Tcl_Obj rep. This structure is not
+ * shared between Tcl_Objs referring to the same subcommand, even where one is
+ * a duplicate of another.
*/
typedef struct EnsembleCmdRep {
@@ -176,7 +173,7 @@ typedef struct EnsembleCmdRep {
} EnsembleCmdRep;
/*
- * Declarations for procedures local to this file:
+ * Declarations for functions local to this file:
*/
static void DeleteImportedCmd _ANSI_ARGS_((ClientData clientData));
@@ -186,10 +183,10 @@ static int DoImport _ANSI_ARGS_((Tcl_Interp *interp,
Namespace *importNsPtr, int allowOverwrite));
static void DupNsNameInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr,
Tcl_Obj *copyPtr));
-static char * ErrorCodeRead _ANSI_ARGS_(( ClientData clientData,
+static char * ErrorCodeRead _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, CONST char *name1,
CONST char *name2, int flags));
-static char * ErrorInfoRead _ANSI_ARGS_(( ClientData clientData,
+static char * ErrorInfoRead _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, CONST char *name1,
CONST char *name2, int flags));
static char * EstablishErrorCodeTraces _ANSI_ARGS_((
@@ -278,10 +275,10 @@ static void SetNsPath _ANSI_ARGS_((Namespace *nsPtr,
int pathLength, Tcl_Namespace *pathAry[]));
/*
- * This structure defines a Tcl object type that contains a
- * namespace reference. It is used in commands that take the
- * name of a namespace as an argument. The namespace reference
- * is resolved, and the result in cached in the object.
+ * This structure defines a Tcl object type that contains a namespace
+ * reference. It is used in commands that take the name of a namespace as an
+ * argument. The namespace reference is resolved, and the result in cached in
+ * the object.
*/
Tcl_ObjType tclNsNameType = {
@@ -293,10 +290,10 @@ Tcl_ObjType tclNsNameType = {
};
/*
- * This structure defines a Tcl object type that contains a reference
- * to an ensemble subcommand (e.g. the "length" in [string length ab])
- * It is used to cache the mapping between the subcommand itself and
- * the real command that implements it.
+ * This structure defines a Tcl object type that contains a reference to an
+ * ensemble subcommand (e.g. the "length" in [string length ab]) It is used to
+ * cache the mapping between the subcommand itself and the real command that
+ * implements it.
*/
static Tcl_ObjType ensembleCmdType = {
@@ -312,8 +309,8 @@ static Tcl_ObjType ensembleCmdType = {
*
* TclInitNamespaceSubsystem --
*
- * This procedure is called to initialize all the structures that
- * are used by namespaces on a per-process basis.
+ * This function is called to initialize all the structures that are used
+ * by namespaces on a per-process basis.
*
* Results:
* None.
@@ -382,8 +379,8 @@ Tcl_GetCurrentNamespace(interp)
Tcl_Namespace *
Tcl_GetGlobalNamespace(interp)
- register Tcl_Interp *interp; /* Interpreter whose global namespace
- * should be returned. */
+ register Tcl_Interp *interp; /* Interpreter whose global namespace should
+ * be returned. */
{
register Interp *iPtr = (Interp *) interp;
@@ -395,9 +392,9 @@ Tcl_GetGlobalNamespace(interp)
*
* Tcl_PushCallFrame --
*
- * Pushes a new call frame onto the interpreter's Tcl call stack.
- * Called when executing a Tcl procedure or a "namespace eval" or
- * "namespace inscope" command.
+ * Pushes a new call frame onto the interpreter's Tcl call stack. Called
+ * when executing a Tcl procedure or a "namespace eval" or "namespace
+ * inscope" command.
*
* Results:
* Returns TCL_OK if successful, or TCL_ERROR (along with an error
@@ -411,31 +408,30 @@ Tcl_GetGlobalNamespace(interp)
int
Tcl_PushCallFrame(interp, callFramePtr, namespacePtr, isProcCallFrame)
- Tcl_Interp *interp; /* Interpreter in which the new call frame
- * is to be pushed. */
- Tcl_CallFrame *callFramePtr; /* Points to a call frame structure to
- * push. Storage for this has already been
- * allocated by the caller; typically this
- * is the address of a CallFrame structure
- * allocated on the caller's C stack. The
+ Tcl_Interp *interp; /* Interpreter in which the new call frame is
+ * to be pushed. */
+ Tcl_CallFrame *callFramePtr; /* Points to a call frame structure to push.
+ * Storage for this has already been
+ * allocated by the caller; typically this is
+ * the address of a CallFrame structure
+ * allocated on the caller's C stack. The
* call frame will be initialized by this
- * procedure. The caller can pop the frame
+ * function. The caller can pop the frame
* later with Tcl_PopCallFrame, and it is
* responsible for freeing the frame's
* storage. */
- Tcl_Namespace *namespacePtr; /* Points to the namespace in which the
- * frame will execute. If NULL, the
- * interpreter's current namespace will
- * be used. */
- int isProcCallFrame; /* If nonzero, the frame represents a
- * called Tcl procedure and may have local
- * vars. Vars will ordinarily be looked up
- * in the frame. If new variables are
- * created, they will be created in the
- * frame. If 0, the frame is for a
- * "namespace eval" or "namespace inscope"
- * command and var references are treated
- * as references to namespace variables. */
+ Tcl_Namespace *namespacePtr; /* Points to the namespace in which the frame
+ * will execute. If NULL, the interpreter's
+ * current namespace will be used. */
+ int isProcCallFrame; /* If nonzero, the frame represents a called
+ * Tcl procedure and may have local vars.
+ * Vars will ordinarily be looked up in the
+ * frame. If new variables are created, they
+ * will be created in the frame. If 0, the
+ * frame is for a "namespace eval" or
+ * "namespace inscope" command and var
+ * references are treated as references to
+ * namespace variables. */
{
Interp *iPtr = (Interp *) interp;
register CallFrame *framePtr = (CallFrame *) callFramePtr;
@@ -469,8 +465,8 @@ Tcl_PushCallFrame(interp, callFramePtr, namespacePtr, isProcCallFrame)
framePtr->compiledLocals = NULL;
/*
- * Push the new call frame onto the interpreter's stack of procedure
- * call frames making it the current frame.
+ * Push the new call frame onto the interpreter's stack of procedure call
+ * frames making it the current frame.
*/
iPtr->framePtr = framePtr;
@@ -491,9 +487,8 @@ Tcl_PushCallFrame(interp, callFramePtr, namespacePtr, isProcCallFrame)
*
* Side effects:
* Modifies the call stack of the interpreter. Resets various fields of
- * the popped call frame. If a namespace has been deleted and
- * has no more activations on the call stack, the namespace is
- * destroyed.
+ * the popped call frame. If a namespace has been deleted and has no more
+ * activations on the call stack, the namespace is destroyed.
*
*----------------------------------------------------------------------
*/
@@ -507,10 +502,9 @@ Tcl_PopCallFrame(interp)
Namespace *nsPtr;
/*
- * It's important to remove the call frame from the interpreter's stack
- * of call frames before deleting local variables, so that traces
- * invoked by the variable deletion don't see the partially-deleted
- * frame.
+ * It's important to remove the call frame from the interpreter's stack of
+ * call frames before deleting local variables, so that traces invoked by
+ * the variable deletion don't see the partially-deleted frame.
*/
iPtr->framePtr = framePtr->callerPtr;
@@ -526,9 +520,9 @@ Tcl_PopCallFrame(interp)
}
/*
- * Decrement the namespace's count of active call frames. If the
- * namespace is "dying" and there are no more active call frames,
- * call Tcl_DeleteNamespace to destroy it.
+ * Decrement the namespace's count of active call frames. If the namespace
+ * is "dying" and there are no more active call frames, call
+ * Tcl_DeleteNamespace to destroy it.
*/
nsPtr = framePtr->nsPtr;
@@ -545,9 +539,8 @@ Tcl_PopCallFrame(interp)
* TclPushStackFrame --
*
* Allocates a new call frame in the interpreter's execution stack, then
- * pushes it onto the interpreter's Tcl call stack.
- * Called when executing a Tcl procedure or a "namespace eval" or
- * "namespace inscope" command.
+ * pushes it onto the interpreter's Tcl call stack. Called when executing
+ * a Tcl procedure or a "namespace eval" or "namespace inscope" command.
*
* Results:
* Returns TCL_OK if successful, or TCL_ERROR (along with an error
@@ -561,27 +554,26 @@ Tcl_PopCallFrame(interp)
int
TclPushStackFrame(interp, framePtrPtr, namespacePtr, isProcCallFrame)
- Tcl_Interp *interp; /* Interpreter in which the new call frame
- * is to be pushed. */
+ Tcl_Interp *interp; /* Interpreter in which the new call frame is
+ * to be pushed. */
Tcl_CallFrame **framePtrPtr; /* Place to store a pointer to the stack
* allocated call frame.*/
- Tcl_Namespace *namespacePtr; /* Points to the namespace in which the
- * frame will execute. If NULL, the
- * interpreter's current namespace will
- * be used. */
- int isProcCallFrame; /* If nonzero, the frame represents a
- * called Tcl procedure and may have local
- * vars. Vars will ordinarily be looked up
- * in the frame. If new variables are
- * created, they will be created in the
- * frame. If 0, the frame is for a
- * "namespace eval" or "namespace inscope"
- * command and var references are treated
- * as references to namespace variables. */
+ Tcl_Namespace *namespacePtr; /* Points to the namespace in which the frame
+ * will execute. If NULL, the interpreter's
+ * current namespace will be used. */
+ int isProcCallFrame; /* If nonzero, the frame represents a called
+ * Tcl procedure and may have local vars.
+ * Vars will ordinarily be looked up in the
+ * frame. If new variables are created, they
+ * will be created in the frame. If 0, the
+ * frame is for a "namespace eval" or
+ * "namespace inscope" command and var
+ * references are treated as references to
+ * namespace variables. */
{
-
*framePtrPtr = (Tcl_CallFrame *) TclStackAlloc(interp, sizeof(CallFrame));
- return Tcl_PushCallFrame(interp, *framePtrPtr, namespacePtr, isProcCallFrame);
+ return Tcl_PushCallFrame(interp, *framePtrPtr, namespacePtr,
+ isProcCallFrame);
}
void
@@ -589,7 +581,7 @@ TclPopStackFrame(interp)
Tcl_Interp* interp; /* Interpreter with call frame to pop. */
{
Tcl_PopCallFrame(interp);
- TclStackFree(interp);
+ TclStackFree(interp);
}
/*
@@ -629,8 +621,8 @@ EstablishErrorCodeTraces(clientData, interp, name1, name2, flags)
*
* ErrorCodeRead --
*
- * Called when the ::errorCode variable is read. Copies the
- * current value of the interp's errorCode field into ::errorCode.
+ * Called when the ::errorCode variable is read. Copies the current value
+ * of the interp's errorCode field into ::errorCode.
*
* Results:
* None.
@@ -651,9 +643,11 @@ ErrorCodeRead(clientData, interp, name1, name2, flags)
{
Interp *iPtr = (Interp *)interp;
- if (flags & TCL_INTERP_DESTROYED) return NULL;
- if (iPtr->errorCode == NULL) return NULL;
- Tcl_ObjSetVar2(interp, iPtr->ecVar, NULL, iPtr->errorCode, TCL_GLOBAL_ONLY);
+ if (flags & TCL_INTERP_DESTROYED || iPtr->errorCode == NULL) {
+ return NULL;
+ }
+ Tcl_ObjSetVar2(interp, iPtr->ecVar, NULL, iPtr->errorCode,
+ TCL_GLOBAL_ONLY);
return NULL;
}
@@ -694,8 +688,8 @@ EstablishErrorInfoTraces(clientData, interp, name1, name2, flags)
*
* ErrorInfoRead --
*
- * Called when the ::errorInfo variable is read. Copies the
- * current value of the interp's errorInfo field into ::errorInfo.
+ * Called when the ::errorInfo variable is read. Copies the current value
+ * of the interp's errorInfo field into ::errorInfo.
*
* Results:
* None.
@@ -716,9 +710,11 @@ ErrorInfoRead(clientData, interp, name1, name2, flags)
{
Interp *iPtr = (Interp *)interp;
- if (flags & TCL_INTERP_DESTROYED) return NULL;
- if (iPtr->errorInfo == NULL) return NULL;
- Tcl_ObjSetVar2(interp, iPtr->eiVar, NULL, iPtr->errorInfo, TCL_GLOBAL_ONLY);
+ if (flags & TCL_INTERP_DESTROYED || iPtr->errorInfo == NULL) {
+ return NULL;
+ }
+ Tcl_ObjSetVar2(interp, iPtr->eiVar, NULL, iPtr->errorInfo,
+ TCL_GLOBAL_ONLY);
return NULL;
}
@@ -727,38 +723,36 @@ ErrorInfoRead(clientData, interp, name1, name2, flags)
*
* Tcl_CreateNamespace --
*
- * Creates a new namespace with the given name. If there is no
- * active namespace (i.e., the interpreter is being initialized),
- * the global :: namespace is created and returned.
+ * Creates a new namespace with the given name. If there is no active
+ * namespace (i.e., the interpreter is being initialized), the global ::
+ * namespace is created and returned.
*
* Results:
- * Returns a pointer to the new namespace if successful. If the
- * namespace already exists or if another error occurs, this routine
- * returns NULL, along with an error message in the interpreter's
- * result object.
+ * Returns a pointer to the new namespace if successful. If the namespace
+ * already exists or if another error occurs, this routine returns NULL,
+ * along with an error message in the interpreter's result object.
*
* Side effects:
- * If the name contains "::" qualifiers and a parent namespace does
- * not already exist, it is automatically created.
+ * If the name contains "::" qualifiers and a parent namespace does not
+ * already exist, it is automatically created.
*
*----------------------------------------------------------------------
*/
Tcl_Namespace *
Tcl_CreateNamespace(interp, name, clientData, deleteProc)
- Tcl_Interp *interp; /* Interpreter in which a new namespace
- * is being created. Also used for
- * error reporting. */
+ Tcl_Interp *interp; /* Interpreter in which a new namespace is
+ * being created. Also used for error
+ * reporting. */
CONST char *name; /* Name for the new namespace. May be a
* qualified name with names of ancestor
* namespaces separated by "::"s. */
ClientData clientData; /* One-word value to store with
* namespace. */
Tcl_NamespaceDeleteProc *deleteProc;
- /* Procedure called to delete client
- * data when the namespace is deleted.
- * NULL if no procedure should be
- * called. */
+ /* Function called to delete client data
+ * when the namespace is deleted. NULL if
+ * no function should be called. */
{
Interp *iPtr = (Interp *) interp;
register Namespace *nsPtr, *ancestorPtr;
@@ -771,14 +765,13 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
- * If there is no active namespace, the interpreter is being
- * initialized.
+ * If there is no active namespace, the interpreter is being initialized.
*/
if ((globalNsPtr == NULL) && (iPtr->varFramePtr == NULL)) {
/*
- * Treat this namespace as the global namespace, and avoid
- * looking for a parent.
+ * Treat this namespace as the global namespace, and avoid looking for
+ * a parent.
*/
parentPtr = NULL;
@@ -799,9 +792,8 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
/*
* If the unqualified name at the end is empty, there were trailing
- * "::"s after the namespace's name which we ignore. The new
- * namespace was already (recursively) created and is pointed to
- * by parentPtr.
+ * "::"s after the namespace's name which we ignore. The new namespace
+ * was already (recursively) created and is pointed to by parentPtr.
*/
if (*simpleName == '\0') {
@@ -809,8 +801,8 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
}
/*
- * Check for a bad namespace name and make sure that the name
- * does not already exist in the parent namespace.
+ * Check for a bad namespace name and make sure that the name does not
+ * already exist in the parent namespace.
*/
if (Tcl_FindHashEntry(&parentPtr->childTable, simpleName) != NULL) {
@@ -821,8 +813,8 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
}
/*
- * Create the new namespace and root it in its parent. Increment the
- * count of namespaces created.
+ * Create the new namespace and root it in its parent. Increment the count
+ * of namespaces created.
*/
nsPtr = (Namespace *) ckalloc(sizeof(Namespace));
@@ -859,10 +851,11 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
&newEntry);
Tcl_SetHashValue(entryPtr, (ClientData) nsPtr);
} else {
- /*
- * In the global namespace create traces to maintain the
- * ::errorInfo and ::errorCode variables.
+ /*
+ * In the global namespace create traces to maintain the ::errorInfo
+ * and ::errorCode variables.
*/
+
iPtr->globalNsPtr = nsPtr;
EstablishErrorInfoTraces(NULL, interp, NULL, NULL, 0);
EstablishErrorCodeTraces(NULL, interp, NULL, NULL, 0);
@@ -913,9 +906,9 @@ Tcl_CreateNamespace(interp, name, clientData, deleteProc)
* None.
*
* Side effects:
- * When a namespace is deleted, it is automatically removed as a
- * child of its parent namespace. Also, all its commands, variables
- * and child namespaces are deleted.
+ * When a namespace is deleted, it is automatically removed as a child of
+ * its parent namespace. Also, all its commands, variables and child
+ * namespaces are deleted.
*
*----------------------------------------------------------------------
*/
@@ -940,8 +933,7 @@ Tcl_DeleteNamespace(namespacePtr)
while (nsPtr->ensembles != NULL) {
/*
- * Splice out and link to indicate that we've already been
- * killed.
+ * Splice out and link to indicate that we've already been killed.
*/
EnsembleConfig *ensemblePtr = (EnsembleConfig *) nsPtr->ensembles;
nsPtr->ensembles = (Tcl_Ensemble *) ensemblePtr->next;
@@ -951,19 +943,19 @@ Tcl_DeleteNamespace(namespacePtr)
/*
* If the namespace is on the call frame stack, it is marked as "dying"
- * (NS_DYING is OR'd into its flags): the namespace can't be looked up
- * by name but its commands and variables are still usable by those
- * active call frames. When all active call frames referring to the
- * namespace have been popped from the Tcl stack, Tcl_PopCallFrame will
- * call this procedure again to delete everything in the namespace.
- * If no nsName objects refer to the namespace (i.e., if its refCount
- * is zero), its commands and variables are deleted and the storage for
- * its namespace structure is freed. Otherwise, if its refCount is
- * nonzero, the namespace's commands and variables are deleted but the
- * structure isn't freed. Instead, NS_DEAD is OR'd into the structure's
- * flags to allow the namespace resolution code to recognize that the
- * namespace is "deleted". The structure's storage is freed by
- * FreeNsNameInternalRep when its refCount reaches 0.
+ * (NS_DYING is OR'd into its flags): the namespace can't be looked up by
+ * name but its commands and variables are still usable by those active
+ * call frames. When all active call frames referring to the namespace
+ * have been popped from the Tcl stack, Tcl_PopCallFrame will call this
+ * function again to delete everything in the namespace. If no nsName
+ * objects refer to the namespace (i.e., if its refCount is zero), its
+ * commands and variables are deleted and the storage for its namespace
+ * structure is freed. Otherwise, if its refCount is nonzero, the
+ * namespace's commands and variables are deleted but the structure isn't
+ * freed. Instead, NS_DEAD is OR'd into the structure's flags to allow the
+ * namespace resolution code to recognize that the namespace is "deleted".
+ * The structure's storage is freed by FreeNsNameInternalRep when its
+ * refCount reaches 0.
*/
if (nsPtr->activationCount > 0) {
@@ -988,9 +980,9 @@ Tcl_DeleteNamespace(namespacePtr)
if ((nsPtr != globalNsPtr) || (iPtr->flags & DELETED)) {
/*
* If this is the global namespace, then it may have residual
- * "errorInfo" and "errorCode" variables for errors that
- * occurred while it was being torn down. Try to clear the
- * variable list one last time.
+ * "errorInfo" and "errorCode" variables for errors that occurred
+ * while it was being torn down. Try to clear the variable list
+ * one last time.
*/
TclDeleteVars((Interp *) nsPtr->interp, &nsPtr->varTable);
@@ -1009,7 +1001,10 @@ Tcl_DeleteNamespace(namespacePtr)
nsPtr->flags |= NS_DEAD;
}
} else {
- /* Restore the ::errorInfo and ::errorCode traces */
+ /*
+ * Restore the ::errorInfo and ::errorCode traces.
+ */
+
EstablishErrorInfoTraces(NULL, nsPtr->interp, NULL, NULL, 0);
EstablishErrorCodeTraces(NULL, nsPtr->interp, NULL, NULL, 0);
}
@@ -1026,7 +1021,7 @@ Tcl_DeleteNamespace(namespacePtr)
* commands, variables, and child namespaces.
*
* This is kept separate from Tcl_DeleteNamespace so that the global
- * namespace can be handled specially.
+ * namespace can be handled specially.
*
* Results:
* None.
@@ -1051,9 +1046,8 @@ TclTeardownNamespace(nsPtr)
int i;
/*
- * Start by destroying the namespace's variable table,
- * since variables might trigger traces.
- * Variable table should be cleared but not freed!
+ * Start by destroying the namespace's variable table, since variables
+ * might trigger traces. Variable table should be cleared but not freed!
* TclDeleteVars frees it, so we reinitialize it afterwards.
*/
@@ -1092,10 +1086,10 @@ TclTeardownNamespace(nsPtr)
/*
* Delete all the child namespaces.
*
- * BE CAREFUL: When each child is deleted, it will divorce
- * itself from its parent. You can't traverse a hash table
- * properly if its elements are being deleted. We use only
- * the Tcl_FirstHashEntry function to be safe.
+ * BE CAREFUL: When each child is deleted, it will divorce itself from its
+ * parent. You can't traverse a hash table properly if its elements are
+ * being deleted. We use only the Tcl_FirstHashEntry function to be
+ * safe.
*
* Don't optimize to Tcl_NextHashEntry() because of traces.
*/
@@ -1149,9 +1143,9 @@ TclTeardownNamespace(nsPtr)
nsPtr->clientData = NULL;
/*
- * Reset the namespace's id field to ensure that this namespace won't
- * be interpreted as valid by, e.g., the cache validation code for
- * cached command references in Tcl_GetCommandFromObj.
+ * Reset the namespace's id field to ensure that this namespace won't be
+ * interpreted as valid by, e.g., the cache validation code for cached
+ * command references in Tcl_GetCommandFromObj.
*/
nsPtr->nsId = 0;
@@ -1162,9 +1156,8 @@ TclTeardownNamespace(nsPtr)
*
* NamespaceFree --
*
- * Called after a namespace has been deleted, when its
- * reference count reaches 0. Frees the data structure
- * representing the namespace.
+ * Called after a namespace has been deleted, when its reference count
+ * reaches 0. Frees the data structure representing the namespace.
*
* Results:
* None.
@@ -1197,10 +1190,10 @@ NamespaceFree(nsPtr)
* Tcl_Export --
*
* Makes all the commands matching a pattern available to later be
- * imported from the namespace specified by namespacePtr (or the
- * current namespace if namespacePtr is NULL). The specified pattern is
- * appended onto the namespace's export pattern list, which is
- * optionally cleared beforehand.
+ * imported from the namespace specified by namespacePtr (or the current
+ * namespace if namespacePtr is NULL). The specified pattern is appended
+ * onto the namespace's export pattern list, which is optionally cleared
+ * beforehand.
*
* Results:
* Returns TCL_OK if successful, or TCL_ERROR (along with an error
@@ -1216,18 +1209,18 @@ NamespaceFree(nsPtr)
int
Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
Tcl_Interp *interp; /* Current interpreter. */
- Tcl_Namespace *namespacePtr; /* Points to the namespace from which
- * commands are to be exported. NULL for
- * the current namespace. */
+ Tcl_Namespace *namespacePtr; /* Points to the namespace from which
+ * commands are to be exported. NULL for the
+ * current namespace. */
CONST char *pattern; /* String pattern indicating which commands
* to export. This pattern may not include
- * any namespace qualifiers; only commands
- * in the specified namespace may be
+ * any namespace qualifiers; only commands in
+ * the specified namespace may be
* exported. */
- int resetListFirst; /* If nonzero, resets the namespace's
- * export list before appending. */
+ int resetListFirst; /* If nonzero, resets the namespace's export
+ * list before appending. */
{
-#define INIT_EXPORT_PATTERNS 5
+#define INIT_EXPORT_PATTERNS 5
Namespace *nsPtr, *exportNsPtr, *dummyPtr;
Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
CONST char *simplePattern;
@@ -1279,6 +1272,7 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
/*
* Make sure that we don't already have the pattern in the array
*/
+
if (nsPtr->exportArrayPtr != NULL) {
for (i = 0; i < nsPtr->numExportPatterns; i++) {
if (strcmp(pattern, nsPtr->exportArrayPtr[i]) == 0) {
@@ -1291,8 +1285,8 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
}
/*
- * Make sure there is room in the namespace's pattern array for the
- * new pattern.
+ * Make sure there is room in the namespace's pattern array for the new
+ * pattern.
*/
neededElems = nsPtr->numExportPatterns + 1;
@@ -1325,10 +1319,9 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
nsPtr->numExportPatterns++;
/*
- * The list of commands actually exported from the namespace might
- * have changed (probably will have!) However, we do not need to
- * recompute this just yet; next time we need the info will be
- * soon enough.
+ * The list of commands actually exported from the namespace might have
+ * changed (probably will have!) However, we do not need to recompute
+ * this just yet; next time we need the info will be soon enough.
*/
TclInvalidateNsCmdLookup(nsPtr);
@@ -1348,12 +1341,12 @@ Tcl_Export(interp, namespacePtr, pattern, resetListFirst)
* Results:
* The return value is normally TCL_OK; in this case the object
* referenced by objPtr has each export pattern appended to it. If an
- * error occurs, TCL_ERROR is returned and the interpreter's result
- * holds an error message.
+ * error occurs, TCL_ERROR is returned and the interpreter's result holds
+ * an error message.
*
* Side effects:
- * If necessary, the object referenced by objPtr is converted into
- * a list object.
+ * If necessary, the object referenced by objPtr is converted into a list
+ * object.
*
*----------------------------------------------------------------------
*/
@@ -1400,22 +1393,22 @@ Tcl_AppendExportList(interp, namespacePtr, objPtr)
* Tcl_Import --
*
* Imports all of the commands matching a pattern into the namespace
- * specified by namespacePtr (or the current namespace if contextNsPtr
- * is NULL). This is done by creating a new command (the "imported
- * command") that points to the real command in its original namespace.
+ * specified by namespacePtr (or the current namespace if contextNsPtr is
+ * NULL). This is done by creating a new command (the "imported command")
+ * that points to the real command in its original namespace.
*
- * If matching commands are on the autoload path but haven't been
- * loaded yet, this command forces them to be loaded, then creates
- * the links to them.
+ * If matching commands are on the autoload path but haven't been loaded
+ * yet, this command forces them to be loaded, then creates the links to
+ * them.
*
* Results:
* Returns TCL_OK if successful, or TCL_ERROR (along with an error
* message in the interpreter's result) if something goes wrong.
*
* Side effects:
- * Creates new commands in the importing namespace. These indirect
- * calls back to the real command and are deleted if the real commands
- * are deleted.
+ * Creates new commands in the importing namespace. These indirect calls
+ * back to the real command and are deleted if the real commands are
+ * deleted.
*
*----------------------------------------------------------------------
*/
@@ -1424,16 +1417,16 @@ int
Tcl_Import(interp, namespacePtr, pattern, allowOverwrite)
Tcl_Interp *interp; /* Current interpreter. */
Tcl_Namespace *namespacePtr; /* Points to the namespace into which the
- * commands are to be imported. NULL for
- * the current namespace. */
+ * commands are to be imported. NULL for the
+ * current namespace. */
CONST char *pattern; /* String pattern indicating which commands
* to import. This pattern should be
* qualified by the name of the namespace
* from which to import the command(s). */
- int allowOverwrite; /* If nonzero, allow existing commands to
- * be overwritten by imported commands.
- * If 0, return an error if an imported
- * cmd conflicts with an existing one. */
+ int allowOverwrite; /* If nonzero, allow existing commands to be
+ * overwritten by imported commands. If 0,
+ * return an error if an imported cmd
+ * conflicts with an existing one. */
{
Namespace *nsPtr, *importNsPtr, *dummyPtr;
CONST char *simplePattern;
@@ -1451,14 +1444,13 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite)
}
/*
- * First, invoke the "auto_import" command with the pattern
- * being imported. This command is part of the Tcl library.
- * It looks for imported commands in autoloaded libraries and
- * loads them in. That way, they will be found when we try
- * to create links below.
+ * First, invoke the "auto_import" command with the pattern being
+ * imported. This command is part of the Tcl library. It looks for
+ * imported commands in autoloaded libraries and loads them in. That way,
+ * they will be found when we try to create links below.
*
- * Note that we don't just call Tcl_EvalObjv() directly because we
- * do not want absence of the command to be a failure case.
+ * Note that we don't just call Tcl_EvalObjv() directly because we do not
+ * want absence of the command to be a failure case.
*/
if (Tcl_FindCommand(interp,"auto_import",NULL,TCL_GLOBAL_ONLY) != NULL) {
@@ -1481,9 +1473,8 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite)
}
/*
- * From the pattern, find the namespace from which we are importing
- * and get the simple pattern (no namespace qualifiers or ::'s) at
- * the end.
+ * From the pattern, find the namespace from which we are importing and
+ * get the simple pattern (no namespace qualifiers or ::'s) at the end.
*/
if (strlen(pattern) == 0) {
@@ -1530,9 +1521,9 @@ Tcl_Import(interp, namespacePtr, pattern, allowOverwrite)
for (hPtr = Tcl_FirstHashEntry(&importNsPtr->cmdTable, &search);
(hPtr != NULL); hPtr = Tcl_NextHashEntry(&search)) {
char *cmdName = Tcl_GetHashKey(&importNsPtr->cmdTable, hPtr);
- if (Tcl_StringMatch(cmdName, simplePattern)
- && (TCL_ERROR == DoImport( interp, nsPtr, hPtr, cmdName,
- pattern, importNsPtr, allowOverwrite))) {
+ if (Tcl_StringMatch(cmdName, simplePattern) &&
+ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr,
+ allowOverwrite) == TCL_ERROR) {
return TCL_ERROR;
}
}
@@ -1553,9 +1544,8 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
Tcl_HashEntry *found;
/*
- * The command cmdName in the source namespace matches the
- * pattern. Check whether it was exported. If it wasn't,
- * we ignore it.
+ * The command cmdName in the source namespace matches the pattern. Check
+ * whether it was exported. If it wasn't, we ignore it.
*/
while (!exported && (i < importNsPtr->numExportPatterns)) {
@@ -1566,16 +1556,16 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
}
/*
- * Unless there is a name clash, create an imported command
- * in the current namespace that refers to cmdPtr.
+ * Unless there is a name clash, create an imported command in the current
+ * namespace that refers to cmdPtr.
*/
found = Tcl_FindHashEntry(&nsPtr->cmdTable, cmdName);
if ((found == NULL) || allowOverwrite) {
/*
- * Create the imported command and its client data.
- * To create the new command in the current namespace,
- * generate a fully qualified name for it.
+ * Create the imported command and its client data. To create the new
+ * command in the current namespace, generate a fully qualified name
+ * for it.
*/
Tcl_DString ds;
@@ -1592,9 +1582,8 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
Tcl_DStringAppend(&ds, cmdName, -1);
/*
- * Check whether creating the new imported command in the
- * current namespace would create a cycle of imported
- * command references.
+ * Check whether creating the new imported command in the current
+ * namespace would create a cycle of imported command references.
*/
cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
@@ -1608,11 +1597,9 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
dataPtr = (ImportedCmdData *) link->objClientData;
link = dataPtr->realCmdPtr;
if (overwrite == link) {
- Tcl_AppendResult(interp, "import pattern \"",
- pattern,
- "\" would create a loop containing ",
- "command \"", Tcl_DStringValue(&ds),
- "\"", (char *) NULL);
+ Tcl_AppendResult(interp, "import pattern \"", pattern,
+ "\" would create a loop containing command \"",
+ Tcl_DStringValue(&ds), "\"", (char *) NULL);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
@@ -1620,18 +1607,16 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
}
dataPtr = (ImportedCmdData *) ckalloc(sizeof(ImportedCmdData));
- importedCmd = Tcl_CreateObjCommand(interp,
- Tcl_DStringValue(&ds), InvokeImportedCmd,
- (ClientData) dataPtr, DeleteImportedCmd);
+ importedCmd = Tcl_CreateObjCommand(interp, Tcl_DStringValue(&ds),
+ InvokeImportedCmd, (ClientData) dataPtr, DeleteImportedCmd);
dataPtr->realCmdPtr = cmdPtr;
dataPtr->selfPtr = (Command *) importedCmd;
dataPtr->selfPtr->compileProc = cmdPtr->compileProc;
Tcl_DStringFree(&ds);
/*
- * Create an ImportRef structure describing this new import
- * command and add it to the import ref list in the "real"
- * command.
+ * Create an ImportRef structure describing this new import command
+ * and add it to the import ref list in the "real" command.
*/
refPtr = (ImportRef *) ckalloc(sizeof(ImportRef));
@@ -1640,9 +1625,10 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
cmdPtr->importRefPtr = refPtr;
} else {
Command *overwrite = (Command *) Tcl_GetHashValue(found);
+
if (overwrite->deleteProc == DeleteImportedCmd) {
- ImportedCmdData *dataPtr =
- (ImportedCmdData *) overwrite->objClientData;
+ ImportedCmdData *dataPtr = (ImportedCmdData *)
+ overwrite->objClientData;
if (dataPtr->realCmdPtr == (Command *) Tcl_GetHashValue(hPtr)) {
/* Repeated import of same command -- acceptable */
return TCL_OK;
@@ -1660,25 +1646,24 @@ DoImport(interp, nsPtr, hPtr, cmdName, pattern, importNsPtr, allowOverwrite)
*
* Tcl_ForgetImport --
*
- * Deletes commands previously imported into the namespace indicated. The
- * by namespacePtr, or the current namespace of interp, when
+ * Deletes commands previously imported into the namespace indicated.
+ * The by namespacePtr, or the current namespace of interp, when
* namespacePtr is NULL. The pattern controls which imported commands
- * are deleted. A simple pattern, one without namespace separators,
+ * are deleted. A simple pattern, one without namespace separators,
* matches the current command names of imported commands in the
- * namespace. Matching imported commands are deleted. A qualified
- * pattern is interpreted as deletion selection on the basis of where
- * the command is imported from. The original command and "first link"
- * command for each imported command are determined, and they are matched
- * against the pattern. A match leads to deletion of the imported
- * command.
+ * namespace. Matching imported commands are deleted. A qualified pattern
+ * is interpreted as deletion selection on the basis of where the command
+ * is imported from. The original command and "first link" command for
+ * each imported command are determined, and they are matched against the
+ * pattern. A match leads to deletion of the imported command.
*
* Results:
- * Returns TCL_ERROR and records an error message in the interp
- * result if a namespace qualified pattern refers to a namespace
- * that does not exist. Otherwise, returns TCL_OK.
+ * Returns TCL_ERROR and records an error message in the interp result if
+ * a namespace qualified pattern refers to a namespace that does not
+ * exist. Otherwise, returns TCL_OK.
*
* Side effects:
- * May delete commands.
+ * May delete commands.
*
*----------------------------------------------------------------------
*/
@@ -1709,8 +1694,8 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
}
/*
- * Parse the pattern into its namespace-qualification (if any)
- * and the simple pattern.
+ * Parse the pattern into its namespace-qualification (if any) and the
+ * simple pattern.
*/
TclGetNamespaceForQualName(interp, pattern, nsPtr,
@@ -1726,8 +1711,7 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
if (strcmp(pattern, simplePattern) == 0) {
/*
- * The pattern is simple.
- * Delete any imported commands that match it.
+ * The pattern is simple. Delete any imported commands that match it.
*/
if (TclMatchIsTrivial(simplePattern)) {
@@ -1741,8 +1725,7 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
return TCL_OK;
}
for (hPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
- (hPtr != NULL);
- hPtr = Tcl_NextHashEntry(&search)) {
+ (hPtr != NULL); hPtr = Tcl_NextHashEntry(&search)) {
Command *cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
if (cmdPtr->deleteProc != DeleteImportedCmd) {
continue;
@@ -1755,7 +1738,9 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
return TCL_OK;
}
- /* The pattern was namespace-qualified */
+ /*
+ * The pattern was namespace-qualified.
+ */
for (hPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search); (hPtr != NULL);
hPtr = Tcl_NextHashEntry(&search)) {
@@ -1764,13 +1749,14 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
Tcl_Command origin = TclGetOriginalCommand(token);
if (Tcl_GetCommandInfoFromToken(origin, &info) == 0) {
- continue; /* Not an imported command */
+ continue; /* Not an imported command */
}
if (info.namespacePtr != (Tcl_Namespace *) sourceNsPtr) {
/*
- * Original not in namespace we're matching.
- * Check the first link in the import chain.
+ * Original not in namespace we're matching. Check the first link
+ * in the import chain.
*/
+
Command *cmdPtr = (Command *) token;
ImportedCmdData *dataPtr =
(ImportedCmdData *) cmdPtr->objClientData;
@@ -1798,15 +1784,15 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
*
* An imported command is created in an namespace when a "real" command
* is imported from another namespace. If the specified command is an
- * imported command, this procedure returns the original command it
- * refers to.
+ * imported command, this function returns the original command it refers
+ * to.
*
* Results:
* If the command was imported into a sequence of namespaces a, b,...,n
* where each successive namespace just imports the command from the
- * previous namespace, this procedure returns the Tcl_Command token in
- * the first namespace, a. Otherwise, if the specified command is not
- * an imported command, the procedure returns NULL.
+ * previous namespace, this function returns the Tcl_Command token in the
+ * first namespace, a. Otherwise, if the specified command is not an
+ * imported command, the function returns NULL.
*
* Side effects:
* None.
@@ -1816,8 +1802,8 @@ Tcl_ForgetImport(interp, namespacePtr, pattern)
Tcl_Command
TclGetOriginalCommand(command)
- Tcl_Command command; /* The imported command for which the
- * original command should be returned. */
+ Tcl_Command command; /* The imported command for which the original
+ * command should be returned. */
{
register Command *cmdPtr = (Command *) command;
ImportedCmdData *dataPtr;
@@ -1838,16 +1824,16 @@ TclGetOriginalCommand(command)
*
* InvokeImportedCmd --
*
- * Invoked by Tcl whenever the user calls an imported command that
- * was created by Tcl_Import. Finds the "real" command (in another
+ * Invoked by Tcl whenever the user calls an imported command that was
+ * created by Tcl_Import. Finds the "real" command (in another
* namespace), and passes control to it.
*
* Results:
- * Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
+ * Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result object is set to an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result object is set to an error message.
*
*----------------------------------------------------------------------
*/
@@ -1873,11 +1859,11 @@ InvokeImportedCmd(clientData, interp, objc, objv)
* DeleteImportedCmd --
*
* Invoked by Tcl whenever an imported command is deleted. The "real"
- * command keeps a list of all the imported commands that refer to it,
- * so those imported commands can be deleted when the real command is
- * deleted. This procedure removes the imported command reference from
- * the real command's list, and frees up the memory associated with
- * the imported command.
+ * command keeps a list of all the imported commands that refer to it, so
+ * those imported commands can be deleted when the real command is
+ * deleted. This function removes the imported command reference from the
+ * real command's list, and frees up the memory associated with the
+ * imported command.
*
* Results:
* None.
@@ -1928,70 +1914,70 @@ DeleteImportedCmd(clientData)
* TclGetNamespaceForQualName --
*
* Given a qualified name specifying a command, variable, or namespace,
- * and a namespace in which to resolve the name, this procedure returns
- * a pointer to the namespace that contains the item. A qualified name
- * consists of the "simple" name of an item qualified by the names of
- * an arbitrary number of containing namespace separated by "::"s. If
- * the qualified name starts with "::", it is interpreted absolutely
- * from the global namespace. Otherwise, it is interpreted relative to
- * the namespace specified by cxtNsPtr if it is non-NULL. If cxtNsPtr
- * is NULL, the name is interpreted relative to the current namespace.
- *
- * A relative name like "foo::bar::x" can be found starting in either
- * the current namespace or in the global namespace. So each search
- * usually follows two tracks, and two possible namespaces are
- * returned. If the procedure sets either *nsPtrPtr or *altNsPtrPtr to
- * NULL, then that path failed.
+ * and a namespace in which to resolve the name, this function returns a
+ * pointer to the namespace that contains the item. A qualified name
+ * consists of the "simple" name of an item qualified by the names of an
+ * arbitrary number of containing namespace separated by "::"s. If the
+ * qualified name starts with "::", it is interpreted absolutely from the
+ * global namespace. Otherwise, it is interpreted relative to the
+ * namespace specified by cxtNsPtr if it is non-NULL. If cxtNsPtr is
+ * NULL, the name is interpreted relative to the current namespace.
+ *
+ * A relative name like "foo::bar::x" can be found starting in either the
+ * current namespace or in the global namespace. So each search usually
+ * follows two tracks, and two possible namespaces are returned. If the
+ * function sets either *nsPtrPtr or *altNsPtrPtr to NULL, then that path
+ * failed.
*
* If "flags" contains TCL_GLOBAL_ONLY, the relative qualified name is
- * sought only in the global :: namespace. The alternate search
- * (also) starting from the global namespace is ignored and
- * *altNsPtrPtr is set NULL.
- *
- * If "flags" contains TCL_NAMESPACE_ONLY, the relative qualified
- * name is sought only in the namespace specified by cxtNsPtr. The
- * alternate search starting from the global namespace is ignored and
- * *altNsPtrPtr is set NULL. If both TCL_GLOBAL_ONLY and
- * TCL_NAMESPACE_ONLY are specified, TCL_GLOBAL_ONLY is ignored and
- * the search starts from the namespace specified by cxtNsPtr.
- *
- * If "flags" contains TCL_CREATE_NS_IF_UNKNOWN, all namespace
- * components of the qualified name that cannot be found are
- * automatically created within their specified parent. This makes sure
- * that functions like Tcl_CreateCommand always succeed. There is no
- * alternate search path, so *altNsPtrPtr is set NULL.
- *
- * If "flags" contains TCL_FIND_ONLY_NS, the qualified name is treated as a
- * reference to a namespace, and the entire qualified name is
- * followed. If the name is relative, the namespace is looked up only
- * in the current namespace. A pointer to the namespace is stored in
- * *nsPtrPtr and NULL is stored in *simpleNamePtr. Otherwise, if
- * TCL_FIND_ONLY_NS is not specified, only the leading components are
- * treated as namespace names, and a pointer to the simple name of the
- * final component is stored in *simpleNamePtr.
+ * sought only in the global :: namespace. The alternate search (also)
+ * starting from the global namespace is ignored and *altNsPtrPtr is set
+ * NULL.
+ *
+ * If "flags" contains TCL_NAMESPACE_ONLY, the relative qualified name is
+ * sought only in the namespace specified by cxtNsPtr. The alternate
+ * search starting from the global namespace is ignored and *altNsPtrPtr
+ * is set NULL. If both TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY are
+ * specified, TCL_GLOBAL_ONLY is ignored and the search starts from the
+ * namespace specified by cxtNsPtr.
+ *
+ * If "flags" contains TCL_CREATE_NS_IF_UNKNOWN, all namespace components
+ * of the qualified name that cannot be found are automatically created
+ * within their specified parent. This makes sure that functions like
+ * Tcl_CreateCommand always succeed. There is no alternate search path,
+ * so *altNsPtrPtr is set NULL.
+ *
+ * If "flags" contains TCL_FIND_ONLY_NS, the qualified name is treated as
+ * a reference to a namespace, and the entire qualified name is followed.
+ * If the name is relative, the namespace is looked up only in the
+ * current namespace. A pointer to the namespace is stored in *nsPtrPtr
+ * and NULL is stored in *simpleNamePtr. Otherwise, if TCL_FIND_ONLY_NS
+ * is not specified, only the leading components are treated as namespace
+ * names, and a pointer to the simple name of the final component is
+ * stored in *simpleNamePtr.
*
* Results:
* 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
+ * qualified name. If the function sets either *nsPtrPtr or *altNsPtrPtr
+ * to NULL, then the search along that path failed. The function 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 (TCL_FIND_ONLY_NS), the procedure stores a pointer
+ * namespace reference (TCL_FIND_ONLY_NS), the function 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"
+ * If there is an error, this function returns TCL_ERROR. If "flags"
* contains TCL_LEAVE_ERR_MSG, an error message is returned in the
* interpreter's result object. Otherwise, the interpreter's result
* object is left unchanged.
*
- * *actualCxtPtrPtr is set to the actual context namespace. It is
- * set to the input context namespace pointer in cxtNsPtr. If cxtNsPtr
- * is NULL, it is set to the current namespace context.
+ * *actualCxtPtrPtr is set to the actual context namespace. It is 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.
+ * For backwards compatibility with the TclPro byte code loader, this
+ * function always returns TCL_OK.
*
* Side effects:
* If "flags" contains TCL_CREATE_NS_IF_UNKNOWN, new namespaces may be
@@ -2003,42 +1989,42 @@ DeleteImportedCmd(clientData)
int
TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
nsPtrPtr, altNsPtrPtr, actualCxtPtrPtr, simpleNamePtr)
- Tcl_Interp *interp; /* Interpreter in which to find the
- * namespace containing qualName. */
- CONST char *qualName; /* A namespace-qualified name of an
- * command, variable, or namespace. */
- Namespace *cxtNsPtr; /* The namespace in which to start the
- * search for qualName's namespace. If NULL
- * start from the current namespace.
- * Ignored if TCL_GLOBAL_ONLY is set. */
+ Tcl_Interp *interp; /* Interpreter in which to find the namespace
+ * containing qualName. */
+ CONST char *qualName; /* A namespace-qualified name of an command,
+ * variable, or namespace. */
+ Namespace *cxtNsPtr; /* The namespace in which to start the search
+ * for qualName's namespace. If NULL start
+ * from the current namespace. Ignored if
+ * TCL_GLOBAL_ONLY is set. */
int flags; /* Flags controlling the search: an OR'd
* combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY,
* TCL_CREATE_NS_IF_UNKNOWN, and
* TCL_FIND_ONLY_NS. */
- Namespace **nsPtrPtr; /* Address where procedure stores a pointer
- * to containing namespace if qualName is
- * found starting from *cxtNsPtr or, if
+ Namespace **nsPtrPtr; /* Address where function stores a pointer to
+ * containing namespace if qualName is found
+ * starting from *cxtNsPtr or, if
* TCL_GLOBAL_ONLY is set, if qualName is
- * found in the global :: namespace. NULL
- * is stored otherwise. */
- Namespace **altNsPtrPtr; /* Address where procedure stores a pointer
- * to containing namespace if qualName is
- * found starting from the global ::
- * namespace. NULL is stored if qualName
- * isn't found starting from :: or if the
+ * found in the global :: namespace. NULL is
+ * stored otherwise. */
+ Namespace **altNsPtrPtr; /* Address where function stores a pointer to
+ * containing namespace if qualName is found
+ * starting from the global :: namespace.
+ * NULL is stored if qualName isn't found
+ * starting from :: or if the
* TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_CREATE_NS_IF_UNKNOWN, TCL_FIND_ONLY_NS
* flag is set. */
- Namespace **actualCxtPtrPtr; /* Address where procedure stores a pointer
- * to the actual namespace from which the
- * search started. This is either cxtNsPtr,
- * the :: namespace if TCL_GLOBAL_ONLY was
+ Namespace **actualCxtPtrPtr; /* Address where function stores a pointer to
+ * the actual namespace from which the search
+ * started. This is either cxtNsPtr, the ::
+ * namespace if TCL_GLOBAL_ONLY was
* specified, or the current namespace if
* cxtNsPtr was NULL. */
- CONST char **simpleNamePtr; /* Address where procedure stores the
- * simple name at end of the qualName, or
- * NULL if qualName is "::" or the flag
+ CONST char **simpleNamePtr; /* Address where function stores the simple
+ * name at end of the qualName, or NULL if
+ * qualName is "::" or the flag
* TCL_FIND_ONLY_NS was specified. */
{
Interp *iPtr = (Interp *) interp;
@@ -2053,11 +2039,11 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
/*
* Determine the context namespace nsPtr in which to start the primary
- * search. If the qualName name starts with a "::" or TCL_GLOBAL_ONLY
- * was specified, search from the global namespace. Otherwise, use the
+ * search. If the qualName name starts with a "::" or TCL_GLOBAL_ONLY was
+ * specified, search from the global namespace. Otherwise, use the
* namespace given in cxtNsPtr, or if that is NULL, use the current
- * namespace context. Note that we always treat two or more
- * adjacent ":"s as a namespace separator.
+ * namespace context. Note that we always treat two or more adjacent ":"s
+ * as a namespace separator.
*/
if (flags & TCL_GLOBAL_ONLY) {
@@ -2108,10 +2094,10 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
end = start;
while (*start != '\0') {
/*
- * Find the next namespace qualifier (i.e., a name ending in "::")
- * or the end of the qualified name (i.e., a name ending in "\0").
- * Set len to the number of characters, starting from start,
- * in the name; set end to point after the "::"s or at the "\0".
+ * Find the next namespace qualifier (i.e., a name ending in "::") or
+ * the end of the qualified name (i.e., a name ending in "\0"). Set
+ * len to the number of characters, starting from start, in the name;
+ * set end to point after the "::"s or at the "\0".
*/
len = 0;
@@ -2129,8 +2115,8 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
if (*end=='\0' && !(end-start>=2 && *(end-1)==':' && *(end-2)==':')) {
/*
* qualName ended with a simple name at start. If TCL_FIND_ONLY_NS
- * was specified, look this up as a namespace. Otherwise,
- * start is the name of a cmd or var and we are done.
+ * was specified, look this up as a namespace. Otherwise, start is
+ * the name of a cmd or var and we are done.
*/
if (flags & TCL_FIND_ONLY_NS) {
@@ -2146,9 +2132,9 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
/*
* start points to the beginning of a namespace qualifier ending
* in "::". end points to the start of a name in that namespace
- * that might be empty. Copy the namespace qualifier to a
- * buffer so it can be null terminated. We can't modify the
- * incoming qualName since it may be a string constant.
+ * that might be empty. Copy the namespace qualifier to a buffer
+ * so it can be null terminated. We can't modify the incoming
+ * qualName since it may be a string constant.
*/
Tcl_DStringSetLength(&buffer, 0);
@@ -2159,8 +2145,8 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
/*
* Look up the namespace qualifier nsName in the current namespace
* context. If it isn't found but TCL_CREATE_NS_IF_UNKNOWN is set,
- * create that qualifying namespace. This is needed for procedures
- * like Tcl_CreateCommand that cannot fail.
+ * create that qualifying namespace. This is needed for functions like
+ * Tcl_CreateCommand that cannot fail.
*/
if (nsPtr != NULL) {
@@ -2225,10 +2211,10 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
}
/*
- * As a special case, if we are looking for a namespace and qualName
- * is "" and the current active namespace (nsPtr) is not the global
- * namespace, return NULL (no namespace was found). This is because
- * namespaces can not have empty names except for the global namespace.
+ * As a special case, if we are looking for a namespace and qualName is ""
+ * and the current active namespace (nsPtr) is not the global namespace,
+ * return NULL (no namespace was found). This is because namespaces can
+ * not have empty names except for the global namespace.
*/
if ((flags & TCL_FIND_ONLY_NS) && (*qualName == '\0')
@@ -2250,9 +2236,9 @@ TclGetNamespaceForQualName(interp, qualName, cxtNsPtr, flags,
* Searches for a namespace.
*
* Results:
- * Returns a pointer to the namespace if it is found. Otherwise,
- * returns NULL and leaves an error message in the interpreter's
- * result object if "flags" contains TCL_LEAVE_ERR_MSG.
+ * Returns a pointer to the namespace if it is found. Otherwise, returns
+ * NULL and leaves an error message in the interpreter's result object if
+ * "flags" contains TCL_LEAVE_ERR_MSG.
*
* Side effects:
* None.
@@ -2269,11 +2255,11 @@ Tcl_FindNamespace(interp, name, contextNsPtr, flags)
* Else, looked up first in contextNsPtr
* (current namespace if contextNsPtr is
* NULL), then in global namespace. */
- Tcl_Namespace *contextNsPtr; /* Ignored if TCL_GLOBAL_ONLY flag is set
- * or if the name starts with "::".
- * Otherwise, points to namespace in which
- * to resolve name; if NULL, look up name
- * in the current namespace. */
+ Tcl_Namespace *contextNsPtr; /* Ignored if TCL_GLOBAL_ONLY flag is set or
+ * if the name starts with "::". Otherwise,
+ * points to namespace in which to resolve
+ * name; if NULL, look up name in the current
+ * namespace. */
register int flags; /* Flags controlling namespace lookup: an
* OR'd combination of TCL_GLOBAL_ONLY and
* TCL_LEAVE_ERR_MSG flags. */
@@ -2282,9 +2268,9 @@ Tcl_FindNamespace(interp, name, contextNsPtr, flags)
CONST char *dummy;
/*
- * Find the namespace(s) that contain the specified namespace name.
- * Add the TCL_FIND_ONLY_NS flag to resolve the name all the way down
- * to its last component, a namespace.
+ * Find the namespace(s) that contain the specified namespace name. Add
+ * the TCL_FIND_ONLY_NS flag to resolve the name all the way down to its
+ * last component, a namespace.
*/
TclGetNamespaceForQualName(interp, name, (Namespace *) contextNsPtr,
@@ -2308,10 +2294,10 @@ Tcl_FindNamespace(interp, name, contextNsPtr, flags)
* Searches for a command.
*
* Results:
- * Returns a token for the command if it is found. Otherwise, if it
- * can't be found or there is an error, returns NULL and leaves an
- * error message in the interpreter's result object if "flags"
- * contains TCL_LEAVE_ERR_MSG.
+ * Returns a token for the command if it is found. Otherwise, if it can't
+ * be found or there is an error, returns NULL and leaves an error
+ * message in the interpreter's result object if "flags" contains
+ * TCL_LEAVE_ERR_MSG.
*
* Side effects:
* None.
@@ -2329,18 +2315,17 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
* (current namespace if contextNsPtr is
* NULL), then in global namespace. */
Tcl_Namespace *contextNsPtr; /* Ignored if TCL_GLOBAL_ONLY flag set.
- * Otherwise, points to namespace in which
- * to resolve name. If NULL, look up name
- * in the current namespace. */
+ * Otherwise, points to namespace in which to
+ * resolve name. If NULL, look up name in the
+ * current namespace. */
int flags; /* An OR'd combination of flags:
* TCL_GLOBAL_ONLY (look up name only in
* global namespace), TCL_NAMESPACE_ONLY
* (look up only in contextNsPtr, or the
* current namespace if contextNsPtr is
* NULL), and TCL_LEAVE_ERR_MSG. If both
- * TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY
- * are given, TCL_GLOBAL_ONLY is
- * ignored. */
+ * TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY are
+ * given, TCL_GLOBAL_ONLY is ignored. */
{
Interp *iPtr = (Interp*)interp;
Namespace *cxtNsPtr;
@@ -2350,12 +2335,13 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
int result;
/*
- * If this namespace has a command resolver, then give it first
- * crack at the command resolution. If the interpreter has any
- * command resolvers, consult them next. The command resolver
- * procedures may return a Tcl_Command value, they may signal
- * to continue onward, or they may signal an error.
+ * If this namespace has a command resolver, then give it first crack at
+ * the command resolution. If the interpreter has any command resolvers,
+ * consult them next. The command resolver functions may return a
+ * Tcl_Command value, they may signal to continue onward, or they may
+ * signal an error.
*/
+
if (flags & TCL_GLOBAL_ONLY) {
cxtNsPtr = (Namespace *) Tcl_GetGlobalNamespace(interp);
} else if (contextNsPtr != NULL) {
@@ -2430,8 +2416,8 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
}
/*
- * If we've still not found the command, look in the global
- * namespace as a last resort.
+ * If we've still not found the command, look in the global namespace
+ * as a last resort.
*/
if (cmdPtr == NULL) {
@@ -2453,9 +2439,9 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName);
/*
- * Look for the command in the command table of its namespace.
- * Be sure to check both possible search paths: from the
- * specified namespace context and from the global namespace.
+ * Look for the command in the command table of its namespace. Be sure
+ * to check both possible search paths: from the specified namespace
+ * context and from the global namespace.
*/
for (search = 0; (search < 2) && (cmdPtr == NULL); search++) {
@@ -2487,14 +2473,14 @@ Tcl_FindCommand(interp, name, contextNsPtr, flags)
* Tcl_FindNamespaceVar --
*
* Searches for a namespace variable, a variable not local to a
- * procedure. The variable can be either a scalar or an array, but
- * may not be an element of an array.
+ * procedure. The variable can be either a scalar or an array, but may
+ * not be an element of an array.
*
* Results:
* Returns a token for the variable if it is found. Otherwise, if it
- * can't be found or there is an error, returns NULL and leaves an
- * error message in the interpreter's result object if "flags"
- * contains TCL_LEAVE_ERR_MSG.
+ * can't be found or there is an error, returns NULL and leaves an error
+ * message in the interpreter's result object if "flags" contains
+ * TCL_LEAVE_ERR_MSG.
*
* Side effects:
* None.
@@ -2512,18 +2498,17 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
* (current namespace if contextNsPtr is
* NULL), then in global namespace. */
Tcl_Namespace *contextNsPtr; /* Ignored if TCL_GLOBAL_ONLY flag set.
- * Otherwise, points to namespace in which
- * to resolve name. If NULL, look up name
- * in the current namespace. */
+ * Otherwise, points to namespace in which to
+ * resolve name. If NULL, look up name in the
+ * current namespace. */
int flags; /* An OR'd combination of flags:
* TCL_GLOBAL_ONLY (look up name only in
* global namespace), TCL_NAMESPACE_ONLY
* (look up only in contextNsPtr, or the
* current namespace if contextNsPtr is
* NULL), and TCL_LEAVE_ERR_MSG. If both
- * TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY
- * are given, TCL_GLOBAL_ONLY is
- * ignored. */
+ * TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY are
+ * given, TCL_GLOBAL_ONLY is ignored. */
{
Interp *iPtr = (Interp*)interp;
ResolverScheme *resPtr;
@@ -2536,11 +2521,11 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
Tcl_Var var;
/*
- * If this namespace has a variable resolver, then give it first
- * crack at the variable resolution. It may return a Tcl_Var
- * value, it may signal to continue onward, or it may signal
- * an error.
+ * If this namespace has a variable resolver, then give it first crack at
+ * the variable resolution. It may return a Tcl_Var value, it may signal
+ * to continue onward, or it may signal an error.
*/
+
if ((flags & TCL_GLOBAL_ONLY) != 0) {
cxtNsPtr = (Namespace *) Tcl_GetGlobalNamespace(interp);
} else if (contextNsPtr != NULL) {
@@ -2582,9 +2567,9 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName);
/*
- * Look for the variable in the variable table of its namespace.
- * Be sure to check both possible search paths: from the specified
- * namespace context and from the global namespace.
+ * Look for the variable in the variable table of its namespace. Be sure
+ * to check both possible search paths: from the specified namespace
+ * context and from the global namespace.
*/
varPtr = NULL;
@@ -2615,25 +2600,25 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
* command references that the new command may invalidate. Consider the
* following cases that could happen when you add a command "foo" to a
* namespace "b":
- * 1. It could shadow a command named "foo" at the global scope.
- * If it does, all command references in the namespace "b" are
+ * 1. It could shadow a command named "foo" at the global scope. If
+ * it does, all command references in the namespace "b" are
* suspect.
- * 2. Suppose the namespace "b" resides in a namespace "a".
- * Then to "a" the new command "b::foo" could shadow another
- * command "b::foo" in the global namespace. If so, then all
- * command references in "a" are suspect.
- * The same checks are applied to all parent namespaces, until we
- * reach the global :: namespace.
+ * 2. Suppose the namespace "b" resides in a namespace "a". Then to
+ * "a" the new command "b::foo" could shadow another command
+ * "b::foo" in the global namespace. If so, then all command
+ * references in "a" * are suspect.
+ * The same checks are applied to all parent namespaces, until we reach
+ * the global :: namespace.
*
* Results:
* None.
*
* Side effects:
* If the new command shadows an existing command, the cmdRefEpoch
- * counter is incremented in each namespace that sees the shadow.
- * This invalidates all command references that were previously cached
- * in that namespace. The next time the commands are used, they are
- * resolved from scratch.
+ * counter is incremented in each namespace that sees the shadow. This
+ * invalidates all command references that were previously cached in that
+ * namespace. The next time the commands are used, they are resolved from
+ * scratch.
*
*----------------------------------------------------------------------
*/
@@ -2651,7 +2636,7 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
int found, i;
/*
- * This procedure generates an array used to hold the trail list. This
+ * This function generates an array used to hold the trail list. This
* starts out with stack-allocated space but uses dynamically-allocated
* storage if needed.
*/
@@ -2662,9 +2647,9 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
int trailSize = NUM_TRAIL_ELEMS;
/*
- * Start at the namespace containing the new command, and work up
- * through the list of parents. Stop just before the global namespace,
- * since the global namespace can't "shadow" its own entries.
+ * Start at the namespace containing the new command, and work up through
+ * the list of parents. Stop just before the global namespace, since the
+ * global namespace can't "shadow" its own entries.
*
* The namespace "trail" list we build consists of the names of each
* namespace that encloses the new command, in order from outermost to
@@ -2672,23 +2657,22 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
* eventually extends the trail upwards by one namespace, nsPtr. We use
* this trail list to see if nsPtr (e.g. "a" in 2. above) could have
* now-invalid cached command references. This will happen if nsPtr
- * (e.g. "a") contains a sequence of child namespaces (e.g. "b")
- * such that there is a identically-named sequence of child namespaces
- * starting from :: (e.g. "::b") whose tail namespace contains a command
- * also named cmdName.
+ * (e.g. "a") contains a sequence of child namespaces (e.g. "b") such that
+ * there is a identically-named sequence of child namespaces starting from
+ * :: (e.g. "::b") whose tail namespace contains a command also named
+ * cmdName.
*/
cmdName = Tcl_GetHashKey(newCmdPtr->hPtr->tablePtr, newCmdPtr->hPtr);
- for (nsPtr = newCmdPtr->nsPtr;
- (nsPtr != NULL) && (nsPtr != globalNsPtr);
- nsPtr = nsPtr->parentPtr) {
+ for (nsPtr=newCmdPtr->nsPtr ; (nsPtr!=NULL) && (nsPtr!=globalNsPtr) ;
+ nsPtr=nsPtr->parentPtr) {
/*
* Find the maximal sequence of child namespaces contained in nsPtr
- * such that there is a identically-named sequence of child
- * namespaces starting from ::. shadowNsPtr will be the tail of this
- * sequence, or the deepest namespace under :: that might contain a
- * command now shadowed by cmdName. We check below if shadowNsPtr
- * actually contains a command cmdName.
+ * such that there is a identically-named sequence of child namespaces
+ * starting from ::. shadowNsPtr will be the tail of this sequence, or
+ * the deepest namespace under :: that might contain a command now
+ * shadowed by cmdName. We check below if shadowNsPtr actually
+ * contains a command cmdName.
*/
found = 1;
@@ -2707,8 +2691,8 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
}
/*
- * If shadowNsPtr contains a command named cmdName, we invalidate
- * all of the command refs cached in nsPtr. As a boundary case,
+ * If shadowNsPtr contains a command named cmdName, we invalidate all
+ * of the command refs cached in nsPtr. As a boundary case,
* shadowNsPtr is initially :: and we check for case 1. above.
*/
@@ -2718,7 +2702,7 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
nsPtr->cmdRefEpoch++;
TclInvalidateNsPath(nsPtr);
- /*
+ /*
* If the shadowed command was compiled to bytecodes, we
* invalidate all the bytecodes in nsPtr, to force a new
* compilation. We use the resolverEpoch to signal the need
@@ -2732,8 +2716,8 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
}
/*
- * Insert nsPtr at the front of the trail list: i.e., at the end
- * of the trailPtr array.
+ * Insert nsPtr at the front of the trail list: i.e., at the end of
+ * the trailPtr array.
*/
trailFront++;
@@ -2741,8 +2725,7 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
size_t currBytes = trailSize * sizeof(Namespace *);
int newSize = 2*trailSize;
size_t newBytes = newSize * sizeof(Namespace *);
- Namespace **newPtr =
- (Namespace **) ckalloc((unsigned) newBytes);
+ Namespace **newPtr = (Namespace **) ckalloc((unsigned) newBytes);
memcpy((VOID *) newPtr, (VOID *) trailPtr, currBytes);
if (trailPtr != trailStorage) {
@@ -2771,19 +2754,19 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
* Gets the namespace specified by the name in a Tcl_Obj.
*
* Results:
- * Returns TCL_OK if the namespace was resolved successfully, and
- * stores a pointer to the namespace in the location specified by
- * nsPtrPtr. If the namespace can't be found, the procedure stores
- * NULL in *nsPtrPtr and returns TCL_OK. If anything else goes wrong,
- * this procedure returns TCL_ERROR.
+ * Returns TCL_OK if the namespace was resolved successfully, and stores
+ * a pointer to the namespace in the location specified by nsPtrPtr. If
+ * the namespace can't be found, the function stores NULL in *nsPtrPtr
+ * and returns TCL_OK. If anything else goes wrong, this function returns
+ * TCL_ERROR.
*
* Side effects:
* May update the internal representation for the object, caching the
- * namespace reference. The next time this procedure is called, the
+ * namespace reference. The next time this function is called, the
* namespace value can be found quickly.
*
- * If anything goes wrong, an error message is left in the
- * interpreter's result object.
+ * If anything goes wrong, an error message is left in the interpreter's
+ * result object.
*
*----------------------------------------------------------------------
*/
@@ -2791,8 +2774,8 @@ TclResetShadowedCmdRefs(interp, newCmdPtr)
int
TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
Tcl_Interp *interp; /* The current interpreter. */
- Tcl_Obj *objPtr; /* The object to be resolved as the name
- * of a namespace. */
+ Tcl_Obj *objPtr; /* The object to be resolved as the name of a
+ * namespace. */
Tcl_Namespace **nsPtrPtr; /* Result namespace pointer goes here. */
{
Interp *iPtr = (Interp *) interp;
@@ -2804,9 +2787,9 @@ TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
char *name;
/*
- * If the namespace name is fully qualified, do as if the lookup were
- * done from the global namespace; this helps avoid repeated lookups
- * of fully qualified names.
+ * If the namespace name is fully qualified, do as if the lookup were done
+ * from the global namespace; this helps avoid repeated lookups of fully
+ * qualified names.
*/
savedFramePtr = iPtr->varFramePtr;
@@ -2819,8 +2802,8 @@ TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
/*
* Get the internal representation, converting to a namespace type if
- * needed. The internal representation is a ResolvedNsName that points
- * to the actual namespace.
+ * needed. The internal representation is a ResolvedNsName that points to
+ * the actual namespace.
*/
if (objPtr->typePtr != &tclNsNameType) {
@@ -2832,17 +2815,16 @@ TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
resNamePtr = (ResolvedNsName *) objPtr->internalRep.otherValuePtr;
/*
- * Check the context namespace of the resolved symbol to make sure that
- * it is fresh. If not, then force another conversion to the namespace
- * type, to discard the old rep and create a new one. Note that we
- * verify that the namespace id of the cached namespace is the same as
- * the id when we cached it; this insures that the namespace wasn't
- * deleted and a new one created at the same address.
+ * Check the context namespace of the resolved symbol to make sure that it
+ * is fresh. If not, then force another conversion to the namespace type,
+ * to discard the old rep and create a new one. Note that we verify that
+ * the namespace id of the cached namespace is the same as the id when we
+ * cached it; this insures that the namespace wasn't deleted and a new one
+ * created at the same address.
*/
nsPtr = NULL;
- if ((resNamePtr != NULL)
- && (resNamePtr->refNsPtr == currNsPtr)
+ if ((resNamePtr != NULL) && (resNamePtr->refNsPtr == currNsPtr)
&& (resNamePtr->nsId == resNamePtr->nsPtr->nsId)) {
nsPtr = resNamePtr->nsPtr;
if (nsPtr->flags & NS_DEAD) {
@@ -2874,8 +2856,8 @@ TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
*
* Tcl_NamespaceObjCmd --
*
- * Invoked to implement the "namespace" command that creates, deletes,
- * or manipulates Tcl namespaces. Handles the following syntax:
+ * Invoked to implement the "namespace" command that creates, deletes, or
+ * manipulates Tcl namespaces. Handles the following syntax:
*
* namespace children ?name? ?pattern?
* namespace code arg
@@ -2899,13 +2881,12 @@ TclGetNamespaceFromObj(interp, objPtr, nsPtrPtr)
* anything goes wrong.
*
* Side effects:
- * Based on the subcommand name (e.g., "import"), this procedure
- * dispatches to a corresponding procedure NamespaceXXXCmd defined
- * statically in this file. This procedure's side effects depend on
- * whatever that subcommand procedure does. If there is an error, this
- * procedure returns an error message in the interpreter's result
- * object. Otherwise it may return a result in the interpreter's result
- * object.
+ * Based on the subcommand name (e.g., "import"), this function
+ * dispatches to a corresponding function NamespaceXXXCmd defined
+ * statically in this file. This function's side effects depend on
+ * whatever that subcommand function does. If there is an error, this
+ * function returns an error message in the interpreter's result object.
+ * Otherwise it may return a result in the interpreter's result object.
*
*----------------------------------------------------------------------
*/
@@ -3008,8 +2989,8 @@ Tcl_NamespaceObjCmd(clientData, interp, objc, objv)
* NamespaceChildrenCmd --
*
* Invoked to implement the "namespace children" command that returns a
- * list containing the fully-qualified names of the child namespaces of
- * a given namespace. Handles the following syntax:
+ * list containing the fully-qualified names of the child namespaces of a
+ * given namespace. Handles the following syntax:
*
* namespace children ?name? ?pattern?
*
@@ -3017,8 +2998,8 @@ Tcl_NamespaceObjCmd(clientData, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -3082,8 +3063,8 @@ NamespaceChildrenCmd(dummy, interp, objc, objv)
}
/*
- * Create a list containing the full names of all child namespaces
- * whose names match the specified pattern, if any.
+ * Create a list containing the full names of all child namespaces whose
+ * names match the specified pattern, if any.
*/
listPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL);
@@ -3105,7 +3086,7 @@ NamespaceChildrenCmd(dummy, interp, objc, objv)
entryPtr = Tcl_NextHashEntry(&search);
}
-searchDone:
+ searchDone:
Tcl_SetObjResult(interp, listPtr);
Tcl_DStringFree(&buffer);
return TCL_OK;
@@ -3126,15 +3107,15 @@ searchDone:
*
* list ::namespace inscope [namespace current] $arg
*
- * However, if "arg" is itself a scoped value starting with
- * "::namespace inscope", then the result is just "arg".
+ * However, if "arg" is itself a scoped value starting with "::namespace
+ * inscope", then the result is just "arg".
*
* Results:
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * If anything goes wrong, this procedure returns an error
- * message as the result in the interpreter's result object.
+ * If anything goes wrong, this function returns an error message as the
+ * result in the interpreter's result object.
*
*----------------------------------------------------------------------
*/
@@ -3177,10 +3158,10 @@ NamespaceCodeCmd(dummy, interp, objc, objv)
/*
* Otherwise, construct a scoped command by building a list with
- * "namespace inscope", the full name of the current namespace, and
- * the argument "arg". By constructing a list, we ensure that scoped
- * commands are interpreted properly when they are executed later,
- * by the "namespace inscope" command.
+ * "namespace inscope", the full name of the current namespace, and the
+ * argument "arg". By constructing a list, we ensure that scoped commands
+ * are interpreted properly when they are executed later, by the
+ * "namespace inscope" command.
*/
listPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL);
@@ -3208,9 +3189,9 @@ NamespaceCodeCmd(dummy, interp, objc, objv)
*
* NamespaceCurrentCmd --
*
- * Invoked to implement the "namespace current" command which returns
- * the fully-qualified name of the current namespace. Handles the
- * following syntax:
+ * Invoked to implement the "namespace current" command which returns the
+ * fully-qualified name of the current namespace. Handles the following
+ * syntax:
*
* namespace current
*
@@ -3218,8 +3199,8 @@ NamespaceCodeCmd(dummy, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -3239,10 +3220,10 @@ NamespaceCurrentCmd(dummy, interp, objc, objv)
}
/*
- * The "real" name of the global namespace ("::") is the null string,
- * but we return "::" for it as a convenience to programmers. Note that
- * "" and "::" are treated as synonyms by the namespace code so that it
- * is still easy to do things like:
+ * The "real" name of the global namespace ("::") is the null string, but
+ * we return "::" for it as a convenience to programmers. Note that "" and
+ * "::" are treated as synonyms by the namespace code so that it is still
+ * easy to do things like:
*
* namespace [namespace current]::bar { ... }
*/
@@ -3269,12 +3250,12 @@ NamespaceCurrentCmd(dummy, interp, objc, objv)
* Each name identifies a namespace. It may include a sequence of
* namespace qualifiers separated by "::"s. If a namespace is found, it
* is deleted: all variables and procedures contained in that namespace
- * are deleted. If that namespace is being used on the call stack, it
- * is kept alive (but logically deleted) until it is removed from the
- * call stack: that is, it can no longer be referenced by name but any
+ * are deleted. If that namespace is being used on the call stack, it is
+ * kept alive (but logically deleted) until it is removed from the call
+ * stack: that is, it can no longer be referenced by name but any
* currently executing procedure that refers to it is allowed to do so
* until the procedure returns. If the namespace can't be found, this
- * procedure returns an error. If no namespaces are specified, this
+ * function returns an error. If no namespaces are specified, this
* command does nothing.
*
* Results:
@@ -3282,8 +3263,7 @@ NamespaceCurrentCmd(dummy, interp, objc, objv)
*
* Side effects:
* Deletes the specified namespaces. If anything goes wrong, this
- * procedure returns an error message in the interpreter's
- * result object.
+ * function returns an error message in the interpreter's result object.
*
*----------------------------------------------------------------------
*/
@@ -3305,9 +3285,9 @@ NamespaceDeleteCmd(dummy, interp, objc, objv)
}
/*
- * Destroying one namespace may cause another to be destroyed. Break
- * this into two passes: first check to make sure that all namespaces on
- * the command line are valid, and report any errors.
+ * Destroying one namespace may cause another to be destroyed. Break this
+ * into two passes: first check to make sure that all namespaces on the
+ * command line are valid, and report any errors.
*/
for (i = 2; i < objc; i++) {
@@ -3342,24 +3322,24 @@ NamespaceDeleteCmd(dummy, interp, objc, objv)
*
* NamespaceEvalCmd --
*
- * Invoked to implement the "namespace eval" command. Executes
- * commands in a namespace. If the namespace does not already exist,
- * it is created. Handles the following syntax:
+ * Invoked to implement the "namespace eval" command. Executes commands
+ * in a namespace. If the namespace does not already exist, it is
+ * created. Handles the following syntax:
*
* namespace eval name arg ?arg...?
*
* If more than one arg argument is specified, the command that is
- * executed is the result of concatenating the arguments together with
- * a space between each argument.
+ * executed is the result of concatenating the arguments together with a
+ * space between each argument.
*
* Results:
- * Returns TCL_OK if the namespace is found and the commands are
- * executed successfully. Returns TCL_ERROR if anything goes wrong.
+ * Returns TCL_OK if the namespace is found and the commands are executed
+ * successfully. Returns TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns the result of the command in the interpreter's result
- * object. If anything goes wrong, this procedure returns an error
- * message as the result.
+ * Returns the result of the command in the interpreter's result object.
+ * If anything goes wrong, this function returns an error message as the
+ * result.
*
*----------------------------------------------------------------------
*/
@@ -3397,7 +3377,7 @@ NamespaceEvalCmd(dummy, interp, objc, objv)
if (namespacePtr == NULL) {
char *name = TclGetString(objv[2]);
- namespacePtr = Tcl_CreateNamespace(interp, name, (ClientData) NULL,
+ namespacePtr = Tcl_CreateNamespace(interp, name, (ClientData) NULL,
(Tcl_NamespaceDeleteProc *) NULL);
if (namespacePtr == NULL) {
return TCL_ERROR;
@@ -3411,7 +3391,7 @@ NamespaceEvalCmd(dummy, interp, objc, objv)
/* This is needed to satisfy GCC 3.3's strict aliasing rules */
framePtrPtr = &framePtr;
- result = TclPushStackFrame(interp, (Tcl_CallFrame **) framePtrPtr,
+ result = TclPushStackFrame(interp, (Tcl_CallFrame **) framePtrPtr,
namespacePtr, /*isProcCallFrame*/ 0);
if (result != TCL_OK) {
return TCL_ERROR;
@@ -3424,9 +3404,10 @@ NamespaceEvalCmd(dummy, interp, objc, objv)
} else {
/*
* More than one argument: concatenate them together with spaces
- * between, then evaluate the result. Tcl_EvalObjEx will delete
- * the object when it decrements its refcount after eval'ing it.
+ * between, then evaluate the result. Tcl_EvalObjEx will delete the
+ * object when it decrements its refcount after eval'ing it.
*/
+
objPtr = Tcl_ConcatObj(objc-3, objv+3);
result = Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_DIRECT);
}
@@ -3458,7 +3439,7 @@ NamespaceEvalCmd(dummy, interp, objc, objv)
*
* NamespaceExistsCmd --
*
- * Invoked to implement the "namespace exists" command that returns
+ * Invoked to implement the "namespace exists" command that returns
* true if the given namespace currently exists, and false otherwise.
* Handles the following syntax:
*
@@ -3507,18 +3488,18 @@ NamespaceExistsCmd(dummy, interp, objc, objv)
*
* Invoked to implement the "namespace export" command that specifies
* which commands are exported from a namespace. The exported commands
- * are those that can be imported into another namespace using
- * "namespace import". Both commands defined in a namespace and
- * commands the namespace has imported can be exported by a
- * namespace. This command has the following syntax:
+ * are those that can be imported into another namespace using "namespace
+ * import". Both commands defined in a namespace and commands the
+ * namespace has imported can be exported by a namespace. This command
+ * has the following syntax:
*
* namespace export ?-clear? ?pattern pattern...?
*
- * Each pattern may contain "string match"-style pattern matching
- * special characters, but the pattern may not include any namespace
- * qualifiers: that is, the pattern must specify commands in the
- * current (exporting) namespace. The specified patterns are appended
- * onto the namespace's list of export patterns.
+ * Each pattern may contain "string match"-style pattern matching special
+ * characters, but the pattern may not include any namespace qualifiers:
+ * that is, the pattern must specify commands in the current (exporting)
+ * namespace. The specified patterns are appended onto the namespace's
+ * list of export patterns.
*
* To reset the namespace's export pattern list, specify the "-clear"
* flag.
@@ -3530,8 +3511,8 @@ NamespaceExistsCmd(dummy, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -3567,8 +3548,8 @@ NamespaceExportCmd(dummy, interp, objc, objv)
}
/*
- * If no pattern arguments are given, and "-clear" isn't specified,
- * return the namespace's current export pattern list.
+ * If no pattern arguments are given, and "-clear" isn't specified, return
+ * the namespace's current export pattern list.
*/
patternCt = (objc - firstArg);
@@ -3607,26 +3588,26 @@ NamespaceExportCmd(dummy, interp, objc, objv)
*
* NamespaceForgetCmd --
*
- * Invoked to implement the "namespace forget" command to remove
- * imported commands from a namespace. Handles the following syntax:
+ * Invoked to implement the "namespace forget" command to remove imported
+ * commands from a namespace. Handles the following syntax:
*
* namespace forget ?pattern pattern...?
*
* Each pattern is a name like "foo::*" or "a::b::x*". That is, the
- * pattern may include the special pattern matching characters
- * recognized by the "string match" command, but only in the command
- * name at the end of the qualified name; the special pattern
- * characters may not appear in a namespace name. All of the commands
- * that match that pattern are checked to see if they have an imported
- * command in the current namespace that refers to the matched
- * command. If there is an alias, it is removed.
- *
+ * pattern may include the special pattern matching characters recognized
+ * by the "string match" command, but only in the command name at the end
+ * of the qualified name; the special pattern characters may not appear
+ * in a namespace name. All of the commands that match that pattern are
+ * checked to see if they have an imported command in the current
+ * namespace that refers to the matched command. If there is an alias, it
+ * is removed.
+ *
* Results:
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Imported commands are removed from the current namespace. If
- * anything goes wrong, this procedure returns an error message in the
+ * Imported commands are removed from the current namespace. If anything
+ * goes wrong, this function returns an error message in the
* interpreter's result object.
*
*----------------------------------------------------------------------
@@ -3667,28 +3648,27 @@ NamespaceForgetCmd(dummy, interp, objc, objv)
*
* namespace import ?-force? ?pattern pattern...?
*
- * Each pattern is a namespace-qualified name like "foo::*",
- * "a::b::x*", or "bar::p". That is, the pattern may include the
- * special pattern matching characters recognized by the "string match"
- * command, but only in the command name at the end of the qualified
- * name; the special pattern characters may not appear in a namespace
- * name. All of the commands that match the pattern and which are
- * exported from their namespace are made accessible from the current
- * namespace context. This is done by creating a new "imported command"
- * in the current namespace that points to the real command in its
- * original namespace; when the imported command is called, it invokes
- * the real command.
+ * Each pattern is a namespace-qualified name like "foo::*", "a::b::x*",
+ * or "bar::p". That is, the pattern may include the special pattern
+ * matching characters recognized by the "string match" command, but only
+ * in the command name at the end of the qualified name; the special
+ * pattern characters may not appear in a namespace name. All of the
+ * commands that match the pattern and which are exported from their
+ * namespace are made accessible from the current namespace context. This
+ * is done by creating a new "imported command" in the current namespace
+ * that points to the real command in its original namespace; when the
+ * imported command is called, it invokes the real command.
*
* If an imported command conflicts with an existing command, it is
* treated as an error. But if the "-force" option is included, then
* existing commands are overwritten by the imported commands.
- *
+ *
* Results:
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
* Adds imported commands to the current namespace. If anything goes
- * wrong, this procedure returns an error message in the interpreter's
+ * wrong, this function returns an error message in the interpreter's
* result object.
*
*----------------------------------------------------------------------
@@ -3746,17 +3726,17 @@ NamespaceImportCmd(dummy, interp, objc, objv)
*
* Invoked to implement the "namespace inscope" command that executes a
* script in the context of a particular namespace. This command is not
- * expected to be used directly by programmers; calls to it are
- * generated implicitly when programs use "namespace code" commands
- * to register callback scripts. Handles the following syntax:
+ * expected to be used directly by programmers; calls to it are generated
+ * implicitly when programs use "namespace code" commands to register
+ * callback scripts. Handles the following syntax:
*
* namespace inscope name arg ?arg...?
*
* The "namespace inscope" command is much like the "namespace eval"
* command except that it has lappend semantics and the namespace must
- * already exist. It treats the first argument as a list, and appends
- * any arguments after the first onto the end as proper list elements.
- * For example,
+ * already exist. It treats the first argument as a list, and appends any
+ * arguments after the first onto the end as proper list elements. For
+ * example,
*
* namespace inscope ::foo a b c d
*
@@ -3764,12 +3744,11 @@ NamespaceImportCmd(dummy, interp, objc, objv)
*
* namespace eval ::foo [concat a [list b c d]]
*
- * This lappend semantics is important because many callback scripts
- * are actually prefixes.
+ * This lappend semantics is important because many callback scripts are
+ * actually prefixes.
*
* Results:
- * Returns TCL_OK to indicate success, or TCL_ERROR to indicate
- * failure.
+ * Returns TCL_OK to indicate success, or TCL_ERROR to indicate failure.
*
* Side effects:
* Returns a result in the Tcl interpreter's result object.
@@ -3818,8 +3797,8 @@ NamespaceInscopeCmd(dummy, interp, objc, objv)
}
/*
- * Execute the command. If there is just one argument, just treat it as
- * a script and evaluate it. Otherwise, create a list from the arguments
+ * Execute the command. If there is just one argument, just treat it as a
+ * script and evaluate it. Otherwise, create a list from the arguments
* after the first one, then concatenate the first argument and the list
* of extra arguments to form the command to evaluate.
*/
@@ -3849,6 +3828,7 @@ NamespaceInscopeCmd(dummy, interp, objc, objv)
if (result == TCL_ERROR) {
Tcl_Obj *errorLine = Tcl_NewIntObj(interp->errorLine);
Tcl_Obj *msg = Tcl_NewStringObj("\n (in namespace inscope \"", -1);
+
Tcl_IncrRefCount(errorLine);
Tcl_IncrRefCount(msg);
TclAppendLimitedToObj(msg, namespacePtr->fullName, -1, 200, "");
@@ -3887,12 +3867,12 @@ NamespaceInscopeCmd(dummy, interp, objc, objv)
* command returns the fully-qualified name of the original command in
* the first namespace, a. If "name" does not refer to an alias, its
* fully-qualified name is returned. The returned name is stored in the
- * interpreter's result object. This procedure returns TCL_OK if
+ * interpreter's result object. This function returns TCL_OK if
* successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * If anything goes wrong, this procedure returns an error message in
- * the interpreter's result object.
+ * If anything goes wrong, this function returns an error message in the
+ * interpreter's result object.
*
*----------------------------------------------------------------------
*/
@@ -3923,8 +3903,8 @@ NamespaceOriginCmd(dummy, interp, objc, objv)
if (origCommand == (Tcl_Command) NULL) {
/*
* The specified command isn't an imported command. Return the
- * command's name qualified by the full name of the namespace it
- * was defined in.
+ * command's name qualified by the full name of the namespace it was
+ * defined in.
*/
Tcl_GetCommandFullName(interp, command, resultPtr);
@@ -3950,8 +3930,8 @@ NamespaceOriginCmd(dummy, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -4000,24 +3980,24 @@ NamespaceParentCmd(dummy, interp, objc, objv)
*
* NamespacePathCmd --
*
- * Invoked to implement the "namespace path" command that reads
- * and writes the current namespace's command resolution path.
- * Has one optional argument: if present, it is a list of named
- * namespaces to set the path to, and if absent, the current path
- * should be returned. Handles the following syntax:
+ * Invoked to implement the "namespace path" command that reads and
+ * writes the current namespace's command resolution path. Has one
+ * optional argument: if present, it is a list of named namespaces to set
+ * the path to, and if absent, the current path should be returned.
+ * Handles the following syntax:
*
* namespace path ?nsList?
*
* Results:
- * Returns TCL_OK if successful, and TCL_ERROR if anything goes
- * wrong (most notably if the namespace list contains the name of
- * something other than a namespace). In the successful-exit
- * case, may set the interpreter result to the list of names of
- * the namespaces on the current namespace's path.
+ * Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong
+ * (most notably if the namespace list contains the name of something
+ * other than a namespace). In the successful-exit case, may set the
+ * interpreter result to the list of names of the namespaces on the
+ * current namespace's path.
*
* Side effects:
- * May update the namespace path (triggering a recomputing of all
- * command names that depend on the namespace for resolution).
+ * May update the namespace path (triggering a recomputing of all command
+ * names that depend on the namespace for resolution).
*
*----------------------------------------------------------------------
*/
@@ -4048,6 +4028,7 @@ NamespacePathCmd(dummy, interp, objc, objv)
/*
* Not a very fast way to compute this, but easy to get right.
*/
+
for (i=0 ; i<nsPtr->commandPathLength ; i++) {
if (nsPtr->commandPathArray[i].nsPtr != NULL) {
Tcl_AppendElement(interp,
@@ -4058,8 +4039,7 @@ NamespacePathCmd(dummy, interp, objc, objv)
}
/*
- * There is a path given, so parse it into an array of namespace
- * pointers.
+ * There is a path given, so parse it into an array of namespace pointers.
*/
if (Tcl_ListObjGetElements(interp, objv[2], &nsObjc, &nsObjv) != TCL_OK) {
@@ -4087,8 +4067,7 @@ NamespacePathCmd(dummy, interp, objc, objv)
}
/*
- * Now we have the list of valid namespaces, install it as the
- * path.
+ * Now we have the list of valid namespaces, install it as the path.
*/
SetNsPath(nsPtr, nsObjc, namespaceList);
@@ -4106,10 +4085,10 @@ NamespacePathCmd(dummy, interp, objc, objv)
*
* SetNsPath --
*
- * Sets the namespace command name resolution path to the given
- * list of namespaces. If the list is empty (of zero length) the
- * path is set to empty and the default old-style behaviour of
- * command name resolution is used.
+ * Sets the namespace command name resolution path to the given list of
+ * namespaces. If the list is empty (of zero length) the path is set to
+ * empty and the default old-style behaviour of command name resolution
+ * is used.
*
* Results:
* nothing
@@ -4165,16 +4144,16 @@ SetNsPath(nsPtr, pathLength, pathAry)
*
* UnlinkNsPath --
*
- * Delete the given namespace's command name resolution path. Only
- * call if the path is non-empty. Caller must reset the counter
- * containing the path size.
+ * Delete the given namespace's command name resolution path. Only call
+ * if the path is non-empty. Caller must reset the counter containing the
+ * path size.
*
* Results:
* nothing
*
* Side effects:
- * Deletes the array of path entries and unlinks those path entries
- * from the target namespace's list of interested namespaces.
+ * Deletes the array of path entries and unlinks those path entries from
+ * the target namespace's list of interested namespaces.
*
*----------------------------------------------------------------------
*/
@@ -4206,17 +4185,17 @@ UnlinkNsPath(nsPtr)
*
* TclInvalidateNsPath --
*
- * Invalidate the name resolution caches for all names looked up
- * in namespaces whose name path includes the given namespace.
+ * Invalidate the name resolution caches for all names looked up in
+ * namespaces whose name path includes the given namespace.
*
* Results:
* nothing
*
* Side effects:
- * Increments the command reference epoch in each namespace whose
- * path includes the given namespace. This causes any cached
- * resolved names whose root cacheing context starts at that
- * namespace to be recomputed the next time they are used.
+ * Increments the command reference epoch in each namespace whose path
+ * includes the given namespace. This causes any cached resolved names
+ * whose root cacheing context starts at that namespace to be recomputed
+ * the next time they are used.
*
*----------------------------------------------------------------------
*/
@@ -4242,11 +4221,10 @@ TclInvalidateNsPath(nsPtr)
* Invoked to implement the "namespace qualifiers" command that returns
* any leading namespace qualifiers in a string. These qualifiers are
* namespace names separated by "::"s. For example, for "::foo::p" this
- * command returns "::foo", and for "::" it returns "". This command
- * is the complement of the "namespace tail" command. Note that this
- * command does not check whether the "namespace" names are, in fact,
- * the names of currently defined namespaces. Handles the following
- * syntax:
+ * command returns "::foo", and for "::" it returns "". This command is
+ * the complement of the "namespace tail" command. Note that this command
+ * does not check whether the "namespace" names are, in fact, the names
+ * of currently defined namespaces. Handles the following syntax:
*
* namespace qualifiers string
*
@@ -4254,8 +4232,8 @@ TclInvalidateNsPath(nsPtr)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -4276,8 +4254,8 @@ NamespaceQualifiersCmd(dummy, interp, objc, objv)
}
/*
- * Find the end of the string, then work backward and find
- * the start of the last "::" qualifier.
+ * Find the end of the string, then work backward and find the start of
+ * the last "::" qualifier.
*/
name = TclGetString(objv[2]);
@@ -4307,13 +4285,13 @@ NamespaceQualifiersCmd(dummy, interp, objc, objv)
* NamespaceTailCmd --
*
* Invoked to implement the "namespace tail" command that returns the
- * trailing name at the end of a string with "::" namespace
- * qualifiers. These qualifiers are namespace names separated by
- * "::"s. For example, for "::foo::p" this command returns "p", and for
- * "::" it returns "". This command is the complement of the "namespace
- * qualifiers" command. Note that this command does not check whether
- * the "namespace" names are, in fact, the names of currently defined
- * namespaces. Handles the following syntax:
+ * trailing name at the end of a string with "::" namespace qualifiers.
+ * These qualifiers are namespace names separated by "::"s. For example,
+ * for "::foo::p" this command returns "p", and for "::" it returns
+ * "". This command is the complement of the "namespace qualifiers"
+ * command. Note that this command does not check whether the "namespace"
+ * names are, in fact, the names of currently defined namespaces. Handles
+ * the following syntax:
*
* namespace tail string
*
@@ -4321,8 +4299,8 @@ NamespaceQualifiersCmd(dummy, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -4342,8 +4320,8 @@ NamespaceTailCmd(dummy, interp, objc, objv)
}
/*
- * Find the end of the string, then work backward and find the
- * last "::" qualifier.
+ * Find the end of the string, then work backward and find the last "::"
+ * qualifier.
*/
name = TclGetString(objv[2]);
@@ -4379,8 +4357,8 @@ NamespaceTailCmd(dummy, interp, objc, objv)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Returns a result in the interpreter's result object. If anything
- * goes wrong, the result is an error message.
+ * Returns a result in the interpreter's result object. If anything goes
+ * wrong, the result is an error message.
*
*----------------------------------------------------------------------
*/
@@ -4421,7 +4399,7 @@ NamespaceWhichCmd(dummy, interp, objc, objv)
switch (lookupType) {
case 0: { /* -command */
Tcl_Command cmd = Tcl_GetCommandFromObj(interp, objv[objc-1]);
- if (cmd != (Tcl_Command) NULL) {
+ if (cmd != (Tcl_Command) NULL) {
Tcl_GetCommandFullName(interp, cmd, resultPtr);
}
break;
@@ -4451,9 +4429,9 @@ NamespaceWhichCmd(dummy, interp, objc, objv)
* None.
*
* Side effects:
- * Decrements the ref count of any Namespace structure pointed
- * to by the nsName's internal representation. If there are no more
- * references to the namespace, it's structure will be freed.
+ * Decrements the ref count of any Namespace structure pointed to by the
+ * nsName's internal representation. If there are no more references to
+ * the namespace, it's structure will be freed.
*
*----------------------------------------------------------------------
*/
@@ -4468,8 +4446,8 @@ FreeNsNameInternalRep(objPtr)
Namespace *nsPtr;
/*
- * Decrement the reference count of the namespace. If there are no
- * more references, free it up.
+ * Decrement the reference count of the namespace. If there are no more
+ * references, free it up.
*/
if (resNamePtr != NULL) {
@@ -4477,9 +4455,9 @@ FreeNsNameInternalRep(objPtr)
if (resNamePtr->refCount == 0) {
/*
- * Decrement the reference count for the cached namespace. If
- * the namespace is dead, and there are no more references to
- * it, free it.
+ * Decrement the reference count for the cached namespace. If the
+ * namespace is dead, and there are no more references to it, free
+ * it.
*/
nsPtr = resNamePtr->nsPtr;
@@ -4505,8 +4483,8 @@ FreeNsNameInternalRep(objPtr)
*
* Side effects:
* copyPtr's internal rep is set to refer to the same namespace
- * referenced by srcPtr's internal rep. Increments the ref count of
- * the ResolvedNsName structure used to hold the namespace reference.
+ * referenced by srcPtr's internal rep. Increments the ref count of the
+ * ResolvedNsName structure used to hold the namespace reference.
*
*----------------------------------------------------------------------
*/
@@ -4531,29 +4509,28 @@ DupNsNameInternalRep(srcPtr, copyPtr)
*
* SetNsNameFromAny --
*
- * Attempt to generate a nsName internal representation for a
- * Tcl object.
+ * Attempt to generate a nsName internal representation for a Tcl object.
*
* Results:
- * Returns TCL_OK if the value could be converted to a proper
- * namespace reference. Otherwise, it returns TCL_ERROR, along
- * with an error message in the interpreter's result object.
+ * Returns TCL_OK if the value could be converted to a proper namespace
+ * reference. Otherwise, it returns TCL_ERROR, along with an error
+ * message in the interpreter's result object.
*
* Side effects:
- * If successful, the object is made a nsName object. Its internal rep
- * is set to point to a ResolvedNsName, which contains a cached pointer
- * to the Namespace. Reference counts are kept on both the
- * ResolvedNsName and the Namespace, so we can keep track of their
- * usage and free them when appropriate.
+ * If successful, the object is made a nsName object. Its internal rep is
+ * set to point to a ResolvedNsName, which contains a cached pointer to
+ * the Namespace. Reference counts are kept on both the ResolvedNsName
+ * and the Namespace, so we can keep track of their usage and free them
+ * when appropriate.
*
*----------------------------------------------------------------------
*/
static int
SetNsNameFromAny(interp, objPtr)
- Tcl_Interp *interp; /* Points to the namespace in which to
- * resolve name. Also used for error
- * reporting if not NULL. */
+ Tcl_Interp *interp; /* Points to the namespace in which to resolve
+ * name. Also used for error reporting if not
+ * NULL. */
register Tcl_Obj *objPtr; /* The object to convert. */
{
char *name;
@@ -4571,10 +4548,10 @@ SetNsNameFromAny(interp, objPtr)
}
/*
- * Look for the namespace "name" in the current namespace. If there is
- * an error parsing the (possibly qualified) name, return an error.
- * If the namespace isn't found, we convert the object to an nsName
- * object with a NULL ResolvedNsName* internal rep.
+ * Look for the namespace "name" in the current namespace. If there is an
+ * error parsing the (possibly qualified) name, return an error. If the
+ * namespace isn't found, we convert the object to an nsName object with a
+ * NULL ResolvedNsName* internal rep.
*/
TclGetNamespaceForQualName(interp, name, (Namespace *) NULL,
@@ -4600,9 +4577,9 @@ SetNsNameFromAny(interp, objPtr)
}
/*
- * Free the old internalRep before setting the new one.
- * We do this as late as possible to allow the conversion code
- * (in particular, Tcl_GetStringFromObj) to use that old internalRep.
+ * Free the old internalRep before setting the new one. We do this as
+ * late as possible to allow the conversion code (in particular,
+ * Tcl_GetStringFromObj) to use that old internalRep.
*/
TclFreeIntRep(objPtr);
@@ -4616,16 +4593,16 @@ SetNsNameFromAny(interp, objPtr)
*
* UpdateStringOfNsName --
*
- * Updates the string representation for a nsName object.
- * Note: This procedure does not free an existing old string rep
- * so storage will be lost if this has not already been done.
+ * Updates the string representation for a nsName object. Note: This
+ * function does not free an existing old string rep so storage will be
+ * lost if this has not already been done.
*
* Results:
* None.
*
* Side effects:
- * The object's string is set to a copy of the fully qualified
- * namespace name.
+ * The object's string is set to a copy of the fully qualified namespace
+ * name.
*
*----------------------------------------------------------------------
*/
@@ -4652,8 +4629,8 @@ UpdateStringOfNsName(objPtr)
}
/*
- * The following sets the string rep to an empty string on the heap
- * if the internal rep is NULL.
+ * The following sets the string rep to an empty string on the heap if the
+ * internal rep is NULL.
*/
length = strlen(name);
@@ -4672,9 +4649,9 @@ UpdateStringOfNsName(objPtr)
*
* NamespaceEnsembleCmd --
*
- * Invoked to implement the "namespace ensemble" command that
- * creates and manipulates ensembles built on top of namespaces.
- * Handles the following syntax:
+ * Invoked to implement the "namespace ensemble" command that creates and
+ * manipulates ensembles built on top of namespaces. Handles the
+ * following syntax:
*
* namespace ensemble name ?dictionary?
*
@@ -4682,9 +4659,9 @@ UpdateStringOfNsName(objPtr)
* Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong.
*
* Side effects:
- * Creates the ensemble for the namespace if one did not
- * previously exist. Alternatively, alters the way that the
- * ensemble's subcommand => implementation prefix is configured.
+ * Creates the ensemble for the namespace if one did not previously
+ * exist. Alternatively, alters the way that the ensemble's subcommand
+ * => implementation prefix is configured.
*
*----------------------------------------------------------------------
*/
@@ -4754,19 +4731,18 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
objc -= 3;
/*
- * Work out what name to use for the command to create. If
- * supplied, it is either fully specified or relative to the
- * current namespace. If not supplied, it is exactly the name
- * of the current namespace.
+ * Work out what name to use for the command to create. If supplied,
+ * it is either fully specified or relative to the current namespace.
+ * If not supplied, it is exactly the name of the current namespace.
*/
name = nsPtr->fullName;
/*
- * Parse the option list, applying type checks as we go. Note
- * that we are not incrementing any reference counts in the
- * objects at this stage, so the presence of an option
- * multiple times won't cause any memory leaks.
+ * Parse the option list, applying type checks as we go. Note that we
+ * are not incrementing any reference counts in the objects at this
+ * stage, so the presence of an option multiple times won't cause any
+ * memory leaks.
*/
for (; objc>1 ; objc-=2,objv+=2 ) {
@@ -4792,9 +4768,11 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
continue;
case CRT_MAP: {
Tcl_Obj *patchedDict = NULL, *subcmdObj;
+
/*
* Verify that the map is sensible.
*/
+
if (Tcl_DictObjFirst(interp, objv[1], &search,
&subcmdObj, &listObj, &done) != TCL_OK) {
if (allocatedMapFlag) {
@@ -4837,8 +4815,8 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
cmd = TclGetString(listv[0]);
if (!(cmd[0] == ':' && cmd[1] == ':')) {
Tcl_Obj *newList = Tcl_NewListObj(len, listv);
- Tcl_Obj *newCmd =
- Tcl_NewStringObj(nsPtr->fullName, -1);
+ Tcl_Obj *newCmd = Tcl_NewStringObj(nsPtr->fullName,-1);
+
if (nsPtr->parentPtr) {
Tcl_AppendStringsToObj(newCmd, "::", NULL);
}
@@ -4851,6 +4829,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
}
Tcl_DictObjNext(&search, &subcmdObj, &listObj, &done);
} while (!done);
+
if (allocatedMapFlag) {
Tcl_DecrRefCount(mapObj);
}
@@ -4882,11 +4861,10 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
}
/*
- * Create the ensemble. Note that this might delete another
- * ensemble linked to the same namespace, so we must be
- * careful. However, we should be OK because we only link the
- * namespace into the list once we've created it (and after
- * any deletions have occurred.)
+ * Create the ensemble. Note that this might delete another ensemble
+ * linked to the same namespace, so we must be careful. However, we
+ * should be OK because we only link the namespace into the list once
+ * we've created it (and after any deletions have occurred.)
*/
token = Tcl_CreateEnsemble(interp, name, NULL,
@@ -4976,6 +4954,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
int flags;
TclNewObj(resultObj);
+
/* -map option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_MAP], -1));
@@ -4985,6 +4964,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
+
/* -namespace option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_NAMESPACE], -1));
@@ -4992,12 +4972,14 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(((Namespace *)namespacePtr)->fullName,
-1));
+
/* -prefix option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_PREFIX], -1));
Tcl_GetEnsembleFlags(NULL, token, &flags);
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewBooleanObj(flags & TCL_ENSEMBLE_PREFIX));
+
/* -subcommands option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_SUBCMDS], -1));
@@ -5007,6 +4989,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
+
/* -unknown option */
Tcl_ListObjAppendElement(NULL, resultObj,
Tcl_NewStringObj(configOptions[CONF_UNKNOWN], -1));
@@ -5016,9 +4999,9 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
} else {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewObj());
}
+
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
-
} else {
Tcl_DictSearch search;
Tcl_Obj *listObj;
@@ -5039,10 +5022,10 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
objc -= 4;
/*
- * Parse the option list, applying type checks as we go.
- * Note that we are not incrementing any reference counts
- * in the objects at this stage, so the presence of an
- * option multiple times won't cause any memory leaks.
+ * Parse the option list, applying type checks as we go. Note
+ * that we are not incrementing any reference counts in the
+ * objects at this stage, so the presence of an option multiple
+ * times won't cause any memory leaks.
*/
for (; objc>0 ; objc-=2,objv+=2 ) {
@@ -5163,8 +5146,7 @@ NamespaceEnsembleCmd(dummy, interp, objc, objv)
}
/*
- * Update the namespace now that we've finished the
- * parsing stage.
+ * Update the namespace now that we've finished the parsing stage.
*/
flags = (permitPrefix ? flags|TCL_ENSEMBLE_PREFIX
@@ -5215,8 +5197,8 @@ Tcl_CreateEnsemble(interp, name, namespacePtr, flags)
}
/*
- * Make the name of the ensemble into a fully qualified name.
- * This might allocate a temporary object.
+ * Make the name of the ensemble into a fully qualified name. This might
+ * allocate a temporary object.
*/
if (!(name[0] == ':' && name[1] == ':')) {
@@ -5243,12 +5225,14 @@ Tcl_CreateEnsemble(interp, name, namespacePtr, flags)
DeleteEnsembleConfig);
ensemblePtr->next = (EnsembleConfig *) nsPtr->ensembles;
nsPtr->ensembles = (Tcl_Ensemble *) ensemblePtr;
+
/*
- * Trigger an eventual recomputation of the ensemble command
- * set. Note that this is slightly tricky, as it means that
- * we are not actually counting the number of namespace export
- * actions, but it is the simplest way to go!
+ * Trigger an eventual recomputation of the ensemble command set. Note
+ * that this is slightly tricky, as it means that we are not actually
+ * counting the number of namespace export actions, but it is the simplest
+ * way to go!
*/
+
nsPtr->exportLookupEpoch++;
if (nameObj != NULL) {
@@ -5265,8 +5249,8 @@ Tcl_CreateEnsemble(interp, name, namespacePtr, flags)
* Set the subcommand list for a particular ensemble.
*
* Results:
- * Tcl result code (error if command token does not indicate an
- * ensemble or the subcommand list - if non-NULL - is not a list).
+ * Tcl result code (error if command token does not indicate an ensemble
+ * or the subcommand list - if non-NULL - is not a list).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
@@ -5311,11 +5295,12 @@ Tcl_SetEnsembleSubcommandList(interp, token, subcmdList)
}
/*
- * Trigger an eventual recomputation of the ensemble command
- * set. Note that this is slightly tricky, as it means that
- * we are not actually counting the number of namespace export
- * actions, but it is the simplest way to go!
+ * Trigger an eventual recomputation of the ensemble command set. Note
+ * that this is slightly tricky, as it means that we are not actually
+ * counting the number of namespace export actions, but it is the simplest
+ * way to go!
*/
+
ensemblePtr->nsPtr->exportLookupEpoch++;
return TCL_OK;
@@ -5329,8 +5314,8 @@ Tcl_SetEnsembleSubcommandList(interp, token, subcmdList)
* Set the mapping dictionary for a particular ensemble.
*
* Results:
- * Tcl result code (error if command token does not indicate an
- * ensemble or the mapping - if non-NULL - is not a dict).
+ * Tcl result code (error if command token does not indicate an ensemble
+ * or the mapping - if non-NULL - is not a dict).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
@@ -5375,11 +5360,12 @@ Tcl_SetEnsembleMappingDict(interp, token, mapDict)
}
/*
- * Trigger an eventual recomputation of the ensemble command
- * set. Note that this is slightly tricky, as it means that
- * we are not actually counting the number of namespace export
- * actions, but it is the simplest way to go!
+ * Trigger an eventual recomputation of the ensemble command set. Note
+ * that this is slightly tricky, as it means that we are not actually
+ * counting the number of namespace export actions, but it is the simplest
+ * way to go!
*/
+
ensemblePtr->nsPtr->exportLookupEpoch++;
return TCL_OK;
@@ -5393,8 +5379,8 @@ Tcl_SetEnsembleMappingDict(interp, token, mapDict)
* Set the unknown handler for a particular ensemble.
*
* Results:
- * Tcl result code (error if command token does not indicate an
- * ensemble or the unknown handler - if non-NULL - is not a list).
+ * Tcl result code (error if command token does not indicate an ensemble
+ * or the unknown handler - if non-NULL - is not a list).
*
* Side effects:
* The ensemble is updated and marked for recompilation.
@@ -5440,11 +5426,12 @@ Tcl_SetEnsembleUnknownHandler(interp, token, unknownList)
}
/*
- * Trigger an eventual recomputation of the ensemble command
- * set. Note that this is slightly tricky, as it means that
- * we are not actually counting the number of namespace export
- * actions, but it is the simplest way to go!
+ * Trigger an eventual recomputation of the ensemble command set. Note
+ * that this is slightly tricky, as it means that we are not actually
+ * counting the number of namespace export actions, but it is the simplest
+ * way to go!
*/
+
ensemblePtr->nsPtr->exportLookupEpoch++;
return TCL_OK;
@@ -5491,11 +5478,12 @@ Tcl_SetEnsembleFlags(interp, token, flags)
ensemblePtr->flags |= flags & ~ENS_DEAD;
/*
- * Trigger an eventual recomputation of the ensemble command
- * set. Note that this is slightly tricky, as it means that
- * we are not actually counting the number of namespace export
- * actions, but it is the simplest way to go!
+ * Trigger an eventual recomputation of the ensemble command set. Note
+ * that this is slightly tricky, as it means that we are not actually
+ * counting the number of namespace export actions, but it is the simplest
+ * way to go!
*/
+
ensemblePtr->nsPtr->exportLookupEpoch++;
return TCL_OK;
@@ -5511,9 +5499,9 @@ Tcl_SetEnsembleFlags(interp, token, flags)
* Results:
* Tcl result code (error if command token does not indicate an
* ensemble). The list of subcommands is returned by updating the
- * variable pointed to by the last parameter (NULL if this is to
- * be derived from the mapping dictionary or the associated
- * namespace's exported commands).
+ * variable pointed to by the last parameter (NULL if this is to be
+ * derived from the mapping dictionary or the associated namespace's
+ * exported commands).
*
* Side effects:
* None
@@ -5547,14 +5535,13 @@ Tcl_GetEnsembleSubcommandList(interp, token, subcmdListPtr)
*
* Tcl_GetEnsembleMappingDict --
*
- * Get the command mapping dictionary associated with a
- * particular ensemble.
+ * Get the command mapping dictionary associated with a particular
+ * ensemble.
*
* Results:
* Tcl result code (error if command token does not indicate an
- * ensemble). The mapping dict is returned by updating the
- * variable pointed to by the last parameter (NULL if none is
- * installed).
+ * ensemble). The mapping dict is returned by updating the variable
+ * pointed to by the last parameter (NULL if none is installed).
*
* Side effects:
* None
@@ -5592,9 +5579,8 @@ Tcl_GetEnsembleMappingDict(interp, token, mapDictPtr)
*
* Results:
* Tcl result code (error if command token does not indicate an
- * ensemble). The unknown handler is returned by updating the
- * variable pointed to by the last parameter (NULL if no handler
- * is installed).
+ * ensemble). The unknown handler is returned by updating the variable
+ * pointed to by the last parameter (NULL if no handler is installed).
*
* Side effects:
* None
@@ -5632,8 +5618,8 @@ Tcl_GetEnsembleUnknownHandler(interp, token, unknownListPtr)
*
* Results:
* Tcl result code (error if command token does not indicate an
- * ensemble). The flags are returned by updating the variable
- * pointed to by the last parameter.
+ * ensemble). The flags are returned by updating the variable pointed to
+ * by the last parameter.
*
* Side effects:
* None
@@ -5671,8 +5657,8 @@ Tcl_GetEnsembleFlags(interp, token, flagsPtr)
*
* Results:
* Tcl result code (error if command token does not indicate an
- * ensemble). Namespace is returned by updating the variable
- * pointed to by the last parameter.
+ * ensemble). Namespace is returned by updating the variable pointed to
+ * by the last parameter.
*
* Side effects:
* None
@@ -5706,14 +5692,13 @@ Tcl_GetEnsembleNamespace(interp, token, namespacePtrPtr)
*
* Tcl_FindEnsemble --
*
- * Given a command name, get the ensemble token for it, allowing
- * for [namespace import]s. [Bug 1017022]
+ * Given a command name, get the ensemble token for it, allowing for
+ * [namespace import]s. [Bug 1017022]
*
* Results:
- * The token for the ensemble command with the given name, or
- * NULL if the command either does not exist or is not an
- * ensemble (when an error message will be written into the
- * interp if thats non-NULL).
+ * The token for the ensemble command with the given name, or NULL if the
+ * command either does not exist or is not an ensemble (when an error
+ * message will be written into the interp if thats non-NULL).
*
* Side effects:
* None
@@ -5728,8 +5713,9 @@ Tcl_FindEnsemble(interp, cmdNameObj, flags)
* TCL_LEAVE_ERR_MSG is set in the
* flags. */
Tcl_Obj *cmdNameObj; /* Name of command to look up. */
- int flags; /* Either 0 or TCL_LEAVE_ERR_MSG; other
- * flags are probably not useful. */
+ int flags; /* Either 0 or TCL_LEAVE_ERR_MSG;
+ * other flags are probably not
+ * useful. */
{
Command *cmdPtr;
@@ -5740,9 +5726,10 @@ Tcl_FindEnsemble(interp, cmdNameObj, flags)
}
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
/*
- * Reuse existing infrastructure for following import link
- * chains rather than duplicating it.
+ * Reuse existing infrastructure for following import link chains
+ * rather than duplicating it.
*/
+
cmdPtr = (Command *) TclGetOriginalCommand((Tcl_Command) cmdPtr);
if (cmdPtr == NULL || cmdPtr->objProc != NsEnsembleImplementationCmd) {
@@ -5794,18 +5781,18 @@ Tcl_IsEnsemble(token)
* NsEnsembleImplementationCmd --
*
* Implements an ensemble of commands (being those exported by a
- * namespace other than the global namespace) as a command with
- * the same (short) name as the namespace in the parent namespace.
+ * namespace other than the global namespace) as a command with the same
+ * (short) name as the namespace in the parent namespace.
*
* Results:
- * A standard Tcl result code. Will be TCL_ERROR if the command
- * is not an unambiguous prefix of any command exported by the
- * ensemble's namespace.
+ * A standard Tcl result code. Will be TCL_ERROR if the command is not
+ * an unambiguous prefix of any command exported by the ensemble's
+ * namespace.
*
* Side effects:
- * Depends on the command within the namespace that gets executed.
- * If the ensemble itself returns TCL_ERROR, a descriptive error
- * message will be placed in the interpreter's result.
+ * Depends on the command within the namespace that gets executed. If
+ * the ensemble itself returns TCL_ERROR, a descriptive error message
+ * will be placed in the interpreter's result.
*
*----------------------------------------------------------------------
*/
@@ -5826,13 +5813,13 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
int result; /* The result of the subcommand
* execution. */
Tcl_Obj *prefixObj; /* An object containing the prefix
- * words of the command that implements
- * the subcommand. */
+ * words of the command that
+ * implements the subcommand. */
Tcl_HashEntry *hPtr; /* Used for efficient lookup of fully
- * specified but not yet cached command
- * names. */
- Tcl_Obj **prefixObjv; /* The list of objects to substitute in
- * as the target command prefix. */
+ * specified but not yet cached
+ * command names. */
+ Tcl_Obj **prefixObjv; /* The list of objects to substitute
+ * in as the target command prefix. */
int prefixObjc; /* Size of prefixObjv of course! */
int reparseCount = 0; /* Number of reparses. */
@@ -5846,6 +5833,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
/*
* Don't know how we got here, but make things give up quickly.
*/
+
if (!Tcl_InterpDeleted(interp)) {
Tcl_AppendResult(interp,
"ensemble activated for deleted namespace", NULL);
@@ -5858,11 +5846,10 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
BuildEnsembleConfig(ensemblePtr);
} else {
/*
- * Table of subcommands is still valid; therefore there might
- * be a valid cache of discovered information which we can
- * reuse. Do the check here, and if we're still valid, we can
- * jump straight to the part where we do the invocation of the
- * subcommand.
+ * Table of subcommands is still valid; therefore there might be a
+ * valid cache of discovered information which we can reuse. Do the
+ * check here, and if we're still valid, we can jump straight to the
+ * part where we do the invocation of the subcommand.
*/
if (objv[1]->typePtr == &ensembleCmdType) {
@@ -5879,8 +5866,8 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
}
/*
- * Look in the hashtable for the subcommand name; this is the
- * fastest way of all.
+ * Look in the hashtable for the subcommand name; this is the fastest way
+ * of all.
*/
hPtr = Tcl_FindHashEntry(&ensemblePtr->subcommandTable,
@@ -5901,9 +5888,9 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
goto unknownOrAmbiguousSubcommand;
} else {
/*
- * If we've not already confirmed the command with the hash as
- * part of building our export table, we need to scan the
- * sorted array for matches.
+ * If we've not already confirmed the command with the hash as part of
+ * building our export table, we need to scan the sorted array for
+ * matches.
*/
char *subcmdName; /* Name of the subcommand, or unique
@@ -5918,24 +5905,23 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
for (i=0 ; i<tableLength ; i++) {
register int cmp = strncmp(subcmdName,
ensemblePtr->subcommandArrayPtr[i],
- (unsigned)stringLength);
+ (unsigned) stringLength);
if (cmp == 0) {
if (fullName != NULL) {
/*
- * Since there's never the exact-match case to
- * worry about (hash search filters this), getting
- * here indicates that our subcommand is an
- * ambiguous prefix of (at least) two exported
- * subcommands, which is an error case.
+ * Since there's never the exact-match case to worry about
+ * (hash search filters this), getting here indicates that
+ * our subcommand is an ambiguous prefix of (at least) two
+ * exported subcommands, which is an error case.
*/
goto unknownOrAmbiguousSubcommand;
}
fullName = ensemblePtr->subcommandArrayPtr[i];
} else if (cmp < 0) {
/*
- * Because we are searching a sorted table, we can now
- * stop searching because we have gone past anything
- * that could possibly match.
+ * Because we are searching a sorted table, we can now stop
+ * searching because we have gone past anything that could
+ * possibly match.
*/
break;
}
@@ -5961,14 +5947,13 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
}
/*
- * Do the real work of execution of the subcommand by building an
- * array of objects (note that this is potentially not the same
- * length as the number of arguments to this ensemble command),
- * populating it and then feeding it back through the main
- * command-lookup engine. In theory, we could look up the command
- * in the namespace ourselves, as we already have the namespace in
- * which it is guaranteed to exist, but we don't do that (the
- * cacheing of the command object used should help with that.)
+ * Do the real work of execution of the subcommand by building an array of
+ * objects (note that this is potentially not the same length as the
+ * number of arguments to this ensemble command), populating it and then
+ * feeding it back through the main command-lookup engine. In theory, we
+ * could look up the command in the namespace ourselves, as we already
+ * have the namespace in which it is guaranteed to exist, but we don't do
+ * that (the cacheing of the command object used should help with that.)
*/
Tcl_IncrRefCount(prefixObj);
@@ -6008,10 +5993,10 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
unknownOrAmbiguousSubcommand:
/*
- * Have not been able to match the subcommand asked for with a
- * real subcommand that we export. See whether a handler has been
- * registered for dealing with this situation. Will only call (at
- * most) once for any particular ensemble invocation.
+ * Have not been able to match the subcommand asked for with a real
+ * subcommand that we export. See whether a handler has been registered
+ * for dealing with this situation. Will only call (at most) once for any
+ * particular ensemble invocation.
*/
if (ensemblePtr->unknownHandler != NULL && reparseCount++ < 1) {
@@ -6044,9 +6029,9 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
}
/*
- * Namespace is still there. Check if the result is a
- * valid list. If it is, and it is non-empty, that list
- * is what we are using as our replacement.
+ * Namespace is still there. Check if the result is a valid list.
+ * If it is, and it is non-empty, that list is what we are using
+ * as our replacement.
*/
if (Tcl_ListObjLength(interp, prefixObj, &prefixObjc) != TCL_OK) {
@@ -6103,9 +6088,9 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
/*
* Cannot determine what subcommand to hand off to, so generate a
- * (standard) failure message. Note the one odd case compared
- * with standard ensemble-like command, which is where a namespace
- * has no exported commands at all...
+ * (standard) failure message. Note the one odd case compared with
+ * standard ensemble-like command, which is where a namespace has no
+ * exported commands at all...
*/
Tcl_ResetResult(interp);
@@ -6137,11 +6122,10 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
*
* MakeCachedEnsembleCommand --
*
- * Cache what we've computed so far; it's not nice to repeatedly
- * copy strings about. Note that to do this, we start by
- * deleting any old representation that there was (though if it
- * was an out of date ensemble rep, we can skip some of the
- * deallocation process.)
+ * Cache what we've computed so far; it's not nice to repeatedly copy
+ * strings about. Note that to do this, we start by deleting any old
+ * representation that there was (though if it was an out of date
+ * ensemble rep, we can skip some of the deallocation process.)
*
* Results:
* None
@@ -6172,8 +6156,8 @@ MakeCachedEnsembleCommand(objPtr, ensemblePtr, subcommandName, prefixObjPtr)
ckfree(ensembleCmd->fullSubcmdName);
} else {
/*
- * Kill the old internal rep, and replace it with a brand new
- * one of our own.
+ * Kill the old internal rep, and replace it with a brand new one of
+ * our own.
*/
TclFreeIntRep(objPtr);
ensembleCmd = (EnsembleCmdRep *) ckalloc(sizeof(EnsembleCmdRep));
@@ -6184,6 +6168,7 @@ MakeCachedEnsembleCommand(objPtr, ensemblePtr, subcommandName, prefixObjPtr)
/*
* Populate the internal rep.
*/
+
ensembleCmd->nsPtr = ensemblePtr->nsPtr;
ensembleCmd->epoch = ensemblePtr->epoch;
ensembleCmd->token = ensemblePtr->token;
@@ -6200,11 +6185,11 @@ MakeCachedEnsembleCommand(objPtr, ensemblePtr, subcommandName, prefixObjPtr)
*
* DeleteEnsembleConfig --
*
- * Destroys the data structure used to represent an ensemble.
- * This is called when the ensemble's command is deleted (which
- * happens automatically if the ensemble's namespace is deleted.)
- * Maintainers should note that ensembles should be deleted by
- * deleting their commands.
+ * Destroys the data structure used to represent an ensemble. This is
+ * called when the ensemble's command is deleted (which happens
+ * automatically if the ensemble's namespace is deleted.) Maintainers
+ * should note that ensembles should be deleted by deleting their
+ * commands.
*
* Results:
* None.
@@ -6225,8 +6210,8 @@ DeleteEnsembleConfig(clientData)
Tcl_HashEntry *hEnt;
/*
- * Unlink from the ensemble chain if it has not been marked as
- * having been done already.
+ * Unlink from the ensemble chain if it has not been marked as having been
+ * done already.
*/
if (ensemblePtr->next != ensemblePtr) {
@@ -6245,8 +6230,8 @@ DeleteEnsembleConfig(clientData)
}
/*
- * Mark the namespace as dead so code that uses Tcl_Preserve() can
- * tell whether disaster happened anyway.
+ * Mark the namespace as dead so code that uses Tcl_Preserve() can tell
+ * whether disaster happened anyway.
*/
ensemblePtr->flags |= ENS_DEAD;
@@ -6276,10 +6261,10 @@ DeleteEnsembleConfig(clientData)
}
/*
- * Arrange for the structure to be reclaimed. Note that this is
- * complex because we have to make sure that we can react sensibly
- * when an ensemble is deleted during the process of initialising
- * the ensemble (especially the unknown callback.)
+ * Arrange for the structure to be reclaimed. Note that this is complex
+ * because we have to make sure that we can react sensibly when an
+ * ensemble is deleted during the process of initialising the ensemble
+ * (especially the unknown callback.)
*/
Tcl_EventuallyFree((ClientData) ensemblePtr, TCL_DYNAMIC);
@@ -6290,19 +6275,19 @@ DeleteEnsembleConfig(clientData)
*
* BuildEnsembleConfig --
*
- * Create the internal data structures that describe how an
- * ensemble looks, being a hash mapping from the full command
- * name to the Tcl list that describes the implementation prefix
- * words, and a sorted array of all the full command names to
- * allow for reasonably efficient unambiguous prefix handling.
+ * Create the internal data structures that describe how an ensemble
+ * looks, being a hash mapping from the full command name to the Tcl list
+ * that describes the implementation prefix words, and a sorted array of
+ * all the full command names to allow for reasonably efficient
+ * unambiguous prefix handling.
*
* Results:
* None.
*
* Side effects:
- * Reallocates and rebuilds the hash table and array stored at
- * the ensemblePtr argument. For large ensembles or large
- * namespaces, this is a potentially expensive operation.
+ * Reallocates and rebuilds the hash table and array stored at the
+ * ensemblePtr argument. For large ensembles or large namespaces, this
+ * is a potentially expensive operation.
*
*----------------------------------------------------------------------
*/
@@ -6336,10 +6321,9 @@ BuildEnsembleConfig(ensemblePtr)
}
/*
- * See if we've got an export list. If so, we will only export
- * exactly those commands, which may be either implemented by the
- * prefix in the subcommandDict or mapped directly onto the
- * namespace's commands.
+ * See if we've got an export list. If so, we will only export exactly
+ * those commands, which may be either implemented by the prefix in the
+ * subcommandDict or mapped directly onto the namespace's commands.
*/
if (ensemblePtr->subcmdList != NULL) {
@@ -6357,9 +6341,11 @@ BuildEnsembleConfig(ensemblePtr)
if (!isNew) {
continue;
}
+
/*
* Look in our dictionary (if present) for the command.
*/
+
if (ensemblePtr->subcommandDict != NULL) {
Tcl_DictObjGet(NULL, ensemblePtr->subcommandDict, subcmdv[i],
&target);
@@ -6369,12 +6355,13 @@ BuildEnsembleConfig(ensemblePtr)
continue;
}
}
+
/*
- * Not there, so map onto the namespace. Note in this
- * case that we do not guarantee that the command is
- * actually there; that is the programmer's responsibility
- * (or [::unknown] of course).
+ * Not there, so map onto the namespace. Note in this case that
+ * we do not guarantee that the command is actually there; that is
+ * the programmer's responsibility (or [::unknown] of course).
*/
+
cmdObj = Tcl_NewStringObj(ensemblePtr->nsPtr->fullName, -1);
if (ensemblePtr->nsPtr->parentPtr != NULL) {
Tcl_AppendStringsToObj(cmdObj, "::", name, NULL);
@@ -6387,11 +6374,11 @@ BuildEnsembleConfig(ensemblePtr)
}
} else if (ensemblePtr->subcommandDict != NULL) {
/*
- * No subcmd list, but we do have a mapping dictionary so we
- * should use the keys of that. Convert the dictionary's
- * contents into the form required for the ensemble's internal
- * hashtable.
+ * No subcmd list, but we do have a mapping dictionary so we should
+ * use the keys of that. Convert the dictionary's contents into the
+ * form required for the ensemble's internal hashtable.
*/
+
Tcl_DictSearch dictSearch;
Tcl_Obj *keyObj, *valueObj;
int done;
@@ -6400,6 +6387,7 @@ BuildEnsembleConfig(ensemblePtr)
&keyObj, &valueObj, &done);
while (!done) {
char *name = TclGetString(keyObj);
+
hPtr = Tcl_CreateHashEntry(hash, name, &isNew);
Tcl_SetHashValue(hPtr, (ClientData) valueObj);
Tcl_IncrRefCount(valueObj);
@@ -6407,19 +6395,18 @@ BuildEnsembleConfig(ensemblePtr)
}
} else {
/*
- * Discover what commands are actually exported by the
- * namespace. What we have is an array of patterns and a hash
- * table whose keys are the command names exported by the
- * namespace (the contents do not matter here.) We must find
- * out what commands are actually exported by filtering each
- * command in the namespace against each of the patterns in
- * the export list. Note that we use an intermediate hash
- * table to make memory management easier, and because that
- * makes exact matching far easier too.
+ * Discover what commands are actually exported by the namespace.
+ * What we have is an array of patterns and a hash table whose keys
+ * are the command names exported by the namespace (the contents do
+ * not matter here.) We must find out what commands are actually
+ * exported by filtering each command in the namespace against each of
+ * the patterns in the export list. Note that we use an intermediate
+ * hash table to make memory management easier, and because that makes
+ * exact matching far easier too.
*
- * Suggestion for future enhancement: compute the unique
- * prefixes and place them in the hash too, which should make
- * for even faster matching.
+ * Suggestion for future enhancement: compute the unique prefixes and
+ * place them in the hash too, which should make for even faster
+ * matching.
*/
hPtr = Tcl_FirstHashEntry(&ensemblePtr->nsPtr->cmdTable, &search);
@@ -6433,9 +6420,9 @@ BuildEnsembleConfig(ensemblePtr)
hPtr = Tcl_CreateHashEntry(hash, nsCmdName, &isNew);
/*
- * Remember, hash entries have a full reference to
- * the substituted part of the command (as a list)
- * as their content!
+ * Remember, hash entries have a full reference to the
+ * substituted part of the command (as a list) as their
+ * content!
*/
if (isNew) {
@@ -6462,40 +6449,36 @@ BuildEnsembleConfig(ensemblePtr)
}
/*
- * Create a sorted array of all subcommands in the ensemble; hash
- * tables are all very well for a quick look for an exact match,
- * but they can't determine things like whether a string is a
- * prefix of another (not without lots of preparation anyway) and
- * they're no good for when we're generating the error message
- * either.
+ * Create a sorted array of all subcommands in the ensemble; hash tables
+ * are all very well for a quick look for an exact match, but they can't
+ * determine things like whether a string is a prefix of another (not
+ * without lots of preparation anyway) and they're no good for when we're
+ * generating the error message either.
*
- * We do this by filling an array with the names (we use the hash
- * keys directly to save a copy, since any time we change the
- * array we change the hash too, and vice versa) and running
- * quicksort over the array.
+ * We do this by filling an array with the names (we use the hash keys
+ * directly to save a copy, since any time we change the array we change
+ * the hash too, and vice versa) and running quicksort over the array.
*/
ensemblePtr->subcommandArrayPtr = (char **)
ckalloc(sizeof(char *) * hash->numEntries);
/*
- * Fill array from both ends as this makes us less likely to end
- * up with performance problems in qsort(), which is good. Note
- * that doing this makes this code much more opaque, but the naive
- * alternatve:
+ * Fill array from both ends as this makes us less likely to end up with
+ * performance problems in qsort(), which is good. Note that doing this
+ * makes this code much more opaque, but the naive alternatve:
*
* for (hPtr=Tcl_FirstHashEntry(hash,&search),i=0 ;
- * hPtr!=NULL ; hPtr=Tcl_NextHashEntry(&search),i++) {
- * ensemblePtr->subcommandArrayPtr[i] =
- * Tcl_GetHashKey(hash, &hPtr);
+ * hPtr!=NULL ; hPtr=Tcl_NextHashEntry(&search),i++) {
+ * ensemblePtr->subcommandArrayPtr[i] = Tcl_GetHashKey(hash, &hPtr);
* }
*
- * can produce long runs of precisely ordered table entries when
- * the commands in the namespace are declared in a sorted fashion
- * (an ordering some people like) and the hashing functions (or
- * the command names themselves) are fairly unfortunate. By
- * filling from both ends, it requires active malice (and probably
- * a debugger) to get qsort() to have awful runtime behaviour.
+ * can produce long runs of precisely ordered table entries when the
+ * commands in the namespace are declared in a sorted fashion (an ordering
+ * some people like) and the hashing functions (or the command names
+ * themselves) are fairly unfortunate. By filling from both ends, it
+ * requires active malice (and probably a debugger) to get qsort() to have
+ * awful runtime behaviour.
*/
i = 0;
@@ -6521,12 +6504,12 @@ BuildEnsembleConfig(ensemblePtr)
*
* NsEnsembleStringOrder --
*
- * Helper function to compare two pointers to two strings for use
- * with qsort().
+ * Helper function to compare two pointers to two strings for use with
+ * qsort().
*
* Results:
- * -1 if the first string is smaller, 1 if the second string is
- * smaller, and 0 if they are equal.
+ * -1 if the first string is smaller, 1 if the second string is smaller,
+ * and 0 if they are equal.
*
* Side effects:
* None.
@@ -6582,15 +6565,15 @@ FreeEnsembleCmdRep(objPtr)
*
* DupEnsembleCmdRep --
*
- * Makes one Tcl_Obj into a copy of another that is a subcommand
- * of an ensemble.
+ * Makes one Tcl_Obj into a copy of another that is a subcommand of an
+ * ensemble.
*
* Results:
* None.
*
* Side effects:
- * Memory is allocated, and the namespace that the ensemble is
- * built on top of gains another reference.
+ * Memory is allocated, and the namespace that the ensemble is built on
+ * top of gains another reference.
*
*----------------------------------------------------------------------
*/
@@ -6623,8 +6606,8 @@ DupEnsembleCmdRep(objPtr, copyPtr)
*
* StringOfEnsembleCmdRep --
*
- * Creates a string representation of a Tcl_Obj that holds a
- * subcommand of an ensemble.
+ * Creates a string representation of a Tcl_Obj that holds a subcommand
+ * of an ensemble.
*
* Results:
* None.