Replace the various identical error callbacks with a single one in cmd-queue.c.

This commit is contained in:
nicm
2019-05-20 11:46:06 +00:00
parent 8db89f8efb
commit e128c7fcd8
8 changed files with 47 additions and 89 deletions

25
menu.c
View File

@ -191,17 +191,6 @@ menu_free_cb(struct client *c)
free(md);
}
static enum cmd_retval
menu_error_cb(struct cmdq_item *item, void *data)
{
char *error = data;
cmdq_error(item, "%s", error);
free(error);
return (CMD_RETURN_NORMAL);
}
static int
menu_key_cb(struct client *c, struct key_event *event)
{
@ -284,12 +273,14 @@ chosen:
return (1);
}
cmdlist = cmd_string_parse(item->command, NULL, 0, &cause);
if (cmdlist == NULL && cause != NULL)
new_item = cmdq_get_callback(menu_error_cb, cause);
else if (cmdlist == NULL)
new_item = NULL;
else {
new_item = cmdq_get_command(cmdlist, &md->fs, NULL, 0);
if (cmdlist == NULL) {
if (cause != NULL)
new_item = cmdq_get_error(cause);
else
new_item = NULL;
free(cause);
} else {
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
cmd_list_free(cmdlist);
}
if (new_item != NULL) {