helper/command: rename s/command_unknown/jim_command_dispatch/
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 3 Aug 2020 21:03:46 +0000 (23:03 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 18 Apr 2021 14:35:18 +0000 (15:35 +0100)
The function's name was consistent with its purpose to handle
commands that were not at root level, thus not directly 'known'
by jimtcl.

Rename it as jim_command_dispatch() to highlight that now it is
a jim_handler and its purpose is to dispatch the call to the
proper command handler.

Change-Id: I9491a6d6459b8eb37a6c402abcae08388c693764
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5791
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
src/helper/command.c

index a7990d4f8ac49bc5162ec1b07f8f50be8629855b..80e297b1f8baea7e5dd28761a11caad74971da82 100644 (file)
@@ -51,7 +51,7 @@ struct log_capture_state {
 
 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);
@@ -64,7 +64,7 @@ static inline bool jimcmd_is_proc(Jim_Cmd *cmd)
 
 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)
@@ -340,7 +340,7 @@ static struct command *register_command(struct command_context *context,
 
        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);
@@ -942,7 +942,7 @@ static int exec_command(Jim_Interp *interp, struct command_context *cmd_ctx,
        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);
 
@@ -982,7 +982,7 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *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)