This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5091

-- gerrit

commit e8972b5f43b6a375b7e587f0313c78d2bfc3168b
Author: Antonio Borneo <[email protected]>
Date:   Sat Apr 6 11:30:54 2019 +0200

    helper/command: deprecate the old commands "ocd_%s"
    
    Even if it is not required anymore, there are still around OpenOCD
    scripts that use the commands with "ocd_" prefix to capture the
    output.
    
    Create a wrapper with "ocd_" prefix that calls the right command
    and dump a deprecate message.
    
    In the future, when we could drop this hack, this patch can be
    simply reverted.
    
    Change-Id: I489aee032dca2530e783a4631ba63359458a53c5
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/helper/command.c b/src/helper/command.c
index a3940a8..234a553 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -356,6 +356,18 @@ static int register_command_handler(struct command_context 
*cmd_ctx,
 
        Jim_CmdProc *func = c->handler ? &script_command : &command_unknown;
        int retval = Jim_CreateCommand(interp, c->name, func, c, NULL);
+       if (retval != JIM_OK)
+               return retval;
+
+       /* FIXME: this should be removed sometime in the future */
+       /* old commands "ocd_%s" are now deprecated */
+       char *deprecated_proc = alloc_printf(
+               "proc ocd_%s {args} {eval ocd_wrapper_deprecated %s $args}",
+               c->name, c->name);
+       if (!deprecated_proc)
+               return JIM_ERR;
+       retval = Jim_Eval_Named(interp, deprecated_proc, 0, 0);
+       free(deprecated_proc);
 
        return retval;
 }
diff --git a/src/helper/startup.tcl b/src/helper/startup.tcl
index 691e382..83aaa72 100644
--- a/src/helper/startup.tcl
+++ b/src/helper/startup.tcl
@@ -30,3 +30,7 @@ add_usage_text script "<file>"
 
 #########
 
+proc ocd_wrapper_deprecated {name args} {
+       echo "DEPRECATED! use '$name' not 'ocd_$name'"
+       eval $name $args
+}

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to