Index: generic/nsfError.c =================================================================== diff -u -r6b1a83846ee9bd80b7ce10d88cc427bdb5585819 -r8a6eddd18d929736bd1d3fefe985c2b1f2963fc0 --- generic/nsfError.c (.../nsfError.c) (revision 6b1a83846ee9bd80b7ce10d88cc427bdb5585819) +++ generic/nsfError.c (.../nsfError.c) (revision 8a6eddd18d929736bd1d3fefe985c2b1f2963fc0) @@ -3,7 +3,7 @@ * * Error reporting functions for the Next Scripting Framework. * - * Copyright (C) 1999-2013 Gustaf Neumann + * Copyright (C) 1999-2014 Gustaf Neumann * Copyright (C) 1999-2007 Uwe Zdun * Copyright (C) 2011 Stefan Sobernig * @@ -78,7 +78,7 @@ failure = (result == -1 && errno == ERANGE); #else assert(result > -1); - failure = (result > avail); + failure = (result >= avail); #endif if (likely(failure == 0)) { @@ -128,6 +128,10 @@ */ void NsfDStringArgv(Tcl_DString *dsPtr, int objc, Tcl_Obj *CONST objv[]) { + + assert(dsPtr); + assert(objv); + if (objc > 0) { int i; Tcl_DStringAppendElement(dsPtr, NsfMethodName(objv[0])); @@ -231,18 +235,25 @@ NsfObjWrongArgs(Tcl_Interp *interp, CONST char *msg, Tcl_Obj *cmdName, Tcl_Obj *methodName, char *arglist) { int need_space = 0; + + assert(interp); + assert(msg); + Tcl_ResetResult(interp); Tcl_AppendResult(interp, msg, " should be \"", (char *) NULL); if (cmdName) { Tcl_AppendResult(interp, ObjStr(cmdName), (char *) NULL); need_space = 1; } + if (methodName) { Tcl_Obj *resultObj; if (need_space) Tcl_AppendResult(interp, " ", (char *) NULL); - resultObj = NsfMethodNamePath(interp, methodName); + resultObj = NsfMethodNamePath(interp, + NULL /* use topmost frame */, + NsfMethodName(methodName)); INCR_REF_COUNT(resultObj); Tcl_AppendResult(interp, ObjStr(resultObj), (char *) NULL); DECR_REF_COUNT(resultObj); @@ -278,6 +289,10 @@ Tcl_Obj *cmdNameObj, Tcl_Obj *methodObj) { Tcl_Obj *argStringObj = NsfParamDefsSyntax(paramPtr); + assert(interp); + assert(errorMsg); + assert(paramPtr); + NsfObjWrongArgs(interp, errorMsg, cmdNameObj, methodObj, ObjStr(argStringObj)); DECR_REF_COUNT2("paramDefsObj", argStringObj); @@ -304,6 +319,12 @@ NsfUnexpectedArgumentError(Tcl_Interp *interp, CONST char *argumentString, Nsf_Object *object, Nsf_Param CONST *paramPtr, Tcl_Obj *procNameObj) { Tcl_DString ds, *dsPtr = &ds; + + assert(interp); + assert(argumentString); + assert(paramPtr); + assert(procNameObj); + DSTRING_INIT(dsPtr); Tcl_DStringAppend(dsPtr, "invalid argument '", -1); Tcl_DStringAppend(dsPtr, argumentString, -1); @@ -340,6 +361,12 @@ Tcl_DString ds, *dsPtr = &ds; Nsf_Param CONST *pPtr; + assert(interp); + assert(argumentString); + assert(currentParamPtr); + assert(paramPtr); + assert(procNameObj); + DSTRING_INIT(dsPtr); Tcl_DStringAppend(dsPtr, "invalid non-positional argument '", -1); Tcl_DStringAppend(dsPtr, argumentString, -1); @@ -379,6 +406,11 @@ int NsfDispatchClientDataError(Tcl_Interp *interp, ClientData clientData, CONST char *what, CONST char *methodName) { + + assert(interp); + assert(what); + assert(methodName); + if (clientData) { return NsfPrintError(interp, "method %s not dispatched on valid %s", methodName, what); @@ -405,6 +437,9 @@ */ int NsfNoCurrentObjectError(Tcl_Interp *interp, CONST char *what) { + + assert(interp); + return NsfPrintError(interp, "no current object; %s called outside the context of a Next Scripting method", what ? what : "command"); }