summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-10-28 08:06:07 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-10-28 08:06:07 +0000
commitf8cd20e28418704c572cf9e69138e1eb83fe4c0a (patch)
treed3c561e2fed7605ba1fe61bc6dff4fe7bbb1fd11 /src
parentdf77b45054b7929b90f348481823d6b0b38fe219 (diff)
downloadopenocd_libswd-f8cd20e28418704c572cf9e69138e1eb83fe4c0a.tar.gz
openocd_libswd-f8cd20e28418704c572cf9e69138e1eb83fe4c0a.tar.bz2
openocd_libswd-f8cd20e28418704c572cf9e69138e1eb83fe4c0a.tar.xz
openocd_libswd-f8cd20e28418704c572cf9e69138e1eb83fe4c0a.zip
Rick Altherr <kc8apf@kc8apf.net> - fix support for old target syntax
git-svn-id: svn://svn.berlios.de/openocd/trunk@1108 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/target/target.c35
1 files 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 <typename> <endian> <chain position> <variant>
+ *
+ * and
+ *
+ * target <typename> <endian> <reset mode> <chain position> <variant>
+ *
+ * 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 <type> <endian> <chain position> <variant> */
+ chain_position_offset = 2;
+ } else {
+ chain_position_offset = 3;
+ /* target <type> <endian> <reset mode> <chain position> <variant> */
+ }
+
/* 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