summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/control-notify.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-03-08 13:36:12 +0000
committernicm <nicm@openbsd.org>2017-03-08 13:36:12 +0000
commite35be1bbf4eba1dc2915a61ee09f1af8f875b2dd (patch)
tree3df2cd70fb95ec0fd53f8b7f685c6ebbd9e6a0e5 /usr.bin/tmux/control-notify.c
parentprevent infinite recursion while expanding the arguments (diff)
downloadwireguard-openbsd-e35be1bbf4eba1dc2915a61ee09f1af8f875b2dd.tar.xz
wireguard-openbsd-e35be1bbf4eba1dc2915a61ee09f1af8f875b2dd.zip
Add a helper function for the most common format_create/defaults/expand
pattern.
Diffstat (limited to 'usr.bin/tmux/control-notify.c')
-rw-r--r--usr.bin/tmux/control-notify.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/tmux/control-notify.c b/usr.bin/tmux/control-notify.c
index 888f1f78510..dd330ba2fee 100644
--- a/usr.bin/tmux/control-notify.c
+++ b/usr.bin/tmux/control-notify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control-notify.c,v 1.19 2017/02/03 11:57:27 nicm Exp $ */
+/* $OpenBSD: control-notify.c,v 1.20 2017/03/08 13:36:12 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -64,10 +64,9 @@ control_notify_window_layout_changed(struct window *w)
{
struct client *c;
struct session *s;
- struct format_tree *ft;
struct winlink *wl;
const char *template;
- char *expanded;
+ char *cp;
template = "%layout-change #{window_id} #{window_layout} "
"#{window_visible_layout} #{window_flags}";
@@ -88,15 +87,12 @@ control_notify_window_layout_changed(struct window *w)
if (w->layout_root == NULL)
continue;
- ft = format_create(NULL, FORMAT_NONE, 0);
wl = winlink_find_by_window(&s->windows, w);
if (wl != NULL) {
- format_defaults(ft, c, NULL, wl, NULL);
- expanded = format_expand(ft, template);
- control_write(c, "%s", expanded);
- free(expanded);
+ cp = format_single(NULL, template, c, NULL, wl, NULL);
+ control_write(c, "%s", cp);
+ free(cp);
}
- format_free(ft);
}
}