Index: generic/nsf.c =================================================================== diff -u -r3b5f62d43eeca24c06993127a7637e7b9ec17216 -r8eecbe5b3a2640ba1d3e1dc6dc5e9cec0c2a26ba --- generic/nsf.c (.../nsf.c) (revision 3b5f62d43eeca24c06993127a7637e7b9ec17216) +++ generic/nsf.c (.../nsf.c) (revision 8eecbe5b3a2640ba1d3e1dc6dc5e9cec0c2a26ba) @@ -1013,12 +1013,12 @@ /* * Support for variable hash tables */ -static NSF_INLINE Var *VarHashCreateVar(TclVarHashTable *tablePtr, Tcl_Obj *key, int *newPtr) nonnull(1) nonnull(2); +static NSF_INLINE Var *VarHashCreateVar(TclVarHashTable *tablePtr, const Tcl_Obj *key, int *newPtr) nonnull(1) nonnull(2); static NSF_INLINE Var * -VarHashCreateVar(TclVarHashTable *tablePtr, Tcl_Obj *key, int *newPtr) { - Var *varPtr = NULL; - Tcl_HashEntry *hPtr; +VarHashCreateVar(TclVarHashTable *tablePtr, const Tcl_Obj *key, int *newPtr) { + Var *varPtr = NULL; + const Tcl_HashEntry *hPtr; nonnull_assert(tablePtr != NULL); nonnull_assert(key != NULL); @@ -1136,7 +1136,7 @@ /*********************************************************************** * EXTERN callable routines for the preliminary C interface ***********************************************************************/ -Nsf_Object * NsfGetSelfObj(Tcl_Interp *interp) nonnull(1); +Nsf_Object * NsfGetSelfObj(const Tcl_Interp *interp) nonnull(1); Nsf_Object * NsfGetObject(Tcl_Interp *interp, const char *name) nonnull(1) nonnull(2); Nsf_Class * NsfGetClass(Tcl_Interp *interp, const char *name) nonnull(1) nonnull(2); Nsf_Class * NsfIsClass(Tcl_Interp *interp, ClientData clientData) nonnull(1) nonnull(2); @@ -1163,7 +1163,7 @@ ClientData NsfGetClassClientData(Tcl_Interp *interp, Nsf_Class *cl) nonnull(1) nonnull(2); Nsf_Object * -NsfGetSelfObj(Tcl_Interp *interp) { +NsfGetSelfObj(const Tcl_Interp *interp) { nonnull_assert(interp != NULL); return (Nsf_Object *) GetSelfObj(interp); } @@ -2241,14 +2241,14 @@ * *---------------------------------------------------------------------- */ -static NsfClasses *NsfClassListFind(NsfClasses *clPtr, NsfClass *cl) nonnull(2); +static NsfClasses *NsfClassListFind(NsfClasses *clPtr, const NsfClass *cl) nonnull(2); static NsfClasses * -NsfClassListFind(NsfClasses *clPtr, NsfClass *cl) { +NsfClassListFind(NsfClasses *clPtr, const NsfClass *cl) { nonnull_assert(cl != NULL); - for (; clPtr; clPtr = clPtr->nextPtr) { + for (; clPtr != NULL; clPtr = clPtr->nextPtr) { if (clPtr->cl == cl) { break; } @@ -2284,7 +2284,7 @@ nonnull_assert(title != NULL); cl = (classListPtr != NULL) ? classListPtr->cl : NULL; - for (; classListPtr; classListPtr = classListPtr->nextPtr) { + for (; classListPtr != NULL; classListPtr = classListPtr->nextPtr) { count++; } @@ -2328,10 +2328,10 @@ * *---------------------------------------------------------------------- */ -static NsfClasses *NsfClassListUnlink(NsfClasses **firstPtrPtr, void *key) nonnull(1) nonnull(2); +static NsfClasses *NsfClassListUnlink(NsfClasses **firstPtrPtr, const void *key) nonnull(1) nonnull(2); static NsfClasses * -NsfClassListUnlink(NsfClasses **firstPtrPtr, void *key) { +NsfClassListUnlink(NsfClasses **firstPtrPtr, const void *key) { NsfClasses *entryPtr = NULL; nonnull_assert(firstPtrPtr != NULL); @@ -2341,7 +2341,10 @@ NsfClasses *prevPtr = NULL; /* list is non-empty */ - for (entryPtr = *firstPtrPtr; entryPtr; prevPtr = entryPtr, entryPtr = entryPtr->nextPtr) { + for (entryPtr = *firstPtrPtr; + entryPtr != NULL; + prevPtr = entryPtr, entryPtr = entryPtr->nextPtr + ) { if ((void *)entryPtr->cl == key) { /* found entry */ if (prevPtr != NULL) { @@ -2412,20 +2415,21 @@ cl->color = GRAY; for (; sl != NULL; sl = sl->nextPtr) { NsfClass *sc = sl->cl; + if (sc->color == GRAY) { cl->color = WHITE; return 0; } if (unlikely(sc->color == WHITE && !TopoSort(sc, baseClass, direction, withMixinOfs))) { cl->color = WHITE; if (cl == baseClass) { - register NsfClasses *pc; - for (pc = cl->order; pc; pc = pc->nextPtr) { pc->cl->color = WHITE; } + const register NsfClasses *pc; + for (pc = cl->order; pc != NULL; pc = pc->nextPtr) { pc->cl->color = WHITE; } } return 0; } } if (withMixinOfs != 0) { NsfCmdList *classMixins = ((cl->opt != NULL) && cl->opt->isClassMixinOf) ? cl->opt->isClassMixinOf : NULL; - for (; classMixins; classMixins = classMixins->nextPtr) { + for (; classMixins != NULL; classMixins = classMixins->nextPtr) { NsfClass *sc = NsfGetClassFromCmdPtr(classMixins->cmdPtr); if (likely(sc != NULL) @@ -2906,7 +2910,7 @@ #endif } - for (pl = sl->cl->order; pl; pl = pl->nextPtr) { + for (pl = sl->cl->order; pl != NULL; pl = pl->nextPtr) { #if defined(NSF_LINEARIZER_TRACE) fprintf(stderr, "====== PO order: %s %p\n", ClassName(pl->cl), pl->cl->order); #endif @@ -3407,8 +3411,8 @@ if (tailContainsSpace != 0) { const char *firstElementString; - Tcl_Namespace *parentNsPtr; - NsfObject *ensembleObject; + const Tcl_Namespace *parentNsPtr; + const NsfObject *ensembleObject; Tcl_Obj *methodHandleObj, **ov; int oc, i; @@ -3636,15 +3640,18 @@ NSF_INLINE static Tcl_Command FindMethod(Tcl_Namespace *nsPtr, const char *methodName) { - register Tcl_HashEntry *entryPtr; + register const Tcl_HashEntry *entryPtr; + Tcl_Command result; nonnull_assert(nsPtr != NULL); nonnull_assert(methodName != NULL); if ((entryPtr = Tcl_CreateHashEntry(Tcl_Namespace_cmdTablePtr(nsPtr), methodName, NULL))) { - return (Tcl_Command) Tcl_GetHashValue(entryPtr); + result = (Tcl_Command) Tcl_GetHashValue(entryPtr); + } else { + result = NULL; } - return NULL; + return result; } /* @@ -3837,7 +3844,7 @@ nonnull_assert(methodObj != NULL); nonnull_assert(cmdPtr != NULL); - for (pl = PrecedenceOrder(cl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(cl); pl != NULL; pl = pl->nextPtr) { Tcl_Command cmd = ResolveMethodName(interp, pl->cl->nsPtr, methodObj, NULL, NULL, NULL, NULL, &fromClassNS); if (cmd != NULL) { @@ -4058,7 +4065,7 @@ * Collect all instances from all object systems */ - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = osPtr->nextPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = osPtr->nextPtr) { GetAllInstances(interp, &instances, osPtr->rootClass); } @@ -4067,7 +4074,7 @@ /*fprintf(stderr, "===CALL destroy on OBJECTS\n");*/ - for (entryPtr = instances; entryPtr; entryPtr = entryPtr->nextPtr) { + for (entryPtr = instances; entryPtr != NULL; entryPtr = entryPtr->nextPtr) { NsfObject *object = (NsfObject *)entryPtr->clorobj; /*fprintf(stderr, "key = %s %p %d flags %.6x\n", @@ -4081,7 +4088,7 @@ /*fprintf(stderr, "===CALL destroy on CLASSES\n");*/ - for (entryPtr = instances; entryPtr; entryPtr = entryPtr->nextPtr) { + for (entryPtr = instances; entryPtr != NULL; entryPtr = entryPtr->nextPtr) { NsfClass *cl = entryPtr->clorobj; if (cl != NULL && ((cl->object.flags & NSF_DESTROY_CALLED) == 0u)) { @@ -4100,7 +4107,7 @@ #endif /* now free all objects systems with their root classes */ - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = nPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = nPtr) { nPtr = osPtr->nextPtr; ObjectSystemFree(interp, osPtr); } @@ -4358,11 +4365,11 @@ * *---------------------------------------------------------------------- */ -static void GetVarAndNameFromHash(Tcl_HashEntry *hPtr, Var **val, Tcl_Obj **varNameObj) +static void GetVarAndNameFromHash(const Tcl_HashEntry *hPtr, Var **val, Tcl_Obj **varNameObj) nonnull(1) nonnull(2) nonnull(3); static void -GetVarAndNameFromHash(Tcl_HashEntry *hPtr, Var **val, Tcl_Obj **varNameObj) { +GetVarAndNameFromHash(const Tcl_HashEntry *hPtr, Var **val, Tcl_Obj **varNameObj) { nonnull_assert(hPtr != NULL); nonnull_assert(val != NULL); @@ -4595,7 +4602,7 @@ * TCL_CONTINUE takes care for variable creation. */ - Var *newVar = VarHashCreateVar(varTablePtr, key, &new); + const Var *newVar = VarHashCreateVar(varTablePtr, key, &new); *varPtr = (Tcl_Var)newVar; } DECR_REF_COUNT(key); @@ -4755,7 +4762,7 @@ VarHashRefCount(var)++; #if defined(VAR_RESOLVER_TRACE) { - Var *v = (Var *)(resVarInfo->var); + const Var *v = (Var *)(resVarInfo->var); fprintf(stderr, ".... looked up existing var %s var %p flags = %.6x undefined %d\n", ObjStr(resVarInfo->nameObj), v, v->flags, @@ -5198,7 +5205,7 @@ NsfObjectSystem *osPtr; if ((frameFlags & (FRAME_IS_NSF_METHOD|FRAME_IS_NSF_CMETHOD)) != 0u) { - NsfCallStackContent *cscPtr = (NsfCallStackContent *)varFramePtr->clientData; + const NsfCallStackContent *cscPtr = (NsfCallStackContent *)varFramePtr->clientData; assert(cscPtr != NULL); object = cscPtr->self; } else if ((frameFlags & (FRAME_IS_NSF_OBJECT)) != 0u) { @@ -5627,7 +5634,7 @@ NSDeleteChildren(Tcl_Interp *interp, Tcl_Namespace *nsPtr) { Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(nsPtr); Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; int expected; nonnull_assert(interp != NULL); @@ -5699,7 +5706,7 @@ TclVarHashTable *varTablePtr = Tcl_Namespace_varTablePtr(nsPtr); Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(nsPtr); Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(interp != NULL); nonnull_assert(nsPtr != NULL); @@ -6123,7 +6130,7 @@ ReverseLookupCmdFromCmdTable(Tcl_Interp *interp /* needed? */, Tcl_Command searchCmdPtr, Tcl_HashTable *cmdTablePtr) { Tcl_HashSearch search; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(searchCmdPtr != NULL); nonnull_assert(cmdTablePtr != NULL); @@ -6230,7 +6237,7 @@ /*fprintf(stderr, "GetObjectFromString name = '%s'\n", name);*/ cmd = NSFindCommand(interp, name); - if (likely(cmd && CmdIsNsfObject(cmd))) { + if (likely(cmd != NULL && CmdIsNsfObject(cmd))) { /*fprintf(stderr, "GetObjectFromString %s => %p\n", name, Tcl_Command_objClientData(cmd));*/ return (NsfObject *)Tcl_Command_objClientData(cmd); } @@ -6546,6 +6553,7 @@ ALLOC_ON_STACK(Tcl_Obj*, 3, ov); savedResultObj = Tcl_GetObjResult(interp); INCR_REF_COUNT(savedResultObj); + ov[0] = NULL; ov[1] = resultObj; ov[2] = valueObj; if (NsfCallCommand(interp, NSF_FORMAT, 3, ov) != TCL_OK) { @@ -7210,7 +7218,7 @@ nonnull_assert(value != NULL); keyString = ObjStr(key); - for (elt = *list, prevPtr = list; elt; prevPtr = &elt->nextPtr, elt = elt->nextPtr) { + for (elt = *list, prevPtr = list; elt != NULL; prevPtr = &elt->nextPtr, elt = elt->nextPtr) { const char *eltString = ObjStr(elt->content); if (key == elt->content || strcmp(keyString, eltString) == 0) { @@ -7274,7 +7282,7 @@ nonnull_assert(interp != NULL); - for (; alist; alist = alist->nextPtr) { + for (; alist != NULL; alist = alist->nextPtr) { Tcl_ListObjAppendElement(interp, listObj, alist->content); } return listObj; @@ -7318,7 +7326,7 @@ static NsfProcAssertion * AssertionFindProcs(NsfAssertionStore *aStore, const char *name) { - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(aStore != NULL); nonnull_assert(name != NULL); @@ -7394,7 +7402,7 @@ static void AssertionRemoveStore(NsfAssertionStore *aStore) { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(aStore != NULL); @@ -7731,11 +7739,11 @@ CmdListRemoveDeleted(mixinList, GuardDel); - for (m = *mixinList; m; m = m->nextPtr) { + for (m = *mixinList; m != NULL; m = m->nextPtr) { NsfClass *mCl = NsfGetClassFromCmdPtr(m->cmdPtr); if (mCl != NULL) { - for (pl = PrecedenceOrder(mCl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(mCl); pl != NULL; pl = pl->nextPtr) { if (IsRootClass(pl->cl) == 0) { NsfClassOpt *opt = pl->cl->opt; @@ -7823,7 +7831,7 @@ nonnull_assert(classListPtr != NULL); nonnull_assert(checkList != NULL); - for (pl = PrecedenceOrder(cl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(cl); pl != NULL; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt != NULL && clopt->classMixins) { MixinComputeOrderFullList(interp, &clopt->classMixins, @@ -7874,7 +7882,7 @@ * TODO: we could add this already in MixinComputeOrderFullList() if we * provide an additional flag. */ - for (m = object->opt->objMixins; m; m = m->nextPtr) { + for (m = object->opt->objMixins; m != NULL; m = m->nextPtr) { NsfClass *mCl = NsfGetClassFromCmdPtr(m->cmdPtr); if (mCl != NULL) { NsfClassListAddNoDup(&checkList, mCl, NULL, NULL); @@ -7902,7 +7910,7 @@ * Don't add duplicates or classes of the precedence order to the resulting * list. */ - for (clPtr = mixinClasses; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = mixinClasses; clPtr != NULL; clPtr = clPtr->nextPtr) { NsfClass *cl = clPtr->cl; NsfClasses *checker; @@ -8152,10 +8160,10 @@ nonnull_assert(startCl != NULL); subClasses = TransitiveSubClasses(startCl); - for (clPtr = subClasses; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = subClasses; clPtr != NULL; clPtr = clPtr->nextPtr) { Tcl_HashTable *tablePtr = &clPtr->cl->instances; Tcl_HashSearch search; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; @@ -8366,7 +8374,7 @@ if (startCl->opt != NULL) { NsfCmdList *m; - for (m = startCl->opt->isClassMixinOf; m; m = m->nextPtr) { + for (m = startCl->opt->isClassMixinOf; m != NULL; m = m->nextPtr) { NsfClass *cl; /* we should have no deleted commands in the list */ @@ -8390,7 +8398,7 @@ if (startCl->opt != NULL) { NsfCmdList *m; - for (m = startCl->opt->isObjectMixinOf; m; m = m->nextPtr) { + for (m = startCl->opt->isObjectMixinOf; m != NULL; m = m->nextPtr) { NsfObject *object; /* we should have no deleted commands in the list */ @@ -8447,7 +8455,7 @@ nonnull_assert(resultSet != NULL); nonnull_assert(mixinOfs != NULL); - for (m = mixinOfs; m; m = m->nextPtr) { + for (m = mixinOfs; m != NULL; m = m->nextPtr) { NsfClass *cl; int rc, new; @@ -8623,7 +8631,7 @@ if (startCl->opt != NULL) { NsfCmdList *m; - for (m = startCl->opt->classMixins; m; m = m->nextPtr) { + for (m = startCl->opt->classMixins; m != NULL; m = m->nextPtr) { /* we should have no deleted commands in the list */ assert((Tcl_Command_flags(m->cmdPtr) & CMD_IS_DELETED) == 0); @@ -8916,7 +8924,7 @@ */ do { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashTable *instanceTablePtr; /* @@ -9192,7 +9200,7 @@ /*fprintf(stderr, "... new branch\n");*/ - for (; cmdList; cmdList = cmdList->nextPtr) { + for (; cmdList != NULL; cmdList = cmdList->nextPtr) { NsfClass *cl1; /* @@ -9674,7 +9682,7 @@ if (guardAdded == 0) { /* search per-class filters */ - for (pl = PrecedenceOrder(object->cl); !guardAdded && pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(object->cl); !guardAdded && pl != NULL; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt != NULL && clopt->classFilters != NULL) { guardAdded = GuardAddFromDefinitionList(dest, filterCmd, clopt->classFilters); @@ -9804,7 +9812,7 @@ static int FilterIsActive(Tcl_Interp *interp, const char *methodName) { NsfRuntimeState *rst = RUNTIME_STATE(interp); - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(interp != NULL); nonnull_assert(methodName != NULL); @@ -9958,16 +9966,17 @@ static void FilterSearchAgain(Tcl_Interp *interp, NsfCmdList **filters, NsfObject *startingObject, NsfClass *startingClass) { - NsfCmdList *cmdList = NULL, *del = NULL; + NsfCmdList *cmdList; nonnull_assert(interp != NULL); nonnull_assert(filters != NULL); CmdListRemoveDeleted(filters, GuardDel); cmdList = *filters; - + while (cmdList != NULL) { - NsfClass *cl = NULL; + NsfCmdList *del = NULL; + NsfClass *cl = NULL; const char *simpleName = Tcl_GetCommandName(interp, cmdList->cmdPtr); Tcl_Command cmd = FilterSearch(simpleName, startingObject, startingClass, &cl); @@ -9985,7 +9994,6 @@ if (del != NULL) { CmdListDeleteCmdListEntry(del, GuardDel); - del = NULL; } } } @@ -10017,7 +10025,7 @@ do { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; assert(subClasses->cl); @@ -10076,7 +10084,7 @@ do { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; NsfClassOpt *opt; assert(subClasses->cl); @@ -10247,7 +10255,7 @@ /* don't search on the start class again */ pl = pl->nextPtr; /* now go up the hierarchy */ - for(; pl; pl = pl->nextPtr) { + for(; pl != NULL; pl = pl->nextPtr) { Tcl_Command pi = FindMethod(pl->cl->nsPtr, simpleName); if (pi != NULL) { CmdListAdd(filterList, pi, pl->cl, /*noDuplicates*/ 0, 1); @@ -10324,7 +10332,7 @@ /* * Append per-class filters. */ - for (pl = PrecedenceOrder(object->cl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(object->cl); pl != NULL; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt != NULL && clopt->classFilters != NULL) { FilterComputeOrderFullList(interp, &clopt->classFilters, &filterList); @@ -10339,7 +10347,7 @@ /* * Search for filterList->cmdPtr */ - for (checker = next = filterList->nextPtr; checker; checker = checker->nextPtr) { + for (checker = next = filterList->nextPtr; checker != NULL; checker = checker->nextPtr) { if (checker->cmdPtr == filterList->cmdPtr) { break; } @@ -10502,7 +10510,7 @@ } /* search per-class filters */ - for (pl = PrecedenceOrder(object->cl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(object->cl); pl != NULL; pl = pl->nextPtr) { NsfClassOpt *opt = pl->cl->opt; if (opt != NULL && opt->classFilters != NULL) { if (CmdListFindCmdInList(cmd, opt->classFilters)) { @@ -10800,7 +10808,8 @@ VarExists(Tcl_Interp *interp, NsfObject *object, const char *name1, const char *name2, unsigned int flags) { CallFrame frame, *framePtr = &frame; - Var *varPtr, *arrayPtr; + const Var *varPtr; + Var *arrayPtr; int result; nonnull_assert(interp != NULL); @@ -11056,7 +11065,7 @@ firstChar = *methodName; defOsPtr = GetObjectSystem(object); - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = osPtr->nextPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = osPtr->nextPtr) { int i, isRootClassMethod; unsigned int flag = 0u; NsfObject *defObject; @@ -11248,7 +11257,7 @@ nonnull_assert(paramsPtr != NULL); /*fprintf(stderr, "ParamsFree %p\n", paramsPtr);*/ - for (paramPtr = paramsPtr; paramPtr->name; paramPtr++) { + for (paramPtr = paramsPtr; paramPtr->name != NULL; paramPtr++) { ParamFree(paramPtr); } @@ -11320,14 +11329,16 @@ /* * Count the parameters */ - for (pPtr = paramsPtr, maxParams = 0; pPtr->name; pPtr++, maxParams++); + for (pPtr = paramsPtr, maxParams = 0; pPtr->name != NULL; pPtr++, maxParams++) { + ; + } /* * Allocate the number of potentional matches */ paramList = ParamsNew(maxParams); - for (pPtr = paramsPtr, nrMatchingParams = 0; pPtr->name; pPtr++) { + for (pPtr = paramsPtr, nrMatchingParams = 0; pPtr->name != NULL; pPtr++) { if (Tcl_StringMatch( ObjStr(pPtr->nameObj), pattern)) { paramList[nrMatchingParams] = *pPtr; nrMatchingParams++; @@ -12137,7 +12148,7 @@ INCR_REF_COUNT2("paramDefsObj", argStringObj); - for (pPtr = paramsPtr; pPtr->name; pPtr++) { + for (pPtr = paramsPtr; pPtr->name != NULL; pPtr++) { if ((pPtr->flags & NSF_ARG_NOCONFIG) != 0u) { /* @@ -12419,7 +12430,11 @@ assert((object->flags & NSF_FILTER_ORDER_VALID) != 0u); /* otherwise: FilterComputeDefined(interp, object);*/ - for (cmdList = object->filterOrder; cmdList && cmdList->cmdPtr != cmdPtr; cmdList = cmdList->nextPtr); + for (cmdList = object->filterOrder; + (cmdList != NULL) && (cmdList->cmdPtr != cmdPtr); + cmdList = cmdList->nextPtr) { + ; + } if (cmdList != NULL) { /* @@ -12908,7 +12923,7 @@ for (varFramePtr = (Tcl_CallFrame *)framePtr; likely(varFramePtr != NULL); varFramePtr = Tcl_CallFrame_callerVarPtr(varFramePtr)) { - NsfCallStackContent *cscPtr; + const NsfCallStackContent *cscPtr; /* * If we reach a non-nsf frame, or it is not an ensemble, we are done. @@ -13318,7 +13333,7 @@ NSF_INLINE static int ObjectDispatchFinalize(Tcl_Interp *interp, NsfCallStackContent *cscPtr, int result /*, char *msg, const char *methodName*/) { - NsfRuntimeState *rst = RUNTIME_STATE(interp); + const NsfRuntimeState *rst = RUNTIME_STATE(interp); NsfObject *object; unsigned int flags; @@ -13341,9 +13356,9 @@ if (likely(result == TCL_OK && (cscPtr->cmdPtr != NULL) && (Tcl_Command_cmdEpoch(cscPtr->cmdPtr) == 0))) { - NsfParamDefs *paramDefs = ParamDefsGet(cscPtr->cmdPtr, NULL); + const NsfParamDefs *paramDefs = ParamDefsGet(cscPtr->cmdPtr, NULL); - if ((paramDefs != NULL) && paramDefs->returns) { + if ((paramDefs != NULL) && (paramDefs->returns != NULL)) { Tcl_Obj *valueObj = Tcl_GetObjResult(interp); result = ParameterCheck(interp, paramDefs->returns, valueObj, "return-value:", @@ -13456,7 +13471,7 @@ Tcl_Obj *cmdName, *methodObj; NsfCallStackContent csc, *cscPtr = NULL; int isValidCsc = 1; - NsfRuntimeState *rst; + const NsfRuntimeState *rst; nonnull_assert(clientData != NULL); nonnull_assert(interp != NULL); @@ -14434,6 +14449,7 @@ Tcl_Obj *objv[4]; /*fprintf(stderr, "ConvertToTclobj %s (must be %s)\n", ObjStr(objPtr), ObjStr(pPtr->converterArg));*/ + objv[0] = NULL; objv[1] = pPtr->converterArg; objv[2] = NsfGlobalObjs[NSF_OPTION_STRICT]; objv[3] = objPtr; @@ -14500,14 +14516,14 @@ Nsf_ConvertToBoolean(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { int result, boolVal; - result = Tcl_GetBooleanFromObj(interp, objPtr, &boolVal); nonnull_assert(interp != NULL); nonnull_assert(objPtr != NULL); nonnull_assert(pPtr != NULL); nonnull_assert(clientData != NULL); nonnull_assert(outObjPtr != NULL); + result = Tcl_GetBooleanFromObj(interp, objPtr, &boolVal); if (likely(result == TCL_OK)) { *clientData = (ClientData)INT2PTR(boolVal); } else { @@ -14540,8 +14556,7 @@ int Nsf_ConvertToInt32(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { - int result; - int i; + int result, i; nonnull_assert(interp != NULL); nonnull_assert(objPtr != NULL); @@ -14696,6 +14711,7 @@ int Nsf_ConvertToObject(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { + int result; nonnull_assert(interp != NULL); nonnull_assert(objPtr != NULL); @@ -14705,9 +14721,11 @@ assert(*outObjPtr == objPtr); if (likely(GetObjectFromObj(interp, objPtr, (NsfObject **)clientData) == TCL_OK)) { - return IsObjectOfType(interp, (NsfObject *)*clientData, "object", objPtr, pPtr); + result = IsObjectOfType(interp, (NsfObject *)*clientData, "object", objPtr, pPtr); + } else { + result = NsfObjErrType(interp, NULL, objPtr, "object", (Nsf_Param *)pPtr); } - return NsfObjErrType(interp, NULL, objPtr, "object", (Nsf_Param *)pPtr); + return result; } /* @@ -14734,7 +14752,7 @@ int Nsf_ConvertToClass(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { - int withUnkown; + int withUnkown, result; nonnull_assert(interp != NULL); nonnull_assert(objPtr != NULL); @@ -14746,9 +14764,11 @@ withUnkown = (RUNTIME_STATE(interp)->doClassConverterOmitUnkown == 0); if (likely(GetClassFromObj(interp, objPtr, (NsfClass **)clientData, withUnkown) == TCL_OK)) { - return IsObjectOfType(interp, (NsfObject *)*clientData, "class", objPtr, pPtr); + result = IsObjectOfType(interp, (NsfObject *)*clientData, "class", objPtr, pPtr); + } else { + result = NsfObjErrType(interp, NULL, objPtr, "class", (Nsf_Param *)pPtr); } - return NsfObjErrType(interp, NULL, objPtr, "class", (Nsf_Param *)pPtr); + return result; } @@ -14790,9 +14810,10 @@ result = Tcl_ConvertToType(interp, objPtr, &NsfFilterregObjType); if (likely(result == TCL_OK)) { *clientData = objPtr; - return result; + } else { + result = NsfObjErrType(interp, NULL, objPtr, "filterreg", (Nsf_Param *)pPtr); } - return NsfObjErrType(interp, NULL, objPtr, "filterreg", (Nsf_Param *)pPtr); + return result; } /* @@ -14832,9 +14853,10 @@ result = Tcl_ConvertToType(interp, objPtr, &NsfMixinregObjType); if (likely(result == TCL_OK)) { *clientData = objPtr; - return result; + } else { + result = NsfObjErrType(interp, NULL, objPtr, "mixinreg", (Nsf_Param *)pPtr); } - return NsfObjErrType(interp, NULL, objPtr, "mixinreg", (Nsf_Param *)pPtr); + return result; } /* @@ -14863,6 +14885,7 @@ Nsf_ConvertToParameter(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { const char *value; + int result; nonnull_assert(interp != NULL); nonnull_assert(objPtr != NULL); @@ -14875,13 +14898,14 @@ value = ObjStr(objPtr); /*fprintf(stderr, "convert to parameter '%s' t '%s'\n", value, pPtr->type);*/ if (*value == ':' || (*value == '-' && *(value + 1) == ':')) { - return NsfPrintError(interp, "leading colon in '%s' not allowed in parameter specification '%s'", - ObjStr(objPtr), pPtr->name); + result = NsfPrintError(interp, "leading colon in '%s' not allowed in parameter specification '%s'", + ObjStr(objPtr), pPtr->name); + } else { + *clientData = (char *)ObjStr(objPtr); + result = TCL_OK; } - *clientData = (char *)ObjStr(objPtr); - - return TCL_OK; + return result; } /* @@ -16276,7 +16300,7 @@ Nsf_Param *pPtr; Tcl_Obj *argList = Tcl_NewListObj(0, NULL); - for (pPtr = parsedParam.paramDefs->paramsPtr; pPtr->name; pPtr++) { + for (pPtr = parsedParam.paramDefs->paramsPtr; pPtr->name != NULL; pPtr++) { if (*pPtr->name == '-') { Tcl_ListObjAppendElement(interp, argList, Tcl_NewStringObj(pPtr->name+1, -1)); } else { @@ -16865,7 +16889,7 @@ if (paramDefs != NULL) { Nsf_Param *paramPtr; - for (paramPtr = paramDefs->paramsPtr; paramPtr->name; paramPtr++) { + for (paramPtr = paramDefs->paramsPtr; paramPtr->name != NULL; paramPtr++) { if (*paramPtr->name == '-') { Tcl_Obj *varNameObj = Tcl_NewStringObj(paramPtr->name+1, -1); @@ -17180,7 +17204,7 @@ * provide for ImportedCmdData client data etc., we cannot * directly use it. */ - for (refPtr = aliasedCmd->importRefPtr; refPtr; refPtr = refPtr->nextPtr) { + for (refPtr = aliasedCmd->importRefPtr; refPtr != NULL; refPtr = refPtr->nextPtr) { if (refPtr->importedCmdPtr == (Command *) tcd->aliasCmd) { if (prevPtr == NULL) { aliasedCmd->importRefPtr = refPtr->nextPtr; @@ -17448,7 +17472,7 @@ if (slotContainerObject != NULL && slotContainerObject->nsPtr && ((slotContainerObject->flags & NSF_IS_SLOT_CONTAINER) != 0u)) { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(slotContainerObject->nsPtr); Tcl_Command cmd; @@ -17729,7 +17753,7 @@ /* * Skip until actual class */ - for ( ; pl; pl = pl->nextPtr) { + for ( ; pl != NULL; pl = pl->nextPtr) { if (pl->cl == cl) { pl = pl->nextPtr; break; @@ -18359,7 +18383,7 @@ int rc = 0; Tcl_HashSearch search; Tcl_HashEntry *entryPtr; - Tcl_Var *varPtr; + const Tcl_Var *varPtr; nonnull_assert(interp != NULL); nonnull_assert(nsPtr != NULL); @@ -18415,10 +18439,10 @@ *---------------------------------------------------------------------- */ -static int FreeUnsetTraceVariable(Tcl_Interp *interp, NsfObject *object) nonnull(1) nonnull(2); +static int FreeUnsetTraceVariable(Tcl_Interp *interp, const NsfObject *object) nonnull(1) nonnull(2); static int -FreeUnsetTraceVariable(Tcl_Interp *interp, NsfObject *object) { +FreeUnsetTraceVariable(Tcl_Interp *interp, const NsfObject *object) { nonnull_assert(interp != NULL); nonnull_assert(object != NULL); @@ -19257,7 +19281,7 @@ if (IsRootClass(cl) == 0) { Tcl_HashTable *instanceTablePtr = &cl->instances; Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(instanceTablePtr, &hSrch); hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSrch)) { @@ -19854,7 +19878,7 @@ } /* is the class a subclass of a meta-class? */ - for (pl = PrecedenceOrder(cl); pl; pl = pl->nextPtr) { + for (pl = PrecedenceOrder(cl); pl != NULL; pl = pl->nextPtr) { if (IsRootMetaClass(pl->cl)) { return 1; } @@ -21243,7 +21267,7 @@ nonnull_assert(interp != NULL); nonnull_assert(nsPtr != NULL); - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = osPtr->nextPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = osPtr->nextPtr) { Tcl_Command cmd = osPtr->rootClass->object.id; if ((Tcl_Namespace *)((Command *)cmd)->nsPtr == nsPtr) { return 1; @@ -21805,7 +21829,7 @@ #if defined(PARSE_TRACE) { Nsf_Param const *pPtr; fprintf(stderr, "PARAMETER "); - for (o = 0, pPtr = paramPtr; pPtr->name; o++, pPtr++) { + for (o = 0, pPtr = paramPtr; pPtr->name != NULL; o++, pPtr++) { fprintf(stderr, "[%d]%s (nrargs %d %s) ", o, pPtr->name, pPtr->nrArgs, (pPtr->flags & NSF_ARG_REQUIRED) != 0u ? "req" : "opt"); @@ -22249,7 +22273,7 @@ static int ListVarKeys(Tcl_Interp *interp, Tcl_HashTable *tablePtr, const char *pattern) { - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; nonnull_assert(interp != NULL); @@ -22259,21 +22283,23 @@ INCR_REF_COUNT(patternObj); hPtr = (tablePtr != NULL) ? Tcl_CreateHashEntry(tablePtr, (char *)patternObj, NULL) : NULL; if (hPtr != NULL) { - Var *val = TclVarHashGetValue(hPtr); + const Var *val = TclVarHashGetValue(hPtr); + Tcl_SetObjResult(interp, TclVarHashGetKey(val)); } else { Tcl_SetObjResult(interp, NsfGlobalObjs[NSF_EMPTY]); } DECR_REF_COUNT(patternObj); } else { - Tcl_Obj *list = Tcl_NewListObj(0, NULL); + Tcl_Obj *list = Tcl_NewListObj(0, NULL); Tcl_HashSearch hSrch; hPtr = (tablePtr != NULL) ? Tcl_FirstHashEntry(tablePtr, &hSrch) : NULL; for (; hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSrch)) { - Var *val = TclVarHashGetValue(hPtr); - Tcl_Obj *key = TclVarHashGetKey(val); + const Var *val = TclVarHashGetValue(hPtr); + Tcl_Obj *key = TclVarHashGetKey(val); + if (pattern == NULL || Tcl_StringMatch(ObjStr(key), pattern)) { Tcl_ListObjAppendElement(interp, list, key); } @@ -23457,7 +23483,7 @@ int methodType, int withCallprotection, int withPath, Tcl_HashTable *dups, NsfObject *object, int withPer_object) { Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_Command cmd; const char *key; int isObject, methodTypeMatch; @@ -23693,7 +23719,7 @@ Tcl_Obj *list = Tcl_NewListObj(0, NULL); Tcl_HashSearch hSrch; Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(object->nsPtr); - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(cmdTablePtr, &hSrch); hPtr != NULL; @@ -23750,7 +23776,7 @@ nonnull_assert(tablePtr != NULL); if (withDefinition != 0) { - Tcl_HashEntry *hPtr = (pattern != NULL) ? Tcl_CreateHashEntry(tablePtr, pattern, NULL) : NULL; + const Tcl_HashEntry *hPtr = (pattern != NULL) ? Tcl_CreateHashEntry(tablePtr, pattern, NULL) : NULL; /* * Notice: we don't use pattern for wildcard matching here; pattern can * only contain wildcards when used without "-definition". @@ -24378,7 +24404,7 @@ return TCL_OK; } - + /* cmd __db_get_obj NsfDebugGetDict { {-argName "obj" -required 1 -type tclobj} @@ -24433,7 +24459,7 @@ /* * Collect all instances from all object systems. */ - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = osPtr->nextPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = osPtr->nextPtr) { GetAllInstances(interp, &instances, osPtr->rootClass); } @@ -24457,7 +24483,7 @@ object, ObjectName(object), object->activationCount);*/ framePtr = (Tcl_CallFrame *)Tcl_Interp_framePtr(interp); - for (; framePtr; framePtr = Tcl_CallFrame_callerPtr(framePtr)) { + for (; framePtr != NULL; framePtr = Tcl_CallFrame_callerPtr(framePtr)) { int frameFlags = Tcl_CallFrame_isProcCallFrame(framePtr); NsfCallStackContent *cscPtr = ((frameFlags & (FRAME_IS_NSF_METHOD|FRAME_IS_NSF_CMETHOD)) != 0u) ? @@ -24573,9 +24599,9 @@ nonnull_assert(interp != NULL); if (likely(proc != NULL)) { - CompiledLocal *ap; - Var *varPtr; - int i; + const CompiledLocal *ap; + const Var *varPtr; + int i; for (ap = proc->firstLocalPtr, i = 0; ap; ap = ap->nextPtr, i++) { if (!TclIsCompiledLocalArgument(ap)) { @@ -24698,7 +24724,7 @@ NsfObjectSystem *osPtr; Tcl_Obj *list = Tcl_NewListObj(0, NULL); - for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr; osPtr = osPtr->nextPtr) { + for (osPtr = RUNTIME_STATE(interp)->objectSystems; osPtr != NULL; osPtr = osPtr->nextPtr) { Tcl_Obj *osObj = Tcl_NewListObj(0, NULL); Tcl_Obj *systemMethods = Tcl_NewListObj(0, NULL); int idx; @@ -25288,7 +25314,7 @@ Tcl_Obj *resultObj; int i; - for (i = 0, paramPtr = paramDefs->paramsPtr; paramPtr->name; paramPtr++, i++) { + for (i = 0, paramPtr = paramDefs->paramsPtr; paramPtr->name != NULL; paramPtr++, i++) { Tcl_Obj *valueObj = pc.objv[i]; if (valueObj != NsfGlobalObjs[NSF___UNKNOWN__]) { @@ -26509,7 +26535,7 @@ Tcl_Namespace *fromNsPtr = NULL, *toNsPtr; Var *varPtr = NULL; Tcl_HashSearch hSrch; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; TclVarHashTable *varTablePtr; NsfObject *object, *destObject; const char *destFullName; @@ -26790,7 +26816,7 @@ if (dependentSubClasses != NULL) { - for (clPtr = dependentSubClasses; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = dependentSubClasses; clPtr != NULL; clPtr = clPtr->nextPtr) { NsfClass *subClass = clPtr->cl; if (subClass->parsedParamPtr != NULL) { @@ -26920,7 +26946,7 @@ * Fold the per-position lists into a flat result list */ resultObj = Tcl_NewListObj(0, NULL); - for (elt = objList; elt; elt = elt->nextPtr) { + for (elt = objList; elt != NULL; elt = elt->nextPtr) { Tcl_ListObjGetElements(interp, elt->payload, &objc, &objv); for (i = 0; i < objc; i++) { Tcl_ListObjAppendElement(interp, resultObj, objv[i]); @@ -27237,7 +27263,7 @@ /* * Delete from old isObjectMixinOf lists */ - for (cmdlist = objopt->objMixins; cmdlist; cmdlist = cmdlist->nextPtr) { + for (cmdlist = objopt->objMixins; cmdlist != NULL; cmdlist = cmdlist->nextPtr) { cl = NsfGetClassFromCmdPtr(cmdlist->cmdPtr); clopt = (cl != NULL) ? cl->opt : NULL; if (clopt != NULL) { @@ -28280,7 +28306,9 @@ #if defined(CONFIGURE_ARGS_TRACE) fprintf(stderr, "*** POPULATE OBJ '%s': nr of parsed args %d\n", ObjectName(object), pc.objc); #endif - for (i = 1, paramPtr = paramDefs->paramsPtr; paramPtr->name; paramPtr++, i++) { + for (i = 1, paramPtr = paramDefs->paramsPtr; + paramPtr->name != NULL; + paramPtr++, i++) { /* * Set the new value always when the new value was specified (was not @@ -28610,7 +28638,7 @@ * (very unlikely). */ for (paramPtr = paramDefs->paramsPtr; - paramPtr->name && *paramPtr->name != '-'; + (paramPtr->name != NULL) && (*paramPtr->name != '-'); paramPtr++); /* @@ -30475,7 +30503,7 @@ nonnull_assert(object != NULL); precedenceList = ComputePrecedenceList(interp, object, pattern, !withIntrinsicOnly, 1); - for (pl = precedenceList; pl; pl = pl->nextPtr) { + for (pl = precedenceList; pl != NULL; pl = pl->nextPtr) { assert(pl->cl != NULL); Tcl_ListObjAppendElement(interp, resultObj, pl->cl->object.cmdName); } @@ -30616,15 +30644,15 @@ intrinsic = PrecedenceOrder(cl); NsfClassListAddPerClassMixins(interp, cl, &mixinClasses, &checkList); - for (pl = mixinClasses; pl; pl = pl->nextPtr) { + for (pl = mixinClasses; pl != NULL; pl = pl->nextPtr) { if (NsfClassListFind(pl->nextPtr, pl->cl) == NULL && NsfClassListFind(intrinsic, pl->cl) == NULL) { AppendMatchingElement(interp, resultObj, pl->cl->object.cmdName, pattern); } } if (intrinsic != NULL) { - for (pl = intrinsic->nextPtr; pl; pl = pl->nextPtr) { + for (pl = intrinsic->nextPtr; pl != NULL; pl = pl->nextPtr) { AppendMatchingElement(interp, resultObj, pl->cl->object.cmdName, pattern); } } @@ -30672,7 +30700,7 @@ do { Tcl_HashTable *tablePtr = &subClasses->cl->instances; - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashSearch search; for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); @@ -30834,7 +30862,7 @@ } NsfClassListAddPerClassMixins(interp, class, &mixinClasses, &checkList); - for (clPtr = mixinClasses; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = mixinClasses; clPtr != NULL; clPtr = clPtr->nextPtr) { if (NsfClassListFind(clPtr->nextPtr, clPtr->cl)) { continue; } @@ -30982,7 +31010,7 @@ * Compute the closure: first the transitive mixin-classes... */ NsfClassListAddPerClassMixins(interp, class, &mixinClasses, &checkList); - for (clPtr = mixinClasses; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = mixinClasses; clPtr != NULL; clPtr = clPtr->nextPtr) { if (NsfClassListFind(clPtr->nextPtr, clPtr->cl) == NULL && NsfClassListFind(intrinsicClasses, clPtr->cl) == NULL) { NsfClassListAdd(&precedenceList, clPtr->cl, NULL); @@ -30992,7 +31020,7 @@ * ... followed by the intrinsic classes. */ NsfClassListAdd(&precedenceList, class, NULL); - for (clPtr = intrinsicClasses->nextPtr; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = intrinsicClasses->nextPtr; clPtr != NULL; clPtr = clPtr->nextPtr) { NsfClassListAdd(&precedenceList, clPtr->cl, NULL); } if (checkList != NULL) { @@ -31014,7 +31042,7 @@ Tcl_InitHashTable(&slotTable, TCL_STRING_KEYS); MEM_COUNT_ALLOC("Tcl_InitHashTable", &slotTable); - for (clPtr = precedenceList; clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = precedenceList; clPtr != NULL; clPtr = clPtr->nextPtr) { if (MethodSourceMatches(withSource, clPtr->cl, NULL)) { AddSlotObjects(interp, &clPtr->cl->object, "::slot", &slotTable, withSource, type, pattern, listObj); @@ -31104,7 +31132,7 @@ Tcl_HashTable *varTablePtr, *cmdTablePtr, *childTablePtr; Tcl_HashSearch search; Tcl_Command cmd; - Var *varPtr; + const Var *varPtr; register Tcl_HashEntry *entryPtr; nonnull_assert(interp != NULL); @@ -31120,14 +31148,16 @@ * Deleting the procs and vars in the child namespaces does not seem to be * necessary, but we do it anyway. */ - for (entryPtr = Tcl_FirstHashEntry(childTablePtr, &search); entryPtr; + for (entryPtr = Tcl_FirstHashEntry(childTablePtr, &search); + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Namespace *childNsPtr = (Tcl_Namespace *) Tcl_GetHashValue(entryPtr); DeleteProcsAndVars(interp, childNsPtr, withKeepvars); } if (withKeepvars == 0) { - for (entryPtr = Tcl_FirstHashEntry(varTablePtr, &search); entryPtr; + for (entryPtr = Tcl_FirstHashEntry(varTablePtr, &search); + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Obj *nameObj; GetVarAndNameFromHash(entryPtr, &varPtr, &nameObj); @@ -31138,7 +31168,8 @@ } } - for (entryPtr = Tcl_FirstHashEntry(cmdTablePtr, &search); entryPtr; + for (entryPtr = Tcl_FirstHashEntry(cmdTablePtr, &search); + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr); @@ -31254,7 +31285,8 @@ cmdTablePtr = Tcl_Namespace_cmdTablePtr(nsPtr); childTablePtr = Tcl_Namespace_childTablePtr(nsPtr); - for (entryPtr = Tcl_FirstHashEntry(cmdTablePtr, &search); entryPtr; + for (entryPtr = Tcl_FirstHashEntry(cmdTablePtr, &search); + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Command cmd = (Tcl_Command)Tcl_GetHashValue(entryPtr); @@ -31264,7 +31296,8 @@ Tcl_DeleteCommandFromToken(interp, cmd); } } - for (entryPtr = Tcl_FirstHashEntry(childTablePtr, &search); entryPtr; + for (entryPtr = Tcl_FirstHashEntry(childTablePtr, &search); + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Namespace *childNsPtr = (Tcl_Namespace *) Tcl_GetHashValue(entryPtr); @@ -31338,26 +31371,26 @@ * *---------------------------------------------------------------------- */ -static int ObjectHasChildren(NsfObject *object) nonnull(1); +static int ObjectHasChildren(const NsfObject *object) nonnull(1); static int -ObjectHasChildren(NsfObject *object) { - Tcl_Namespace *ns; +ObjectHasChildren(const NsfObject *object) { + const Tcl_Namespace *ns; int result = 0; nonnull_assert(object != NULL); ns = object->nsPtr; if (ns != NULL) { - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashSearch hSrch; Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(ns); for (hPtr = Tcl_FirstHashEntry(cmdTablePtr, &hSrch); hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSrch)) { Tcl_Command cmd = Tcl_GetHashValue(hPtr); - NsfObject *childObject = NsfGetObjectFromCmdPtr(cmd); + const NsfObject *childObject = NsfGetObjectFromCmdPtr(cmd); if (childObject != NULL) { result = 1; @@ -31410,7 +31443,7 @@ /* delete per-object methods */ if (object != NULL && object->nsPtr != NULL) { - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashSearch hSrch; for (hPtr = Tcl_FirstHashEntry(Tcl_Namespace_cmdTablePtr(object->nsPtr), &hSrch); @@ -31434,7 +31467,7 @@ * objects, which will resolved this way. */ if (object != NULL && NsfObjectIsClass(object)) { - Tcl_HashEntry *hPtr; + const Tcl_HashEntry *hPtr; Tcl_HashSearch hSrch; for (hPtr = Tcl_FirstHashEntry(Tcl_Namespace_cmdTablePtr(((NsfClass *)object)->nsPtr), @@ -31564,7 +31597,7 @@ * to the most general superclass. */ for (entry = *instances; - entry; + entry != NULL; entry = entry->nextPtr) { NsfObject *object = (NsfObject *)entry->clorobj; NsfClass *baseClass;