Index: generic/nsf.c =================================================================== diff -u -rbe1aa824abfe207d9ae86bdb66b53b7e405f4daa -r16324e94fee054ff57d403e5b51cf96117317ea0 --- generic/nsf.c (.../nsf.c) (revision be1aa824abfe207d9ae86bdb66b53b7e405f4daa) +++ generic/nsf.c (.../nsf.c) (revision 16324e94fee054ff57d403e5b51cf96117317ea0) @@ -7072,27 +7072,25 @@ static NsfCmdList * CmdListRemoveFromList(NsfCmdList **cmdList, NsfCmdList *delCL) { register NsfCmdList *c; - NsfCmdList *del = NULL; + NsfCmdList *del = NULL; nonnull_assert(cmdList != NULL); nonnull_assert(delCL != NULL); c = *cmdList; - if (c == NULL) { - return NULL; - } - - if (c == delCL) { - *cmdList = c->nextPtr; - del = c; - } else { - while ((c->nextPtr != NULL) && (c->nextPtr != delCL)) { - c = c->nextPtr; + if (likely(c != NULL)) { + if (c == delCL) { + *cmdList = c->nextPtr; + del = c; + } else { + while ((c->nextPtr != NULL) && (c->nextPtr != delCL)) { + c = c->nextPtr; + } + if (c->nextPtr == delCL) { + del = delCL; + c->nextPtr = delCL->nextPtr; + } } - if (c->nextPtr == delCL) { - del = delCL; - c->nextPtr = delCL->nextPtr; - } } return del; } @@ -9012,7 +9010,7 @@ nonnull_assert(cmdList != NULL); do { - NsfObject *nobj = NsfGetObjectFromCmdPtr(cmdList->cmdPtr); + NsfObject *nobj = NsfGetObjectFromCmdPtr(cmdList->cmdPtr); NsfObjectOpt *objopt = (nobj != 0) ? nobj->opt : NULL; if (objopt != NULL) { @@ -10051,11 +10049,12 @@ static int FilterAdd(Tcl_Interp *interp, NsfCmdList **filterList, Tcl_Obj *filterregObj, NsfObject *startingObject, NsfClass *startingClass) { - Tcl_Obj *filterObj = NULL; - Tcl_Obj *guardObj = NULL; - Tcl_Command cmd; - NsfCmdList *new; - NsfClass *cl; + Tcl_Obj *filterObj = NULL; + Tcl_Obj *guardObj = NULL; + Tcl_Command cmd; + NsfCmdList *new; + NsfClass *cl; + int result = TCL_OK; nonnull_assert(interp != NULL); nonnull_assert(filterList != NULL); @@ -10068,36 +10067,42 @@ if (filterregObj->typePtr != &NsfFilterregObjType) { /*fprintf(stderr, "FilterAdd: convert %s in FilterAdd\n", ObjStr(filterregObj));*/ if (Tcl_ConvertToType(interp, filterregObj, &NsfFilterregObjType) != TCL_OK) { - return TCL_ERROR; + result = TCL_ERROR; } } else { /*fprintf(stderr, "FilterAdd: %s already converted\n", ObjStr(filterregObj));*/ } - NsfFilterregGet(interp, filterregObj, &filterObj, &guardObj); + if (result == TCL_OK) { + result = NsfFilterregGet(interp, filterregObj, &filterObj, &guardObj); - if (!(cmd = FilterSearch(ObjStr(filterObj), startingObject, startingClass, &cl))) { - if (startingObject != NULL) { - return NsfPrintError(interp, "object filter: can't find filterproc '%s' on %s ", - ObjStr(filterObj), ObjectName(startingObject)); - } else { - return NsfPrintError(interp, "class filter: can't find filterproc '%s' on %s ", - ObjStr(filterObj), ClassName(startingClass)); + if (result == TCL_OK) { + if (!(cmd = FilterSearch(ObjStr(filterObj), startingObject, startingClass, &cl))) { + if (startingObject != NULL) { + result = NsfPrintError(interp, "object filter: can't find filterproc '%s' on %s ", + ObjStr(filterObj), ObjectName(startingObject)); + } else { + result = NsfPrintError(interp, "class filter: can't find filterproc '%s' on %s ", + ObjStr(filterObj), ClassName(startingClass)); + } + } } } - /*fprintf(stderr, " +++ adding filter %s cl %p\n", ObjStr(nameObj), cl);*/ + if (result == TCL_OK) { + /*fprintf(stderr, " +++ adding filter %s cl %p\n", ObjStr(nameObj), cl);*/ - new = CmdListAdd(filterList, cmd, cl, /*noDuplicates*/ 1, 1); - FilterAddActive(interp, ObjStr(filterObj)); + new = CmdListAdd(filterList, cmd, cl, /*noDuplicates*/ 1, 1); + FilterAddActive(interp, ObjStr(filterObj)); - if (guardObj != NULL) { - GuardAdd(new, guardObj); - } else if (new->clientData != NULL) { - GuardDel(new); + if (guardObj != NULL) { + GuardAdd(new, guardObj); + } else if (new->clientData != NULL) { + GuardDel(new); + } } - - return TCL_OK; + + return result; } /* @@ -17745,32 +17750,48 @@ static NsfClass * FindCalledClass(Tcl_Interp *interp, NsfObject *object) { - NsfCallStackContent *cscPtr = CallStackGetTopFrame0(interp); - const char *methodName; - Tcl_Command cmd; + NsfCallStackContent *cscPtr; + NsfClass *result; nonnull_assert(interp != NULL); nonnull_assert(object != NULL); - if (cscPtr->frameType == NSF_CSC_TYPE_PLAIN) { - return cscPtr->cl; - } - if (cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_FILTER) { - methodName = MethodName(cscPtr->filterStackEntry->calledProc); - } else if (cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_MIXIN && object->mixinStack != NULL) { - methodName = Tcl_GetCommandName(interp, cscPtr->cmdPtr); + cscPtr = CallStackGetTopFrame0(interp); + if (unlikely(cscPtr == NULL)) { + result = NULL; + } else { - return NULL; - } - if (object->nsPtr != NULL) { - cmd = FindMethod(object->nsPtr, methodName); - if (cmd != NULL) { - /* we called an object specific method */ - return NULL; + if (cscPtr->frameType == NSF_CSC_TYPE_PLAIN) { + result = cscPtr->cl; + } else { + const char *methodName; + + if (cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_FILTER) { + methodName = MethodName(cscPtr->filterStackEntry->calledProc); + } else if (cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_MIXIN && object->mixinStack != NULL) { + methodName = Tcl_GetCommandName(interp, cscPtr->cmdPtr); + } else { + methodName = NULL; + } + + if (unlikely(methodName == NULL)) { + result = NULL; + + } else { + if (object->nsPtr != NULL && FindMethod(object->nsPtr, methodName) != NULL) { + /* + * An object specific method was called. + */ + result = NULL; + } else { + Tcl_Command cmd; + + result = SearchCMethod(object->cl, methodName, &cmd); + } + } } } - - return SearchCMethod(object->cl, methodName, &cmd); + return result; } /* @@ -18440,30 +18461,40 @@ static int FindSelfNext(Tcl_Interp *interp) { - NsfCallStackContent *cscPtr = CallStackGetTopFrame0(interp); - Tcl_Command cmd = NULL, currentCmd = NULL; - int result, isMixinEntry = 0, - isFilterEntry = 0, - endOfFilterChain = 0; - NsfClass *cl = cscPtr->cl; - NsfObject *object = cscPtr->self; - const char *methodName; + NsfCallStackContent *cscPtr; + int result; nonnull_assert(interp != NULL); - Tcl_ResetResult(interp); + cscPtr = CallStackGetTopFrame0(interp); + if (unlikely(cscPtr == NULL)) { + result = NsfPrintError(interp, "called outside NSF scope"); + + } else { + Tcl_Command cmd = NULL, currentCmd = NULL; + const char *methodName; + + Tcl_ResetResult(interp); - methodName = Tcl_GetCommandName(interp, cscPtr->cmdPtr); - if (methodName == NULL) { - return TCL_OK; + methodName = Tcl_GetCommandName(interp, cscPtr->cmdPtr); + if (methodName == NULL) { + /* + * In case, we do not find the command, we return OK. Why? + */ + result = TCL_OK; + } else { + int isMixinEntry = 0, isFilterEntry = 0, endOfFilterChain = 0; + NsfClass *cl = cscPtr->cl; + NsfObject *object = cscPtr->self; + + result = NextSearchMethod(object, interp, cscPtr, &cl, &methodName, &cmd, + &isMixinEntry, &isFilterEntry, &endOfFilterChain, ¤tCmd); + if (cmd != NULL) { + Tcl_SetObjResult(interp, MethodHandleObj((cl != NULL) ? (NsfObject *)cl : object, + cl == NULL, methodName)); + } + } } - - result = NextSearchMethod(object, interp, cscPtr, &cl, &methodName, &cmd, - &isMixinEntry, &isFilterEntry, &endOfFilterChain, ¤tCmd); - if (cmd != NULL) { - Tcl_SetObjResult(interp, MethodHandleObj((cl != NULL) ? (NsfObject *)cl : object, - cl == NULL, methodName)); - } return result; } @@ -27432,7 +27463,7 @@ case RelationtypeClass_mixinIdx: /* fall through */ case RelationtypeClass_filterIdx: - + assert(cl != NULL); if (valueObj == NULL) { clopt = cl->opt; if (relationtype == RelationtypeClass_mixinIdx) { Index: generic/nsfObj.c =================================================================== diff -u -rb089be700bb58579a48e77619512a47eb3c5562d -r16324e94fee054ff57d403e5b51cf96117317ea0 --- generic/nsfObj.c (.../nsfObj.c) (revision b089be700bb58579a48e77619512a47eb3c5562d) +++ generic/nsfObj.c (.../nsfObj.c) (revision 16324e94fee054ff57d403e5b51cf96117317ea0) @@ -763,6 +763,7 @@ int NsfFilterregGet(Tcl_Interp *UNUSED(interp), Tcl_Obj *obj, Tcl_Obj **filterObj, Tcl_Obj **guardObj) { + int result; nonnull_assert(obj != NULL); nonnull_assert(filterObj != NULL); @@ -772,10 +773,12 @@ Filterreg *filterregPtr = obj->internalRep.twoPtrValue.ptr1; *filterObj = filterregPtr->filterObj; *guardObj = filterregPtr->guardObj; - return TCL_OK; + result = TCL_OK; + } else { + result = TCL_ERROR; } - - return TCL_ERROR; + + return result; } /* * Filterreg type end Index: generic/nsfStack.c =================================================================== diff -u -r6af35a888e33da976e283271bb68060f34d91a9a -r16324e94fee054ff57d403e5b51cf96117317ea0 --- generic/nsfStack.c (.../nsfStack.c) (revision 6af35a888e33da976e283271bb68060f34d91a9a) +++ generic/nsfStack.c (.../nsfStack.c) (revision 16324e94fee054ff57d403e5b51cf96117317ea0) @@ -502,17 +502,19 @@ NSF_INLINE static NsfCallStackContent* CallStackGetTopFrame0(const Tcl_Interp *interp) { register Tcl_CallFrame *varFramePtr; + NsfCallStackContent *result = NULL; nonnull_assert(interp != NULL); for (varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); varFramePtr != NULL; varFramePtr = Tcl_CallFrame_callerPtr(varFramePtr)) { if (likely(((unsigned int)Tcl_CallFrame_isProcCallFrame(varFramePtr) & (FRAME_IS_NSF_METHOD|FRAME_IS_NSF_CMETHOD)) != 0u)) { - return (NsfCallStackContent *)Tcl_CallFrame_clientData(varFramePtr); + result = (NsfCallStackContent *)Tcl_CallFrame_clientData(varFramePtr); + break; } } - return NULL; + return result; } #if defined(NSF_PROFILE) Index: library/mongodb/README =================================================================== diff -u -rc7c8cac1e78cf37d8763888588195759b5ed1b99 -r16324e94fee054ff57d403e5b51cf96117317ea0 --- library/mongodb/README (.../README) (revision c7c8cac1e78cf37d8763888588195759b5ed1b99) +++ library/mongodb/README (.../README) (revision 16324e94fee054ff57d403e5b51cf96117317ea0) @@ -32,7 +32,7 @@ make sudo make install - Alternatively, one can get the newest version form git + Alternatively, one can get the newest version from git cd /usr/local/src git clone https://github.com/mongodb/mongo-c-driver