summaryrefslogtreecommitdiffstats
path: root/cfg.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-04-07 16:01:21 +0100
committerThomas Adam <thomas@xteddy.org>2021-04-07 16:01:21 +0100
commit3cd63cc9e0f8f1a4fb4e9da7f39de77ed58d61fb (patch)
treebc2b0c9e555b94eb2eadb8771fd6f1f2fd221394 /cfg.c
parent998a6b0aea560a3c43c23b38b039e9f77d067fe3 (diff)
parent71fc9f3ee8753a2bb163c85c784936a8d6d3e0ac (diff)
Merge branch 'obsd-master' into master
Diffstat (limited to 'cfg.c')
-rw-r--r--cfg.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/cfg.c b/cfg.c
index 3ef46e66..8ec5a95b 100644
--- a/cfg.c
+++ b/cfg.c
@@ -102,6 +102,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmdq_item *new_item0;
+ struct cmdq_state *state;
if (new_item != NULL)
*new_item = NULL;
@@ -135,12 +136,19 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
return (0);
}
- new_item0 = cmdq_get_command(pr->cmdlist, NULL);
+ if (item != NULL)
+ state = cmdq_copy_state(cmdq_get_state(item));
+ else
+ state = cmdq_new_state(NULL, NULL, 0);
+ cmdq_add_format(state, "current_file", "%s", pi.file);
+
+ new_item0 = cmdq_get_command(pr->cmdlist, state);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
+ cmdq_free_state(state);
if (new_item != NULL)
*new_item = new_item0;
@@ -155,6 +163,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmdq_item *new_item0;
+ struct cmdq_state *state;
if (new_item != NULL)
*new_item = NULL;
@@ -181,12 +190,19 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
return (0);
}
- new_item0 = cmdq_get_command(pr->cmdlist, NULL);
+ if (item != NULL)
+ state = cmdq_copy_state(cmdq_get_state(item));
+ else
+ state = cmdq_new_state(NULL, NULL, 0);
+ cmdq_add_format(state, "current_file", "%s", pi.file);
+
+ new_item0 = cmdq_get_command(pr->cmdlist, state);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
+ cmdq_free_state(state);
if (new_item != NULL)
*new_item = new_item0;