From f8cd20e28418704c572cf9e69138e1eb83fe4c0a Mon Sep 17 00:00:00 2001 From: oharboe Date: Tue, 28 Oct 2008 08:06:07 +0000 Subject: [PATCH] Rick Altherr - fix support for old target syntax git-svn-id: svn://svn.berlios.de/openocd/trunk@1108 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/target.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index efb67a04..6f086b3e 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -3878,24 +3878,36 @@ jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv ) } if( target_types[x] ){ /* YES IT IS OLD SYNTAX */ + int chain_position_offset; Jim_Obj *new_argv[10]; int new_argc; /* target_old_syntax * - * argv[0] typename (above) - * argv[1] endian - * argv[2] reset method, deprecated/ignored - * argv[3] = old param - * argv[4] = old param + * It appears that there are 2 old syntaxes: * - * We will combine all "old params" into a single param. - * Then later, split them again. + * target + * + * and + * + * target + * + * The following uses the number of arguments to switch between them. */ - if( argc < 4 ){ - Jim_WrongNumArgs( interp, 1, argv, "[OLDSYNTAX] ?TYPE? ?ENDIAN? ?RESET? ?old-params?"); + if( argc < 5 ){ + Jim_WrongNumArgs( interp, 1, argv, "[OLDSYNTAX] ?TYPE? ?ENDIAN? ?CHAIN-POSITION? ?VARIANT?"); return JIM_ERR; } + + /* Use the correct argument offset for the chain position */ + if (argc < 6) { + /* target */ + chain_position_offset = 2; + } else { + chain_position_offset = 3; + /* target */ + } + /* the command */ new_argv[0] = argv[0]; new_argv[1] = Jim_NewStringObj( interp, "create", -1 ); @@ -3908,10 +3920,11 @@ jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv ) new_argv[4] = Jim_NewStringObj( interp, "-endian", -1 ); new_argv[5] = goi.argv[1]; new_argv[6] = Jim_NewStringObj( interp, "-chain-position", -1 ); - new_argv[7] = goi.argv[3]; + new_argv[7] = goi.argv[chain_position_offset]; new_argv[8] = Jim_NewStringObj( interp, "-variant", -1 ); - new_argv[9] = goi.argv[4]; + new_argv[9] = goi.argv[chain_position_offset + 1]; new_argc = 10; + /* * new arg syntax: * argv[0] = command -- 2.39.5