Index: generic/nsfShadow.c =================================================================== diff -u -r880487204ff2da18d2d25ebd727b9b4bbda86c8e -rdb831678bc92ce4e39bf4ff303f32491a3c4f9d9 --- generic/nsfShadow.c (.../nsfShadow.c) (revision 880487204ff2da18d2d25ebd727b9b4bbda86c8e) +++ generic/nsfShadow.c (.../nsfShadow.c) (revision db831678bc92ce4e39bf4ff303f32491a3c4f9d9) @@ -4,7 +4,7 @@ * API support for shadowing (overloading) and accessing C-implemented * Tcl obj-commands. * - * Copyright (C) 1999-2013 Gustaf Neumann + * Copyright (C) 1999-2014 Gustaf Neumann * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -44,12 +44,16 @@ * *---------------------------------------------------------------------- */ +static int NsfReplaceCommandCleanup(Tcl_Interp *interp, NsfGlobalNames name) nonnull(1); + static int NsfReplaceCommandCleanup(Tcl_Interp *interp, NsfGlobalNames name) { Tcl_Command cmd; int result = TCL_OK; NsfShadowTclCommandInfo *ti = &RUNTIME_STATE(interp)->tclCommands[name-NSF_EXPR]; + assert(interp); + /*fprintf(stderr," cleanup for %s ti=%p in %p\n", NsfGlobalStrings[name], ti, interp);*/ cmd = Tcl_GetCommandFromObj(interp, NsfGlobalObjs[name]); if (cmd != NULL) { @@ -77,10 +81,16 @@ * *---------------------------------------------------------------------- */ +static void NsfReplaceCommandCheck(Tcl_Interp *interp, NsfGlobalNames name, Tcl_ObjCmdProc *proc) nonnull(1) nonnull(3); + static void NsfReplaceCommandCheck(Tcl_Interp *interp, NsfGlobalNames name, Tcl_ObjCmdProc *proc) { - Tcl_Command cmd; NsfShadowTclCommandInfo *ti = &RUNTIME_STATE(interp)->tclCommands[name-NSF_EXPR]; + Tcl_Command cmd; + + assert(interp); + assert(proc); + cmd = Tcl_GetCommandFromObj(interp, NsfGlobalObjs[name]); if (cmd != NULL && ti->proc && Tcl_Command_objProc(cmd) != proc) { @@ -110,13 +120,18 @@ * *---------------------------------------------------------------------- */ +static int NsfReplaceCommand(Tcl_Interp *interp, NsfGlobalNames name, + Tcl_ObjCmdProc *nsfReplacementProc, int pass) nonnull(1); + static int NsfReplaceCommand(Tcl_Interp *interp, NsfGlobalNames name, Tcl_ObjCmdProc *nsfReplacementProc, int pass) { Tcl_Command cmd; NsfShadowTclCommandInfo *ti = &RUNTIME_STATE(interp)->tclCommands[name-NSF_EXPR]; int result = TCL_OK; + assert(interp); + /*fprintf(stderr,"NsfReplaceCommand %d\n", name);*/ cmd = Tcl_GetCommandFromObj(interp, NsfGlobalObjs[name]); @@ -162,13 +177,16 @@ * *---------------------------------------------------------------------- */ -EXTERN int -NsfProcStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); +EXTERN int NsfProcStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + nonnull(1) nonnull(2) nonnull(4); static int Nsf_InfoBodyObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Command cmd; + assert(interp); + assert(objv); + if (objc != 2) { /* wrong # args, let Tcl generate the error */ return NsfCallCommand(interp, NSF_INFO_BODY, objc, objv); @@ -369,8 +387,11 @@ int NsfShadowTclCommands(Tcl_Interp *interp, NsfShadowOperations load) { int rc = TCL_OK; + assert(interp); + if (load == SHADOW_LOAD) { int initialized = (RUNTIME_STATE(interp)->tclCommands != NULL); + assert(initialized == 0); RUNTIME_STATE(interp)->tclCommands = NEW_ARRAY(NsfShadowTclCommandInfo, NSF_RENAME - NSF_EXPR + 1); @@ -385,7 +406,7 @@ #endif rc |= NsfReplaceCommand(interp, NSF_FORMAT, NULL, initialized); rc |= NsfReplaceCommand(interp, NSF_INTERP, NULL, initialized); - rc |= NsfReplaceCommand(interp, NSF_IS, NULL, initialized); + rc |= NsfReplaceCommand(interp, NSF_STRING_IS, NULL, initialized); /* for the following commands, we have to add our own semantics */ rc |= NsfReplaceCommand(interp, NSF_INFO_BODY, Nsf_InfoBodyObjCmd, initialized);