aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-06-24 13:02:26 +0100
committerThomas Adam <thomas@xteddy.org>2019-06-24 13:02:26 +0100
commita1d4bf20f774707c22249399dd89d1d6acf049ef (patch)
tree42f6c58fa5919b15bbf9396ae967c2ce64fc4b4d /format.c
parentc14b0d7c00373d08b7704a54c88a181aeed8f2ca (diff)
parent20b938bcb18b8ae8b0535a1bcf8e7e1670a830bc (diff)
downloadrtmux-a1d4bf20f774707c22249399dd89d1d6acf049ef.tar.gz
rtmux-a1d4bf20f774707c22249399dd89d1d6acf049ef.tar.bz2
rtmux-a1d4bf20f774707c22249399dd89d1d6acf049ef.zip
Merge branch 'obsd-master'
Diffstat (limited to 'format.c')
-rw-r--r--format.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/format.c b/format.c
index ba26de66..8d2d8db8 100644
--- a/format.c
+++ b/format.c
@@ -1660,13 +1660,15 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
goto fail;
} else if (search != NULL) {
/* Search in pane. */
+ new = format_expand(ft, copy);
if (wp == NULL) {
- format_log(ft, "search '%s' but no pane", copy);
+ format_log(ft, "search '%s' but no pane", new);
value = xstrdup("0");
} else {
- format_log(ft, "search '%s' pane %%%u", copy, wp->id);
- value = format_search(fm, wp, copy);
+ format_log(ft, "search '%s' pane %%%u", new, wp->id);
+ value = format_search(fm, wp, new);
}
+ free(new);
} else if (cmp != NULL) {
/* Comparison of left and right. */
if (format_choose(ft, copy, &left, &right, 1) != 0) {
@@ -1796,11 +1798,14 @@ done:
/* Perform substitution if any. */
if (sub != NULL) {
- new = format_sub(sub, value, sub->argv[0], sub->argv[1]);
- format_log(ft, "substituted '%s' to '%s': %s", sub->argv[0],
- sub->argv[1], new);
+ left = format_expand(ft, sub->argv[0]);
+ right = format_expand(ft, sub->argv[1]);
+ new = format_sub(sub, value, left, right);
+ format_log(ft, "substitute '%s' to '%s': %s", left, right, new);
free(value);
value = new;
+ free(right);
+ free(left);
}
/* Truncate the value if needed. */