alias = alias->next;
}
- /* A hidden option must be a full match (no best matches) */
- if (as->parms[i].flags & CMD_HIDE || !enableAbbreviation)
+ /* A hidden option, or one which cannot be abbreviated,
+ * must be a full match (no best matches) */
+ if (as->parms[i].flags & CMD_HIDE ||
+ as->parms[i].flags & CMD_NOABBRV ||
+ !enableAbbreviation)
continue;
if (strncmp(as->parms[i].name, aname, cmdlen) == 0) {
#define CMD_EXPANDS 2 /* if list, try to eat tokens through eoline, instead of just 1 */
#define CMD_HIDE 4 /* A hidden option */
#define CMD_PROCESSED 8
+#define CMD_NOABBRV 16 /* Abbreviation not supported */
struct cmd_syndesc {
struct cmd_syndesc *next; /* next one in system list */
#define FLAG_OFF 0
#define FIRST_OFF 1
#define SECOND_OFF 2
+#define SUGAR_OFF 3
#define FOURTH_OFF 4
#define FIFTH_OFF 5
#define PERHAPS_OFF 6
int retval;
char *retstring = NULL;
- plan(79);
+ plan(85);
initialize_CMD_error_table();
is_int(CMD_UNKNOWNSWITCH, code, "and fail with cmd_Parse too");
cmd_FreeArgv(tv);
+ /* Check that paramaters with abbreviation disabled don't make things
+ * ambiguous */
+ cmd_AddParmAtOffset(opts, "-sugar", CMD_SINGLE, CMD_OPTIONAL | CMD_NOABBRV,
+ "sugar with that", SUGAR_OFF);
+ code = cmd_ParseLine("-fi foo -s bar -flag", tv, &tc, 100);
+ is_int(0, code, "cmd_ParseLine succeeds");
+ code = cmd_Dispatch(tc, tv);
+ is_int(0, code, "disabling specific abbreviations succeeds");
+ code = cmd_Parse(tc, tv, &retopts);
+ is_int(0, code, "and works with cmd_Parse into the bargain");
+ cmd_FreeOptions(&retopts);
+ cmd_FreeArgv(tv);
+
/* Disable positional commands */
cmd_DisablePositionalCommands();
code = cmd_ParseLine("foo bar -flag", tv, &tc, 100);