From f4232a7930f91d2beea0a88a0587a97f34914dbb Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 18 Jan 2018 14:28:12 +0000 Subject: Discard all but the last line when reading from a #() command - the callback is just going to be fired again straight away to go through all the lines, it is better just to use the last one straight away. --- usr.bin/tmux/format.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 9b310e9ee9e..c2b7f215fcc 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.150 2017/11/02 18:52:05 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.151 2018/01/18 14:28:11 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -191,10 +191,15 @@ static void format_job_update(struct job *job) { struct format_job *fj = job->data; - char *line; + struct evbuffer *evb = job->event->input; + char *line = NULL, *next; time_t t; - if ((line = evbuffer_readline(job->event->input)) == NULL) + while ((next = evbuffer_readline(evb)) != NULL) { + free(line); + line = next; + } + if (line == NULL) return; fj->updated = 1; -- cgit v1.2.3