aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2017-09-17 09:56:58 +1000
committerSteve Bennett <steveb@workware.net.au>2017-09-21 16:30:55 +1000
commitab299323709d7e974262b257bf75909aed9d8d97 (patch)
treec2c106c286cbe1106bf01e5bffdbad32a5e049bf
parent87002c14df88714e7618e52e541199c4a5f354d5 (diff)
downloadjimtcl-ab299323709d7e974262b257bf75909aed9d8d97.zip
jimtcl-ab299323709d7e974262b257bf75909aed9d8d97.tar.gz
jimtcl-ab299323709d7e974262b257bf75909aed9d8d97.tar.bz2
tcl::prefix: respect -message when no valid options
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim-tclprefix.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/jim-tclprefix.c b/jim-tclprefix.c
index 6434499..dcffd4d 100644
--- a/jim-tclprefix.c
+++ b/jim-tclprefix.c
@@ -53,7 +53,7 @@ static int Jim_TclPrefixCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const
const char **table;
Jim_Obj *tableObj;
Jim_Obj *errorObj = NULL;
- Jim_Obj *messageObj = NULL;
+ const char *message = "option";
static const char * const matchoptions[] = { "-error", "-exact", "-message", NULL };
enum { OPT_MATCH_ERROR, OPT_MATCH_EXACT, OPT_MATCH_MESSAGE };
int flags = JIM_ERRMSG | JIM_ENUM_ABBREV;
@@ -91,7 +91,7 @@ static int Jim_TclPrefixCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const
Jim_SetResultString(interp, "missing message", -1);
return JIM_ERR;
}
- messageObj = argv[i];
+ message = Jim_String(argv[i]);
break;
}
}
@@ -104,7 +104,7 @@ static int Jim_TclPrefixCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const
}
table[i] = NULL;
- ret = Jim_GetEnum(interp, stringObj, table, &i, messageObj ? Jim_String(messageObj) : NULL, flags);
+ ret = Jim_GetEnum(interp, stringObj, table, &i, message, flags);
Jim_Free(table);
if (ret == JIM_OK) {
Jim_ListIndex(interp, tableObj, i, &objPtr, JIM_NONE);
@@ -112,7 +112,7 @@ static int Jim_TclPrefixCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const
return JIM_OK;
}
if (tablesize == 0) {
- Jim_SetResultFormatted(interp, "bad option \"%#s\": no valid options", stringObj);
+ Jim_SetResultFormatted(interp, "bad %s \"%#s\": no valid options", message, stringObj);
return JIM_ERR;
}
if (errorObj) {