summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-06-24 10:04:30 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-06-24 10:04:30 +0000
commit843d80f719f7270c08b4bc27707f76ea39b1b9e6 (patch)
treef27e60bf88857ead8903b7603395f2d17480ed01
parent6e362578e8020fa6de5da1e0d11e30e360318a5a (diff)
Expand arguments to C and s format modifiers (matches m which already expands).
-rw-r--r--usr.bin/tmux/format.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 7799732f326..019940cf8c7 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.206 2019/06/20 11:59:59 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.207 2019/06/24 10:04:29 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1644,13 +1644,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) {
@@ -1780,11 +1782,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. */