Posted to tcl by de at Fri Feb 10 15:57:26 GMT 2023view pretty

#include <tcl.h>

#if TCL_MAJOR_VERSION == 8
# define STUB_VERSION "8.6"
#else
# define STUB_VERSION "9"
#endif

static int rdeCmd(
    void *clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    size_t len;
    
    if (objc != 2) {
        Tcl_WrongNumArgs (interp, 1, objv, "string");
        return TCL_ERROR;
    }
    Tcl_GetStringFromObj (objv[1], &len);
    Tcl_SetObjResult (interp, Tcl_NewWideIntObj(len));
    return TCL_OK;
}

int Rde_Init(Tcl_Interp *interp) {
    if (Tcl_InitStubs(interp, STUB_VERSION, 0) == NULL) {
        return TCL_ERROR;
    }
    Tcl_CreateObjCommand(interp, "rde", rdeCmd, NULL, NULL);
    return TCL_OK;
}