Index: generic/nsfError.c =================================================================== diff -u -rcb7e3a02c1964d38d85c7e129027fc1b3225d3e6 -rf2c0f8e055015e58f3fa7bd338c872a2b7d76113 --- generic/nsfError.c (.../nsfError.c) (revision cb7e3a02c1964d38d85c7e129027fc1b3225d3e6) +++ generic/nsfError.c (.../nsfError.c) (revision f2c0f8e055015e58f3fa7bd338c872a2b7d76113) @@ -13,6 +13,39 @@ #include "nsfInt.h" + +/* + *---------------------------------------------------------------------- + * + * NsfDStringPrintf -- + * + * Set a Tcl_DString to a formatted value. This function + * currently copies at most TCL_DSTRING_STATIC_SIZE characters + * into the DString (this limit might be lifted in the future) + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +NsfDStringPrintf(Tcl_DString *dsPtr, CONST char *fmt, va_list apSrc) +{ + int result; + va_list ap; + + va_copy(ap, apSrc); + result = vsnprintf(Tcl_DStringValue(dsPtr), TCL_DSTRING_STATIC_SIZE, fmt, ap); + va_end(ap); + + Tcl_DStringSetLength(dsPtr, result < TCL_DSTRING_STATIC_SIZE ? result : TCL_DSTRING_STATIC_SIZE); +} + + int NsfErrMsg(Tcl_Interp *interp, char *msg, Tcl_FreeProc* type) { Tcl_SetResult(interp, msg, type);