mirror of
https://github.com/tmux/tmux.git
synced 2025-01-14 12:48:56 +00:00
Remove unnecessary initializers of cmd_ctx.
This commit is contained in:
parent
0ff9275ad7
commit
a1722d5c2e
@ -150,7 +150,7 @@ cmd_command_prompt_callback(void *data, const char *s)
|
||||
struct cmd_command_prompt_cdata *cdata = data;
|
||||
struct client *c = cdata->c;
|
||||
struct cmd_list *cmdlist;
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
char *cause, *new_template, *prompt, *ptr;
|
||||
char *input = NULL;
|
||||
|
||||
@ -184,17 +184,15 @@ cmd_command_prompt_callback(void *data, const char *s)
|
||||
return (0);
|
||||
}
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
ctx.curclient = c;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->curclient = c;
|
||||
ctx->error = key_bindings_error;
|
||||
ctx->print = key_bindings_print;
|
||||
ctx->info = key_bindings_info;
|
||||
|
||||
ctx.error = key_bindings_error;
|
||||
ctx.print = key_bindings_print;
|
||||
ctx.info = key_bindings_info;
|
||||
|
||||
ctx.cmdclient = NULL;
|
||||
|
||||
cmd_list_exec(cmdlist, &ctx);
|
||||
cmd_list_exec(cmdlist, ctx);
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_ctx(ctx);
|
||||
|
||||
if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
|
||||
return (1);
|
||||
|
@ -108,7 +108,7 @@ cmd_confirm_before_callback(void *data, const char *s)
|
||||
struct cmd_confirm_before_data *cdata = data;
|
||||
struct client *c = cdata->c;
|
||||
struct cmd_list *cmdlist;
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
char *cause;
|
||||
|
||||
if (s == NULL || *s == '\0')
|
||||
@ -125,17 +125,15 @@ cmd_confirm_before_callback(void *data, const char *s)
|
||||
return (0);
|
||||
}
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
ctx.curclient = c;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->curclient = c;
|
||||
ctx->error = key_bindings_error;
|
||||
ctx->print = key_bindings_print;
|
||||
ctx->info = key_bindings_info;
|
||||
|
||||
ctx.error = key_bindings_error;
|
||||
ctx.print = key_bindings_print;
|
||||
ctx.info = key_bindings_info;
|
||||
|
||||
ctx.cmdclient = NULL;
|
||||
|
||||
cmd_list_exec(cmdlist, &ctx);
|
||||
cmd_list_exec(cmdlist, ctx);
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_ctx(ctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
17
control.c
17
control.c
@ -93,7 +93,7 @@ void
|
||||
control_callback(struct client *c, int closed, unused void *data)
|
||||
{
|
||||
char *line, *cause;
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
struct cmd_list *cmdlist;
|
||||
|
||||
if (closed)
|
||||
@ -108,22 +108,21 @@ control_callback(struct client *c, int closed, unused void *data)
|
||||
break;
|
||||
}
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
ctx.cmdclient = NULL;
|
||||
ctx.curclient = c;
|
||||
|
||||
ctx.error = control_msg_error;
|
||||
ctx.print = control_msg_print;
|
||||
ctx.info = control_msg_info;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->curclient = c;
|
||||
ctx->error = control_msg_error;
|
||||
ctx->print = control_msg_print;
|
||||
ctx->info = control_msg_info;
|
||||
|
||||
if (cmd_string_parse(line, &cmdlist, &cause) != 0) {
|
||||
control_write(c, "%%error in line \"%s\": %s", line,
|
||||
cause);
|
||||
free(cause);
|
||||
} else {
|
||||
cmd_list_exec(cmdlist, &ctx);
|
||||
cmd_list_exec(cmdlist, ctx);
|
||||
cmd_list_free(cmdlist);
|
||||
}
|
||||
cmd_free_ctx(ctx);
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
@ -262,18 +262,15 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
void
|
||||
key_bindings_dispatch(struct key_binding *bd, struct client *c)
|
||||
{
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
struct cmd *cmd;
|
||||
int readonly;
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
ctx.curclient = c;
|
||||
|
||||
ctx.error = key_bindings_error;
|
||||
ctx.print = key_bindings_print;
|
||||
ctx.info = key_bindings_info;
|
||||
|
||||
ctx.cmdclient = NULL;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->curclient = c;
|
||||
ctx->error = key_bindings_error;
|
||||
ctx->print = key_bindings_print;
|
||||
ctx->info = key_bindings_info;
|
||||
|
||||
readonly = 1;
|
||||
TAILQ_FOREACH(cmd, &bd->cmdlist->list, qentry) {
|
||||
@ -281,9 +278,10 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c)
|
||||
readonly = 0;
|
||||
}
|
||||
if (!readonly && c->flags & CLIENT_READONLY) {
|
||||
key_bindings_info(&ctx, "Client is read-only");
|
||||
key_bindings_info(ctx, "client is read-only");
|
||||
return;
|
||||
}
|
||||
|
||||
cmd_list_exec(bd->cmdlist, &ctx);
|
||||
cmd_list_exec(bd->cmdlist, ctx);
|
||||
cmd_free_ctx(ctx);
|
||||
}
|
||||
|
@ -865,24 +865,22 @@ server_client_msg_info(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
void
|
||||
server_client_msg_command(struct client *c, struct msg_command_data *data)
|
||||
{
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
struct cmd_list *cmdlist = NULL;
|
||||
int argc;
|
||||
char **argv, *cause;
|
||||
|
||||
ctx.error = server_client_msg_error;
|
||||
ctx.print = server_client_msg_print;
|
||||
ctx.info = server_client_msg_info;
|
||||
|
||||
ctx.msgdata = data;
|
||||
ctx.curclient = NULL;
|
||||
|
||||
ctx.cmdclient = c;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->msgdata = data;
|
||||
ctx->cmdclient = c;
|
||||
ctx->error = server_client_msg_error;
|
||||
ctx->print = server_client_msg_print;
|
||||
ctx->info = server_client_msg_info;
|
||||
|
||||
argc = data->argc;
|
||||
data->argv[(sizeof data->argv) - 1] = '\0';
|
||||
if (cmd_unpack_argv(data->argv, sizeof data->argv, argc, &argv) != 0) {
|
||||
server_client_msg_error(&ctx, "command too long");
|
||||
server_client_msg_error(ctx, "command too long");
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -893,13 +891,13 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
|
||||
}
|
||||
|
||||
if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) {
|
||||
server_client_msg_error(&ctx, "%s", cause);
|
||||
server_client_msg_error(ctx, "%s", cause);
|
||||
cmd_free_argv(argc, argv);
|
||||
goto error;
|
||||
}
|
||||
cmd_free_argv(argc, argv);
|
||||
|
||||
switch (cmd_list_exec(cmdlist, &ctx))
|
||||
switch (cmd_list_exec(cmdlist, ctx))
|
||||
{
|
||||
case CMD_RETURN_ERROR:
|
||||
case CMD_RETURN_NORMAL:
|
||||
@ -910,11 +908,14 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
|
||||
break;
|
||||
}
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_ctx(ctx);
|
||||
return;
|
||||
|
||||
error:
|
||||
if (cmdlist != NULL)
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_ctx(ctx);
|
||||
|
||||
c->flags |= CLIENT_EXIT;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ window_choose_data_free(struct window_choose_data *wcd)
|
||||
void
|
||||
window_choose_data_run(struct window_choose_data *cdata)
|
||||
{
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd_ctx *ctx;
|
||||
struct cmd_list *cmdlist;
|
||||
char *cause;
|
||||
|
||||
@ -220,17 +220,15 @@ window_choose_data_run(struct window_choose_data *cdata)
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
ctx.curclient = cdata->start_client;
|
||||
ctx = cmd_get_ctx();
|
||||
ctx->curclient = cdata->start_client;
|
||||
ctx->error = key_bindings_error;
|
||||
ctx->print = key_bindings_print;
|
||||
ctx->info = key_bindings_info;
|
||||
|
||||
ctx.error = key_bindings_error;
|
||||
ctx.print = key_bindings_print;
|
||||
ctx.info = key_bindings_info;
|
||||
|
||||
ctx.cmdclient = NULL;
|
||||
|
||||
cmd_list_exec(cmdlist, &ctx);
|
||||
cmd_list_exec(cmdlist, ctx);
|
||||
cmd_list_free(cmdlist);
|
||||
cmd_free_ctx(ctx);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user