summaryrefslogtreecommitdiffstats
path: root/cmd-unbind-key.c
diff options
context:
space:
mode:
authorThomas <thomas@xteddy.org>2013-10-11 14:33:29 +0100
committerThomas <thomas@xteddy.org>2013-10-11 14:33:29 +0100
commit7f479ffdce8f49f6c57d575b708c4cbe8cbe18df (patch)
treec0b1ddfb340c9bd59bbc02e83f30bf34aeb29a88 /cmd-unbind-key.c
parentc190c73240576aa2a8274a305844f1fa7fcb0e71 (diff)
parent4901d9ddc8d8c33ecdca363dcb67e66482745fa5 (diff)
Merge branch 'obsd-master' into mtemp
Diffstat (limited to 'cmd-unbind-key.c')
-rw-r--r--cmd-unbind-key.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c
index dc037dde..cf6ad506 100644
--- a/cmd-unbind-key.c
+++ b/cmd-unbind-key.c
@@ -26,7 +26,6 @@
* Unbind key from command.
*/
-enum cmd_retval cmd_unbind_key_check(struct args *);
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_unbind_key_table(struct cmd *, struct cmd_q *, int);
@@ -36,21 +35,10 @@ const struct cmd_entry cmd_unbind_key_entry = {
"[-acn] [-t key-table] key",
0,
NULL,
- cmd_unbind_key_check,
cmd_unbind_key_exec
};
enum cmd_retval
-cmd_unbind_key_check(struct args *args)
-{
- if (args_has(args, 'a') && args->argc != 0)
- return (CMD_RETURN_ERROR);
- if (!args_has(args, 'a') && args->argc != 1)
- return (CMD_RETURN_ERROR);
- return (CMD_RETURN_NORMAL);
-}
-
-enum cmd_retval
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
@@ -58,13 +46,22 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
int key;
if (!args_has(args, 'a')) {
+ if (args->argc != 1) {
+ cmdq_error(cmdq, "missing key");
+ return (CMD_RETURN_ERROR);
+ }
key = key_string_lookup_string(args->argv[0]);
if (key == KEYC_NONE) {
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
- } else
+ } else {
+ if (args->argc != 0) {
+ cmdq_error(cmdq, "key given with -a");
+ return (CMD_RETURN_ERROR);
+ }
key = KEYC_NONE;
+ }
if (args_has(args, 't'))
return (cmd_unbind_key_table(self, cmdq, key));