static int unregister_command(struct command_context *context,
const char *cmd_prefix, const char *name);
-static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj * const *argv);
+static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *argv);
static int help_add_command(struct command_context *cmd_ctx,
const char *cmd_name, const char *help_text, const char *usage_text);
static int help_del_command(struct command_context *cmd_ctx, const char *cmd_name);
static inline bool jimcmd_is_ocd_command(Jim_Cmd *cmd)
{
- return !cmd->isproc && cmd->u.native.cmdProc == command_unknown;
+ return !cmd->isproc && cmd->u.native.cmdProc == jim_command_dispatch;
}
static inline void *jimcmd_privdata(Jim_Cmd *cmd)
{
/* capture log output and return it. A garbage collect can
* happen, so we need a reference count to this object */
- Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0);
- if (NULL == tclOutput)
+ Jim_Obj *jim_output = Jim_NewStringObj(interp, "", 0);
+ if (!jim_output)
return NULL;
+ Jim_IncrRefCount(jim_output);
+
struct log_capture_state *state = malloc(sizeof(*state));
- if (NULL == state)
+ if (!state) {
+ LOG_ERROR("Out of memory");
+ Jim_DecrRefCount(interp, jim_output);
return NULL;
+ }
state->interp = interp;
- Jim_IncrRefCount(tclOutput);
- state->output = tclOutput;
+ state->output = jim_output;
log_add_callback(tcl_output, state);
/* dump a single line to the log for the command.
* Do nothing in case we are not at debug level 3 */
-void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv)
+static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv)
{
if (debug_level < LOG_LVL_DEBUG)
return;
LOG_DEBUG("registering '%s'...", full_name);
int retval = Jim_CreateCommand(context->interp, full_name,
- command_unknown, c, command_free);
+ jim_command_dispatch, c, command_free);
if (retval != JIM_OK) {
command_run_linef(context, "del_help_text {%s}", full_name);
command_run_linef(context, "del_usage_text {%s}", full_name);
continue;
}
LOG_DEBUG("delete command \"%s\"", name);
+#if JIM_VERSION >= 80
Jim_DeleteCommand(interp, elem);
+#else
+ Jim_DeleteCommand(interp, name);
+#endif
help_del_command(cmd_ctx, name);
return command_retval_set(interp, retval);
}
-static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
{
script_debug(interp, argc, argv);
* current_target_override is used also for event handlers
* therefore we prevent touching it if command has no prefix.
* Previous override is saved and restored back to ensure
- * correct work when command_unknown() is re-entered.
+ * correct work when jim_command_dispatch() is re-entered.
*/
struct target *saved_target_override = cmd_ctx->current_target_override;
if (c->jim_override_target)