diff options
author | sabetts <sabetts> | 2005-01-15 05:20:21 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2005-01-15 05:20:21 +0000 |
commit | 253455bf72fc461f55d428387c746ba06150e2aa (patch) | |
tree | de4dab5a01262efffa3862a0a6a042a6669c6c64 /src | |
parent | 8f7f08967c669769ec46876b7493bec8d228614b (diff) | |
download | ratpoison-253455bf72fc461f55d428387c746ba06150e2aa.zip |
(parse_args): remove erroneous pointer dereference
of i when gobbling whitespace.
(init_user_commands): set second argument to "alias" command to
arg_REST.
(init_user_commands): likewise for "set"
(cmd_readkey): remove useless PRINT_DEBUG
(cmd_set): pass an empty string to parse_args when the args[1] is
NULL.
(cmd_set): call the set function if the arg list size is 0.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/actions.c b/src/actions.c index 8091041..d708ef0 100644 --- a/src/actions.c +++ b/src/actions.c @@ -157,7 +157,7 @@ init_user_commands() "Command: ", arg_STRING); add_command ("alias", cmd_alias, 2, 2, 2, "Alias: ", arg_STRING, - "Command: ", arg_STRING); + "Command: ", arg_REST); add_command ("banish", cmd_banish, 0, 0, 0); add_command ("chdir", cmd_chdir, 1, 0, 0, "Dir: ", arg_STRING); @@ -271,7 +271,7 @@ init_user_commands() "Select window: ", arg_STRING); add_command ("set", cmd_set, 2, 0, 0, "", arg_VARIABLE, - "", arg_STRING); + "", arg_REST); add_command ("setenv", cmd_setenv, 2, 2, 2, "Variable: ", arg_STRING, "Value: ", arg_REST); @@ -2140,9 +2140,9 @@ parse_args (char *str, struct list_head *list, int nargs) /* Should we eat the whitespace? */ if (gobble) { - while (*i && *i == ' ') *i++; + while (*i && *i == ' ') i++; /* Did we go too far? */ - if (*i && *i != ' ') *i--; + if (*i && *i != ' ') i--; gobble = 0; } } @@ -4584,8 +4584,6 @@ cmd_readkey (int interactive, struct cmdarg **args) int rat_grabbed = 0; rp_keymap *map; - PRINT_DEBUG (("hero\n")); - map = ARG(0,keymap); XGrabKeyboard (dpy, current_screen()->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); @@ -4699,6 +4697,7 @@ cmd_set (int interactive, struct cmdarg **args) int parsed_args; cmdret *result = NULL; struct cmdarg **cmdargs; + char *input; INIT_LIST_HEAD (&arglist); INIT_LIST_HEAD (&head); @@ -4712,17 +4711,23 @@ cmd_set (int interactive, struct cmdarg **args) } /* Parse the arguments and call the function. */ - result = parse_args (ARG_STRING(1), &head, nargs); + if (args[1]) + input = xstrdup (args[1]->string); + else + input = xstrdup (""); + result = parse_args (input, &head, nargs); + free (input); + if (result) goto failed; result = parsed_input_to_args (ARG(0,variable)->nargs, ARG(0,variable)->args, &head, &arglist, &parsed_args); if (result) goto failed; - if (list_size (&arglist) < ARG(0,variable)->nargs) + /* 0 or nargs is acceptable */ + if (list_size (&arglist) > 0 && list_size (&arglist) < ARG(0,variable)->nargs) { - result = cmdret_new_printf (RET_FAILURE, "not enough arguments. %d %d", - list_size (&arglist), ARG(0,variable)->nargs); + result = cmdret_new ("not enough arguments.", RET_FAILURE); goto failed; } |