mirror of
https://github.com/tmux/tmux.git
synced 2026-10-06 17:49:52 +00:00
Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master: Change correct depth counter for source-file when used from hooks, GitHub issue 5437.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: cmd-source-file.c,v 1.62 2025/11/18 08:42:09 nicm Exp $ */
|
/* $OpenBSD: cmd-source-file.c,v 1.63 2026/08/18 08:05:05 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
|
||||||
@@ -50,6 +50,7 @@ const struct cmd_entry cmd_source_file_entry = {
|
|||||||
|
|
||||||
struct cmd_source_file_data {
|
struct cmd_source_file_data {
|
||||||
struct cmdq_item *item;
|
struct cmdq_item *item;
|
||||||
|
struct client *client;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
struct cmdq_item *after;
|
struct cmdq_item *after;
|
||||||
@@ -60,10 +61,24 @@ struct cmd_source_file_data {
|
|||||||
u_int nfiles;
|
u_int nfiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum cmd_retval
|
static void
|
||||||
cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data)
|
cmd_source_file_free_data(struct cmd_source_file_data *cdata)
|
||||||
{
|
{
|
||||||
struct client *c = cmdq_get_client(item);
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < cdata->nfiles; i++)
|
||||||
|
free(cdata->files[i]);
|
||||||
|
free(cdata->files);
|
||||||
|
if (cdata->client != NULL)
|
||||||
|
server_client_unref(cdata->client);
|
||||||
|
free(cdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_source_file_complete_cb(struct cmdq_item *item, void *data)
|
||||||
|
{
|
||||||
|
struct cmd_source_file_data *cdata = data;
|
||||||
|
struct client *c = cdata->client;
|
||||||
|
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
cmd_source_file_depth--;
|
cmd_source_file_depth--;
|
||||||
@@ -74,36 +89,36 @@ cmd_source_file_complete_cb(struct cmdq_item *item, __unused void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg_print_causes(item);
|
cfg_print_causes(item);
|
||||||
|
cmd_source_file_free_data(cdata);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata)
|
cmd_source_file_complete(struct cmd_source_file_data *cdata)
|
||||||
{
|
{
|
||||||
|
struct client *c = cdata->client;
|
||||||
struct cmdq_item *new_item;
|
struct cmdq_item *new_item;
|
||||||
u_int i;
|
|
||||||
|
|
||||||
if (cfg_finished) {
|
if (!cfg_finished) {
|
||||||
if (cdata->retval == CMD_RETURN_ERROR &&
|
cmd_source_file_free_data(cdata);
|
||||||
c != NULL &&
|
return;
|
||||||
c->session == NULL)
|
|
||||||
c->retval = 1;
|
|
||||||
new_item = cmdq_get_callback(cmd_source_file_complete_cb, NULL);
|
|
||||||
cmdq_insert_after(cdata->after, new_item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < cdata->nfiles; i++)
|
if (cdata->retval == CMD_RETURN_ERROR &&
|
||||||
free(cdata->files[i]);
|
c != NULL &&
|
||||||
free(cdata->files);
|
c->session == NULL)
|
||||||
free(cdata);
|
c->retval = 1;
|
||||||
|
new_item = cmdq_get_callback(cmd_source_file_complete_cb, cdata);
|
||||||
|
cmdq_insert_after(cdata->after, new_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_source_file_done(struct client *c, const char *path, int error,
|
cmd_source_file_done(__unused struct client *oc, const char *path,
|
||||||
int closed, struct evbuffer *buffer, void *data)
|
int error, int closed, struct evbuffer *buffer, void *data)
|
||||||
{
|
{
|
||||||
struct cmd_source_file_data *cdata = data;
|
struct cmd_source_file_data *cdata = data;
|
||||||
struct cmdq_item *item = cdata->item;
|
struct cmdq_item *item = cdata->item;
|
||||||
|
struct client *c = cdata->client;
|
||||||
void *bdata = EVBUFFER_DATA(buffer);
|
void *bdata = EVBUFFER_DATA(buffer);
|
||||||
size_t bsize = EVBUFFER_LENGTH(buffer);
|
size_t bsize = EVBUFFER_LENGTH(buffer);
|
||||||
u_int n;
|
u_int n;
|
||||||
@@ -127,7 +142,7 @@ cmd_source_file_done(struct client *c, const char *path, int error,
|
|||||||
if (n < cdata->nfiles)
|
if (n < cdata->nfiles)
|
||||||
file_read(c, cdata->files[n], cmd_source_file_done, cdata);
|
file_read(c, cdata->files[n], cmd_source_file_done, cdata);
|
||||||
else {
|
else {
|
||||||
cmd_source_file_complete(c, cdata);
|
cmd_source_file_complete(cdata);
|
||||||
cmdq_continue(item);
|
cmdq_continue(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,6 +202,9 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
cdata->item = item;
|
cdata->item = item;
|
||||||
|
cdata->client = c;
|
||||||
|
if (c != NULL)
|
||||||
|
c->references++;
|
||||||
|
|
||||||
if (args_has(args, 'q'))
|
if (args_has(args, 'q'))
|
||||||
cdata->flags |= CMD_PARSE_QUIET;
|
cdata->flags |= CMD_PARSE_QUIET;
|
||||||
@@ -249,7 +267,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
file_read(c, cdata->files[0], cmd_source_file_done, cdata);
|
file_read(c, cdata->files[0], cmd_source_file_done, cdata);
|
||||||
retval = CMD_RETURN_WAIT;
|
retval = CMD_RETURN_WAIT;
|
||||||
} else
|
} else
|
||||||
cmd_source_file_complete(c, cdata);
|
cmd_source_file_complete(cdata);
|
||||||
|
|
||||||
free(cwd);
|
free(cwd);
|
||||||
return (retval);
|
return (retval);
|
||||||
|
|||||||
Reference in New Issue
Block a user