diff --git a/src/core/commands.c b/src/core/commands.c index b4362d59..174824a3 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -361,7 +361,6 @@ static int option_find(char **array, const char *option) g_return_val_if_fail(option != NULL, -1); len = strlen(option); - g_return_val_if_fail(len > 0, -1); found = -1; index = 0; multiple = FALSE; for (tmp = array; *tmp != NULL; tmp++, index++) { @@ -411,7 +410,7 @@ static int get_cmd_options(char **data, int ignore_unknown, } (*data)++; - if (**data == '-') { + if (**data == '-' && isspace((*data)[1])) { /* -- option means end of options even if next word starts with - */ (*data)++; @@ -419,7 +418,12 @@ static int get_cmd_options(char **data, int ignore_unknown, break; } - option = cmd_get_param(data); + if (!isspace(**data)) + option = cmd_get_param(data); + else { + option = "-"; + (*data)++; + } /* check if this option can have argument */ pos = optlist == NULL ? -1 : @@ -443,7 +447,8 @@ static int get_cmd_options(char **data, int ignore_unknown, if (options != NULL) g_hash_table_insert(options, option, ""); - if (pos == -1 || !iscmdtype(*optlist[pos])) + if (pos < 0 || !iscmdtype(*optlist[pos]) || + *optlist[pos] == '!') option = NULL; while (isspace(**data)) (*data)++; diff --git a/src/core/commands.h b/src/core/commands.h index f5a5c084..6a9d9be4 100644 --- a/src/core/commands.h +++ b/src/core/commands.h @@ -68,6 +68,7 @@ int command_have_sub(const char *command); options separated with space, each option can contain a special char in front of it: + '!': no argument (default) '-': optional argument '+': argument required '@': optional numeric argument @@ -79,7 +80,7 @@ int command_have_sub(const char *command); will be merged. If there's any conflicts with option types, the last call will override the previous */ #define iscmdtype(c) \ - ((c) == '-' || (c) == '+' || (c) == '@') + ((c) == '!' || (c) == '-' || (c) == '+' || (c) == '@') void command_set_options(const char *cmd, const char *options); /* Returns TRUE if command has specified option. */ diff --git a/src/fe-text/gui-textwidget.c b/src/fe-text/gui-textwidget.c index 745162aa..ce2b58a5 100644 --- a/src/fe-text/gui-textwidget.c +++ b/src/fe-text/gui-textwidget.c @@ -431,7 +431,7 @@ void gui_textwidget_init(void) command_bind("scrollback goto", NULL, (SIGNAL_FUNC) cmd_scrollback_goto); command_bind("scrollback home", NULL, (SIGNAL_FUNC) cmd_scrollback_home); command_bind("scrollback end", NULL, (SIGNAL_FUNC) cmd_scrollback_end); - command_set_options("lastlog", "new away word regexp"); + command_set_options("lastlog", "!- new away word regexp"); signal_add("away mode changed", (SIGNAL_FUNC) sig_away_changed); }